QB64 Phoenix Edition
Pringle-like Shape Animation - Printable Version

+- QB64 Phoenix Edition (https://qb64phoenix.com/forum)
+-- Forum: QB64 Rising (https://qb64phoenix.com/forum/forumdisplay.php?fid=1)
+--- Forum: Code and Stuff (https://qb64phoenix.com/forum/forumdisplay.php?fid=3)
+---- Forum: Programs (https://qb64phoenix.com/forum/forumdisplay.php?fid=7)
+---- Thread: Pringle-like Shape Animation (/showthread.php?tid=3705)



Pringle-like Shape Animation - SierraKen - 05-24-2025

I asked ChatGPT to make me a Pringle. So tinkering around with it I made this animation. 

Code: (Select All)

Screen _NewImage(600, 600, 32)
CENTERX = 300
CENTERY = 300
' Pringle parameters
SIZE = 300
STP = 1
Const ZSCALE = 30 ' Controls how much "curve" there is
num = 20
dir = 20
t = 4

Do
    If num > 3000 Then
        dir = -20
    End If
    If num < -3000 Then
        dir = 20
    End If
    num = num + dir * t
    For x! = -SIZE To SIZE Step STP
        For y! = -SIZE To SIZE Step STP
            ' Hyperbolic paraboloid formula: z = (x^2 - y^2) / scale
            z! = ((x! ^ 2) - (y! ^ 2)) / (SIZE * ZSCALE)

            ' Project to screen (top-down view with z as shading)
            screenX = CENTERX + x!
            screenY = CENTERY + y!

            ' Shade based on height (z)
            shade = 128 + z! * num
            If shade < 0 Then shade = 0
            If shade > 255 Then shade = 255

            PSet (screenX, screenY), _RGB(shade, shade, 255 - shade)
        Next
    Next
Loop Until InKey$ = Chr$(27)