Sha256: ecaafbb75aefdb3c26e90eea26db0fcd9f1494d00b4a406e0f5b710f5deae34a

Contents?: true

Size: 715 Bytes

Versions: 9

Compression:

Stored size: 715 Bytes

Contents

require 'ruby-processing'

# Hue is the color reflected from or transmitted through an object 
# and is typically referred to as the name of the color (red, blue, yellow, etc.) 
# Move the cursor vertically over each bar to alter its hue. 

class Hue < Processing::App

  def setup
    @bar_width = 5
    @hue = Array.new( (width/@bar_width), 0 )
    
    color_mode HSB, 360, height, height
    no_stroke
  end
  
  def draw
  	(width/@bar_width).times do |i|
  	  n = i * @bar_width
  	  range = (n..n+@bar_width)
  	  @hue[i] = mouse_y if range.include?(mouse_x)
  		fill @hue[i], height/1.2, height/1.2
  		rect n, 0, @bar_width, height
		end
  end
  
end

Hue.new :title => "Hue", :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/hue.rb
ruby-processing-1.0.10.1 samples/processing_app/basics/color/hue.rb
ruby-processing-1.0.9 samples/processing_app/basics/color/hue.rb
ruby-processing-1.0.4 samples/processing_app/basics/color/hue.rb
ruby-processing-1.0.3 samples/processing_app/basics/color/hue.rb
ruby-processing-1.0.5 samples/processing_app/basics/color/hue.rb
ruby-processing-1.0.6 samples/processing_app/basics/color/hue.rb
ruby-processing-1.0.7 samples/processing_app/basics/color/hue.rb
ruby-processing-1.0.8 samples/processing_app/basics/color/hue.rb