Class: SparkleMotion::Nodes::Generators::Perlin
- Inherits:
-
SparkleMotion::Nodes::Generator
- Object
- SparkleMotion::Node
- SparkleMotion::Nodes::Generator
- SparkleMotion::Nodes::Generators::Perlin
- Defined in:
- lib/sparkle_motion/nodes/generators/perlin.rb
Overview
Manage and run a Perlin-noise based simulation.
TODO: Play with octaves / persistence, etc.
Constant Summary
Constants inherited from SparkleMotion::Node
SparkleMotion::Node::DEBUG_SCALE, SparkleMotion::Node::FRAME_PERIOD
Instance Attribute Summary
Attributes inherited from SparkleMotion::Node
Instance Method Summary collapse
-
#initialize(lights:, speed:) ⇒ Perlin
constructor
A new instance of Perlin.
- #update(t) ⇒ Object
Methods inherited from SparkleMotion::Node
Constructor Details
#initialize(lights:, speed:) ⇒ Perlin
Returns a new instance of Perlin.
10 11 12 13 14 15 |
# File 'lib/sparkle_motion/nodes/generators/perlin.rb', line 10 def initialize(lights:, speed:) super(lights: lights) @speed = speed # TODO: See if we need/want to tinker with the `interval` option... @perlin = ::Perlin::Noise.new(2, seed: 0) end |
Instance Method Details
#update(t) ⇒ Object
17 18 19 20 21 22 |
# File 'lib/sparkle_motion/nodes/generators/perlin.rb', line 17 def update(t) @lights.times do |n| self[n] = @perlin[n * @speed.x, t * @speed.y] end super(t) end |