Sha256: 88b732d15ad196c8ebdb131c4f2cd81cdd7e2fae866af13594c1097d2b0b7c54

Contents?: true

Size: 968 Bytes

Versions: 3

Compression:

Stored size: 968 Bytes

Contents

require 'cf3'

def setup_the_spiral
  @spiral= ContextFree.define do
    ############ Begin defining custom terminal, an isosceles triangle
    class << self
      define_method(:isosceles) do |some_options| # isosceles triangle
        options = get_shape_values(some_options)
        size = options[:size]
        rot = options[:rotation]
        rotate(rot) if rot
        @app.triangle(-0.5 * size, -0.5 * size, -0.5 * size, 0.5 * size, 0.5 * size, 0.5 * size)
        rotate(-rot) if rot
      end
    end
    ########### End definition of custom terminal 'isosceles'
    shape :spiral do
      isosceles brightness: -1, rotation: 90
      spiral rotation: 135, size: 1 / sqrt(2), x: 1 / sqrt(2)
    end
  end
end

def settings
  size 800, 500
end

def setup
  sketch_title 'Isosceles'
  setup_the_spiral
  draw_it
end

def draw
  # Do nothing.
end

def draw_it
  background 255
  @spiral.render :spiral, size: height, start_x: width / 3, start_y: height / 2
end

Version data entries

3 entries across 3 versions & 1 rubygems

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