Sha256: 95c817bbd4cd3adcef436f102751de82c0008cb135b1614213234e0254b1c82f

Contents?: true

Size: 1.03 KB

Versions: 1

Compression:

Stored size: 1.03 KB

Contents

require 'cf3'

#######################################################
# This sketch takes some time to develop,             #
# clicking the mouse, allows you view current state   #
# in the final state background will be green         #
#######################################################

def setup_the_fern
  
  @fern = ContextFree.define do
    
    shape :start do
      fern rotation: 8, hue: 306
    end
    
    shape :fern do
      square size: 0.75, rotation: -49
      split do
        fern size: 0.92, y: -2, rotation: 5, hue: 306
        rewind
        fern size: 0.5, y: -2, rotation: 90
        rewind                                  
        fern size: 0.5, y: -2, rotation: -90
      end
    end
    
  end
end

def setup
  size 600, 600
  setup_the_fern
  no_stroke
end

def draw
  # Do nothing.
end

def draw_it
  background 119, 0.25, 0.2, 1.0
  @fern.render :start, size: height/23, color: [126, 0.4, 0.9, 0.55], stop_size: 1,
                       start_x: width/2.5, start_y: height/1.285
end

def mouse_clicked
  draw_it
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cf3-0.0.5 samples/fern.rb