12-23-2025, 08:48 AM
Here is a Plasma demo that I found on QB64pe site (coded by Dav)
There are 20 pre-sets. Roughly 5 seconds between each. Space key to advance the count. Frame rates may need tweaking a little...
There are 20 pre-sets. Roughly 5 seconds between each. Space key to advance the count. Frame rates may need tweaking a little...
Code:
set window "Plasma", 720, 720, false
' Coded by Dav for QB64PE, NOV/2025
' N7 version johnno56 DEC/2025
set redraw off
visible cx = width(primary) / 2
visible cy = height(primary) / 2
visible plasma
visible radd
fnt = createfont("arial", 48, true, false, false, true)
set font fnt
t = clock()
oldt = 0 'clock()
plasma = 1
set color 0, 0, 0; cls
do
pulse = sin(t) * 0.8
t = clock()
if t - oldt >= 5000
plasma = plasma + 1
if plasma > 20 plasma = 1
oldt = t
endif
for y = 0 to height(primary) step 4
for x = 0 to width(primary) 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(radd * 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) * radd 'spiral radius
case 5
a = a + atan2(y - cy, x - cx) + sin(t * 4 + (x / width(primary))) * 0.5 'edge wave
case 6
a = a + atan2(y - cy, x - cx) + (x / width(primary)) * sin(t) * 5 'distort
case 7
a = a + atan2(y - cy, x - cx) + cos(t) * 3 + sin(x / width(primary) + t * 3) 'better wave
case 8
a = a + atan2(y - cy, x - cx) + sin(t * 2) * cos(radd * 2) 'double twist!
case 9
a = a + atan2(y - cy, x - cx) + sin(radd * 1.5 + t * 4) 'inward spiral
case 10
a = a + atan2(y - cy, x - cx) + sin(x * 0.01 + t) * cos(y * 0.01 + t) 'mumps!
'new effects
case 11
a = a + atan2(y - cy, x - cx) + sin(t * 0.5 + radd * 0.3) * 2 'slower spiral wave
case 12
a = a + atan2(y - cy, x - cx) + cos(t * 1.5 + radd * 0.7) * 3 'another twist
case 13
a = a + atan2(y - cy, x - cx) + sin(radd * 4 + t * 0.8) * 1.5 'radial ripple
case 14
a = a + atan2(y - cy, x - cx) + sin(x * 0.05 + t) * 2 'horizontal wave
case 15
a = a + atan2(y - cy, x - cx) + cos(y * 0.05 + t) * 2 'vertical wave
case 16
a = a + atan2(y - cy, x - cx) + sin(radd * 6 + t * 1.2) * 2 'higher ripples
case 17
a = a + atan2(y - cy, x - cx) + sin(x * 0.02 + t * 2) * cos(y * 0.02 + t * 2) 'more wave
case 18
a = a + atan2(y - cy, x - cx) + sin(radd * 3 + t * 1.5) * sin(radd * 3 + t * 1.5) 'more ripples
case 19
a = a + atan2(y - cy, x - cx) + sin(radd * 3 + t * 2) * 3 'wavy circles
case 20
a = a + atan2(y - cy, x - cx) + sin(radd * 6 + t) + sin(a * 3 + t * 2) 'more wavy pattern
endsel
radd = sqr((x - cx) ^ 2 + (y - cy) ^ 2) / 100
' Plasma colours
r1 = (sin(radd * 2 + t) + sin(a * 5 + t)) * 127 + 128
g1 = (sin(radd * 2 + t + 1) + sin(a * 5 + t + 1)) * 127 + 128
b1 = (sin(radd * 2 + t + 2) + sin(a * 5 + t + 2)) * 127 + 128
r2 = (sin(radd * 3 + t) + sin(a * 3 + t + 1)) * 127 + 128
g2 = (sin(radd * 3 + t + 2) + sin(a * 3 + t + 3)) * 127 + 128
b2 = (sin(radd * 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
set color r, g, b, 150
draw rect x, y, 4, 4, true
next
next
set color 0, 0, 0
set caret 5, 5
wln str(plasma)
set color 255, 255, 255
set caret 3, 3
wln str(plasma)
if keydown(KEY_ESCAPE, true) break
if keydown(KEY_SPACE)
plasma = plasma + 1
if plasma > 20 plasma = 1
oldt = t
endif
redraw
fwait 10
loop
Logic is the beginning of wisdom.

