Sha256: 4e4b3424e8207d7feb9964423a3dead33a3c4a4f69cb28844596e276a5d013eb

Contents?: true

Size: 988 Bytes

Versions: 6

Compression:

Stored size: 988 Bytes

Contents

require 'ruby-processing'

# TRIANGLE_STRIP Mode
# by Ira Greenberg. 
# 
# Generate a closed ring using vertex() 
# function and beginShape(TRIANGLE_STRIP)
# mode. outerRad and innerRad variables 
# control ring's outer/inner radii respectively.
# Trig functions generate ring.

class TriangleStrip < Processing::App

  def setup
    background 204
    smooth
    
    x = width/2
    y = height/2
    outer_radius = 80
    inner_radius = 50
    px, py, angle = 0.0, 0.0, 0.0
    number_of_points = 36
    rotation = 360.0/number_of_points
    
    begin_shape TRIANGLE_STRIP
    number_of_points.times do |i|
      px = x + cos(angle.radians)*outer_radius
		  py = y + sin(angle.radians)*outer_radius
		  angle += rotation
		  vertex px, py
		  
		  px = x + cos(angle.radians)*inner_radius
		  py = y + sin(angle.radians)*inner_radius
		  angle += rotation
		  vertex px, py
    end
    end_shape
  end
  
end

TriangleStrip.new :title => "Triangle Strip", :width => 200, :height => 200

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
ruby-processing-1.0.4 samples/processing_app/basics/form/triangle_strip.rb
ruby-processing-1.0.3 samples/processing_app/basics/form/triangle_strip.rb
ruby-processing-1.0.5 samples/processing_app/basics/form/triangle_strip.rb
ruby-processing-1.0.6 samples/processing_app/basics/form/triangle_strip.rb
ruby-processing-1.0.7 samples/processing_app/basics/form/triangle_strip.rb
ruby-processing-1.0.8 samples/processing_app/basics/form/triangle_strip.rb