
Here the code :
Code: Select all
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Written in PB 6.20 by threedslider (05/2025)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
InitSprite()
InitKeyboard()
InitMouse()
move.f = 0
Structure myround
x.f
y.f
rayon.i
r.f
g.f
b.f
EndStructure
Myvar.myround
myvar\x = 1.0
myvar\y = 1.0
myvar\rayon = 3
myvar\r = 0.0
myvar\g = 0.0
myvar\b = 0.0
Dim cc1.f(360)
Dim cc2.f(360)
Procedure lerp(*a.myround, *b.myround, c.f)
Shared myvar.myround
myvar\r = (*a\r + (*b\r - *a\r) * c)
myvar\g = *a\g + (*b\g - *a\g) * c
myvar\b = *a\b + (*b\b - *a\b) * c
EndProcedure
Procedure myCircle(X, Y, *cl.myround)
Shared cc1()
Shared cc2()
For n=0 To 360
cc1(n) = *cl\rayon * Cos(n)
cc2(n)= *cl\rayon * Sin(n)
Next
For n=0 To 360
glPointSize_(2.0)
glBegin_(#GL_POINTS)
lerp(@red, @white, 0.5)
glColor3f_(1.0, 0.0, 0.0)
glVertex3f_(-25.0+cc1(n)+*cl\x+ X, 15.0+cc2(n)+*cl\y-Y, 0.0)
glEnd_()
Next
EndProcedure
Procedure mySim(X, Y, *cl.myround, iter)
Shared move
radius.f = 0.0
Shared Myvar.myround
Shared cc1()
Shared cc2()
For n=0 To 360
cc1(n) = (*cl\rayon + radius*0.1) * Cos(n+move*iter)*iter
cc2(n)= (*cl\rayon + radius*0.1) * Sin(n+move*iter)*iter
radius = radius + 1.0
Next
For n=0 To 360
glPointSize_(2.0)
glBegin_(#GL_POINTS)
red.myround
red\r = 1.0
red\g = 0.0
red\b = 0.0
white.myround
white\r = 1.0
white\g = 1.0
white\b = 1.0
lerp(@red, @white, 0.8555)
glColor3f_(myvar\r, myvar\g, myvar\b)
glVertex3f_(-25.0+cc1(n)+*cl\x+ X, 15.0+cc2(n)+*cl\y-Y, 0.0)
glEnd_()
Next
If iter = 0
iter = 0
Else
mySim(X, Y, @cl, iter-1)
EndIf
EndProcedure
OpenWindow(1, 0,0,800/DesktopResolutionX(),600/DesktopResolutionY(),"Funny cluster in spiral ", #PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(1),0,0,800,600,0,0,0)
glMatrixMode_(#GL_PROJECTION)
glLoadIdentity_()
gluPerspective_(45.0, 800/600, 1.0, 60.0)
glMatrixMode_(#GL_MODELVIEW)
glTranslatef_(0, 0, -50)
glShadeModel_(#GL_SMOOTH)
glEnable_(#GL_LIGHT0)
glEnable_(#GL_LIGHTING)
glEnable_(#GL_COLOR_MATERIAL)
glEnable_(#GL_DEPTH_TEST)
glEnable_(#GL_CULL_FACE)
glViewport_(0, 0, 800, 600)
glClear_(#GL_COLOR_BUFFER_BIT | #GL_DEPTH_BUFFER_BIT)
glClearColor_(0.1, 0.1, 0.1, 0) ; background color
Repeat
event = WindowEvent()
ClearScreen(RGB(0,0,0))
ExamineMouse()
mpx.f = MouseX()
mpy.f = MouseY()
If mpx < 0
mpx = 10
EndIf
If mpy < 0
mpy = 10
EndIf
If mpx > 50
mpx = 50
EndIf
If mpy > 30
mpy = 30
EndIf
myCircle(mpx, mpy, @Myvar)
radius + 1/1000
If MouseButton(#PB_MouseButton_Left)
move + 1/10
If move > 50
move = 0.0
move + 1/10
EndIf
mySim(mpx,mpy, @myvar, 30)
EndIf
ExamineKeyboard()
FlipBuffers()
Until event = #PB_Event_CloseWindow Or KeyboardPushed(#PB_Key_Escape)
End

Enjoy !