rem Start of BASIC! Program FN.DEF bezier(p1x,p1y,s1x,s1y,s2x,s2y,p2x,p2y) n=(HYPOT(s1x-p1x,s1y-p1y)+ HYPOT(s2x-s1x,s2y-s1y)+ HYPOT(p2x-s2x,p2y-s2y))/20 ox=p1x oy=p1y FOR i=0 TO 1 STEP 1/n x1=p1x+(s1x-p1x)*i y1=p1y+(s1y-p1y)*i x2=s1x+(s2x-s1x)*i y2=s1y+(s2y-s1y)*i x3=s2x+(p2x-s2x)*i y3=s2y+(p2y-s2y)*i x4=x1+(x2-x1)*i y4=y1+(y2-y1)*i x5=x2+(x3-x2)*i y5=y2+(y3-y2)*i x=x4+(x5-x4)*i y=y4+(y5-y4)*i GR.LINE vd,ox,oy,x,y ox=x oy=y NEXT i GR.LINE vd,ox,oy,p2x,p2y FN.END FN.DEF bezier1(p1x,p1y,s1x,s1y,s2x,s2y,p2x,p2y) n=(HYPOT(s1x-p1x,s1y-p1y)+ HYPOT(s2x-s1x,s2y-s1y)+ HYPOT(p2x-s2x,p2y-s2y))/20 ox=p1x oy=p1y FOR i=0 TO 1 STEP 1/n x1=p1x+(s1x-p1x)*i y1=p1y+(s1y-p1y)*i x2=s1x+(s2x-s1x)*i y2=s1y+(s2y-s1y)*i x3=s2x+(p2x-s2x)*i y3=s2y+(p2y-s2y)*i x4=x1+(x2-x1)*i y4=y1+(y2-y1)*i x5=x2+(x3-x2)*i y5=y2+(y3-y2)*i x=x4+(x5-x4)*i y=y4+(y5-y4)*i GR.LINE vd,ox,oy,x,y ox=x oy=y NEXT i GR.LINE vd,ox,oy,p2x,p2y FN.END !test DIM l[8] GR.OPEN 255,255,255,255,0,1 GR.SCREEN sx,sy do gr.touch yyy,x,y until yyy sx=x sy=y x1=INT(sx/10*1) y1=INT(sy/20*8) x2=INT(sx/10*6) y2=INT(sy/20*9) x3=INT(sx/10*4) y3=INT(sy/20*13) x4=INT(sx/10*8) y4=INT(sy/20*10) x5=INT(sx/10*2) y5=INT(sy/20*16) x6=INT(sx/10*8) y6=INT(sy/20*17) x7=INT(sx/10*9) y7=INT(sy/20*19) x8=INT(sx/10*7) y8=INT(sy/20*20) DO GR.CLS GR.TEXT.SIZE sy/30 GR.TEXT.ALIGN 2 GR.SET.STROKE 1 GR.COLOR 255,255,0,0,1 GR.CIRCLE vd,x1,y1,sx/100 GR.COLOR 255,0,255,0,1 GR.CIRCLE vd,x2,y2,sx/100 GR.COLOR 255,0,0,255,1 GR.CIRCLE vd,x3,y3,sx/100 GR.COLOR 255,255,255,0,1 GR.CIRCLE vd,x4,y4,sx/100 GR.COLOR 255,0,255,255,1 GR.LINE gol1,x1,y1,x2,y2 GR.LINE gol2,x3,y3,x4,y4 GR.COLOR 255,0,0,0,1 GR.SET.STROKE 1 GR.LINE gol3,x1,y1,x2,y2 GR.LINE gol4,x3,y3,x4,y4 GR.SET.STROKE 5 bezier(x1,y1,x2,y2,x3,y3,x4,y4) bezier1(x4,y4,x5,y5,x6,y6,x7,y7) GR.RENDER GR.TOUCH tt,tx,ty IF tt&!ott THEN l[1]=HYPOT(tx-x1,ty-y1) l[2]=HYPOT(tx-x2,ty-y2) l[3]=HYPOT(tx-x3,ty-y3) l[4]=HYPOT(tx-x4,ty-y4) l[5]=HYPOT(tx-x5,ty-y5) l[6]=HYPOT(tx-x6,ty-y6) l[7]=HYPOT(tx-x7,ty-y7) l[8]=HYPOT(tx-x8,ty-y8) ARRAY.MIN amin,l[] ARRAY.SEARCH l[],amin,p ELSEIF tt&ott THEN IF p=1 THEN x1=INT(tx/20)*20 y1=INT(ty/20)*20 ELSEIF p=2 THEN x2=INT(tx/20)*20 y2=INT(ty/20)*20 ELSEIF p=3 THEN x3=INT(tx/20)*20 y3=INT(ty/20)*20 ELSEIF p=4 THEN x4=INT(tx/20)*20 y4=INT(ty/20)*20 ELSEIF p=5 THEN x5=INT(tx/20)*20 y5=INT(ty/20)*20 ELSEIF p=6 THEN x6=INT(tx/20)*20 y6=INT(ty/20)*20 ELSEIF p=7 THEN x7=INT(tx/20)*20 y7=INT(ty/20)*20 ELSEIF p=8 THEN x8=INT(tx/20)*20 y8=INT(ty/20)*20 ENDIF ELSE PAUSE 100 ENDIF ott=tt UNTIL 0