domhofmann / PRTween

Lightweight tween library for iOS
BSD 2-Clause "Simplified" License
459 stars 63 forks source link

Add lerping model #4

Closed domhofmann closed 13 years ago

domhofmann commented 13 years ago

http://en.wikipedia.org/wiki/Linear_interpolation

We should add a lerping model to allow developers to tween a rectangle or point with less effort. While the math is pretty simple, I'm not positive about where we should put this yet. Modifying PRTweenPeriod to take arbitrary types instead of CGFloat sounds good on the surface until you realize it'll force us to wrap CGFloat in NSValue, which hurts simplicity.

I need to do some more thinking here but I'd love to hear any thoughts.

domhofmann commented 13 years ago

I've started work on this in the 0.2-dev branch.

Subclasses of PRTweenLerpPeriod that implement <PRTweenLerpPeriod> can be added to operations and used as normal. I've also added shorthand (see #3 for info.)

Shorthand can be used like this:

[PRTweenCGRectLerp lerp:testView property:@"frame" from:CGRectMake(0, 0, 100, 100) to:CGRectMake(100, 100, 250, 250) duration:3]

Currently CGRect and CGPoint lerps are supported, although it's easy to extend the system for your own uses.

domhofmann commented 13 years ago

Merged into master.