Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
 
 
 
500MB 27GB Web Hosting - $9.95/Month
 
 
 
 
 
Old Pages
 
Old Index
Site Map
What's New
 
Books
How To
Tips & Tricks
Tutorials
Stories
Performance
Essays
Links
Q & A
New in VB6
Free Stuff
Pictures
 
 
 
TitleDraw arcs with arrow heads
Keywordsarrow, arrowhead, line, draw, arc
CategoriesGraphics
 
Draw the arc. Calculate the end point of the arc and the direction at that point. Then use the DrawArrowHead routine to draw an arrow head at that point. For information on this routine, see the HowTo Draw an arrowhead on a line.
 
Private Sub Form_Load()
Const PI = 3.14159265

    AutoRedraw = True

    DrawArrowArc 1440, 1440, 800, PI * 0.125, PI * 0.75
    DrawArrowArc 2000, 3000, 1000, PI * 0.75, PI * 0.25
    DrawArrowArc 3500, 1000, 600, PI * 1.25, PI * 1.75
    DrawArrowArc 2500, 2200, 700, PI * 0.5, PI * 1.5
End Sub

Private Sub DrawArrowArc(ByVal cx As Single, ByVal cy As _
    Single, ByVal radius As Single, ByVal start_angle As _
    Single, ByVal stop_angle As Single)
Dim endx As Single
Dim endy As Single
Dim dx As Single
Dim dy As Single

    Circle (cx, cy), radius, , start_angle, stop_angle

    ' Get the arc's end point.
    endx = cx + radius * Cos(stop_angle)
    endy = cy - radius * Sin(stop_angle)

    ' Get the reverse direction of the circle at the end
    ' point.
    dx = -Sin(stop_angle)
    dy = -Cos(stop_angle)

    ' Draw the arrowhead.
    DrawArrowHead endx, endy, endx + dx, endy + dy, 200
End Sub

' Draw an arrowhead at (x2, y2) pointing in the direction
' from (x1, y1) --> (x2, y2).
Private Sub DrawArrowHead(ByVal x1 As Single, ByVal y1 As _
    Single, ByVal x2 As Single, ByVal y2 As Single, ByVal _
    arm_length As Single)
Dim dx As Single
Dim dy As Single
Dim length As Single

    dx = x2 - x1
    dy = y2 - y1
    length = Sqr(dx * dx + dy * dy)
    If length = 0 Then Exit Sub

    dx = dx / length * arm_length
    dy = dy / length * arm_length
    Line (x2, y2)-Step(-dx - dy, -dy + dx)
    Line (x2, y2)-Step(-dx + dy, -dy - dx)
End Sub
 
 
Copyright © 1997-2003 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated