Sha256: a41b13f0c86f4e62693974fdc4839c1e7e12f85277890259e0e1e4fc44661204

Contents?: true

Size: 852 Bytes

Versions: 9

Compression:

Stored size: 852 Bytes

Contents

require 'ruby-processing'

# Each color is perceived in relation to other colors. 
# The top and bottom bars each contain the same component colors,
# but a different display order causes individual colors to appear differently. 

class Relativity < Processing::App

  def setup
    
    a = color 165, 167, 20
  	b = color 77,  86,  59
  	c = color 42,  106, 105
  	d = color 165, 89,  20
  	e = color 146, 150, 127
  	
  	no_stroke
  	
  	draw_band [a, b, c, d, e], 0, 4
  	draw_band [c, a, d, b, e], height/2, 4
  end
  
  def draw_band( color_order, ypos, bar_width )
  	
  	num = color_order.length
  	
  	(0...width).step(bar_width * num) do |i|
  		num.times do |j|
  			fill color_order[j]
  			rect i + j*bar_width, ypos, bar_width, height/2
  		end
  	end
  	
  end
  
end

Relativity.new :title => "Relativity", :width => 200, :height => 200

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
ruby-processing-1.0.11 samples/processing_app/basics/color/relativity.rb
ruby-processing-1.0.10.1 samples/processing_app/basics/color/relativity.rb
ruby-processing-1.0.9 samples/processing_app/basics/color/relativity.rb
ruby-processing-1.0.4 samples/processing_app/basics/color/relativity.rb
ruby-processing-1.0.3 samples/processing_app/basics/color/relativity.rb
ruby-processing-1.0.5 samples/processing_app/basics/color/relativity.rb
ruby-processing-1.0.6 samples/processing_app/basics/color/relativity.rb
ruby-processing-1.0.7 samples/processing_app/basics/color/relativity.rb
ruby-processing-1.0.8 samples/processing_app/basics/color/relativity.rb