Const n = 7
time = CreateTimer(60)
Global px#[7],py#[7]
Graphics 800,600,32,2
SetBuffer BackBuffer()
px[0] = 100 : py[0] = 100
px[1 ]= 100 : py[1] = 50
px[2] = 200 : py[2] = 50
px[3 ]= 200 : py[3] = 100
px[4] = 300 : py[4] = 300
px[5 ]= 100 : py[5] = 150
px[6 ]= 400 : py[6] = 150
px[7 ]= 400 : py[7] = 300
b# = 1.0/300
b2# = 1.0/300
While Not KeyHit(1)
Cls
mx = MouseX() : my=MouseY()
WaitTimer(time)
Color 255,5,5
For p = 0 To 7
If Dist(px[p] ,py[p],mx,my)<15
Rect px[p]- 4,py[p]-4,8,8,0
ppp= p
EndIf
If MouseDown(1)
px[ppp] = mx
py[ppp] = my
Oval mx-10,my-10, 20,20,0
EndIf
Next
t# = b
buff = BackBuffer()
LockBuffer buff
While t <1.01
t2# = b2
qx1#= Bezie3Q( Px[0],Px[1],Px[2] ,Px[3],t)
qy1#=Bezie3Q (Py[0],Py[1],Py[2] ,Py[3],t)
While t2 <1.01
qx2#= Bezie3Q( Px[4],Px[5],Px[6] ,Px[7],t)
qy2#=Bezie3Q (Py[4],Py[5],Py[6] ,Py[7],t)
x# = BezeQ(qx1,qx2,t2 )
y# = BezeQ(qy1,qy2,t2 )
WritePixel x+1,y,$333333 ,buff
WritePixel x,y,$cccccc ,buff
WritePixel x,y+1,$ccccff,buff
WritePixel qx2,qy2,$ff0000,buff
WritePixel qx1,qy1,$ff0000,buff
t2 = t2 + b2
Wend
t = t + b
Wend
UnlockBuffer buff
For p = 0 To 7
Rect px[p]- 2,py[p]-2,4,4,1
Next
Color 128,228,228
Line px[0] ,py[0] ,px[1 ],py[1 ]
Line px[3] ,py[3] ,px[2] ,py[2]
Line px[4] ,py[4] ,px[5] ,py[5 ]
Line px[6] ,py[6] ,px[7] ,py[7 ]
Text 20,20,"Point selct N - "+ppp
Flip
Wend
FreeTimer time
End
Function Dist#( X1#, Y1#, X2#, Y2# )
Return (( (X1 - X2)*(X1 - X2) + (Y1 - Y2)*(Y1 - Y2) )^0.5)
End Function
Function Bezie3Q#(P0#,P1#,P2#,P3#,Tt# )
Return ( (1.0-Tt)^3*P0 + 3*(1.0-Tt)^2*Tt*P1 +3*(1.0-Tt)*Tt^2*P2 + Tt^3*P3 )
End Function
Function BezeQ#(pp0#,pp1#,tt# ) ; pp0 -> x or y or z ... | pp1 -> x,y,z ... next or end point
Return ( (1.0-tt)*pp0+tt*pp1)
End Function