07-19-2022, 08:28 PM
Another Golden Oldie from bplus collection:
QBJS Share: https://qbjs.org/?code=X1RpdGxlICJNb3Jwa...AMjKI+kBLw==
Some of these actually look better in QBJS, lines are so skinny.
Morph Curve
Code: (Select All)
_Title "Morph Curve" 'b+ 2022-07-19 trans from
' Morph Curve on Plasma.bas SmallBASIC 0.12.8 [B+=MGA] 2017-04-11
'from SpecBAS version Paul Dunn Dec 2, 2015
'https://www.youtube.com/watch?v=j2rmBRLEVms
' mods draw lines segments with drawpoly, add plasma, play with numbers
Option _Explicit
Const xmax = 1200, ymax = 700, pts = 500, interps = 30, pi = _Pi
Dim Shared plasmaR, plasmaG, plasmaB, plasmaN
Randomize Timer
Screen _NewImage(xmax, ymax, 32)
_FullScreen
Dim p(pts + 1, 1), q(pts + 1, 1), s(pts + 1, 1), i(interps)
Dim As Long L, c, j
Dim As Single cx, cy, sc, st, n, m, t, lastx, lasty
L = 0: cx = xmax / 2: cy = ymax / 2: sc = cy * .5: st = 2 * pi / pts
For n = 1 To interps
i(n) = Sin(n / interps * (pi / 2))
Next
While _KeyDown(27) = 0
resetPlasma
n = Int(Rnd * 75) + 2: m = Int(Rnd * 500) - 250: c = 0
For t = 0 To 2 * pi Step st
If _KeyDown(27) Then System
q(c, 0) = cx + sc * (Cos(t) + Cos(n * t) / 2 + Sin(m * t) / 3)
q(c, 1) = cy + sc * (Sin(t) + Sin(n * t) / 2 + Cos(m * t) / 3)
setPlasma
If t > 0 Then pline lastx, lasty, q(c, 0), q(c, 1), 10
lastx = q(c, 0): lasty = q(c, 1)
c = c + 1
Next
q(c, 0) = q(0, 0): q(c, 1) = q(0, 1)
If L = 0 Then
L = L + 1
_Display
_Limit 30
Else
For t = 1 To interps
Cls
For n = 0 To pts
If _KeyDown(27) Then System
s(n, 0) = q(n, 0) * i(t) + p(n, 0) * (1 - i(t))
s(n, 1) = q(n, 1) * i(t) + p(n, 1) * (1 - i(t))
setPlasma
If n > 0 Then pline lastx, lasty, s(n, 0), s(n, 1), 10
lastx = s(n, 0): lasty = s(n, 1)
Next
s(n, 0) = s(0, 0)
s(n, 1) = s(0, 1)
_Display
_Limit 30
Next
End If
For j = 0 To pts + 1 'copy q into p
If _KeyDown(27) Then System
p(j, 0) = q(j, 0)
p(j, 1) = q(j, 1)
Next
_Display
_Delay 4
Wend
'fast thick line!!!
Sub pline (x1, y1, x2, y2, thick) 'this draws a little rectangle
Dim r, dx, dy, perpA1, perpA2, x3, y3, x4, y4, x5, y5, x6, y6
r = thick / 2
dx = x2 - x1
dy = y2 - y1
perpA1 = _Atan2(dy, dx) + pi / 2
perpA2 = perpA1 - pi
x3 = x1 + r * Cos(perpA1) 'corner 1
y3 = y1 + r * Sin(perpA1)
x4 = x2 + r * Cos(perpA1) 'corner 2
y4 = y2 + r * Sin(perpA1)
x5 = x2 + r * Cos(perpA2) 'corner 3
y5 = y2 + r * Sin(perpA2)
x6 = x1 + r * Cos(perpA2) 'corner 4
y6 = y1 + r * Sin(perpA2)
Line (x3, y3)-(x4, y4)
Line (x4, y4)-(x5, y5)
Line (x5, y5)-(x6, y6)
Line (x6, y6)-(x3, y3)
End Sub
Sub resetPlasma () 'all globals
plasmaR = Rnd ^ 2: plasmaG = Rnd ^ 2: plasmaB = Rnd ^ 2: plasmaN = 0
End Sub
Sub setPlasma () 'all globals
plasmaN = plasmaN + .37
Color _RGB32(120 + 84 * Sin(plasmaR * plasmaN), 120 + 84 * Sin(plasmaG * plasmaN), 120 + 84 * Sin(plasmaB * plasmaN))
End Sub
QBJS Share: https://qbjs.org/?code=X1RpdGxlICJNb3Jwa...AMjKI+kBLw==
Some of these actually look better in QBJS, lines are so skinny.
b = b + ...