Does LÖVE Support .svg Files?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
XTUX345
Prole
Posts: 7
Joined: Thu Nov 24, 2011 6:44 pm

Does LÖVE Support .svg Files?

Post 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?
coffee
Party member
Posts: 1206
Joined: Wed Nov 02, 2011 9:07 pm

Re: Does LÖVE Support .svg Files?

Post 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/
Last edited by coffee on Wed Feb 01, 2012 11:00 pm, edited 1 time in total.
User avatar
Taehl
Dreaming in associative arrays
Posts: 1025
Joined: Mon Jan 11, 2010 5:07 am
Location: CA, USA
Contact:

Re: Does LÖVE Support .svg Files?

Post 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.
Earliest Love2D supporter who can't Love anymore. Let me disable pixel shaders if I don't use them, dammit!
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.
coffee
Party member
Posts: 1206
Joined: Wed Nov 02, 2011 9:07 pm

Re: Does LÖVE Support .svg Files?

Post 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.
User avatar
tentus
Inner party member
Posts: 1060
Joined: Sun Oct 31, 2010 7:56 pm
Location: Appalachia
Contact:

Re: Does LÖVE Support .svg Files?

Post 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.
Kurosuke needs beta testers
User avatar
slime
Solid Snayke
Posts: 3132
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: Does LÖVE Support .svg Files?

Post 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.
coffee
Party member
Posts: 1206
Joined: Wed Nov 02, 2011 9:07 pm

Re: Does LÖVE Support .svg Files?

Post 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
User avatar
miko
Party member
Posts: 410
Joined: Fri Nov 26, 2010 2:25 pm
Location: PL

Re: Does LÖVE Support .svg Files?

Post 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.
My lovely code lives at GitHub: http://github.com/miko/Love2d-samples
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Does LÖVE Support .svg Files?

Post 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.
coffee
Party member
Posts: 1206
Joined: Wed Nov 02, 2011 9:07 pm

Re: Does LÖVE Support .svg Files?

Post 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
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 159 guests