Basicprogramming(.org) > SmallBASIC

Beating Cardioid

(1/1)

B+:
A little late, or allot early!  ;D

--- Code: ---'_TITLE "Beating Cardioid" 'B+ 2019-02-16, QB64 translation

'CONST xmax = 800
'CONST ymax = 600
'SCREEN _NEWIMAGE(xmax, ymax, 32)
'_SCREENMOVE (1280 - xmax) / 2 + 30, (760 - ymax) / 2

'center of screen
CX = xmax / 2
CY = ymax / 2

WHILE 1
    CLS
    loopCount = (loopCount + 1) % 2
    IF loopCount THEN magnify = 10 ELSE magnify = 15
    FOR a = -PI TO PI STEP PI*(1 / 360)
        x = CX + magnify * xCard(a)
        y = CY - magnify * yCard(a)
        IF a <> -PI THEN
            LINE x, y,lastx, lasty, 12
        END IF
        lastx = x: lasty = y
    NEXT
    PAINT CX, CY, 12
    Showpage
    IF loopCount THEN delay 460  ELSE delay 400
WEND

'Reference and thanks to:
' http://mathworld.wolfram.com/HeartCurve.html
' find the 6th heart curve equations #7, 8
FUNC xCard (t)
    xCard = 16 * SIN(t) ^ 3
END

FUNC yCard (t)
    yCard = 13 * COS(t) - 5 * COS(2 * t) - 2 * COS(3 * t) - COS(4 * t)
END


--- End code ---

Navigation

[0] Message Index

Go to full version