scour
scour copied to clipboard
Convert polylines and polygons into paths
Polylines and polygons are defined in the SVG specification as being alternate forms for paths starting with an absolute move to the first point and linetos to each of the following points. In the case of polygon, a closepath is also added.
A naive reading of this feature request would just convert "polyline points=..." into "path d=M..." and "polygon points=..." into "path d=M...Z", but the real savings is had from:
- vertical and horizontal line segments;
- short line segments enabling shorter relative linetos.
Consider this polygon, from a test case in https://bugs.launchpad.net/scour/+bug/481605/comments/3 :
<polygon fill-rule="evenodd" clip-rule="evenodd" fill="#993300" points="370.441,402.976 371.967,403.015 374.941,403.343
377.819,403.942 380.601,404.831 383.247,405.989 385.758,407.419 388.113,409.042 390.335,410.916 392.344,413.02 394.141,415.26 ..." />
A naive conversion would just do this:
A real conversion would be done before paths, and thus allow the new path to be converted as well:
which is clearly shorter.
Imported from Launchpad using lp2gh.
- date created: 2010-06-11T00:40:39Z
- owner: louis-simard-deactivatedaccount
- the launchpad url was https://bugs.launchpad.net/bugs/592485
(by louis-simard-deactivatedaccount) Converting polygons and polylines into paths risks running into issues with CSS. Changing one tag to the other might completely mess up internal stylesheets and XSL stylesheets which rely on polygon and polyline, and may even conflict with declarations for paths that are not meant to be applied to the polygon and polyline tags in a document.
If there is no style tag or XSL stylesheet reference in the document, then it's completely fine.
But what should be done when there is one?
I tend to tag this as "wontfix".
Obviously we could convert both polylines andpoligons as well as lines to paths and an implementation probably wouldn't be too hard (as long as we ignore style sheets), however
- most SVG editors do not create them anyway but simply work with paths to start with, therefore we wouldn't gain anything in most cases
- even if there are some of those elements I guess the savings would be small unless huge
polylines orpoligons were involved - some people might actually prefer those elements as they convey some meaning regarding the geometric shape whereas
pathdoes not and we would have to add yet another option