Sha256: 813c8c30ee054cc19b0e6c933ad1a02b7aad16579f259ad70bd8a56658ddf988

Contents?: true

Size: 730 Bytes

Versions: 2

Compression:

Stored size: 730 Bytes

Contents

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

def setup
  size 400, 200 
  @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

2 entries across 2 versions & 1 rubygems

Version Path
cf3-0.0.5 samples/xcross.rb
cf3-0.0.4 samples/xcross.rb