Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Other side of curled page #53

Open
xMonty opened this issue Jun 27, 2013 · 6 comments
Open

Other side of curled page #53

xMonty opened this issue Jun 27, 2013 · 6 comments

Comments

@xMonty
Copy link

xMonty commented Jun 27, 2013

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

@matt-curtis
Copy link

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.

@moscow25
Copy link

moscow25 commented Jul 3, 2013

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.

@xissburg
Copy link
Owner

xissburg commented Jul 5, 2013

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

@moscow25
Copy link

moscow25 commented Jul 5, 2013

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
Copy link

moscow25 commented Jul 5, 2013

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 👍

@moscow25
Copy link

moscow25 commented Jul 6, 2013

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants