this slowpoke moves

Draw Mirror Effect on PaintBox

procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
var
    a,b,c,d,e,f:integer;
begin
  {when the mouse move with the Left mouse button pressed this draws
   a line which follows the mouse
   it also mirrors the line in all 4 quadrants
   draws as position (x,y) (a,b) (c,d) and (e,f)}

  with canvas do
  begin
    MoveTo(X,Y);
    if (shift=[ssLeft] ) then
    begin
      LineTo(x+1,y+1);    //original line
      {mirror in y-axis }
      c:=x;
      d:=Y+2*((clientheight div 2) - Y);
      moveto(c,d);
      lineto(c-1,d-1);
      {mirror in x-axis}
      b:=y;
      a:=x+2*(clientwidth div 2 - x);
      moveto(a,b);
      lineto(a-1,b+1);
      {mirrors (a,b) in y-axis}
      e:=a;f:=d;
      moveto(e,f);
      lineto(e+1,f-1);

    end;
  end;
end;

procedure TForm1.ScrollBar1Change(Sender: TObject);
begin
  {the scrollbar controls the penwidth}
  canvas.Pen.Width:=scrollbar1.Position;
  Edit1.Text:=inttostr(scrollbar1.position);  //display width on form
end;

procedure TForm1.Shape2MouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  {uses color dialog to select new background color and
   clears the screen to the new colour}
  if cd1.Execute then
  begin
      canvas.brush.Color:= cd1.color;
      canvas.FillRect(rect(0,0,clientwidth,clientheight));
      Shape2.Brush.Color:=cd1.color; //display color in rectangle
  end;
end;

procedure TForm1.Shape1MouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  {uses color dialog to change the pen color for drawing}
  if cd1.Execute then
  begin
      canvas.pen.Color:= cd1.color;
      Shape1.Brush.Color:=cd1.Color;
  end;
end;

Keine Kommentare:

Kommentar veröffentlichen

Beliebte Posts

Translate