Jump to content
Xtreme .Net Talk

Recommended Posts

Posted
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 can't 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.
Posted

Easy:

 

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...