Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

Any Plans for SVG support?

edited May 2012 in Suggestions Posts: 141

Are there any plans to support SVG — or some other form of vector graphics?

In my native iOS projects I like to use SVG (or iOS's native handling of PDF) for graphics as much as possible. It makes it much easier to have images scale between iPhone and iPad and eliminates the need for @2x versions of the images.

I would love to have the same flexibility — without needing to resort to writing an SVG interpreter myself.

Comments

  • SimeonSimeon Admin Mod
    Posts: 5,054

    We could probably add PDF support — render PDF to texture using iOS' native PDF rendering. But you would have to dictate a resolution when you do the render-to-texture. Direct rendering of vector graphics in OpenGL is a little bit ambitious for us.

  • edited May 2012 Posts: 141

    @Simeon Correct, I didn't mention that but yes you would have to specify the width and height you want to render, but that is a small price for the benefit vector images afford.

    I personally use SVGKit in my apps, I am not sure how well that will work with Codea's rendering later, or not.

    Though I would also be fine with just PDF, it means more conversion but that isn't too big of a hurdle.

  • SimeonSimeon Admin Mod
    Posts: 5,054

    I hadn't seen SVGKit. We might be able to use that to add PDF and SVG media support.

    The way we will probably handle it is to have it transparently cache the PDF or SVG asset on first use — so whenever you change the rendering dimensions (in the sprite() arguments) it creates a new texture.

  • Posts: 141

    It might not be needed, but you could also let the user pregenerate the vector sprites with a call like:

    smallSprite = makeSprite(vectorImage, 50, 57);
    largeSprite = makeSprite(vectorImage, 100, 114);
    

    As I write this, I realize you could do the same thing with bitmaps as well — assuming Codea creates a texture for each size. Not strictly needed, but it could be a bit of an optimization.

    Though one could do this now with images...

  • SimeonSimeon Admin Mod
    Posts: 5,054

    Yes, you could definitely handle your own caching by creating an image and rendering the sprite() with setContext. We will do some automatic caching for the naïve case (like we do for text rendering).

  • Posts: 141

    Cool, in that case makeSprite() is nothing more than a convenience function anyone can write.

Sign In or Register to comment.