Thread Rating:
  • 1 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Super Plasmas screen saver
#10
Thanks, mstasak.  Here's a new version with some additions, including your colorshift code.

In this one, current plasma num and colorshift used is shown in title bar.  I added so color brightness changing, to make it look more interesting.  If thats not desired you can remove the 'brit' stuff before the LINE call (I added brit to the alpha in the LINE call too)..

Press R to turn on/off rotation to auto-cycle through the plasmas.  Default is on.
Press N to go to next plasma (was space in old one).
Press C to change current colorshift used.
Press P to pause/un-pause program.
ESC quits.

- Dav

EDIT:  Added C to change colorshift

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

'CREDIT: colorshift code provided by mstasak (thanks!)

'This is a plasma screensaver of Sin/Cos patterns.
'Randomly shows colorshift = Int(Rnd * 8) 1 of 20 plasmas every few seconds.
'Current Plasma number used is shown in TITLE bar,
'as well as the colorshift currently used.

'Press N to skip to another plasma number.
'Press C to change colorshift
'Press R to turn On/Off plasma rotation.
'Press P to pause program.
'Press ESC to quit.

Randomize Timer

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

cx = _Width / 2
cy = _Height / 2

rotation = 1 'auto cycle through different plasmas, default is ON

Do

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

    t = Timer

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

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

            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

            'colorshift mod/codes below provided by mstasak

            Select Case colorshift
                Case 0 'original
                    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
                    clr$ = "original"
                Case 1 'vivid (darker darks)
                    r1 = (Sin(rad * 2 + t) + Sin(a * 5 + t)) * 192 + 63
                    g1 = (Sin(rad * 2 + t + 1) + Sin(a * 5 + t + 1)) * 192 + 63
                    b1 = (Sin(rad * 2 + t + 2) + Sin(a * 5 + t + 2)) * 192 + 63
                    r2 = (Sin(rad * 3 + t) + Sin(a * 3 + t + 1)) * 192 + 63
                    g2 = (Sin(rad * 3 + t + 2) + Sin(a * 3 + t + 3)) * 192 + 63
                    b2 = (Sin(rad * 3 + t + 4) + Sin(a * 3 + t + 4)) * 192 + 63
                    clr$ = "vivid - darker darks"
                Case 2 'red shift
                    r1 = (Sin(rad * 2 + t) + Sin(a * 5 + t)) * 127 + 128
                    g1 = (Sin(rad * 2 + t + 1) + Sin(a * 5 + t + 1)) * 63 + 64
                    b1 = (Sin(rad * 2 + t + 2) + Sin(a * 5 + t + 2)) * 63 + 64
                    r2 = (Sin(rad * 3 + t) + Sin(a * 3 + t + 1)) * 127 + 128
                    g2 = (Sin(rad * 3 + t + 2) + Sin(a * 3 + t + 3)) * 63 + 64
                    b2 = (Sin(rad * 3 + t + 4) + Sin(a * 3 + t + 4)) * 63 + 64
                    clr$ = "red shift"
                Case 3 'green shift
                    r1 = (Sin(rad * 2 + t) + Sin(a * 5 + t)) * 63 + 64
                    g1 = (Sin(rad * 2 + t + 1) + Sin(a * 5 + t + 1)) * 127 + 128
                    b1 = (Sin(rad * 2 + t + 2) + Sin(a * 5 + t + 2)) * 63 + 64
                    r2 = (Sin(rad * 3 + t) + Sin(a * 3 + t + 1)) * 63 + 64
                    g2 = (Sin(rad * 3 + t + 2) + Sin(a * 3 + t + 3)) * 127 + 128
                    b2 = (Sin(rad * 3 + t + 4) + Sin(a * 3 + t + 4)) * 63 + 64
                    clr$ = "green shift"
                Case 4 'blue shift
                    r1 = (Sin(rad * 2 + t) + Sin(a * 5 + t)) * 63 + 64
                    g1 = (Sin(rad * 2 + t + 1) + Sin(a * 5 + t + 1)) * 63 + 64
                    b1 = (Sin(rad * 2 + t + 2) + Sin(a * 5 + t + 2)) * 127 + 128
                    r2 = (Sin(rad * 3 + t) + Sin(a * 3 + t + 1)) * 63 + 64
                    g2 = (Sin(rad * 3 + t + 2) + Sin(a * 3 + t + 3)) * 63 + 64
                    b2 = (Sin(rad * 3 + t + 4) + Sin(a * 3 + t + 4)) * 127 + 128
                    clr$ = "blue shift"
                Case 5 'monochrome gray shift
                    r1 = (Sin(rad * 2 + t) + Sin(a * 5 + t)) * 192 + 63
                    g1 = (Sin(rad * 2 + t + 0) + Sin(a * 5 + t + 0)) * 192 + 63
                    b1 = (Sin(rad * 2 + t + 0) + Sin(a * 5 + t + 0)) * 192 + 63
                    r2 = (Sin(rad * 3 + t) + Sin(a * 3 + t + 0)) * 192 + 63
                    g2 = (Sin(rad * 3 + t + 0) + Sin(a * 3 + t + 0)) * 192 + 63
                    b2 = (Sin(rad * 3 + t + 0) + Sin(a * 3 + t + 0)) * 192 + 63
                    clr$ = "monochrome gray"
                Case 6 'hercules green
                    r1 = 0 'r1 = (Sin(rad * 2 + t) + Sin(a * 5 + t)) * 192 + 63
                    g1 = (Sin(rad * 2 + t + 0) + Sin(a * 5 + t + 0)) * 192 + 63
                    b1 = 0 'b1 = (Sin(rad * 2 + t + 0) + Sin(a * 5 + t + 0)) * 192 + 63
                    r2 = 0 'r2 = (Sin(rad * 3 + t) + Sin(a * 3 + t + 0)) * 192 + 63
                    g2 = (Sin(rad * 3 + t + 0) + Sin(a * 3 + t + 0)) * 192 + 63
                    b2 = 0 'b2 = (Sin(rad * 3 + t + 0) + Sin(a * 3 + t + 0)) * 192 + 63
                    clr$ = "hercules green"
                Case 7 'hercules amber
                    r1 = (Sin(rad * 2 + t) + Sin(a * 5 + t)) * 192 + 63
                    g1 = r1 * 0.6 '(Sin(rad * 2 + t + 0) + Sin(a * 5 + t + 0)) * 192 + 63
                    b1 = r1 * 0.1 '(Sin(rad * 2 + t + 0) + Sin(a * 5 + t + 0)) * 192 + 63
                    r2 = (Sin(rad * 3 + t) + Sin(a * 3 + t + 0)) * 192 + 63
                    g2 = r2 * 0.6 '(Sin(rad * 3 + t + 0) + Sin(a * 3 + t + 0)) * 192 + 63
                    b2 = r2 * 0.1 '(Sin(rad * 3 + t + 0) + Sin(a * 3 + t + 0)) * 192 + 63
                    clr$ = "hercules amber"
            End Select

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


            'brit changes color brightness over time for added dynamics.
            brit = .85 + Sin(t * .6 + a * .001) * .6
            r = r * brit
            g = g * brit
            b = b * brit


            Line (x, y)-Step(4, 4), _RGBA(r, g, b, 155 * brit), BF

        Next
    Next

    k$ = UCase$(InKey$)
    If k$ <> "" Then
        If k$ = Chr$(27) Then Exit Do
        If k$ = "N" Then
            plasma = Int(Rnd * 20) + 1
            colorshift = Int(Rnd * 8)
            oldt = t
        End If
        If k$ = "C" Then colorshift = Int(Rnd * 8)
        If k$ = "R" Then
            Select Case rotation
                Case 1: rotation = 0
                Case Else: rotation = 1
            End Select
        End If
        If k$ = "P" Then Sleep
        _KeyClear
    End If


    title$ = "Plasma: " + Str$(plasma) + "  (C)olor: " + clr$ + ", (N)ext, (P)ause, (R}otation:"
    If rotation = 1 Then rot$ = "On" Else rot$ = "Off"
    _Title title$ + rot$

    _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 332 12-27-2025, 06:25 PM
Last Post: bplus
  aquascape screen saver ver1.1 kn0ne 0 575 04-23-2024, 10:20 PM
Last Post: kn0ne
  Space Orbs. Small screen saver. Dav 16 3,144 08-27-2023, 07:52 PM
Last Post: grymmjack
  Updated old Googly Eyes screen saver Dav 10 2,296 07-10-2023, 01:15 PM
Last Post: bplus

Forum Jump:


Users browsing this thread: 1 Guest(s)