Graphics Reference
In-Depth Information
LISTING 6-13
Ripple Layer Implementation
@interface RippleLayer : CALayer {
}
@end
@implementation RippleLayer
+ ( id < CAAction >)defaultActionForKey:( NSString *)key;
{
if ( [key isEqualToString @”bounds” ] )
{
// Going to cheat a little bit here. Since this is a class
// method, we can't get the dimensions from self. Instead,
// we need to obtain this size some other way in a real-world
// application.
float w = 480.0;
float h = 360.0;
NSURL *url = [ NSURL fileURLWithPath :
[[ NSBundle mainBundle ]
pathForResource : @”Shading”
ofType : @”tiff” ]];
CIImage *shadingImage =
[[CIImage alloc ] initWithContentsOfURL : url];
CIFilter *rippleFilter =
[CIFilter filterWithName: @”CIRippleTransition” ];
[rippleFilter setDefaults];
[rippleFilter setValue :shadingImage
forKey : @”inputShadingImage” ];
[rippleFilter setValue :[CIVector vectorWithX: 0.5*w Y: 0.5*h]
forKey : @”inputCenter” ];
CATransition *theTransition=[ CATransition animation ];
[theTransition setFilter :rippleFilter];
[theTransition setDuration :2.0f];
return theTransition;
}
Search WWH ::




Custom Search