Sha256: aaa664dd8c4294c5b83b12dd8d0c28ab1ba8ff59ebb00073430b7e8904bc3763

Contents?: true

Size: 588 Bytes

Versions: 2

Compression:

Stored size: 588 Bytes

Contents

require 'forwardable'

# The Nature of Code
# Daniel Shiffman
# http://natureofcode.com

# class Spore extends the class "VerletParticle2D"
class Particle < Physics::VerletParticle2D
  extend Forwardable
  def_delegators(:@app, :fill, :stroke, :stroke_weight, :ellipse, :physics)
  attr_reader :r

  def initialize(loc)
    super(loc)
    @app = Processing.app
    @r = 8
    physics.add_particle(self)
    physics.add_behavior(Physics::AttractionBehavior2D.new(self, r * 4, -1))
  end

  def display
    fill 127
    stroke 0
    stroke_weight 2
    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/particle.rb
toxiclibs-2.0.0 examples/attract_repel/particle.rb