Solved

Ellipse question

Posted on 2003-11-15
2
188 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Suggested Courses
Course of the Month11 days, 10 hours left to enroll

623 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