XBPageCurl icon indicating copy to clipboard operation
XBPageCurl copied to clipboard

Other side of curled page

Open xMonty opened this issue 11 years ago • 6 comments

Is it possible to have a custom image instead of the "mirrored grayed out image" on the other side of the curled top view (back of the top page), basically i want to curl a playing card lying face down and see what card i have. Thanks a bunch

xMonty avatar Jun 27 '13 12:06 xMonty

I would assume this is possible... There are [XBCurlView drawViewOnBackOfPage:(UIView)view] and [XBCurlView drawImageOnBackOfPage:(UIImage)image] functions you should look at. If you're using XBPageDragView, then you'd invoke them in [XBPageDragView touchesBegan:] after it's call to [XBCurlView drawViewOnFrontOfPage:(UIView*)view].

Disclaimer: I'm guessing here, mostly. I haven't tried it.

matt-curtis avatar Jun 28 '13 17:06 matt-curtis

I'm interested in this, as well. Will try your suggestion, Matt-Curtis. Kind of a noob at graphics, so all I can do is copy & paste code... Thanks.

moscow25 avatar Jul 03 '13 02:07 moscow25

You should do what matt-curtis said. Use the drawViewOnBackOfPage: or the drawImageOnBackOfPage: methods.

xissburg avatar Jul 05 '13 14:07 xissburg

Yep, I used those. Thanks to both of you.

Still not sure what should be done with drawViewOnBackOfPage: and what with drawImageOnBackOfPage:, but got something working. Also had to reset color scheme on back, to remove fade effect. Here's my code, in . Sorry should have posted this earlier...

(void)refreshPageCurlView { // Existing code XBPageCurlView *pageCurlView = [[XBPageCurlView alloc] initWithFrame:self.viewToCurl.frame]; pageCurlView.pageOpaque = YES; pageCurlView.opaque = NO; pageCurlView.snappingEnabled = YES; [pageCurlView drawViewOnFrontOfPage:self.viewToCurl];

// My hack...
NSString *frontPath = [[NSBundle mainBundle] pathForResource:@"back-horizonatal-900" ofType:@"png"];
UIImage *frontCardImage = [[UIImage alloc] initWithContentsOfFile:frontPath];
[pageCurlView drawImageOnFrontOfPage:frontCardImage]; // Change the front image view

NSString *path = [[NSBundle mainBundle] pathForResource:@"QueenDiamonds" ofType:@"png"];
UIImage *backCardImage = [[UIImage alloc] initWithContentsOfFile:path];
UIImageView *myImageView = [[UIImageView alloc] initWithImage:backCardImage];
[pageCurlView drawViewOnBackOfPage:myImageView]; // Added back view

...

And fixing the fade in Resources/BackFragmentShader.glsl

// gl_FragColor = vec4(color.rgb*(1.0 - gradient.a) + gradient.rgb, color.a); // premultiplied alpha [fading, through paper]
gl_FragColor = vec4(color.rgb, 1.0); // premultiplied alpha [no fading, full transparency!]

moscow25 avatar Jul 05 '13 21:07 moscow25

I should clearly define the drawImageOnFrontOfPage: at some earlier point. Still working on that. Also working on re-sizing the peel-back view to my needed exact dimensions. But that's a separate issue, and your multi-view peel example should be good enough for that purpose...

Still a Noob to Open-GL and to UIView, but your code is very well organized and so possible to understand :+1:

moscow25 avatar Jul 05 '13 21:07 moscow25

Looks like this. Obviously needs work, but I like the effect. further peel not as good, but can probably run trial & error with cone properties...

screen shot 2013-07-05 at 4 23 35 am

moscow25 avatar Jul 06 '13 01:07 moscow25