Giter Club home page Giter Club logo

Comments (18)

xissburg avatar xissburg commented on May 21, 2024

Usually, you should not use the curlView while the user can still interact with your view and its contents. While curling, the content should usually be static, because it takes a lot of time to render the view onto a texture, and so it will make your app really slow if you attempt to do that several times per second. Therefore, only apply the curl when necessary.

from xbpagecurl.

overw avatar overw commented on May 21, 2024

I understand that it takes a lot of time. That's why I'm looking for a non-textured version (with transparent background), so it would render only during curl animation. This way I won't need to update the render every time the curled view updated and it won't affect the performance.

Thanks

from xbpagecurl.

xissburg avatar xissburg commented on May 21, 2024

But the curled view needs to be drawn on an OpenGL triangle mesh.

from xbpagecurl.

overw avatar overw commented on May 21, 2024

The thing I want to make has already been made by Apple in their Maps app. By default, they have a small curled corner in the bottom right part of the screen. And because the front view can be scrolled by user (while curved corner is still there) they do not distort the texture of it: http://i.imgur.com/cKWsi.jpg (they also do not render half-transperent texture on the back side of the corner)
Perhaps, they just use a picture for an idle state of the corner (instead of real rendering), but I need this small corner to curl/uncurl with animation, so I can't use an image.

from xbpagecurl.

xissburg avatar xissburg commented on May 21, 2024

Look into the Page Curl Sample. You can do that using the XBPageDragView. You have to add that curled corner image yourself as a subview of it.

from xbpagecurl.

overw avatar overw commented on May 21, 2024

I think you got me wrong. I need the curled corner to be like on the picture (without distorting front view). And I can't use a static picture for the curled corner, because I need it to appear with animation. Here another picture:
http://i.imgur.com/wCm94.jpg
Hope it helps.

Thanks.

from xbpagecurl.

xissburg avatar xissburg commented on May 21, 2024

So the little corner won't be curled all the time… In this case you could do the little curl animation using XBPageCurl and right after replace the corner with a XBPageDragView containing an image in it.

from xbpagecurl.

overw avatar overw commented on May 21, 2024

I thought about this. The problem is the curled corner may appear while user is scrolling. So the curled area will have a different part of the view as a texture.

from xbpagecurl.

xissburg avatar xissburg commented on May 21, 2024

The curled corner will just be an image while the user scrolls. If he touches and drags it the XBCurlView will be added over it and will start to animate the curl.

from xbpagecurl.

overw avatar overw commented on May 21, 2024

By default, when user scrolls there's NO curled corner at all (I showed it on the pic above). Then at some time curled corner appears with animation. But the user may be in the proccess of scrolling when the animation runs. So this way curled corner will have an outdated texture.

from xbpagecurl.

xissburg avatar xissburg commented on May 21, 2024

If you look in the maps app you will notice that the texture/image of the static curled corner does not change, it is a fixed image.

from xbpagecurl.

overw avatar overw commented on May 21, 2024

I know. That's why I need this "light mode" for XBPageCurl - so I could use it instead of a static image.

from xbpagecurl.

xissburg avatar xissburg commented on May 21, 2024

This would require several renderInContext: and glTexImage2D calls per second and would slowdown your app for a very subtle effect. You'd better use an static image instead.

from xbpagecurl.

overw avatar overw commented on May 21, 2024

So, is it impossible to just make alpha=0 (for example) for the front texture? It would be transparent and user would see the actual view instead. This way there's no need to make texture from a view at all.

It would look kinda like this:
http://i.imgur.com/1KNlP.png

GREEN is where pagecurl should be transparent

from xbpagecurl.

xissburg avatar xissburg commented on May 21, 2024

You can do that with an image with transparency. Only start the curlView if the user drags on there, which is what XBPageDragView does.

from xbpagecurl.

overw avatar overw commented on May 21, 2024

Sorry, I already explained that I can't use image for this. I need this transparency when the curled corner appears with animation like in the image I showed above: http://i.imgur.com/wCm94.jpg
Also, let's forget about dragging right now. It's not the issue.

Thanks

from xbpagecurl.

xissburg avatar xissburg commented on May 21, 2024

I don't think that is really possible right now. Anyway, as I said earlier you can achieve an approximate result using an image with transparency. I still can't see a possibility to implement that into XBPagelCurl, I mean dynamic page content, because it's just not cheap to keep updating the texture all the time.

from xbpagecurl.

overw avatar overw commented on May 21, 2024

I found kind of solution for this by making front fragment shader transparent:
In FrontFragmentShader.glsl:

void main()
{
    vec4 color = texture2D(s_tex, v_texCoord);
    vec3 n = normalize(v_normal);
    float alpha = 1.0 - n.z; // using n.z (shading value) that we already have there to determinate which pixels should be transparent
    gl_FragColor = vec4 (0, 0, 0, alpha);
}

Then, set myCurledView.userInteractionEnabled = NO; so that the view that has 'curled' became interactive (not the curled corner itself).

The only few problems here.
First, because now the front layer (curled view that replaces an original interactive view in the original code) is missing, there's should always be a texture for "next page" - [myCurledView drawViewOnNextPage:backgroundView];
Second, the texture for the front page is still being generated and it's not used by the shader.

from xbpagecurl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.