Solved

Ellipse question

Posted on 2003-11-15
2
183 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
Comment Utility
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
Comment Utility
Incredible... Big kuddos to you my good man. Awesome stuff.

0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

743 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now