Thread Rating:
  • 1 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Super Plasmas screen saver
#1
About a year ago, in bplus's cool Proggies thread, a few of us had some fun playing with a program showing a small handful of Sin/Cos plasmas.  I've added a bunch more to those, 20 patterns now,  and put together this little screen saver to show them all.  It will randomly show a different plasma pattern every 5 seconds.  Current plasma number is shown in TITLE bar.  You can skip to a new one by pressing SPACE.  ESC ends.  You can easily add one of your own, just add it to the SELECT CASE (and update the plasma select RND value).

- Dav

Code: (Select All)
'================
'SuperPlasmas.bas
'================
'Coded by Dav for QB64PE, NOV/2025

'Plasma screensaver using Sin/Cos patterns.
'Randomly shows 1 of 20 plasmas every few seconds.
'Current Plasma number used is shown in TITLE bar.
'You can press SPACE to skip to a new Plasma num.
'ESC ends.

Randomize Timer

Screen _NewImage(_DesktopHeight, Int(_DesktopHeight * .75), 32)

cx = _Width / 2
cy = _Height / 2

Do

    pulse = Sin(t) * .8 'pulse factor

    t = Timer
    If t - oldt >= 5 Then
        plasma = Int(Rnd * 20) + 1 'get a new plasma every 5 seconds
        oldt = t
    End If

    For y = 0 To _Height Step 4
        For x = 0 To _Width Step 4

            a = _Atan2(y - cy, x - cx) 'base angle

            Select Case plasma
                'old effects
                Case 1: a = a + _Atan2(y - cy, x - cx) + Sin(rad * 2 + t) 'spiral twist
                Case 2: a = a + _Atan2(y - cy, x - cx) + Sin(t) * 4 'churning sin
                Case 3: a = a + _Atan2(y - cy, x - cx) + Cos(t) * 4 'churning cos
                Case 4: a = a + _Atan2(y - cy, x - cx) + Sin(t) * rad 'spiral radius
                Case 5: a = a + _Atan2(y - cy, x - cx) + Sin(t * 4 + (x / _Width)) * .5 'edge wave
                Case 6: a = a + _Atan2(y - cy, x - cx) + (x / _Width) * Sin(t) * 5 'distort
                Case 7: a = a + _Atan2(y - cy, x - cx) + Cos(t) * 3 + Sin(x / _Width + t * 3) 'better wave
                Case 8: a = a + _Atan2(y - cy, x - cx) + Sin(t * 2) * Cos(rad * 2) 'double twist!
                Case 9: a = a + _Atan2(y - cy, x - cx) + Sin(rad * 1.5 + t * 4) 'inward spiral
                Case 10: a = a + _Atan2(y - cy, x - cx) + Sin(x * .01 + t) * Cos(y * .01 + t) 'mumps!
                    'new effects
                Case 11: a = a + _Atan2(y - cy, x - cx) + Sin(t * .5 + rad * .3) * 2 'slower spiral wave
                Case 12: a = a + _Atan2(y - cy, x - cx) + Cos(t * 1.5 + rad * .7) * 3 'another twist
                Case 13: a = a + _Atan2(y - cy, x - cx) + Sin(rad * 4 + t * .8) * 1.5 'radial ripple
                Case 14: a = a + _Atan2(y - cy, x - cx) + Sin(x * .05 + t) * 2 'horizontal wave
                Case 15: a = a + _Atan2(y - cy, x - cx) + Cos(y * .05 + t) * 2 'vertical wave
                Case 16: a = a + _Atan2(y - cy, x - cx) + Sin(rad * 6 + t * 1.2) * 2 'higher ripples
                Case 17: a = a + _Atan2(y - cy, x - cx) + Sin(x * .02 + t * 2) * Cos(y * .02 + t * 2) 'more wave
                Case 18: a = a + _Atan2(y - cy, x - cx) + Sin(rad * 3 + t * 1.5) * Sin(rad * 3 + t * 1.5) 'more ripples
                Case 19: a = a + _Atan2(y - cy, x - cx) + Sin(rad * 3 + t * 2) * 3 'wavy circles
                Case 20: a = a + _Atan2(y - cy, x - cx) + Sin(rad * 6 + t) + Sin(a * 3 + t * 2) 'more wavy pattern
            End Select

            rad = Sqr((x - cx) ^ 2 + (y - cy) ^ 2) / 100

            'plasma colors
            r1 = (Sin(rad * 2 + t) + Sin(a * 5 + t)) * 127 + 128
            g1 = (Sin(rad * 2 + t + 1) + Sin(a * 5 + t + 1)) * 127 + 128
            b1 = (Sin(rad * 2 + t + 2) + Sin(a * 5 + t + 2)) * 127 + 128
            r2 = (Sin(rad * 3 + t) + Sin(a * 3 + t + 1)) * 127 + 128
            g2 = (Sin(rad * 3 + t + 2) + Sin(a * 3 + t + 3)) * 127 + 128
            b2 = (Sin(rad * 3 + t + 4) + Sin(a * 3 + t + 4)) * 127 + 128

            'blend colors with pulse
            r = r1 * (1 - pulse) + r2 * pulse
            g = g1 * (1 - pulse) + g2 * pulse
            b = b1 * (1 - pulse) + b2 * pulse

            Line (x, y)-Step(3, 3), _RGBA(r, g, b, 150), BF

        Next
    Next

    Select Case InKey$
        Case Chr$(27): Exit Do
        Case Chr$(32)
            plasma = Int(Rnd * 20) + 1
            oldt = t
    End Select


    _Title "Plasma: " + Str$(plasma) + "  (SPACE changes, ESC Quits)"

    _Display
    _Limit 30

