Author Topic: Recursion & Alien Circles  (Read 1674 times)

0 Members and 1 Guest are viewing this topic.

Peter

  • Guest
Recursion & Alien Circles
« on: March 29, 2013, 01:44:35 PM »
Deleted
« Last Edit: April 14, 2015, 04:39:10 AM by Peter »

JRS

  • Guest
Re: Recursion & Alien Circles
« Reply #1 on: March 29, 2013, 08:28:50 PM »


Code: [Select]
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

« Last Edit: March 29, 2013, 09:01:06 PM by JRS »

JRS

  • Guest
Re: Recursion & Alien Circles
« Reply #2 on: March 30, 2013, 06:28:24 AM »
Quote
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.