unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls,
StdCtrls;
type
{ TForm1 }
TForm1 = class(TForm)
Image1: TImage;
Label1: TLabel;
Shape1: TShape;
Timer1: TTimer;
procedure FormCreate(Sender: TObject);
procedure Image1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure Image1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer
);
procedure Timer1Timer(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
var
Form1: TForm1;
speed: single;
implementation
{$R *.lfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
Image1.Canvas.Brush.Color := clWhite;
Image1.Canvas.FillRect(Image1.ClientRect);
end;
procedure TForm1.Image1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if Button = mbRight then begin
Shape1.Left := round(x - Shape1.Width/2);
Shape1.Top := round(y - Shape1.Height/2);
Shape1.Visible := true;
speed := 0;
end;
end;
procedure TForm1.Image1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
if ssLeft in Shift then begin
Image1.Canvas.Pen.Width := 50;
Image1.Canvas.Pen.Style := psSolid;
Image1.Canvas.LineTo(x, y);
end else begin
Image1.Canvas.MoveTo(x, y);
end;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
var
x, y: integer;
begin
if Shape1.Visible then begin
Shape1.Top := Round(Shape1.Top + speed);
speed := speed + 1;
if Shape1.Top > ClientHeight then Shape1.Visible := false;
x := round(Shape1.Left + Shape1.Width/2);
y := round(Shape1.Top + Shape1.Height/2);
if Image1.Canvas.Pixels[x, y] = clBlack then begin
Shape1.Visible := false;
Image1.Canvas.Pen.Style := psClear;
Image1.Canvas.Ellipse(round(x-speed), round(y-speed), round(x+speed), round(y+speed));
end;
end;
end;
end.