Sha256: 073dea782d46b473339cccb7e89129312bc8322163ffd3f6adc2d7fb42bfbc7b

Contents?: true

Size: 878 Bytes

Versions: 5

Compression:

Stored size: 878 Bytes

Contents

# y.rb ruby-processing by Martin Prout
require 'cf3'
Y_TOP = -1 / Math.sqrt(3) 
Y_BOT = Math.sqrt(3) / 6

def setup_the_triangle
  @triangle = ContextFree.define do
    ########  
    shape :start do
    unit brightness: 1.0
    end
    
    shape :unit do
      triangle size: 1.0
      split do
        unit size: 0.5, x: 0, y: Y_TOP/2, brightness: 0.8
        rewind 
        unit size: 0.5, x: -0.25, y: -Y_TOP/4, brightness: 0.8        
        rewind
        unit size: 0.5, x: 0.25, y: -Y_TOP/4, brightness: 0.8
      end
    end
    ########
  end
end
                
def setup
  size 1024, 1024
  setup_the_triangle
  no_stroke
  color_mode RGB, 1
  smooth 8
  draw_it
  save_frame("y.png")
end


def draw
   # Do nothing.
end

def draw_it
  background 225, 225, 0
  @triangle.render :start, size: height, stop_size: 0.5,
  start_x: width/2, start_y: height * 0.6
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
cf3-0.0.5 samples/y.rb
cf3-0.0.4 samples/y.rb
cf3-0.0.3 samples/y.rb
cf3-0.0.2 samples/y.rb
cf3-0.0.1 samples/y.rb