How can i apply lens effect to my UIImage?

前端 未结 1 1732
[愿得一人]
[愿得一人] 2021-01-23 16:27

How can i apply lens effect to my UIImage like it shown here http://processing.org/learning/topics/lens.html?

1条回答
  •  悲&欢浪女
    2021-01-23 17:16

    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.

    0 讨论(0)
提交回复
热议问题