sync on
 
x1#=rnd(640):y1#=rnd(400)
x2#=rnd(640):y2#=rnd(400)
x3#=rnd(640):y3#=rnd(400)
x4#=rnd(640):y4#=rnd(400)
xd1#=(rnd(20)-10)*.1:yd1#=(rnd(20)-10)*.1
xd2#=(rnd(20)-10)*.1:yd2#=(rnd(20)-10)*.1
xd3#=(rnd(20)-10)*.1:yd3#=(rnd(20)-10)*.1
xd4#=(rnd(20)-10)*.1:yd4#=(rnd(20)-10)*.1
 
do
   cls
   set cursor 0,0:print "FPS: "+str$(screen fps())
   if x1#<0 or x1#>640 then xd1#=-xd1#
   if y1#<0 or y1#>400 then yd1#=-yd1#
   if x2#<0 or x2#>640 then xd2#=-xd2#
   if y2#<0 or y2#>400 then yd2#=-yd2#
   if x3#<0 or x3#>640 then xd3#=-xd3#
   if y3#<0 or y3#>400 then yd3#=-yd3#
   if x4#<0 or x4#>640 then xd4#=-xd4#
   if y4#<0 or y4#>400 then yd4#=-yd4#
 
   x1#=x1#+xd1#:y1#=y1#+yd1#
   x2#=x2#+xd2#:y2#=y2#+yd2#
   x3#=x3#+xd3#:y3#=y3#+yd3#
   x4#=x4#+xd4#:y4#=y4#+yd4#
 
   ink rgb(128,128,0),0
   circle x1#,y1#,3
   circle x2#,y2#,3
   circle x3#,y3#,3
   circle x4#,y4#,3
   line x1#,y1#,x2#,y2#
   line x3#,y3#,x4#,y4#
 
   Bezier(x1#,y1#,x2#,y2#,x3#,y3#,x4#,y4#,50,rgb(255,0,0))
 
   sync
loop
 
 
 
Function Bezier(x1#,y1#,bx1#,by1#,x2#,y2#,bx2#,by2#,steps#,color)
`Bezier(startX,startY,StartTailX,StartTailY,EndX,EndY,EndTailX,EndTailY,Number_of_steps,Color)
   stepsval#=1/steps#
   x6#=x1#:y6#=y1#
   ink color,0
   for I#=0 to 1.0001 step stepsval#
      I2#=1-I#
      x3#=bx1#*i2#+bx2#*i#:y3#=by1#*i2#+by2#*i#
      x4#=x1#*i2#+x3#*i#:y4#=y1#*i2#+y3#*i#
      x5#=x3#*i2#+x2#*i#:y5#=y3#*i2#+y2#*i#
      ex#=x6#:ey#=y6#
      x6#=x4#*i2#+x5#*i#:y6#=y4#*i2#+y5#*i#
      line ex#,ey#,x6#,y6#
   next I#
EndFunction