Really nice! Also, fiddling with parts of the code produces other interesting effects - for instance:
1.
Code: Select all
InitSprite() : #WID = 400 : #HIG = 800
OpenWindow(0, 0, 0, #WID, #HIG, "!") : OpenWindowedScreen(WindowID(0), 0, 0, #WID, #HIG)
Procedure.f Min(a.f,b.f) : If a < b : ProcedureReturn a: EndIf: ProcedureReturn b : EndProcedure
Procedure.f Max(a.f,b.f) : If a > b : ProcedureReturn a: EndIf: ProcedureReturn b : EndProcedure
Macro renderLine(x1, x2, y, color, angle)
xMid.f = (x1 + x2) * 0.5 : r = Red(color): g = Green(color): b = Blue(color)
rng.f = 1.0 / (x2 - xMid) : x1 = Min(Max(0,x1),#WID-1) : x2 = Min(Max(0,x2),#WID-1)
For x = x1 To x2
pos.f = (x - xMid) * rng
ang.f = (angle + ASin(pos) + (Cos((angle + pos * 2 * #PI) * 1.78) * 0.3)) + #PI * 0.5
sf.f = 0.2 + 0.8 * Max(0, Min(1, Cos(ang))) : sp.f = Pow(Max(0, Cos(2 * ang)), 20) * 255
Plot(x, y, $ce9A9A)
Next
EndMacro
Repeat
ClearScreen(RGB(64,64,64))
If StartDrawing(ScreenOutput())
t.f = ElapsedMilliseconds() / 1000.0
ta.f = Sin(t * Cos(t) * 0.02) + t : tb.f = (1.0 + Sin(t) * 1.0) * 0.02 + 0.01
xa.f = #WID * 0.5
For y = 0 To #HIG - 1
ya.f = y * 0.01
rad.f = 60 + Sin(ta + ya) * 30: rot.f = t + Sin(ya * 2) * 0.5 + Cos(ta * 0.3) * 0.3
x1 = xa + Sin(rot) * rad : x2 = xa + Sin(rot + #PI * 0.5) * rad
x3 = xa + Sin(rot + #PI) * rad : x4 = xa + Sin(rot + #PI * 1.5) * rad
If x1 < x2 : renderLine(x1, x1, y, #Red, rot) : EndIf
If x2 < x3 : renderLine(x2, x4, y, #Green, rot + #PI * 0.5) : EndIf
If x3 < x4 : renderLine(x3, x4, y, #Blue, rot + #PI) : EndIf
If x4 < x1 : renderLine(x4, x1, y, #Yellow, rot + #PI * 1.5) : EndIf
t + Sin(ta + ya) * tb : xa + Sin(t + ta) * 0.1
Next
StopDrawing()
EndIf
FlipBuffers()
While WindowEvent():If Event() = #PB_Event_CloseWindow:End:EndIf:Wend
ForEver
2.
Code: Select all
InitSprite() : #WID = 400 : #HIG = 800
OpenWindow(0, 0, 0, #WID, #HIG, "!") : OpenWindowedScreen(WindowID(0), 0, 0, #WID, #HIG)
Procedure.f Min(a.f,b.f) : If a < b : ProcedureReturn a: EndIf: ProcedureReturn b : EndProcedure
Procedure.f Max(a.f,b.f) : If a > b : ProcedureReturn a: EndIf: ProcedureReturn b : EndProcedure
Macro renderLine(x1, x2, y, color, angle)
xMid.f = (x1 + x2) * 0.5 : r = Red(color): g = Green(color): b = Blue(color)
rng.f = 1.0 / (x2 - xMid) : x1 = Min(Max(0,x1),#WID-1) : x2 = Min(Max(0,x2),#WID-1)
For x = x1 To x2
pos.f = (x - xMid) * rng
ang.f = (angle + ASin(pos) + (Cos((angle + pos * 2 * #PI) * 1.78) * 0.3)) + #PI * 0.5
sf.f = 0.2 + 0.8 * Max(0, Min(1, Cos(ang))) : sp.f = Pow(Max(0, Cos(2 * ang)), 20) * 255
Plot(x, y, RGB(Min(255, r * sf + sp), Min(255, g * sf + sp), $99))
Next
EndMacro
Repeat
ClearScreen(RGB(64,64,64))
If StartDrawing(ScreenOutput())
t.f = ElapsedMilliseconds() / 1000.0
ta.f = Sin(t * Cos(t) * 0.02) + t : tb.f = (1.0 + Sin(t) * 1.0) * 0.02 + 0.01
xa.f = #WID * 0.5
For y = 0 To #HIG - 1
ya.f = y * 0.01
rad.f = 60 + Sin(ta + ya) * 30: rot.f = t + Sin(ya * 2) * 0.5 + Cos(ta * 0.3) * 0.3
x1 = xa + Sin(rot) * rad : x2 = xa + Sin(rot + #PI * 0.5) * rad
x3 = xa + Sin(rot + #PI) * rad : x4 = xa + Sin(rot + #PI * 1.5) * rad
If x1 < x2 : renderLine(x1, x1, y, #Red, rot) : EndIf
If x2 < x3 : renderLine(x2, x4, y, #Green, rot + #PI * 0.5) : EndIf
If x3 < x4 : renderLine(x3, x4, y, #Blue, rot + #PI) : EndIf
If x4 < x1 : renderLine(x4, x1, y, #Yellow, rot + #PI * 1.5) : EndIf
t + Sin(ta + ya) * tb : xa + Sin(t + ta) * 0.1
Next
StopDrawing()
EndIf
FlipBuffers()
While WindowEvent():If Event() = #PB_Event_CloseWindow:End:EndIf:Wend
ForEver
3.
Code: Select all
InitSprite() : #WID = 400 : #HIG = 800
OpenWindow(0, 0, 0, #WID, #HIG, "!") : OpenWindowedScreen(WindowID(0), 0, 0, #WID, #HIG)
Procedure.f Min(a.f,b.f) : If a < b : ProcedureReturn a: EndIf: ProcedureReturn b : EndProcedure
Procedure.f Max(a.f,b.f) : If a > b : ProcedureReturn a: EndIf: ProcedureReturn b : EndProcedure
Macro renderLine(x1, x2, y, color, angle)
xMid.f = (x1 + x2) * 0.5 : r = Red(color): g = Green(color): b = Blue(color)
rng.f = 1.0 / (x2 - xMid) : x1 = Min(Max(0,x1),#WID-1) : x2 = Min(Max(0,x2),#WID-1)
For x = x1 To x2
pos.f = (x - xMid) * rng
ang.f = (angle + ASin(pos) + (Cos((angle + pos * 2 * #PI) * 1.78) * 0.3)) + #PI * 0.5
sf.f = 0.2 + 0.8 * Max(0, Min(1, Cos(ang))) : sp.f = Pow(Max(0, Cos(2 * ang)), 20) * 255
; Plot(x, y, RGB(Min(255, g * sf + sp), Min(255, g * sf + sp), $29))
Plot(x, y, RGB(Min(255, g * sf + sp), Min(255, g * sf + sp), $29))
Next
EndMacro
Repeat
ClearScreen(RGB(64,64,64))
If StartDrawing(ScreenOutput())
t.f = ElapsedMilliseconds() / 1000.0
ta.f = Sin(t * Cos(t) * 0.02) + t : tb.f = (1.0 + Sin(t) * 1.0) * 0.02 + 0.01
xa.f = #WID * 0.5
For y = 0 To #HIG - 1
ya.f = y * 0.05
rad.f = 60 + Sin(ta + ya) * 30: rot.f = t + Sin(ya * 2) * 0.5 + Cos(ta * 0.3) * 0.3
x1 = xa + Cos(rot) * rad : x2 = xa + Sin(rot + #PI * 0.5) * rad
x3 = xa + Sin(rot + #PI) * rad : x4 = xa + Cos(rot + #PI * 1.5) * rad
If x1 < x2 : renderLine(x1, x1, y, #Red, rot) : EndIf
If x2 < x3 : renderLine(x2, x4, y, #Green, rot + #PI * 0.5) : EndIf
If x3 < x4 : renderLine(x3, x4, y, #Blue, rot + #PI) : EndIf
If x4 < x1 : renderLine(x4, x1, y, #Yellow, rot + #PI * 1.5) : EndIf
t + Sin(ta + ya) * tb : xa + Sin(t + ta) * 0.1
Next
StopDrawing()
EndIf
FlipBuffers()
While WindowEvent():If Event() = #PB_Event_CloseWindow:End:EndIf:Wend
ForEver