Sha256: b69f86b921d0b12a0808d8458cf1ec6ef4761767f2d2b0bbc9cdfb60ca31aa58

Contents?: true

Size: 834 Bytes

Versions: 9

Compression:

Stored size: 834 Bytes

Contents

require 'ruby-processing'

# Move the mouse left and right to shift the balance. 
# The "mouseX" variable is used to control both the 
# size and color of the rectangles. 

class Mouse1d < Processing::App

  def setup
    color_mode RGB, 1.0
    rect_mode CENTER
    no_stroke
  end
  
  def draw
  	background 0
  	
  	x_dist_blocks = width/2
  	block_size = map mouse_x, 0, width, 10, x_dist_blocks-10
  	
  	left_color = -0.002 * mouse_x/2 + 0.06
  	fill 0.0, left_color + 0.4, left_color + 0.6
  	rect  width/4,    height/2, block_size*2, block_size*2
  	
  	block_size = x_dist_blocks - block_size
  	
  	right_color = 0.002 * mouse_x/2 + 0.06
  	fill 0.0, right_color + 0.2, right_color + 0.4
  	rect (width/4)*3, height/2, block_size*2, block_size*2
  end
  
end

Mouse1d.new :title => "Mouse 1d", :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/input/mouse_1d.rb
ruby-processing-1.0.10.1 samples/processing_app/basics/input/mouse_1d.rb
ruby-processing-1.0.9 samples/processing_app/basics/input/mouse_1d.rb
ruby-processing-1.0.4 samples/processing_app/basics/input/mouse_1d.rb
ruby-processing-1.0.3 samples/processing_app/basics/input/mouse_1d.rb
ruby-processing-1.0.5 samples/processing_app/basics/input/mouse_1d.rb
ruby-processing-1.0.6 samples/processing_app/basics/input/mouse_1d.rb
ruby-processing-1.0.7 samples/processing_app/basics/input/mouse_1d.rb
ruby-processing-1.0.8 samples/processing_app/basics/input/mouse_1d.rb