How can i apply lens effect to my UIImage like it shown here http://processing.org/learning/topics/lens.html?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
You can use the Cocos2D framework to do that.
If you choose to use it, here is how you can easily apply a lens effect:
- (void)aFunction
{
const CGSize size = [[CCDirector sharedDirector] winSize];
// Init and position your image
CCSprite *img = [CCSprite spriteWithFile:@"images.png"];
img.position = ccp(size.width/2.f, size.height/2.f);
[self addChild:img];
// Create action and start it
id lens = [CCLens3D actionWithPosition:ccp(size.width/2.f, size.height/2.f)
radius:240.f
grid:ccg(15.f,10.f)
duration:0.f];
[img runAction:lens];
}
Your project is probably a UIKit project so you don't want to restart your project from scratch. So, in the cocos2d-ios Xcode project there are a lot of examples of what you can do.
And there is an exemple which is called AttachTest and it show you how implement an EAGLView (which is a subclass of UIView) in an UIKit project.