[Lazarus] graphics

Mattias Gaertner nc-gaertnma at netcologne.de
Wed Jan 23 12:29:38 CET 2013


On Wed, 23 Jan 2013 11:54:13 +0100
duilio foschi <duiliofoschi at euplan.com> wrote:

> Hi!
> 
> this code
> 
> procedure TForm1.DrawBtnClick(Sender: TObject);
> {Draw some ellipses on the canvas - random size and color}
> var
>   i:integer;
>   cx,cy:integer;
> begin
>   with image1, canvas do
>   begin
>     for i:= 1 to 10 do
>     begin
>       cx:=random(width);
>       cy:=random(height);
>       brush.color:=random(256*256*256);
>       ellipse(cx,cy,cx+random(100), cy+random(100));
>     end;
>   end;
> end;
> 
> will draw 10 ellipses on Image1.
> 
> However, I want to do it interactively, like it is done in Photo-Paint.
> 
> The ellipse should be contained in a rectangle R whose upper-left
> corner is given by the original position of the mouse on screen.
> 
> And the bottom-right corner of R will be the final position of the mouse.
> 
> During dragging, a temporary ellipse should be shown on screen and the
> mouse will be cross-shaped.
> 
> Any idea re how to do it ?

Hint: TImage has two Canvas. The Picture.Canvas for the permanent
changes, the Canvas during OnPaint for the temporary drawings.

 
> An unexpensive well debugged 3th-party library would be the ideal
> solution (as I don't plan to work in graphics in the future).


Mattias




More information about the Lazarus mailing list