samples/processing_app/basics/input/easing.rb in ruby-processing-1.0.11 vs samples/processing_app/basics/input/easing.rb in ruby-processing-2.4.1

- old
+ new

@@ -1,33 +1,31 @@ -require 'ruby-processing' + # Move the mouse across the screen and the symbol will follow. # Between drawing each frame of the animation, the program # calculates the difference between the position of the # symbol and the cursor. If the distance is larger than # 1 pixel, the symbol moves part of the distance (0.05) from its # current position toward the cursor. -class Easing < Processing::App - def setup - @x, @y = 0.0, 0.0 - @easing = 0.05 - smooth - no_stroke - end + +def setup + size 640, 360 + @x, @y = 0.0, 0.0 + @easing = 0.05 + no_stroke +end + +def draw + background 51 - def draw - background 51 - - dx = mouse_x - @x - @x += dx * @easing if dx.abs > 1 - - dy = mouse_y - @y - @y += dy * @easing if dy.abs > 1 - - ellipse @x, @y, 33, 33 - end + dx = mouse_x - @x + @x += dx * @easing if dx.abs > 1 + dy = mouse_y - @y + @y += dy * @easing if dy.abs > 1 + + ellipse @x, @y, 66, 66 end -Easing.new :title => "Easing", :width => 200, :height => 200 \ No newline at end of file +