Class: SparkleMotion::Nodes::Generators::Wave2
- Inherits:
-
SparkleMotion::Nodes::Generator
- Object
- SparkleMotion::Node
- SparkleMotion::Nodes::Generator
- SparkleMotion::Nodes::Generators::Wave2
- Defined in:
- lib/sparkle_motion/nodes/generators/wave2.rb
Overview
Manage and run a simulation of just ‘sin(x + y)`.
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:) ⇒ Wave2
constructor
A new instance of Wave2.
- #update(t) ⇒ Object
Methods inherited from SparkleMotion::Node
Constructor Details
#initialize(lights:, speed:) ⇒ Wave2
Returns a new instance of Wave2.
6 7 8 9 |
# File 'lib/sparkle_motion/nodes/generators/wave2.rb', line 6 def initialize(lights:, speed:) super(lights: lights) @speed = speed end |
Instance Method Details
#update(t) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/sparkle_motion/nodes/generators/wave2.rb', line 11 def update(t) @lights.times do |n| self[n] = (Math.sin((n * @speed.x) + (t * @speed.y)) * 0.5) + 0.5 end super(t) end |