# Ellipse question

I want to follow the line from an Ellipse. So I drop a shape on a form, switch it to stEllipse. I want to draw a character on a start point on the ellipse and then move it over the lineall the way the ellipse round untill it is on the startingpoint again. How do I get the positions of the pixels of the Ellipse?
LVL 1
###### Who is Participating?

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Commented:
procedure EllipsePoint(angle_degrees, left, top, right, bottom : integer; var x, y : integer);
var
w, h, xc, yc : integer;
begin
w := (right - left) div 2;
h := (bottom - top) div 2;
xc := left + w;
yc := top + h;
x := Round(xc + w * Sin(DegToRad(angle_degrees)));
y := Round(yc + h * Cos(DegToRad(angle_degrees)));
end;

procedure TForm1.Button2Click(Sender: TObject);
var
i, x, y : integer;
begin
for i := 0 to 360 do begin
EllipsePoint(i, 200, 200, 250, 300, x, y);
Canvas.Pixels[x,y] := clBlack;
end;
end;

The second routine draws an ellipse based on the parameters passed to EllipsePoint. The angle_degrees is the angle (0 to 360) in degrees that you need. Note that this starts from 6 o'clock and works anti-clockwise, so 90 degrees is 3 o'clock, 180 degrees is 12 o'clock.

The other parameters give the bounding box, and the values are returned in x/y.

Geoff M.
0

Experts Exchange Solution brought to you by