Sha256: 0eb5f1bc6135a369ae3dd63c0ad39ce73744ffcf4d36a7e9a8c1970a1afd31df

Contents?: true

Size: 627 Bytes

Versions: 2

Compression:

Stored size: 627 Bytes

Contents

# Distance 2D. 
# 
# Move the mouse across the image to obscure and reveal the matrix.  
# Measures the distance from the mouse to each square and sets the
# size proportionally. 

class Distance2 < Processing::App

  def setup
    
    size 200, 200
    
    smooth
    no_stroke
    @max_distance = dist 0, 0, width, height
    
  end
  
  def draw
  	
  	background 51
  	
  	(0..width).step( 20 ) { |i|
  	
  		(0..height).step( 20 ) { |j|
  		
  			size = dist mouse_x, mouse_y, i, j
  			size = size / @max_distance * 66
  			
  			ellipse i, j, size, size
  		}
  	}
  	
  end
  
end

Distance2.new :title => "Distance2"

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ruby-processing-1.0.11 samples/processing_app/basics/math/distance2.rb
ruby-processing-1.0.10.1 samples/processing_app/basics/math/distance2.rb