Snowflake

Charlie Veniot 5th November 2022 at 11:44pm
DIM AS INTEGER color_choice(9)
    color_choice(0) = 15 : color_choice(1) = 1
    color_choice(2) = 1 : color_choice(3) = 9
    color_choice(4) = 15 : color_choice(5) = 9
    color_choice(6) = 15 : color_choice(7) = 9
    color_choice(8) = 15

SUB draw_this(x%,y%,length%, line_count%,start_angle%)
    angle_increment% = 360 / line_count%
	 my_color = color_choice(INT(RND*9))
    FOR i% = 0 TO (line_count% - 1)
        DRAW "bm " + x% + "," + y%
        DRAW "C" + my_color + " TA" + STR$(start_angle% + angle_increment% * i%) + " r" + STR$(length%)
        IF length% > 1 THEN
            CALL draw_this(POINT(0),POINT(1),int(length%/2.25),line_count%,start_angle% + angle_increment% * (i% + 1))
        END IF
    NEXT
END SUB

' 🟠 Main Program

    sw = 600
    sh = 600
    SCREEN _NEWIMAGE(sw, sh, 12)
    base_angle = 0

    DO
        CALL draw_this(299,299,150,5,base_angle)

        LOCATE 1,1 : PRINT "Click (or touch) the screen for different random colors"
        PRINT "Hold the click (or the touch) for the images to appear like an animation."
        DO
            mb = _MOUSEBUTTON
        LOOP UNTIL mb = 1
        CLS
        base_angle = base_angle + 3
    LOOP