I have some SVG images of a tree I have drawn. It consists of the main stem of the tree and a few small groups of leaves. I would like to be able to draw all leaves or just some of the leaves based on the time of the year. I also want to be able to talk to the different parts of the tree s.t. I can animate them differently (let the leaves shake in the wind).
The by far nicest solution for me would be to be able to import the SVG image in Love/Lua and then just render parts of it to a canvas or something (for example just specific layers). Then I would just have to do the SVGs in Inkscape and import them. Is this possible? (How much work is this?)
My other idea is just to export the different parts of the image in images of exactly the same size and draw all of these images above each other. But then I have to export all of the parts every time I rescale something for example. If this is the way to go, are there tools that make any part of the process easier? (Can be Inkscape specific tips)
Or is there a whole other way to do this easy which I am not seeing?
Can I read SVG images and just draw parts?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
-
- Prole
- Posts: 14
- Joined: Mon Jan 22, 2018 10:11 pm
-
- Prole
- Posts: 14
- Joined: Mon Jan 22, 2018 10:11 pm
Re: Can I read SVG images and just draw parts?
And I also have another small question which I don't want to post to an own thread: If I have an image consisting of multiple colors (SVG or not SVG, both possible), can I change one of the colors? For example to make only the leave inner color red in autumn but leave the border black?
-
- Prole
- Posts: 14
- Joined: Mon Jan 22, 2018 10:11 pm
Re: Can I read SVG images and just draw parts?
It seems like the answer to both questions could be cairo https://luapower.com/cairo
Does anyone have experience with getting luapower to work with love? (And does anyone know an easy svg->cairo converter)?
Does anyone have experience with getting luapower to work with love? (And does anyone know an easy svg->cairo converter)?
- zorg
- Party member
- Posts: 3468
- Joined: Thu Dec 13, 2012 2:55 pm
- Location: Absurdistan, Hungary
- Contact:
Re: Can I read SVG images and just draw parts?
Löve doesn't support svg-s out of the box, i do recall some effort trying to write importers, but not sure what happened to those;
The second solution might be easier, but you don't need to re-export everyting for each scale level (and rotation, skew, etc.) since löve can transform images in those ways anyway.
Answer to the second question is a twofold yes; you can either load the image into an ImageData first, do the substitution on the pixel colors of your choice, then save it, or create an Image object out of it, or even both. I'm gonna guess you want something like a team-specific color, like in the settlers games, or in the early bomberman games.
Cairo imho would be bloat, imho i'd do it without trying to integrate that.
The second solution might be easier, but you don't need to re-export everyting for each scale level (and rotation, skew, etc.) since löve can transform images in those ways anyway.
Answer to the second question is a twofold yes; you can either load the image into an ImageData first, do the substitution on the pixel colors of your choice, then save it, or create an Image object out of it, or even both. I'm gonna guess you want something like a team-specific color, like in the settlers games, or in the early bomberman games.
Cairo imho would be bloat, imho i'd do it without trying to integrate that.
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
Re: Can I read SVG images and just draw parts?
I did get pretty far with an SVG importer before:
https://love2d.org/forums/viewtopic.php ... 20#p195245
Gave up on it since it's was slow and too hard to support the myriad of SVG features and quirks.
SVG is good as an intermediate format during development but it doesn't make sense in games.
Just export your graphics ahead of time - either as a mesh, PNG or any format that Love2d can already handle.
https://love2d.org/forums/viewtopic.php ... 20#p195245
Gave up on it since it's was slow and too hard to support the myriad of SVG features and quirks.
SVG is good as an intermediate format during development but it doesn't make sense in games.
Just export your graphics ahead of time - either as a mesh, PNG or any format that Love2d can already handle.
Who is online
Users browsing this forum: Ahrefs [Bot], Amazon [Bot] and 5 guests