# Thread: A compass

1. Member
Join Date
Nov 2007
Posts
19
Rep Power
0

## A compass

Hi, can I know how do I draw an arrow in a circle which is similar to a compass. But the arrow doesn't have to move around. Thanks

2. Drawing the shaft of the arrow would be just a straight line from the center of the circle to the end point. Drawing the head of the arrow would require some computations that will have to be worked out.
Can you draw a circle?
Can you draw a line from the center of the circle to the end point?
Do these first then work on drawing the arrow head.
There are code examples for drawing on the forum. Use search.

3. Actually it's not much difficult. Only thing need to identify is about the starting point and the end point of a line, and three lines only need.

4. I think drawing the 2 lines that make the head of the arrow will be tricky. That would require some trig to get the angles right.

5. Not too hard if your trig is good:
Say you have the arrow 100 pixels long pointing to the right.
Say the head is to be 10 pixels long.
Say the angle between the head parts and the shaft is 45 deg.
Go to the end of the arrow and measuse a 45 deg angle above the shaft and find the point 10 pixels away at that angle and draw a line from the end of the arrow to the above point.
Do the same for the angle below the shaft.
Voila you have an arrow with head.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•