Class: SparkleMotion::Nodes::Transforms::Contrast

Inherits:
SparkleMotion::Nodes::Transform show all
Defined in:
lib/sparkle_motion/nodes/transforms/contrast.rb

Overview

Transform values from 0..1 into a new range.

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(function:, iterations:, source:, mask: nil) ⇒ Contrast

Returns a new instance of Contrast.



6
7
8
9
10
# File 'lib/sparkle_motion/nodes/transforms/contrast.rb', line 6

def initialize(function:, iterations:, source:, mask: nil)
  super(source: source, mask: mask)
  function  = Perlin::Curve.const_get(function.to_s.upcase)
  @contrast = Perlin::Curve.contrast(function, iterations.to_i)
end

Instance Method Details

#update(t) ⇒ Object



12
13
14
15
16
# File 'lib/sparkle_motion/nodes/transforms/contrast.rb', line 12

def update(t)
  super(t) do |x|
    @contrast.call(@source[x])
  end
end