我想做的事:
假设我用鼠标按住这条线:
当我移动线时,线没有超出圆圈范围。
我不想做的事情:
如您所见,这条线超出了圆圈范围。
当我用鼠标握住他时,我想画线并让他保持在我的圈子内。
我怎么能做类似图片1的事情?
这是代码:
Dim g As Graphics
Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove
Dim pt As New Drawing.Point
pt.X = e.X
pt.Y = e.Y
g = Me.CreateGraphics
Dim myPen = New Pen(Color.Red)
myPen.Width = 1
g.Clear(Color.White)
g.DrawLine(myPen, 100, 100, pt.X, pt.Y)
End Sub