Loop
End

Find my programs here in Dav's QB64 Corner
Reply


Messages In This Thread
Super Plasmas screen saver - by Dav - 11-12-2025, 01:43 PM
RE: Super Plasmas screen saver - by bplus - 11-12-2025, 02:24 PM
RE: Super Plasmas screen saver - by Dav - 11-12-2025, 02:37 PM
RE: Super Plasmas screen saver - by bplus - 11-12-2025, 04:45 PM
RE: Super Plasmas screen saver - by mstasak - 11-12-2025, 07:19 PM
RE: Super Plasmas screen saver - by mstasak - 11-12-2025, 07:48 PM
RE: Super Plasmas screen saver - by Dav - 11-12-2025, 08:45 PM
RE: Super Plasmas screen saver - by Dav - 11-12-2025, 09:39 PM
RE: Super Plasmas screen saver - by mstasak - 11-12-2025, 10:09 PM
RE: Super Plasmas screen saver - by Dav - 11-13-2025, 12:22 AM
RE: Super Plasmas screen saver - by Dav - 11-13-2025, 12:33 AM
RE: Super Plasmas screen saver - by mstasak - 11-13-2025, 12:45 AM
RE: Super Plasmas screen saver - by mstasak - 11-13-2025, 12:56 AM
RE: Super Plasmas screen saver - by mstasak - 11-13-2025, 01:15 AM
RE: Super Plasmas screen saver - by bplus - 11-13-2025, 01:37 AM
RE: Super Plasmas screen saver - by Dav - 11-13-2025, 12:42 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Christmas Screen Saver (Hardware Accelerated) dcoterel 2 329 12-27-2025, 06:25 PM
Last Post: bplus
  aquascape screen saver ver1.1 kn0ne 0 571 04-23-2024, 10:20 PM
Last Post: kn0ne
  Space Orbs. Small screen saver. Dav 16 3,119 08-27-2023, 07:52 PM
Last Post: grymmjack
  Updated old Googly Eyes screen saver Dav 10 2,283 07-10-2023, 01:15 PM
Last Post: bplus

Forum Jump:


Users browsing this thread: 1 Guest(s)