What do they mean by "the timespace of the animation's layer" and "in the local active time"?

349 Views Asked by At

They say:

The timing protocol provides the means of starting an animation a certain number of seconds into its duration using two properties: beginTime and timeOffset. The beginTime specifies the number of seconds into the duration the animation should start and is scaled to the timespace of the animation's layer. The timeOffset specifies an additional offset, but is stated in the local active time. Both values are combined to determine the final starting offset.

I know about timespaces. But I have trouble grasping their words here.

"is scaled to the timespace of the animation's layer."

Lets say I have this:

  • animator speed = 1.0
  • layer of the animated view's speed = 2.0
  • superlayer's speed = 2.0
  • beginTime = 1.0

then it would begin in realtime after 0.25 seconds? (double superlayer speed, which doubles sublayer speed, so we have quad speed. and local speed of animator is 1. so still quad speed.).

And the timeOffset is stated "in the local active time". They mean the time distorted by speed? i.e. if the speed property of the animator object is 1.0, that's the local active time here?

Local active time could really mean a lot of different things to me. For example clock time, or time throughout the timespace hierarchy how it affects the time in the bottom. Would be great if someone could point out the details here.

1

There are 1 best solutions below

1
On

Check out the headers for Core Animation; specifically CAMediaTiming.h:

/* The CAMediaTiming protocol is implemented by layers and animations, it
 * models a hierarchical timing system, with each object describing the
 * mapping from time values in the object's parent to local time.
 *
 * Absolute time is defined as mach time converted to seconds. The
 * CACurrentMediaTime function is provided as a convenience for querying the
 * current absolute time. 
 * 
 * The conversion from parent time to local time has two stages:
 *
 * 1. conversion to "active local time". This includes the point at
 * which the object appears in the parent's timeline, and how fast it
 * plays relative to the parent.
 *
 * 2. conversion from active to "basic local time". The timing model
 * allows for objects to repeat their basic duration multiple times,
 * and optionally to play backwards before repeating. */

Additionally (from the comments on the properties)

/* The rate of the layer. Used to scale parent time to local time, e.g.
 * if rate is 2, local time progresses twice as fast as parent time.
 * Defaults to 1. */

@property float speed;

/* Additional offset in active local time. i.e. to convert from parent
 * time tp to active local time t: t = (tp - begin) * speed + offset.
 * One use of this is to "pause" a layer by setting `speed' to zero and
 * `offset' to a suitable value. Defaults to 0. */

@property CFTimeInterval timeOffset;

So, it appears your interpretation is correct.