Class: Zyps::BlendAction

Inherits:
TimedAction show all
Defined in:
lib/zyps/actions.rb

Overview

Blend the actor’s color with another color.

Instance Attribute Summary collapse

Attributes inherited from TimedAction

#clock, #rate

Instance Method Summary collapse

Methods inherited from TimedAction

#copy, #delta, #start, #stop

Constructor Details

#initialize(rate, color) ⇒ BlendAction

Returns a new instance of BlendAction.



182
183
184
185
# File 'lib/zyps/actions.rb', line 182

def initialize(rate, color)
	super
	@color = color
end

Instance Attribute Details

#colorObject

Color to apply to actor.



181
182
183
# File 'lib/zyps/actions.rb', line 181

def color
  @color
end

Instance Method Details

#do(actor, targets) ⇒ Object

Blend the actor’s color with the assigned color.



187
188
189
190
191
# File 'lib/zyps/actions.rb', line 187

def do(actor, targets)
	actor.color.red += (@color.red - actor.color.red) * delta
	actor.color.green += (@color.green - actor.color.green) * delta
	actor.color.blue += (@color.blue - actor.color.blue) * delta
end