Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Screen Savers
#31
Another Golden Oldie from bplus collection:

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 + ...
Reply


Messages In This Thread
Screen Savers - by bplus - 04-27-2022, 12:29 AM
RE: Screen Savers - by Dav - 04-27-2022, 02:26 PM
RE: Screen Savers - by bplus - 04-27-2022, 02:33 PM
RE: Screen Savers - by bplus - 04-30-2022, 11:55 PM
RE: Screen Savers - by Dav - 05-01-2022, 07:22 PM
RE: Screen Savers - by bplus - 05-01-2022, 08:26 PM
RE: Screen Savers - by bplus - 05-02-2022, 12:00 AM
RE: Screen Savers - by Coolman - 05-02-2022, 09:42 AM
RE: Screen Savers - by bplus - 05-03-2022, 02:13 AM
RE: Screen Savers - by bplus - 05-09-2022, 01:32 PM
RE: Screen Savers - by bplus - 05-19-2022, 07:22 PM
RE: Screen Savers - by bplus - 05-21-2022, 11:22 PM
RE: Screen Savers - by Pete - 05-21-2022, 11:27 PM
RE: Screen Savers - by bplus - 05-21-2022, 11:38 PM
RE: Screen Savers - by Pete - 05-22-2022, 04:39 AM
RE: Screen Savers - by bplus - 06-17-2022, 01:10 PM
RE: Screen Savers - by johnno56 - 06-18-2022, 12:23 AM
RE: Screen Savers - by Kernelpanic - 06-18-2022, 11:48 AM
RE: Screen Savers - by bplus - 06-18-2022, 01:47 AM
RE: Screen Savers - by bplus - 06-18-2022, 12:33 PM
RE: Screen Savers - by SierraKen - 06-20-2022, 09:50 PM
RE: Screen Savers - by bplus - 06-21-2022, 12:15 AM
RE: Screen Savers - by bplus - 06-29-2022, 04:52 PM
RE: Screen Savers - by SierraKen - 06-29-2022, 06:10 PM
RE: Screen Savers - by vince - 07-01-2022, 10:32 PM
RE: Screen Savers - by bplus - 07-01-2022, 11:05 PM
RE: Screen Savers - by bplus - 07-04-2022, 06:54 PM
RE: Screen Savers - by Kernelpanic - 07-04-2022, 09:11 PM
RE: Screen Savers - by bplus - 07-04-2022, 09:54 PM
RE: Screen Savers - by Kernelpanic - 07-05-2022, 02:14 PM
RE: Screen Savers - by bplus - 07-19-2022, 08:28 PM
RE: Screen Savers - by bplus - 08-28-2022, 12:55 AM
RE: Screen Savers - by TempodiBasic - 08-29-2022, 09:26 AM
RE: Screen Savers - by bplus - 09-06-2022, 12:35 AM
RE: Screen Savers - by SierraKen - 09-08-2022, 07:37 PM
RE: Screen Savers - by bplus - 09-09-2022, 02:22 AM
RE: Screen Savers - by SpriggsySpriggs - 09-15-2022, 04:38 PM
RE: Screen Savers - by bplus - 09-15-2022, 05:20 PM
RE: Screen Savers - by bplus - 01-31-2023, 04:21 PM
RE: Screen Savers - by vince - 02-01-2023, 07:27 AM
RE: Screen Savers - by bplus - 02-01-2023, 05:05 PM
RE: Screen Savers - by bplus - 03-13-2023, 10:51 PM
RE: Screen Savers - by vince - 03-31-2023, 11:09 PM
RE: Screen Savers - by bplus - 04-01-2023, 12:09 AM
RE: Screen Savers - by bplus - 05-14-2024, 03:00 PM
RE: Screen Savers - by PhilOfPerth - 05-15-2024, 08:24 AM
RE: Screen Savers - by bplus - 05-15-2024, 11:15 PM
RE: Screen Savers - by bplus - 08-20-2024, 12:00 AM



Users browsing this thread: 1 Guest(s)