Sha256: 9d240df9c0d260d25009a41b8a3be387eb410903b324b5d6df8a36a474944a06

Contents?: true

Size: 458 Bytes

Versions: 3

Compression:

Stored size: 458 Bytes

Contents

#
# Koch Curve
# by Daniel Shiffman.
# 
# Renders a simple fractal, the Koch snowflake. 
# Each recursive level is drawn in sequence. 
#

load_library 'koch'

attr_reader :k

def setup
  size(640, 360)
  frame_rate(1)  # Animate slowly
  @k = KochFractal.new(width, height)
end

def draw
  background(0)
  # Draws the snowflake!
  k.render
  # Iterate
  k.next_level
  # Let's not do it more than 5 times. . .
  if (k.get_count > 5) 
    k.restart
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ruby-processing-2.4.3 samples/processing_app/topics/lsystems/koch.rb
ruby-processing-2.4.2 samples/processing_app/topics/lsystems/koch.rb
ruby-processing-2.4.1 samples/processing_app/topics/lsystems/koch.rb