Sha256: a290da147972270d3bf06158aa2c5f5bb1f5282aa97673245025df1dcb124012
Contents?: true
Size: 735 Bytes
Versions: 2
Compression:
Stored size: 735 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. class Recursion1 < Processing::App def setup size 200, 200 no_stroke smooth no_loop end def draw draw_circle 126, 170, 6 end def draw_circle ( x, radius, level ) tt = 126 * level / 4.0 fill tt ellipse x, 100, 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 end Recursion1.new :title => "Recursion1"
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ruby-processing-1.0.11 | samples/processing_app/basics/structure/recursion1.rb |
ruby-processing-1.0.10.1 | samples/processing_app/basics/structure/recursion1.rb |