Abstract rotation with color
Posted: Tue Jan 21, 2025 2:27 am
New for abstract rotation with color !
I use the plot with circles and rotation, it is quite fast enough and more various
But sometime it shows black and other abstracts as well.
Recently I don't have used PB so much cause I work to my C++ too
Here the code that i share you as always :
What do you think of my new code ?
Happy coding !

I use the plot with circles and rotation, it is quite fast enough and more various

Recently I don't have used PB so much cause I work to my C++ too

Here the code that i share you as always :
Code: Select all
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Created by threedslider 21/01/2025
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
InitSprite()
InitKeyboard()
InitMouse()
OpenWindow(1, 0,0,(800*2)/DesktopResolutionX(),(600*2)/DesktopResolutionY(),"abstract rotation with color", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(1),0,0,800*2,600*2,0,0,0)
Structure color_3_f
r.f
g.f
b.f
EndStructure
Structure color_3_i
r.i
g.i
b.i
EndStructure
tri.color_3_f
tri\r = 1.0
tri\g = 1.0
tri\b = 1.0
tri2.color_3_f
tri2\r = 1.0
tri2\g = 0
tri2\b = 0
tri3.color_3_i
tri3\r = 0
tri3\g = 0
tri3\b = 0
Structure rond
x.i
y.i
rayon.i
EndStructure
Myvar.rond
myvar\x = 10
myvar\y = 10
myvar\rayon = 5
Myvar2.rond
myvar2\x = 10
myvar2\y = 10
myvar2\rayon = 0
resultx.i = 0
resulty.i = 0
move.f = 0
f_move_circle.f = 0
max_move.f = 0
color_change.i = 0
rnd.i = 90
Procedure lerp(*a.color_3_f, *b.color_3_f, t.f)
Shared tri3.color_3_i
tri3\r = Int((*a\r + ( *b\r - *a\r) * t) * 255.999)
tri3\g = Int((*a\g + ( *b\g - *a\g) * t) * 255.999)
tri3\b = Int((*a\b + ( *b\b - *a\b) * t) * 255.999)
EndProcedure
Procedure myCircle(X, Y, *cl.rond, rot, *col.color_3_i)
Shared f_move_circle
Shared rnd
For n=0 To rot
If rnd > 85 And rnd <= 90
cx = *cl\rayon * Cos(n/rnd) * Sin(f_move_circle+n*rnd)
cy= *cl\rayon * Sin(n*4*rnd) * Cos(f_move_circle-n*rnd)
Plot(cx+*cl\x+ X,cy+*cl\y+Y,RGB((*col\r),(*col\g),*col\b) )
ElseIf rnd > 75 And rnd < 85
cx = *cl\rayon * Cos(n*Cos(rnd)*2*rnd)
cy= *cl\rayon * Sin(n*Cos(n*2)/rnd*n*rnd)
Plot(cx+*cl\x+ X,cy+*cl\y+Y,RGB((*col\r),(*col\g),*col\b) )
ElseIf rnd > 65 And rnd < 75
cx = *cl\rayon * Cos(rnd*n*4*Sin(n*rnd))
cy= *cl\rayon * Sin(rnd*n*4*Cos(n*rnd))
Plot(cx+*cl\x+ X,cy+*cl\y+Y,RGB((*col\r),(*col\g),*col\b) )
ElseIf rnd > 55 And rnd < 65
cx = *cl\rayon * Cos(n*n*rnd*f_move_circle)
cy= *cl\rayon * Sin(n*n*rnd*f_move_circle)
Plot(cx+*cl\x+ X,cy+*cl\y+Y,RGB((*col\r),(*col\g),*col\b) )
ElseIf rnd > 45 And rnd < 55
cx = *cl\rayon * Cos(n*rnd) * Cos(n-rnd-100)
cy= *cl\rayon * Sin(n*rnd) * Cos(n+rnd+100)
Plot(cx+*cl\x+ X,cy+*cl\y+Y,RGB((*col\r),(*col\g),*col\b) )
ElseIf rnd > 35 And rnd < 45
cx = *cl\rayon * Cos(n/rnd*n) * Sin(n)
cy= *cl\rayon * Sin(n*rnd) * Cos(Sin(n)*n)
Plot(cx+*cl\x+ X,cy+*cl\y+Y,RGB((*col\r),(*col\g),*col\b) )
ElseIf rnd > 25 And rnd < 35
cx = *cl\rayon * Cos(n*rnd*f_move_circle)
cy= *cl\rayon * Sin(n*rnd*f_move_circle)
Plot(cx+*cl\x+ X,cy+*cl\y+Y,RGB((*col\r),(*col\g),*col\b) )
ElseIf rnd > 15 And rnd < 25
cx = *cl\rayon * Cos(n*rnd) * Sin(Cos(f_move_circle))
cy= *cl\rayon * Sin(n*rnd) * Cos(f_move_circle)
Plot(cx+*cl\x+ X,cy+*cl\y+Y,RGB((*col\r),(*col\g),*col\b) )
ElseIf rnd > 0 And rnd < 15
cx = *cl\rayon * Cos(n*rnd)
cy= *cl\rayon * Sin(n*rnd)
Plot(cx+*cl\x+ X,cy+*cl\y+Y,RGB((*col\r),(*col\g),*col\b) )
EndIf
Next
EndProcedure
Procedure Circle_rotation(X, Y, iter, c_rot.f)
Shared Myvar2.rond
Shared f_move_circle
Shared rnd
Shared tri.color_3_f
Shared tri2.color_3_f
Shared tri3.color_3_i
If f_move_circle <= 1.0
lerp(@tri, @tri2, f_move_circle)
EndIf
myCircle(X, Y, @Myvar2, c_rot, @tri3)
If iter > 0 And c_rot > 0.0
While c < rnd
If iter > 0
Myvar2\rayon = f_move_circle*5.0 * c
Else
Myvar2\rayon = 5.0
EndIf
Circle_rotation(Exp((f_move_circle*5-c)/100)*Cos(f_move_circle*5+c)*100+X, Exp((f_move_circle*5-c)/100)*Sin(f_move_circle*5+c)*100+Y, iter-1, c_rot-1)
c = c+1
Wend
EndIf
EndProcedure
Repeat
Repeat
event = WindowEvent()
Select event
Case #PB_Event_CloseWindow
Quit = 1
EndSelect
Until event = 0
ExamineKeyboard()
ClearScreen(RGB(0,0,0))
StartDrawing(ScreenOutput())
move.f + 1/1000
wave_x.f = Cos(x) * 200
wave_y.f = Sin(x) * 200
If xm < 3
xm = 3
Else
If xm >790*2
xm = 790*2
EndIf
EndIf
If ym < 3
ym = 3
Else
If ym > 590*2
ym = 590*2
EndIf
EndIf
max_move = 10.0
f_move_circle + 1/700.0
If f_move_circle <= max_move
If move <= 1.0
Circle_rotation(380*2, 300*2, 1, 3600)
move = 0.0
EndIf
EndIf
If f_move_circle > 1.0
rnd = Random(90)
tri\r = Random(10000) / 10000.0
tri\g = Random(10000) / 10000.0
tri\b = Random(10000) / 10000.0
tri2\r = Random(10000) / 10000.0
tri2\g = Random(10000) / 10000.0
tri2\b = Random(10000) / 10000.0
f_move_circle = 0.0
Else
f_move_circle = f_move_circle
EndIf
StopDrawing()
If KeyboardPushed(#PB_Key_Escape) Or Quit = #True
End
EndIf
FlipBuffers()
ForEver
End
Happy coding !