Page 1 of 2

Does LÖVE Support .svg Files?

Posted: Wed Feb 01, 2012 9:20 pm
by XTUX345
Excuse me, but I have been thinking of using vector graphics for my LÖVE project. Can I use .svg files in LÖVE, or must I be forced to use bitmap images?

Re: Does LÖVE Support .svg Files?

Posted: Wed Feb 01, 2012 9:59 pm
by coffee
Unfortunately no. Unless you add it and compile yourself some library like Cairo Graphics I think. You can also try made some SVG library parser but that would be very hard work implement all features I think.

Here some Lua bindings to Cairo (don't know if SVG is already implemented):
http://www.dynaset.org/dogusanh/
http://luaforge.net/projects/oocairo/
http://luaforge.net/projects/luacairo/

Re: Does LÖVE Support .svg Files?

Posted: Wed Feb 01, 2012 10:32 pm
by Taehl
I'd recommend exporting your .svg to .png instead of .bmp. Superior format in every way. It's not that bad that Love2D doesn't support vector images, actually - graphics cards are designed from the ground-up to perform raster work, so you'll be using available hardware as best as possible by using raster.

Re: Does LÖVE Support .svg Files?

Posted: Wed Feb 01, 2012 10:40 pm
by coffee
Taehl wrote:I'd recommend exporting your .svg to .png instead of .bmp. Superior format in every way. It's not that bad that Love2D doesn't support vector images, actually - graphics cards are designed from the ground-up to perform raster work, so you'll be using available hardware as best as possible by using raster.
It's not about performance issues but about the things that you can do with vectors that you cant do with raster formats like zooming to infinite and don't have quality loss or change colors on the fly in chosen elements of vector "image", etc. It's not the same category of graphics. It would be like have a kind of "flash" manipulation in Lua/LOVE.

EDITED For example Corona have a third party tool to build levels using SVG.
Corona SVG Level Builder is a set of libraries to be used in a Corona SDK game that allows you to create Corona SDK physics based games, levels and maps by just drawing in the free and open source vector drawing Inkscape. Everything you draw in Inkscape is automatically converted into Corona physics bodies or paths.
http://levelbuilder.karnakgames.com/doc/
http://karnakgames.com/wp/corona-svg-level-builder/
Would be interesting adapt this to LOVE as test experience
https://github.com/singularity-is-i/SVG-Path-in-Lua

Also SVG is truly open-source and I think would fit well in LOVE spirit and tradition.

Re: Does LÖVE Support .svg Files?

Posted: Thu Feb 02, 2012 2:59 am
by tentus
I wouldn't mind a system where you could load an SVG file, choose a render size, and then use the resulting raster for rendering. It's not as convenient but it'd result in smaller and more flexible games.

Re: Does LÖVE Support .svg Files?

Posted: Thu Feb 02, 2012 3:52 am
by slime
coffee wrote:It's not about performance issues but about the things that you can do with vectors that you cant do with raster formats like zooming to infinite and don't have quality loss or change colors on the fly in chosen elements of vector "image", etc. It's not the same category of graphics. It would be like have a kind of "flash" manipulation in Lua/LOVE.
The thing is, LÖVE is hardware accelerated and graphics cards just aren't designed for that. The next best thing would be to convert to a rasterized image based on the scale, which you can sort of do already, although it might not be as convenient.

Re: Does LÖVE Support .svg Files?

Posted: Thu Feb 02, 2012 9:34 am
by coffee
slime wrote:
coffee wrote:It's not about performance issues but about the things that you can do with vectors that you cant do with raster formats like zooming to infinite and don't have quality loss or change colors on the fly in chosen elements of vector "image", etc. It's not the same category of graphics. It would be like have a kind of "flash" manipulation in Lua/LOVE.
The thing is, LÖVE is hardware accelerated and graphics cards just aren't designed for that. The next best thing would be to convert to a rasterized image based on the scale, which you can sort of do already, although it might not be as convenient.
Slime I agree that raster processing have an older and more faster/direct support, but nowadays browsers and "HTML5" interpret and do SVG render even in mobile plataforms, Flash do it in a compiled way for ages an alternative vector render support. 3D videogames use math and vector operations. Even LOVE already operate well with vector basic operations and the base support is there. Aren't really graphic cards so not designed for that? I would think GPU are well prepared to deal with math operations and vectors long time ago. Do it in a vector or raster form is more a choice, not always speed is intended. Following your thought in a parallel way we should avoid scripted languages just because compiled code are faster/more direct running in CPU.
Modern graphics processing units excel at rendering triangles and triangular approximations to smooth objects. It is somewhat surprising to realize that the same architecture is ideally suited to rendering smooth vector-based objects as well.
http://http.developer.nvidia.com/GPUGem ... _ch25.html

Re: Does LÖVE Support .svg Files?

Posted: Thu Feb 02, 2012 10:12 am
by miko
coffee wrote:Here some Lua bindings to Cairo (don't know if SVG is already implemented):
For svg try this:
http://librsvg.sourceforge.net/

And yes, in GTK you can load a *.svg as an image with specified dimensions (using pixbuf_new_from_file_at_size()), and you get perfectly scaled final raster image. It would be nice to have that in love2d.

Re: Does LÖVE Support .svg Files?

Posted: Thu Feb 02, 2012 10:30 am
by bartbes
The biggest problem with this, when we last looked at it, that svg libraries are huuuuuge, and we're talking about doubling the size of love here.

Re: Does LÖVE Support .svg Files?

Posted: Thu Feb 02, 2012 12:00 pm
by coffee
bartbes wrote:The biggest problem with this, when we last looked at it, that svg libraries are huuuuuge, and we're talking about doubling the size of love here.
Well about that I can't say much more than that XTUX345 will need for a while do only basic vector stuff in LOVE.

I quickly checked LuaCairo (that is already a huuuuuge graphics library with even pdf support) and the full compiled lcairo.dll size don't seem so scary as you say. You checked very bad SVG libraries! :D