Sha256: 5f341a09e089478f8cd50d57f7b7da56f0d3c8e7bd3dfdda2ff11ea4eb17925c

Contents?: true

Size: 669 Bytes

Versions: 3

Compression:

Stored size: 669 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
        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-0.0.5 samples/star.rb
cf3-0.0.4 samples/star.rb
cf3-0.0.3 samples/star.rb