determining the result of a CAAnimation instance for time 't'
determining the result of a CAAnimation instance for time 't'
- Subject: determining the result of a CAAnimation instance for time 't'
- From: John Clayton <email@hidden>
- Date: Wed, 28 Nov 2007 06:50:42 +0100
Hello all,
Another Core Anim question.
I'd like to be able to determine the result of any CAAnimation
instance, given time 't', assuming that 't' is some time between the
animation.beginTime and (animation.beginTime + animation.duration).
The idea being, that I want to apply whatever modifications that an
animation represents to my layer - then draw/render a single frame. I
do not want the animations to 'run' like normal.
Here's the 'use case' for this:
An arbitrarily complex layer containing animations is being drawn into
a view. A slider is being used to scrub backward and forward in time,
and the view draws one single frame based on the time represented by
the slider. Any CALayer animations included in the layer tree must
therefore also be taken into account and applied to the layer before
the frame is rendered.
Here's the problem as I see it:
Core animation layers simply 'run' when they are added into the layer
tree, applying modifications to the presentation layer in the
background. There isn't a way to control their time as such. Sure,
one can define their beginTime and duration, but controlling exactly
*when* they fire/apply their effect is another matter.
I have made a spike solution already that controls the
"transform.scale" property of a CALayer over time. It works well,
however:
During the rendering of each frame, I disable animation on the layer,
spin through all the CABasicAnimation instances, and then use a
*private* method on CAMediaTimingFunction to solve for an input time
(between 0 and 1). This provides me a %age complete value (of the
timing function that is), which is then used to determine 'how far
along' the animation we are. Then I create a CABasicAnimation,
compute its values, and apply that single animation [of a keypath] to
the layer tree.
It works well - my issues with this method are:
1) first and foremost, I'm using a private method - which I don't want
to do in production code (many other discussion exist about this - I
don't really want to duplicate them here)
2) it feels inefficient, because I am having to recompute the results
of CAAnimation instances for each frame, and I'm concerned as to how
this will scale. Then again, I've got no hard data/performance stats
to support my thoughts in this arena.
So my question is; does anyone have an idea of how I could do this
*without* using a private method?
The method in question is:
// used SymbolExplorer to get this...
@interface CAMediaTimingFunction (CAMediaTimingFunction_PrivateMethods)
- (float) _solveForInput:(float)pcnt;
@end
Thanks in advance,
-
john clayton
http://www.coderage-software.com/
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden