Sha256: 9a930aaa4c8974f8ce7edf831592575d210bd2b5a434e8d050614d9e2e4ecacf

Contents?: true

Size: 709 Bytes

Versions: 10

Compression:

Stored size: 709 Bytes

Contents

# 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. 

def setup
  size 640, 360
  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

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
ruby-processing-2.6.3 samples/processing_app/basics/input/mouse_1d.rb
ruby-processing-2.6.2 samples/processing_app/basics/input/mouse_1d.rb
ruby-processing-2.6.1 samples/processing_app/basics/input/mouse_1d.rb
ruby-processing-2.6.0 samples/processing_app/basics/input/mouse_1d.rb
ruby-processing-2.5.1 samples/processing_app/basics/input/mouse_1d.rb
ruby-processing-2.5.0 samples/processing_app/basics/input/mouse_1d.rb
ruby-processing-2.4.4 samples/processing_app/basics/input/mouse_1d.rb
ruby-processing-2.4.3 samples/processing_app/basics/input/mouse_1d.rb
ruby-processing-2.4.2 samples/processing_app/basics/input/mouse_1d.rb
ruby-processing-2.4.1 samples/processing_app/basics/input/mouse_1d.rb