Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2013-01

graphics

2 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

duilio foschi

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 ?

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

Thank you

Duilio

Reply by email

Mattias Gaertner
to duilio foschi
Show quoted text 35 lines
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

Reply by email