What code can i use to draw a line from one point to another. All points would be connected therefore giving us one shape conected to another shape ect... The points would be located in a text file.
ie. 12,34
23,45
34,56
23,23
34,-2
Printable View
What code can i use to draw a line from one point to another. All points would be connected therefore giving us one shape conected to another shape ect... The points would be located in a text file.
ie. 12,34
23,45
34,56
23,23
34,-2
Line -(x,y) 'will continue drawing from a point to next
currentx=x: currenty=y 'will move to the startpoint to draw from.
Open in input and input all the values into an array.
If what you want one polygon you could use the polygon API:
Code:Public Declare Function Polygon Lib "gdi32.dll" (ByVal hdc As Long, lpPoint As POINT_TYPE, ByVal nCount As Long) As Long
Type POINT_TYPE
x As Long
y As Long
End Type
Dim points(0 To 3) As POINT_TYPE
Dim retval As Long
' Load the coordinates of the diamond into the array.
points(0).x = 200: points(0).y = 100 ' 1st point (200,100)
points(1).x = 250: points(1).y = 150 ' 2nd point (250,150)
points(2).x = 200: points(2).y = 200 ' 3rd point (200,200)
points(3).x = 150: points(3).y = 150 ' 4th point (150,150)
' Draw the diamond using Form1's default pen and brush
retval = Polygon(Form1.hDC, points(0), 4) 'Points(0) is the start of
'the array and there are 4 points in the array
If retval = 0 then Debug.Print "Error drawing polygon"
And then use the Split() function to turn a text file into an array of numbers.
You could then use the info from this array to fill the .x and .y of all the points. ;)