Draw a rotating line on a canvas

Posted on 2009-02-09
Last Modified: 2013-11-22

This is a hard one.

I am drawing the TCanva of a form using "Pixels [x, y] := MyColor;"

For example:
- Drawing area is 400x400 pixel starting at position 0,0.
- Draw a line from the center of the area (pos:200,200).
- Line length is half of area size 200 pixels (so it will never touch the corners...)
- Line width is always 1 pixel
Where it gets hard:
- The line color is diferent for each pixel
- The drawing area can change size
- I want to draw the line using radians
- I want to draw the line from center outward (so if the line is 200 pixels, pixel #1 is on center and #200 is at the end of the line)

Radians, pixel number, and color values come from a database. but for the purpouse of this project lets just assign a random value.

Hope you guys can help..
Question by:etiennedemers

    Author Comment

    Just to be cleared:

    I want to call a function like

    DrawAngleLine( RadValue)
    Could also be in degrees, id doesn't mather
    The tough part is figuring which pixels are to be drawn at a given angle...


    Accepted Solution

    X=Radius * COS(angle)
    Y=Radius * SIN(angle)

    The rest is self explanatory...

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    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…
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    759 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

    12 Experts available now in Live!

    Get 1:1 Help Now