' This program exported from BASIC Anywhere Machine (Version [5.2.3].[2023.12.16.16.28]) on 2024.03.29 at 23:50 (Coordinated Universal Time)
' Program by Charlie Veniot
' Inspired from a recent QB64 coding challenge by bplus
' (https://qb64phoenix.com/forum/showthread.php?tid=233&pid=23984#pid23984)
' Not exactly as per the challenge because I'm a tweaker by nature.
' This program reflects my recent obsession with "DRAW",
' and my preference for animation and random colours and the animation in a forever loop.
' NOTE: As I was in a "get 'er done quick" mood, I didn't put much effort in pretty code.

SCREEN _NEWIMAGE(401,401,17)

DECLARE SUB DrawPetal(x%,y%,p%,r%)

rp% = 50
FIRST_CYCLE% = TRUE

DO

xp% = 200
color1% = INT(RND*62 + 1)
color2% = INT(RND*62 + 1)
FOR yp% = 50 to 300 step 50
COLOR color1%
CALL DrawPetal(xp%,yp%,2,rp%)
CALL DrawPetal(xp%,yp%,3,rp%)
CALL DrawPetal(xp%,yp%,4,rp%)
COLOR color2%
CALL DrawPetal(xp%,yp%+50,1,rp%)
CALL DrawPetal(xp%,yp%+50,5,rp%)
next yp%

color1% = INT(RND*62 + 1)
color2% = INT(RND*62 + 1)
xp% = xp% + 45
FOR yp% = 75 to 275 step 50
COLOR color1%
CALL DrawPetal(xp%,yp%,3,rp%)
CALL DrawPetal(xp%,yp%,4,rp%)
CALL DrawPetal(xp%-90,yp%,3,rp%)
CALL DrawPetal(xp%-90,yp%,2,rp%)
COLOR color2%
CALL DrawPetal(xp%,yp%+50,5,rp%)
CALL DrawPetal(xp%-90,yp%+50,1,rp%)
next yp%

color1% = INT(RND*62 + 1)
color2% = INT(RND*62 + 1)
xp% = xp% + 45
FOR yp% = 100 to 250 step 50
COLOR color1%
CALL DrawPetal(xp%,yp%,3,rp%)
CALL DrawPetal(xp%,yp%,4,rp%)
CALL DrawPetal(xp%-180,yp%,3,rp%)
CALL DrawPetal(xp%-180,yp%,2,rp%)
COLOR color2%
CALL DrawPetal(xp%,yp%+50,5,rp%)
CALL DrawPetal(xp%-180,yp%+50,1,rp%)
next yp%

COLOR INT(RND*62 + 1)
xp% = xp% + 45
FOR yp% = 125 to 225 step 50
CALL DrawPetal(xp%,yp%,3,rp%)
CALL DrawPetal(xp%-270,yp%,3,rp%)
next yp%

COLOR int(RND*62 + 1)
FOR A% = 0 TO 360 STEP 10
DRAW "B M 200,200"
DRAW "B TA" + A% + "U 180"
DRAW "B TA" + A% + "U 10"
x% = POINT(0) : y% = POINT(1)
FOR A# = 120 TO 240
DRAW "B M " + x% + "," + y%
DRAW "B TA " + (A#+A%) + " U 20"
CIRCLE (POINT(0),POINT(1)),2, , , , ,T
NEXT A#
DRAW "B M 200,200"
DRAW "B TA" + A% + "U 180"
DRAW "B TA" + A% + "D 10"
x% = POINT(0) : y% = POINT(1)
FOR A# = 120 TO 240
DRAW "B M " + x% + "," + y%
DRAW "B TA " + (A#+A%) + " D 20"
CIRCLE (POINT(0),POINT(1)),2, , , , ,T
NEXT A#
SLEEP 0.05
NEXT A%

sleep 3
IF _MOUSEBUTTON THEN WHILE _MOUSEBUTTON : WEND
FIRST_CYCLE% = FALSE

LOOP


END



SUB DrawPetal(x%,y%,p%,r%)

l% = 0

FOR A% = 0 TO 300 step 60
    l% = l% + 1
    IF l% = p% OR (l% = IFF(p%<5,p% + 2,p% - 4)) THEN
      as% = 120 : ae% = 240
      DRAW "B M " + x% + "," + y%
      DRAW "B TA" + A% + "U " + r%
      px = POINT(0) : py = POINT(1)
      IF l% = p% THEN ae% = 180 ELSE as% = 180
      FOR A# = as% + A% TO ae% + A%  STEP 2.5
        DRAW "B M " + px +"," + py
        DRAW "B TA" + A# + " U" + r%
        CIRCLE (POINT(0),POINT(1)),2, , , , ,T
    IF FIRST_CYCLE% THEN SLEEP 0.001
      NEXT A#
    IF NOT FIRST_CYCLE% THEN SLEEP 0.05
    END IF

NEXT A%

END SUB