Sha256: 2e32f2c89d757d033263ef3db2838c1686d44f913267f350085973179b0c1da4

Contents?: true

Size: 749 Bytes

Versions: 10

Compression:

Stored size: 749 Bytes

Contents

#
# Patterns. 
# 
# Move the cursor over the image to draw with a software tool 
# which responds to the speed of the mouse. 
#
 
def setup
  size(640, 360)
  background(102)
end

def draw
  # Call the variable_ellipse method and send it the
  # parameters for the current mouse position
  # and the previous mouse position
  variable_ellipse(mouse_x, mouse_y, pmouse_x, pmouse_y)
end


# The simple method variable_ellipse was created specifically 
# for this program. It calculates the speed of the mouse
# and draws a small ellipse if the mouse is moving slowly
# and draws a large ellipse if the mouse is moving quickly 

def variable_ellipse(x, y, px, py)
  speed = (x - px).abs + (y - py).abs
  stroke(speed)
  ellipse(x, y, speed, speed)
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
ruby-processing-2.6.3 samples/processing_app/topics/drawing/pattern.rb
ruby-processing-2.6.2 samples/processing_app/topics/drawing/pattern.rb
ruby-processing-2.6.1 samples/processing_app/topics/drawing/pattern.rb
ruby-processing-2.6.0 samples/processing_app/topics/drawing/pattern.rb
ruby-processing-2.5.1 samples/processing_app/topics/drawing/pattern.rb
ruby-processing-2.5.0 samples/processing_app/topics/drawing/pattern.rb
ruby-processing-2.4.4 samples/processing_app/topics/drawing/pattern.rb
ruby-processing-2.4.3 samples/processing_app/topics/drawing/pattern.rb
ruby-processing-2.4.2 samples/processing_app/topics/drawing/pattern.rb
ruby-processing-2.4.1 samples/processing_app/topics/drawing/pattern.rb