Question

Does somebody know if is it possible somehow to create a custom NSAnimationCurve so that it could be used with NSViewAnimation objects but was different from standard linear, EaseIn/Out?

Was it helpful?

Solution

Actually a have already found an answer to my question. I've created a delegate for my animation NSViewAnimation object and set it using:

[animationObject setDelegate: delegateObject]; 

Then in header file for my delagateObject I set it to use "NSAnimationDelegate" protocol typing the following string:

@interface delegateObject : NSObject <NSAnimationDelegate> { 

After that I create a method

-(float)animation:(NSAnimation *)animation valueForProgress:(NSAnimationProgress)progress; 

This should be a function that describes your custom animation curve. So it takes the progress of animation as value from 0.0 to 1.0 and converts it to new value from 0.0 to 1.0 according to function which you use.

I used in my code the following function:

-(float)animation:(NSAnimation *)animation valueForProgress:(NSAnimationProgress)progress {
float value = -1/(20*(progress+0.047)) +1.045;
return value;

}

It is something like EaseOut but working properly without need to change Start and End KeyFrames and with much more significant difference of speed at the beginning and end of animation.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top