Solved

Ellipse question

Posted on 2003-11-15
2
187 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
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…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

751 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