Private Sub DashLine(ByVal obj As Object, ByVal x1 As _
Single, ByVal y1 As Single, ByVal x2 As Single, ByVal _
y2 As Single, ByVal dash_length As Single, ByVal _
skip_length As Single, ByVal draw_width As Integer)
Dim dash_dx As Single
Dim dash_dy As Single
Dim skip_dx As Single
Dim skip_dy As Single
Dim length As Single
Dim X As Single
Dim Y As Single
Dim i As Integer
Dim i_max As Integer
' Get vectors in the desired direction
' with the right length.
skip_dx = x2 - x1
skip_dy = y2 - y1
length = Sqr(skip_dx * skip_dx + skip_dy * skip_dy)
dash_dx = skip_dx / length * dash_length
dash_dy = skip_dy / length * dash_length
skip_dx = skip_dx / length * skip_length
skip_dy = skip_dy / length * skip_length
obj.DrawWidth = draw_width
X = x1
Y = y1
i_max = Int(length / (dash_length + skip_length))
For i = 1 To i_max
obj.Line (X, Y)-Step(dash_dx, dash_dy)
X = X + dash_dx + skip_dx
Y = Y + dash_dy + skip_dy
Next i
' See how much line is undrawn.
length = length - i_max * (dash_length + skip_length)
If length > dash_length Then
obj.Line (X, Y)-Step(dash_dx, dash_dy)
Else
obj.Line (X, Y)-(x2, y2)
End If
End Sub
|