Class: Moon::Transition

Inherits:
Scheduler::Jobs::TimedProcess show all
Defined in:
lib/moon/packages/std/animation/transition.rb

Instance Attribute Summary collapse

Attributes inherited from Scheduler::Jobs::TimeBase

#duration, #time

Attributes inherited from Scheduler::Jobs::Base

#active, #id, #key, #killed, #uptime

Instance Method Summary collapse

Methods inherited from Scheduler::Jobs::TimedProcess

#on_timeout

Methods inherited from Scheduler::Jobs::TimeBase

#done?, #finish, #rate, #restart, #stop, #timeout?, #update_job

Methods inherited from Scheduler::Jobs::Base

#done?, #kill, #killed?, #trigger_callback, #update, #update_job

Methods included from Activatable

#activate, #active?, #deactivate

Methods included from Eventable

#allow_event?, #clear_events, #each_listener, #each_typed_listener, filter_from_options, #has_events?, #initialize_eventable, #off, #on, #ppd_ev, #trigger, #typing

Constructor Details

#initialize(src, dest, duration, easer = Easing::Linear, &block) ⇒ Transition

Returns a new instance of Transition.

Parameters:


12
13
14
15
# File 'lib/moon/packages/std/animation/transition.rb', line 12

def initialize(src, dest, duration, easer = Easing::Linear, &block)
  super(duration, &block)
  setup(src, dest, easer)
end

Instance Attribute Details

#easerObject

instance attributes


6
7
8
# File 'lib/moon/packages/std/animation/transition.rb', line 6

def easer
  @easer
end

Instance Method Details

#setup(src, dest, easer = Easing::Linear) ⇒ self

Parameters:

  • src (Object)
  • dest (Object)
  • easer (#call) (defaults to: Easing::Linear)

Returns:

  • (self)

21
22
23
24
25
26
# File 'lib/moon/packages/std/animation/transition.rb', line 21

def setup(src, dest, easer = Easing::Linear)
  @src = src
  @dest = dest
  @easer = easer
  self
end

#update_ease(delta) ⇒ void

This method returns an undefined value.

Parameters:


30
31
32
33
# File 'lib/moon/packages/std/animation/transition.rb', line 30

def update_ease(delta)
  time_inv = (@duration - @time).clamp(0, @duration)
  @callback.call(@src + (@dest - @src) * @easer.call(time_inv / @duration))
end

#update_job_step(delta) ⇒ void

This method returns an undefined value.

Parameters:


37
38
39
# File 'lib/moon/packages/std/animation/transition.rb', line 37

def update_job_step(delta)
  update_ease delta
end