cjlano / svg Goto Github PK
View Code? Open in Web Editor NEWA Python SVG parser and drawing module
License: GNU General Public License v2.0
A Python SVG parser and drawing module
License: GNU General Public License v2.0
Hi cjlano,
I wanted to send you a private email, but didn't find your contact details on gh.
First of all, thanks for the great svg parser. Works good so far and has some improvements over the one I made for my project.
I needed CSS style parsing so I implemented a rough version of it here: https://github.com/asl-beachbot/pathmaker/tree/master/python/svg
You may or may not be interested in the changes I introduced, but I thought I'd let you know (also in the spirit of the GPL 👍 . Maybe it's a welcomed addition for other users as well.
Cheers,
Wolf
We currently use DeCasteljau Algorithm to find Bézier Curve points, well illustrated in Wikipedia:
It would be faster to implement Bézier Curve drawing using the parametric equation of Quadratic Bézier Curve:
and Cubic Bezier Curve:
We loose the generic solution, but SVG only accept a Quadratic and Cubic Bézier Curve anyway.
Hi @cjlano would you mind giving someone else administrative rights so that pull requests can be merged? I would happily apply.
Best,
Wolf
I had a look but it's a bit hard to search for.
For paramterizing the bezier curve, endpoint is not included because range(1, n)
only goes to n - 1
https://github.com/cjlano/svg/blob/master/svg/geometry.py#L271
Sometimes, Inkscape produces values with exponent notation, such as 0,3e-5 z
.
This could be a fix: http://stackoverflow.com/questions/2293780/how-to-detect-a-floating-point-number-using-a-regular-expression
I have an svg document created by inkscape, which contains
<g xmlns="http://www.w3.org/2000/svg" transform="matrix(0.78833207,0,0,0.78833207,732.35928,2461.464)" id="g6570-6-0" style="display:inline">
<title id="title5036-33-11">AndCirclw</title>
<path transform="matrix(0.9,0,0,0.9,43.799845,168.3607)" d="m 471.69062,1689.2223 a 28.076822,28.076822 0 1 1 -56.15364,0 28.076822,28.076822 0 1 1 56.15364,0 z" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" sodipodi:ry="28.076822" sodipodi:rx="28.076822" sodipodi:cy="1689.2223" sodipodi:cx="443.6138" id="path6572-377-65" style="color:#000000;fill:none;stroke:#ff00ff;stroke-width:5.63778257;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" sodipodi:type="arc"/>
<path xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" inkscape:connector-curvature="0" id="path6578-70-8" d="m 429.22862,1695.7144 12.42464,-21.5201 14.31592,24.7959" style="color:#000000;fill:none;stroke:#ff00ff;stroke-width:5.0740037;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"/>
</g>
and svg_element.bbox() returns ((1070.734,3781.285), (1101.552,3800.832))
which is not even close to a boundingbox to this circular element, since it only takes the second part of the svg group in account and svg_element.items[0].bbox() returns an empty box outside of the element (no transformations applied?)
E.g. class Rect()
is missing:
def scale(self,scale):
self.P1 = scale * self.P1
self.P2 = scale * self.P2
But other Transsformable
s have similar omissions.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.