Sha256: 835ce0fd92cf5e4340a9e5980a0a69257fb6888bf0a55d07407c85a5c72b90f1

Contents?: true

Size: 491 Bytes

Versions: 2

Compression:

Stored size: 491 Bytes

Contents

require 'forwardable'

# The Nature of Code
# Daniel Shiffman
# http://natureofcode.com
class Attractor < Physics::VerletParticle2D
  extend Forwardable
  def_delegators(:@app, :fill, :ellipse, :physics, :width)
  attr_accessor :r

  def initialize(loc)
    super(loc)
    @app = Processing.app
    @r = 24
    physics.add_particle(self)
    physics.add_behavior(Physics::AttractionBehavior2D.new(self, width, 0.1))
  end

  def display
    fill(0)
    ellipse(x, y, r * 2, r * 2)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
toxiclibs-2.1.0 examples/attract_repel/attractor.rb
toxiclibs-2.0.0 examples/attract_repel/attractor.rb