Sha256: 612c351af424b4bac3b2f295d10e210ad10c321f9f49a292d04b6cf26bc9e9f6

Contents?: true

Size: 701 Bytes

Versions: 3

Compression:

Stored size: 701 Bytes

Contents

require 'cf3'
#######
# Simple example demonstrating rewind
# also how to make simple composite shapes
# from primitive terminals (renders on mouse clicked)
###

def settings
  size 400, 200
end

def setup
  sketch_title 'Star Shapes'
  @stars = ContextFree.define do

    shape :stars do
      split do
        sqstar size: 0.8, x: -1
        rewind
        trstar x: 1
      end
    end

    shape :sqstar do
      square
      square rotation: 45
    end

    shape :trstar do
      triangle
      triangle rotation: 180
    end
  end
end

def draw_it
  background 0.2
  @stars.render :stars, size: height/2, color: [220, 1, 1, 1]
end

def draw
  # Do nothing.
end

def mouse_clicked
  draw_it
end

Version data entries

3 entries across 3 versions & 1 rubygems

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