SCREEN 12
DIM SHARED J
DRAW "BM320,460": CALL tree(440)
END
SUB JIAO (JAO) 'This program is used to rotate the pen by a certain angle.
J = J + JAO
IF J > 360 THEN J = J - 360
IF J < -360 THEN J = J + 360
DRAW "TA=" + VARPTR$(J)
PLAY "T255P64" 'This line is only to slow down the speed.
END SUB
SUB tree (C) 'Tree-drawing subroutine.
IF C < 18 THEN DRAW "C2NU=" + VARPTR$(C): EXIT SUB'After drawing the leaves, return.
C3 = C / 3
DRAW "C4U=" + VARPTR$(C3)
CALL JIAO(45): CALL tree(C / 2)'Turn 45 degrees counterclockwise, then draw the left subtree.
CALL JIAO(-45): CALL tree(2 * C / 3)'Turn 45 degrees clockwise, then draw the middle subtree.
CALL JIAO(-45): CALL tree(C / 2)'Turn 45 degrees clockwise, then draw the right subtree.
CALL JIAO(45) 'Turn 45 degrees counterclockwise, then return to the original direction.
DRAW "C7D=" + VARPTR$(C3)
END SUB
DIM SHARED J
DRAW "BM320,460": CALL tree(440)
END
SUB JIAO (JAO) 'This program is used to rotate the pen by a certain angle.
J = J + JAO
IF J > 360 THEN J = J - 360
IF J < -360 THEN J = J + 360
DRAW "TA=" + VARPTR$(J)
PLAY "T255P64" 'This line is only to slow down the speed.
END SUB
SUB tree (C) 'Tree-drawing subroutine.
IF C < 18 THEN DRAW "C2NU=" + VARPTR$(C): EXIT SUB'After drawing the leaves, return.
C3 = C / 3
DRAW "C4U=" + VARPTR$(C3)
CALL JIAO(45): CALL tree(C / 2)'Turn 45 degrees counterclockwise, then draw the left subtree.
CALL JIAO(-45): CALL tree(2 * C / 3)'Turn 45 degrees clockwise, then draw the middle subtree.
CALL JIAO(-45): CALL tree(C / 2)'Turn 45 degrees clockwise, then draw the right subtree.
CALL JIAO(45) 'Turn 45 degrees counterclockwise, then return to the original direction.
DRAW "C7D=" + VARPTR$(C3)
END SUB
