Sha256: 850b48976a2a7439a07e53127bfc218a3d9dc7345c1ead2170150203fd6cfeac

Contents?: true

Size: 863 Bytes

Versions: 3

Compression:

Stored size: 863 Bytes

Contents

# vine.rb by jashkenas, click mouse to re-run

require 'cf3'

def setup_the_vine

  @vine = ContextFree.define do

    shrink = 0.961

    shape :root do
      split do
        shoot y: 1
        rewind
        shoot rotation: 180
      end
    end

    shape :shoot do
      square
      shoot y: 0.98, rotation: 5, size: shrink + rand * 0.05, brightness: 0.990
    end

    shape :shoot, 0.02 do
      square
      split do
        shoot rotation: 90
        rewind
        shoot rotation: -90
      end
    end

  end
end

def settings
  size 700, 700
end

def setup
  sketch_title 'Vine'
  setup_the_vine
  no_stroke
end

def draw
  # Do nothing.
end

def draw_it
  background 270, 1.0, 0.15, 1.0
  @vine.render :root, size: height/75, color: [270, 0.1, 0.9, 1.0],
                     start_x: width/2, start_y: height/2
end

def mouse_clicked
  draw_it
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
cf3-1.2.0 samples/vine.rb
cf3-1.0.1 samples/vine.rb
cf3-1.0.0 samples/vine.rb