Sha256: 83e894ffc16859ad1761dca2e264d459be3bead0380ddf4f6384ccee02024d01

Contents?: true

Size: 620 Bytes

Versions: 10

Compression:

Stored size: 620 Bytes

Contents

# Recursion. 
# 
# A demonstration of recursion, which means functions call themselves. 
# Notice how the drawCircle() function calls itself at the end of its block. 
# It continues to do this until the variable "level" is equal to 1.


def setup    
  size 640, 360    
  no_stroke
  no_loop
end

def draw  
  draw_circle width / 2, 280, 6
end

def draw_circle ( x, radius, level )  
  tt = 126 * level / 4.0  	
  fill tt  	
  ellipse x, height / 2, radius*2, radius*2  	
  if level > 1  		
    level = level - 1  		
    draw_circle x - radius/2, radius/2, level
    draw_circle x + radius/2, radius/2, level
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
ruby-processing-2.6.3 samples/processing_app/basics/structure/recursion1.rb
ruby-processing-2.6.2 samples/processing_app/basics/structure/recursion1.rb
ruby-processing-2.6.1 samples/processing_app/basics/structure/recursion1.rb
ruby-processing-2.6.0 samples/processing_app/basics/structure/recursion1.rb
ruby-processing-2.5.1 samples/processing_app/basics/structure/recursion1.rb
ruby-processing-2.5.0 samples/processing_app/basics/structure/recursion1.rb
ruby-processing-2.4.4 samples/processing_app/basics/structure/recursion1.rb
ruby-processing-2.4.3 samples/processing_app/basics/structure/recursion1.rb
ruby-processing-2.4.2 samples/processing_app/basics/structure/recursion1.rb
ruby-processing-2.4.1 samples/processing_app/basics/structure/recursion1.rb