_TITLE "Lotus Graph"
' This program exported from BASIC Anywhere Machine (Version [5.2.3].[2024.07.14.16.44]) on 2024.08.31 at 17:55 (Coordinated Universal Time)
' This program is a port and mod by Charlie Veniot
' of a QB64 port by Luis Alberto Migliorero (https://www.facebook.com/share/p/SopXe3tgxxsWgkHR/)
' of a C64 (CBM BASIC v2) program by Alvaro Alonso G. (https://www.facebook.com/share/p/KsTAzh7ee41PnVQN/)


210 SCREEN _NEWIMAGE( 641, 481, 17 )
300 REM constants =======================
    310 dr = _PI / 180
320 REM screen resolution ===============
    350 xc = INT( _WIDTH  / 2 ) : REM center screen
    360 yc = INT( _HEIGHT / 2 ) : REM center screen
370 REM axis ============================
    380 LINE( 0,  yc ) - ( XMAX, yc   )
    390 LINE( xc, 0  ) - ( xc,   YMAX )
    cadj% = 0
400 REM ========================
    410 h2 = _PI / 2
    420 k2 = 2
    430 k3 = 3
    440 k5 = 0.25
    450 k6 = 6
    460 k8 = 8
    470 ra = 150
    480 u = 1 : REM Definition of u
    490 z = 0 : REM Definition of z
500 REM Draw the petals fully colored
    510 FOR rScale = ra TO 0 STEP -.1 : REM Gradually Lowering Radio to Fill
        cadj2% = 0
        520 FOR a = 0 TO 360 STEP .1
            530 t = a * dr
            540 p1 = ABS( COS( k3 * t ) ) + k2 * ( k5 - ABS( COS( k3 * t + h2 ) ) )
            550 p2 = k2 + k8 * ABS( COS( k6 * t + h2 ) )
            560 r = rScale * ( u + p1 / p2 )
            570 x2 = xc + r * COS( t )
            580 y2 = yc - r * SIN( t )
            c% = INT( ( ra - rScale ) \ 10 + 1 ) + cadj% + cadj2%
            IF c% = 0 THEN cadj2% = 1 : c% = c% + 1
            590 PSET( INT( x2 ), INT( y2 ) ), c% : REM Choose color based on distance
        600 NEXT a
    SLEEP 0.001
    610 NEXT rScale
    cadj% = cadj% + 1
    SLEEP 1
    IF _MOUSEBUTTON THEN WHILE _MOUSEBUTTON : WEND
    GOTO 400