还是看看这个画鸭程序巴:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;
type
TForm1 = class(TForm)
procedure FormMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure FormMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure FormMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
acolor:Tcolor;
flag:bool;
R1:integer;
implementation
{$R *.dfm}
procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var
R:integer;
// acolor:Tcolor;
begin
flag:=true;
r:=RANDOM(10)+10;
r1:=r;
acolor := RGB(RANDOM(255),RANDOM(255),RANDOM(255));;
canvas.brush.Color:=acolor;//RGB(RANDOM(25),RANDOM(255),RANDOM(255));;
//acolor :=canvas.Brush.Color;
canvas.MoveTo(x,y);
canvas.Ellipse(x-r,y-r,x+r,y+r);
end;
procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
if flag then
begin
canvas.Pen.Color:=acolor;//RGB(RANDOM(255),RANDOM(255),RANDOM(255));
canvas.Pen.Width:=4*r1;
canvas.LineTo(x,y);
end;
end;
procedure TForm1.FormMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
flag:=false;
end;
end.