Class: SparkleMotion::Nodes::Generators::Wave2

Inherits:
SparkleMotion::Nodes::Generator show all
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

#debug, #history, #lights

Instance Method Summary collapse

Methods inherited from SparkleMotion::Node

#[], #[]=, #snapshot_to!

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