Hi everyone!
My problem is that I have a large amount of assets and want to be able to resize each image according to the user's screen resolution. I have each image in vector format, and want to resize them as vectors to retain the image quality. Currently, I am resizing the vectors outside of Love and saving multiple differently sized .pngs of each vector according to a selection of different screen resolutions. This is a pretty tedious task and will often be not perfect, if the user's res doesn't match any of the few resized images.
I'm certain there's a better way of doing this lol. I couldn't find any Lua libraries for manipulating vector images and was just wondering if there was any way of doing this within Love? I'd love to be able to resize the vectors within Love. I know Love only supports raster image formats, but was wondering if there was any other way to do this, such as using ImageData? I'm not really sure
Or if anyone has any other suggestions, they'd be thoroughly appreciated.
Thank you!!
Using vector images in Love?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: Using vector images in Love?
Sure, Love2D supports meshes (vectors) too in addition to textures (raster format).
What you need to do is convert your image files to something that Love2d understands.
Just convert your graphics ahead of time and you're all done!
This is by far easier and faster compared to trying to handle something like SVG from Lua.
If you decide to use raster graphics - just use the user's desktop resolution to determine the maximum texture quality.
You can resize the screen using love.graphics.scale, so if your textures have very high resolution, you can always scale them down.
Good luck!
What you need to do is convert your image files to something that Love2d understands.
Just convert your graphics ahead of time and you're all done!
This is by far easier and faster compared to trying to handle something like SVG from Lua.
If you decide to use raster graphics - just use the user's desktop resolution to determine the maximum texture quality.
You can resize the screen using love.graphics.scale, so if your textures have very high resolution, you can always scale them down.
Good luck!
Last edited by ivan on Thu Mar 07, 2019 7:28 pm, edited 2 times in total.
Re: Using vector images in Love?
LÖVE has no support for any vector formats (it has meshes, but no way to go from a vector file to a mesh directly). There are a bunch of svg renderers, but none of them are very complete to my knowledge. You could also use an external library with ffi bindings, but I don't know of any that renders vector files and comes with ready-to-use bindings.
Re: Using vector images in Love?
https://github.com/poke1024/tove2d This seems to be pretty complete and actively maintained/developed.
viewtopic.php?f=5&t=86419#p226150 this is barebones svg to raster image using nanosvg
But, in my opinion, converting to mesh makes more sense, unlike an image it can scale up nicely after the conversion provided that the mesh has enough detail/vertexes
Also if you just need a raster image you can do it in inkscape for different target resolutions
viewtopic.php?f=5&t=86419#p226150 this is barebones svg to raster image using nanosvg
But, in my opinion, converting to mesh makes more sense, unlike an image it can scale up nicely after the conversion provided that the mesh has enough detail/vertexes
Also if you just need a raster image you can do it in inkscape for different target resolutions
Re: Using vector images in Love?
Thanks for the replies everyone! I know I can convert the vectors outside of Love but I want to avoid using love.graphics.scale on raster images where possible to avoid the quality loss- and there are obviously a lot of resolutions = a lot of raster images of different sizes for each asset, which feels a bit clunky. Although might be my best option.
Thanks for these links, not sure how I didn't find them but I'll check them outingsoc451 wrote: ↑Fri Mar 08, 2019 12:45 am https://github.com/poke1024/tove2d This seems to be pretty complete and actively maintained/developed.
viewtopic.php?f=5&t=86419#p226150 this is barebones svg to raster image using nanosvg
But, in my opinion, converting to mesh makes more sense, unlike an image it can scale up nicely after the conversion provided that the mesh has enough detail/vertexes
Also if you just need a raster image you can do it in inkscape for different target resolutions
Re: Using vector images in Love?
Having different texture sizes is not bad, I use that technique myself.
Also, note that I was talking about scaling textures DOWN. Basically, you can always scale down, so the question becomes, what's the maximum resolution/texture size that you should load. Obviously you don't need to load 4K textures if the user's desktop resolution is 1024x768.
Who is online
Users browsing this forum: Google [Bot] and 5 guests