This example is really 3 parts.
Part A) Allows the user to draw a set of connected points with the mouse.
Part B) Then it builds a SHAPE out of the users clicked set of points
Part C) Then it renders/rotates and scales on screen...
[pbcode]
Do
cls 0
Numb_of_line_sections=0
Dim Vertex_Xpos#(1000)
Dim Vertex_Ypos#(1000)
MouseButtonClicked=0
` ==============================================
` CReate A Shape WIth the Mouse
` ==============================================
repeat
text 10,0,"Create Shape OutLine"
` if mouse clicked
if MouseButtonClicked=0
if (mousebutton()&1)=1
xpos=mousex()
ypos=mousey()
` check If this is the first click or not
if Numb_of_line_sections=0
` remember the first click position
First_xpos=xpos
First_ypos=ypos
Dot xpos,ypos
else
line old_xpos,old_ypos,xpos,ypos
endif
old_xpos=xpos
old_ypos=ypos
Vertex_Xpos#(Numb_of_line_sections)=Xpos
Vertex_Ypos#(Numb_of_line_sections)=Ypos
inc Numb_of_line_sections
MouseButtonClicked=1
endif
endif
` Check the mouse button to make sure it's not being held down
` ============================================================
if (mousebutton()&1)=0
MouseButtonClicked=0
endif
Sync
until (mousebutton()&2)=2
; =========================================
; CREATE A VECTOR SHAPE Form This POint Set
; ==========================================
CreateShape 1,Numb_of_line_sections,Numb_of_line_sections
For lp=0 to Numb_of_line_sections-1
SetShapeVertex 1,lp,Vertex_Xpos#(lp),Vertex_Ypos#(lp)
Edge=lp
v2=LP+1
if v2>(Numb_of_line_sections-1) then V2=0
SetShapeEdge 1,Edge,lp,v2
next
ShiftShape 1,-400,-300
` ==============================================
` Render/Rotate The Shape
` ==============================================
Angle#=0
Repeat
cls 0
setcursor 0,0
Text 0,0,"Number of Sides:"+str$(Numb_of_line_sections-1)
print "Total Length:"+str$(Total_length_of_sides#)
print "Press Any Key TO Start Again:"
RotateShape 1,Angle#,1+sin(angle#)
DrawShape 1,400,300,0
Angle#=wrapvalue(angle#,1)
Sync
until Scancode()<>0
loop
[/pbcode]