' Draw an arrow head at (x2, y2) for a vector from
' (x1, y1). Draw a tail at (x1, y1). Make the barbs
' anf fletchings point at a 45 degree angle away
' from the shaft.
Private Sub DrawArrow45(ByVal pic As Object, ByVal x1 As _
Single, ByVal y1 As Single, ByVal x2 As Single, ByVal _
y2 As Single, ByVal length As Single, Optional ByVal _
draw_head As Boolean = True, Optional ByVal _
num_fletchings As Integer = 0, Optional ByVal _
fletching_gap As Single = 60)
Dim vx As Single
Dim vy As Single
Dim dist As Single
Dim ax As Single
Dim ay As Single
Dim barb_scale As Single
Dim i As Integer
Dim gap_dx As Single
Dim gap_dy As Single
' Draw the shaft.
pic.Line (x1, y1)-(x2, y2)
' Find the arrow shaft unit vector.
vx = x2 - x1
vy = y2 - y1
dist = Sqr(vx * vx + vy * vy)
vx = vx / dist
vy = vy / dist
' See if we need to draw multiple fletchings.
If num_fletchings > 1 Then
' Get the fletching spacing vector.
gap_dx = vx * fletching_gap
gap_dy = vy * fletching_gap
End If
' Draw the right barb.
ax = -vy - vx
ay = vx - vy
' Set the proper length.
ax = ax * length
ay = ay * length
If draw_head Then pic.Line (x2, y2)-Step(ax, ay)
For i = 0 To num_fletchings - 1
pic.Line (x1 + i * gap_dx, y1 + i * _
gap_dy)-Step(ax, ay)
Next i
' Find the left barb.
ax = (vy - vx) * length
ay = (-vx - vy) * length
If draw_head Then pic.Line (x2, y2)-Step(ax, ay)
For i = 0 To num_fletchings - 1
pic.Line (x1 + i * gap_dx, y1 + i * _
gap_dy)-Step(ax, ay)
Next i
End Sub
|