Sha256: 549b6e71aab335a69643c89b3a042a8462ad7c43ee8f924aecad3349e641647f

Contents?: true

Size: 761 Bytes

Versions: 3

Compression:

Stored size: 761 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 'X-Cross'
  @stars = ContextFree.define do    
    shape :stars do
      split do
        cross size: 0.5, x: -2
        rewind
        plus size: 0.5, x: 2
      end
    end

    shape :cross do
      square w: 1, h: 3, rotation: -45
      square w: 1, h: 3, rotation: 45
    end

    shape :plus do
      square w: 1, h: 3
      square w: 1, h: 3, rotation: 90
    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/xcross.rb
cf3-1.0.1 samples/xcross.rb
cf3-1.0.0 samples/xcross.rb