Drawing2D.GraphicsPath

rbulph

Well-known member
Joined
Feb 17, 2003
Messages
343
Does the GraphicsPath have any method for determining whether a given point is within a certain distance of any point on the path? This would seem quite a natural facility for it to provide, but I cant see it anywhere. In its absence it looks as if I will have to call the Flatten method and then test for each pair of points as if they were a short line.
 
Easy:

[VB]Public Class Form1
Dim gp As Drawing2D.GraphicsPath

Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint

gp = New Drawing2D.GraphicsPath
gp.AddArc(New Rectangle(50, 50, 200, 200), 0, 145)
gp.AddLine(gp.GetLastPoint, New Point(100, 100))

e.Graphics.DrawPath(Pens.Blue, gp)

End Sub

Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove
Dim hp As New Pen(Color.Black, 6) Thickness of hypothetical pen is subjective, but 6 seems about right.
If gp.IsOutlineVisible(e.Location, hp) Then
Me.Cursor = Cursors.Cross
Else
Me.Cursor = Cursors.Default
End If
End Sub

End Class[/VB]
 
Back
Top