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
|