globalcitizen / svglover

Library to import and display simple SVGs in LÖVE.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Implement <path>

globalcitizen opened this issue · comments

Unfortunately they are nontrivial and I don't need them, so I am not going to bother. For anyone that does want to bother, one way to implement them may be love.graphics.arc and coordinate system scale manipulation... but that will probably wind up a basic implementation with noticeable issues. Another option is love.math.newBezierCurve. The spec, Mozilla developer tutorial or w3schools summary show how it is nontrivial. There is also a reference python implementation.

From the spec, I think for a basic implementation you might go with line(x,y,x2,y2...etc.)?

For some definition of basic, yep. However, it is the nature of curves that a line between two points often does not approximate the curve at all... so I don't think such a naive implementation would be very useful.

I'm not going to make any promises, but I'll try to tackle this over the weekend. I did a bit of interpolation of splines in my data analysis course last semester. And I'd like to be able to use this library for dynamically sized pieces in a chess game.

I'll need to do some reading on the syntax for paths.

If you need an example, you can just have a look at my svg parser/renderer for Löve - grab the code for parsing paths from there if you like :)
(Not that you need my permission^^)
https://github.com/Bananicorn/lvg
(Parsing is done svg_parser.lua and some kinda helpful bits are in svg.lua as well, since rendering paths properly is tricky)
The part that doesn't work very well in my implementation is the rendering, parsing seems to work 99% of the time, as long as you stick to simple stuff that inkscape outputs)

Thanks, sounds interesting. I am swamped right now though. Someone else, please!

commented

Working on it!
See https://github.com/nasso/svglover to follow the progress