Sha256: 9f32a8c6dacb3689510770ee9979a078ab531a22982d278a8680540ef9a7b841

Contents?: true

Size: 977 Bytes

Versions: 2

Compression:

Stored size: 977 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

2 entries across 2 versions & 1 rubygems

Version Path
ruby-processing-1.0.11 samples/processing_app/basics/form/triangle_strip.rb
ruby-processing-1.0.10.1 samples/processing_app/basics/form/triangle_strip.rb