Oxygen Basic
Programming => Example Code => Topic started by: Peter on March 29, 2013, 01:44:35 PM
-
Deleted
-
(http://files.allbasic.info/ScriptBasic/graphics/recursive_circles.png)
INCLUDE "sbsw.inc"
SW_Window 320,240,1
SW_SetCaption "Recursive Circles"
SUB drawCircle(x, radius, level)
tt = 126 * level / 4
SW_FillEllipse(x, 10, radius * 2, radius * 2, SW_RGB(tt,tt,tt))
IF level > 1 THEN
level = level - 1
drawCircle(x + radius / 2, radius / 2, level)
END IF
SW_Sync
END SUB
SW_Cls SW_RGB(0, 0, 255)
drawCircle(50, 110, 6)
SW_WaitKey
SW_Quit
-
But ScriptBasic knows no recursively
This SB code works exactly as the O2 code does. It calls the drawCircle() function recursively to draw the same number of eclipses as O2.
BTW: SB allows you to set in the configuration file the max levels of recursion as a safe guard so your program doesn't run away with itself.