Solved

Ellipse question

Posted on 2003-11-15
2
185 Views
Last Modified: 2010-04-05
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?
0
Comment
Question by:mpoots
2 Comments
 
LVL 8

Accepted Solution

by:
gmayo earned 200 total points
ID: 9754270
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
 
LVL 1

Author Comment

by:mpoots
ID: 9754296
Incredible... Big kuddos to you my good man. Awesome stuff.

0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question