Page 1 of 2

twisting pillar effect

Posted: Thu Jul 18, 2024 7:46 am
by Mr.L
...just some eyecandy - make sure to disable debug mode

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), Min(255, b * sf + sp)))
    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, x2, y, #Red, rot) : EndIf
            If x2 < x3 : renderLine(x2, x3, 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

Re: twisting pillar effect

Posted: Thu Jul 18, 2024 8:21 am
by Fangbeast
That is totally unreal. Reminds me of many types of candy being twisted on a roller before they harden.

Thanks for that!

Re: twisting pillar effect

Posted: Thu Jul 18, 2024 8:29 am
by RASHAD
Another contender to pf shadoko :mrgreen:
Nice effect
Thanks

Re: twisting pillar effect

Posted: Thu Jul 18, 2024 9:05 am
by idle
wow, i didn't expect that! :shock:

Re: twisting pillar effect

Posted: Thu Jul 18, 2024 10:03 am
by moulder61
Dayum! That's pretty spectacular!
How do you even come up with that stuff?

Moulder.

Re: twisting pillar effect

Posted: Thu Jul 18, 2024 10:22 am
by BarryG
Fangbeast wrote: Thu Jul 18, 2024 8:21 amReminds me of many types of candy being twisted on a roller before they harden.
Was literally about to post this comment as well! Like the candy shop near the Big Banana.

Re: twisting pillar effect

Posted: Thu Jul 18, 2024 10:30 am
by pf shadoko
36 lines of code !
great job !

Re: twisting pillar effect

Posted: Thu Jul 18, 2024 12:40 pm
by Mr.L
moulder61 wrote: Thu Jul 18, 2024 10:03 am How do you even come up with that stuff?
Actually, the idea came to me after reading the previous topic 'Snake simulation'.
In ancient times there was a very active computer demo scene, that came up with the craziest stuff (look for 64k demos or even 4k demos on pouet.net).
One of these effects was the 'twisting 4-Sided column'. And so I started coding, added some Sin here and a little bit of Cos there, and here you go! :lol:

Re: twisting pillar effect

Posted: Thu Jul 18, 2024 1:10 pm
by jacdelad
What the...! :shock:

Re: twisting pillar effect

Posted: Thu Jul 18, 2024 1:19 pm
by moulder61
@Mr.L

In ancient times you would have been burned at the stake for this wizardry. ;)

Moulder.

Re: twisting pillar effect

Posted: Thu Jul 18, 2024 2:10 pm
by Fangbeast
BarryG wrote: Thu Jul 18, 2024 10:22 am
Fangbeast wrote: Thu Jul 18, 2024 8:21 amReminds me of many types of candy being twisted on a roller before they harden.
Was literally about to post this comment as well! Like the candy shop near the Big Banana.
I was channeling your mind in your sleep:):)

Re: twisting pillar effect

Posted: Thu Jul 18, 2024 4:54 pm
by Nituvious
I would like to create a petition; all eye candy code must be accompanied by eye candy screenshots! :mrgreen:

Re: twisting pillar effect

Posted: Mon Jul 22, 2024 7:05 am
by firace
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

Re: twisting pillar effect

Posted: Thu Aug 01, 2024 3:24 pm
by SPH
TOP XTRA ! Waouwwww !! Small code ! GG 👍

Re: twisting pillar effect

Posted: Wed Aug 07, 2024 3:29 pm
by Kwai chang caine
What words can be used for define this splendid effect more true than nature ??? :shock:
Thanks for sharing 8)