found on the forum example, reworked it, but that it does not work
need to get as:

but out here so:
respectively, the object is created an irregular shape. Help!!!
set display mode 1024, 768, 32: sync on: sync rate 0: sync
autocam off
position camera 0, 0, -300
point camera 0, 0, 0
backdrop off
`draw to back
cls rgb(20, 22, 22): ink 0, 0: box 256, 128, 768, 640:ink rgb(0, 255, 0), 0
dim Tochka(1000, 2) as integer
make object plain 1, 10, 10 ` complete perimeter button
color object 1, rgb(255, 0, 0)
position object 1, 150, -20, 0
keyNow = 0
item = 0
complete = 0
`paste image 3,150,150
repeat
mx = mouseX()
my = mouseY()
inside = (mx>=257)*(mx<=767)*(my>=129)*(my<=639)
if mouseclick()
if keyNow = 0
keyNow = 1
if inside = 1
drawDot(mx, my, item)
` print "item=";item
` print "x=";Tochka(item, 0)
` print "y=";Tochka(item, 1)
` print "t=";Tochka(item, 2)
inc item
else
button = pick object(mx, my, 1, 2)
if button
if item > 2
` join last point to first point
dec item
complete = 1
ink rgb(255, 255, 255), 0
line Tochka(item, 0), Tochka(item, 1), Tochka(0, 0), Tochka(0, 1)
` update list pointers
Tochka(item, 2) = 0
endif
endif
endif
endif
else
keyNow = 0
endif
sync
until complete
get image 1, 256, 128, 768, 640
save image "line.bmp", 1
`-=--------------------------------------------------------------------------------------------------
`Save dots for file
if file exist("dots.txt")= 1 then delete file "dots.txt"
open to write 1,"dots.txt"
write string 1,str$((item))
for i=0 to (item)
write string 1,str$(Tochka(i, 0))
write string 1,str$(Tochka(i, 1))
if i=item
Tochka(i, 2)=(item+1)
endif
write string 1,str$(Tochka(i, 2))
next i
close file 1
`-=--------------------------------------------------------------------------------------------------
`SAVE ARRAY "array.txt",Tochka()
`load ARRAY "array.txt",Tochka()
undim Tochka(1000, 2)
dim Tochka(1000, 2) as integer
`-=--------------------------------------------------------------------------------------------------
`Load dots for file
open to read 1,"dots.txt"
read string 1,a$: item=val(a$)
for i=0 to (item)
read string 1,a$: Tochka(i, 0)=val(a$)
read string 1,a$: Tochka(i, 1)=val(a$)
read string 1,a$: Tochka(i, 2)=val(a$)
circle Tochka(i, 0),Tochka(i, 1),7
next i
`Tochka(i, 2)=(item+1)
close file 1
`-=--------------------------------------------------------------------------------------------------
`item=item+1
`for i=0 to item-2
`line Tochka(i, 0),Tochka(i, 1),Tochka(i+1, 0),Tochka(i+1, 1)
`next i
`line Tochka(0, 0),Tochka(0, 1),Tochka(i, 0),Tochka(i, 1)
`Tochka(i, 2)=0
keyNow=1
complete=1
`--------------------------------------------------------------------------------------
print "item=";item
print "keyNow=";keyNow
print "complete=";complete
print
`-=--------------------------------------------------------------------------------------------------
` check whether perimeter is CW or CCW
` method reported by IanM
sum = 0
for v1 = 0 to item
v2 = (v1 + 1) mod (item + 1) ` wrap around if necessary
inc sum, Tochka(v1, 0)*Tochka(v2, 1) - Tochka(v1, 1)*Tochka(v2, 0)
next sum
` if sum > 0 then winding order is clockwise (CW)
` if sum < 0 then winding order is anti-clockwise (CCW)
if sum < 0
` reverse order of vertices so winding order is CW
` suggested by calcyman
for v = 0 to item/2
tmpX = Tochka(v, 0)
tmpY = Tochka(v, 1)
Tochka(v, 0) = Tochka(item-v, 0)
Tochka(v, 1) = Tochka(item-v, 1)
Tochka(item-v, 0) = tmpX
Tochka(item-v, 1) = tmpY
next v
endif
cls
nxt = 0
counter = 1000
gc=100
while Tochka(Tochka(Tochka(nxt, 2), 2), 2) <> nxt+1 and counter>0
dec counter
nxt1 = Tochka(nxt, 2)
nxt2 = Tochka(nxt1, 2)
if checkTriangle(Tochka(nxt, 0), Tochka(nxt, 1), Tochka(nxt1, 0),...
Tochka(nxt1, 1), Tochka(nxt2, 0), Tochka(nxt2, 1))
gc=gc+1
` if gc=101 then ink rgb(255, 0, 0), 0
` if gc=102 then ink rgb(0, 255, 0), 0
` if gc=103 then ink rgb(0, 0, 255), 0
ink rgb(255,0,0),0
line Tochka(nxt, 0), Tochka(nxt, 1),Tochka(nxt1, 0), Tochka(nxt1, 1)
line Tochka(nxt1, 0), Tochka(nxt1, 1),Tochka(nxt2, 0), Tochka(nxt2, 1)
line Tochka(nxt2, 0), Tochka(nxt2, 1),Tochka(nxt, 0), Tochka(nxt, 1)
x1=Tochka(nxt, 0) :z1=Tochka(nxt, 1)
x2=Tochka(nxt1, 0):z2=Tochka(nxt1, 1)
x3=Tochka(nxt2, 0):z3=Tochka(nxt2, 1)
make object triangle gc,x1,0,z1,x2,0,z2,x3,0,z3
if gc=101 then color object gc,rgb(255, 0, 0)
if gc=102 then color object gc,rgb(0, 255, 0)
if gc=103 then color object gc,rgb(0, 0, 255)
color object gc,rgb(rnd(255), rnd(255),rnd(255))
`sync
` wait key
ink rgb(0, 255, 255), 0
if notContainPoint(nxt, nxt1, nxt2)
ink rgb(0, 255, 0), 0
line Tochka(nxt, 0), Tochka(nxt, 1), Tochka(nxt2, 0), Tochka(nxt2, 1)
` update list pointer
Tochka(nxt, 2) = nxt2
endif
endif
nxt = Tochka(nxt, 2)
sync
endwhile
`wait key
get image 1, 256, 128, 768, 640
save image "N triangle.bmp", 1
`-=--------------------------------------------------------------------------------------------------
`-=--------------------------------------------------------------------------------------------------
`make objext from N triangle
FOR i=1 to (gc-100)
l=100+i
make mesh from object 202,l
xx1=object position x(L)
yy1=object position y(L)
zz1=object position z(L)
add limb 101,i,202
link limb 101,0,i
offset limb 101,i,xx1,yy1,zz1
color limb 101,i,rgb(0,255,0)
delete object 100+L
delete mesh 202
next i
xrotate object 101,90
fix object pivot 101
`-=--------------------------------------------------------------------------------------------------
backdrop on
`-=--------------------------------------------------------------------------------------------------
do
position camera 400,0,300
point camera 400,0,300
move camera -1700
paste image 1,0,100
point camera object position x(101),object position y(101),object position z(101)
`xrotate object 101,object angle x(101)+.1
INK RGB(255,255,255),0
set cursor 0,0
print screen fps()
print "Triangle count=";gc-100
sync
loop
`-=--------------------------------------------------------------------------------------------------
function drawDot(mx, my, item)
ink rgb(0, 255, 0), 0
dot mx-1, my
dot mx+1, my
dot mx, my
dot mx, my-1
dot mx, my+1
Tochka(item, 0) = mx
Tochka(item, 1) = my
Tochka(item, 2) = item + 1 ` next item in list
if item > 0
ink rgb(255, 255, 0), 0
line Tochka(item-1,0), Tochka(item-1,1), mx, my
endif
endfunction
function checkTriangle(x1, y1, x2, y2, x3, y3)
c = ((x2-x1)*(y3-y1) - (x3-x1)*(y2-y1))>0
endfunction c
function notContainPoint(p0, p1, p2)
` tests whether or not the triangle with vertices p0, p1, p2 contains
` any other vertices in the current reduced perimeter
nxt = Tochka(p2, 2) ` the next vertex in the reduced perimeter
while nxt <> p0
if CX_2D_PointTriangle(Tochka(nxt, 0), Tochka(nxt, 1),...
Tochka(p0, 0), Tochka(p0, 1),...
Tochka(p1, 0), Tochka(p1, 1),...
Tochka(p2, 0), Tochka(p2, 1))
exitfunction 0
endif
nxt = Tochka(nxt, 2)
endwhile
endfunction 1
`==============================================
` This function was supplied by CuCuMBeR and written by Phaelax
` with minor modifications by Green Gandalf to use integers instead of floats
` Returns 1 if point is inside triangle, 0 if not
` Point (px,py)
` triangle (x1,y1),(x2,y2),(x3,y3)
`==============================================
function CX_2D_PointTriangle(px,py, x1,y1, x2,y2, x3,y3)
dABx = x2-x1
dABy = y2-y1
dBCx = x3-x2
dBCy = y3-y2
rem if verts are clockwise
if (dABx*dBCy - dABy*dBCx) < 0
if dABx*(py-y1) >= dABy*(px-x1) then exitfunction 0
if dBCx*(py-y2) >= dBCy*(px-x2) then exitfunction 0
if (x1-x3)*(py-y3) >= (y1-y3)*(px-x3) then exitfunction 0
rem verts are ccw
else
if dABx*(py-y1) < dABy*(px-x1) then exitfunction 0
if dBCx*(py-y2) < dBCy*(px-x2) then exitfunction 0
if (x1-x3)*(py-y3) < (y1-y3)*(px-x3) then exitfunction 0
endif
rem point is inside triangle
endfunction 1