Re: NSAnimatablePropertyContainer
Re: NSAnimatablePropertyContainer
- Subject: Re: NSAnimatablePropertyContainer
- From: "I. Savant" <email@hidden>
- Date: Fri, 16 Nov 2007 14:00:31 -0500
> ... for example, animate a custom
> "transitionProgress" property from 0.0 to 1.0, and have your view's -
> drawRect: do something like:
>
> [[NSColor whiteColor] set];
> NSRectFill(rect);
>
> float t = [self transitionProgress];
> if (t < 0.5) {
> [oldImage drawAtPoint:NSZeroPoint fromRect:NSZeroRect
> operation:NSCompositeSourceOver fraction:(2.0 * (0.5 - t))];
> } else {
> [newImage drawAtPoint:NSZeroPoint fromRect:NSZeroRect
> operation:NSCompositeSourceOver fraction:(2.0 * (t - 0.5))];
> }
>
> That's one way it could be done.
I've just tried this and it works beautifully. Thanks, Troy! The
trick was (on setImage:) to do the following:
[self setTransitionProgress:0.0]; // no animation, just start from 0
oldImage = image;
image = newImage;
[[self animator] setTransitionProgress:1.0];
... I implemented your code above in my own -drawRect: and it worked
just fine.
--
I.S.
_______________________________________________
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