# Draw a shape then copy the array and use it for Stamps

graphsize 800,500

fastgraphics

print "Shape={";

oldx=0

oldy=0

n=2

dim shape(2)

init= true

fin = false

clickclear

decimal(0)

loop:

gosub drawgraph

circle mousex,mousey,3

color red

circle shape[0],shape[1],4

color black

refresh

clg

x=clickx/20-20

y=-clicky/20+12

if n>3 and shape[n-2]=shape[0] and shape[n-1]=shape[1]then fin=true

# Checks for new click

if oldx<>clickx or oldy<>clicky then

if init = true then print x+","+y;

if init = false then

print ","+x+","+y;

n=n+2

end if

init= false

redim shape(n)

shape[n-2]= round (clickx,20)

shape[n-1]= round (clicky,20)

end if

oldx=clickx

oldy=clicky

if n > 3 then call draw (ref(shape),n,fin)

goto loop

subroutine draw(ref(shape),n,fin)

for p = 4 to n step 2

line shape[p-4],shape[p-3],shape[p-2],shape[p-1]

next p

if fin = true then

refresh

Print "}"

stamp 0,0,shape

refresh

print "Copy paste and run"

end

end if

end subroutine

drawgraph:

color black

for y= 0 to 480 step 20

for x= 0 to 800 step 20

circle x,y,2

next x

next y

line 0,240,800,240

line 400,0,400,480

return

function round(number,nearest)

if number%nearest<nearest/2 then

round = int (number/nearest)*nearest

else

round = int (number/nearest)*nearest+nearest

end if

end function