ref : https://mathcurve.com/courbes2d/astroid/astroid.shtml
Code : Tout sélectionner
Procedure astroide(cx,cy,rayon,ang.f,nb,col=$ffffff)
d=rayon>>2
t.f=0
z2.f=(nb*t)
x1=d*(3*Cos(Radian(t+ang))+(Cos(Radian(z2+ang))))+cx
y1=d*(3*Sin(Radian(t+ang))-(Sin(Radian(z2+ang))))+cy
x0=x1
y0=y1
compt.f=(360/rayon/2)
If compt<0.5:compt=0.5:EndIf
While t<=360
z2.f=(nb*t)
x2.f=Cos(Radian(t+ang))
y2.f=Sin(Radian(t+ang))
x=d*(3*x2+Cos(Radian(z2+ang)))+cx
y=d*(3*y2-Sin(Radian(z2+ang)))+cy
LineXY(x,y,x1,y1,col)
x1=x
y1=y
t=t+compt
Wend
LineXY(x,y,x0,y0,col)
EndProcedure
If OpenWindow(0, 0, 0, 1000, 800, "astroide", #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_SizeGadget | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget)
ii=0
Repeat
Event = WindowEvent()
a.f=ii/1
StartDrawing(WindowOutput(0))
Box(0,0,999,799,0)
astroide(500,400,400,-a,3,$ff)
nb=0
For y=0 To 800 Step 150
For x=0 To 1000 Step 150
astroide(x+50,y,50,a,nb,$ffffff)
nb=Mod(nb+1, 10)
Next
Next
StopDrawing()
Delay(15)
ii=ii+1
ii=Mod(ii,3600)
Until Event = #PB_Event_CloseWindow Or quit=1
CloseWindow(0)
EndIf