|
-
Aug 16th, 2001, 09:19 PM
#1
Thread Starter
Hyperactive Member
Polyline Help.
I am using Polyline to draw a line to the screen. What i want to do is plot 2 points, for example, the user would click at one point on the screen, then at another spot on the screen. i would like to draw from the first point to the second point, but instead of stopping at the second point, continue drawing a line to the end of the screen along the same direction as the 2 points that were plotted
drawing a straight horizontal line or vertical line would be easy to continue on because you just increase the size of the x or y respectively, but what about when its diagonal?
I hope this was clear...
This Business Is Binary. Your a 1 or a 0. Alive or Dead. (AntiTrust)
-
Aug 16th, 2001, 09:55 PM
#2
Thread Starter
Hyperactive Member
come on i know somebody knows this.
This Business Is Binary. Your a 1 or a 0. Alive or Dead. (AntiTrust)
-
Aug 17th, 2001, 03:08 AM
#3
Retired VBF Adm1nistrator
Go onto my website, and grab the sounds corny zip, and look at the maze editor. Then let me know what you need.
Last edited by plenderj; Aug 17th, 2001 at 04:36 AM.
Microsoft MVP : Visual Developer - Visual Basic [2004-2005]
-
Aug 17th, 2001, 05:43 AM
#4
PowerPoster
Hi AAG
here is some code using a picture box and Line method. Am sure u can adapt for ur conditions
Regards
Stuart
VB Code:
Dim fbooDrawLine As Boolean
Dim lsngPoint1X As Single
Dim lsngPoint1Y As Single
Dim lsngPoint2X As Single
Dim lsngPoint2Y As Single
Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If fbooDrawLine Then
lsngPoint2X = X
lsngPoint2Y = Y
Picture1.Line (lsngPoint1X, lsngPoint1Y)-(lsngPoint2X, lsngPoint2Y)
DrawExtendedLine
fbooDrawLine = False
Else
lsngPoint1X = X
lsngPoint1Y = Y
fbooDrawLine = True
End If
End Sub
Private Sub DrawExtendedLine()
Dim mAngle As Single
Dim bStart As Single
Dim lsngNewX As Single
Dim lsngNewY As Single
mAngle = (lsngPoint2Y - lsngPoint1Y) / (lsngPoint2X - lsngPoint1X)
bStart = lsngPoint2Y
lsngNewX = Picture1.ScaleWidth
lsngNewY = mAngle * (lsngNewX - lsngPoint2X) + bStart
Picture1.Line -(lsngNewX, lsngNewY)
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|