W3C home > Mailing lists > Public > www-svg@w3.org > December 2012

Re: SVG2 - suggestion for a new path command to close a subpath smoothly

From: Jasper van de Gronde <th.v.d.gronde@hccnet.nl>
Date: Mon, 03 Dec 2012 10:01:34 +0100
Message-ID: <50BC6A6E.3050900@hccnet.nl>
To: www-svg@w3.org
On 01-12-12 18:01, Dr. Olaf Hoffmann wrote:
> Hello,
> 
> there was already some discussion about new
> path commands in SVG2 to simplify the work 
> of authors.
> I propose to introduce a new path command
> as an extension of the commands S and Z.
> ...
> Today authors have to compute especially the
> second control point manually to get this effect.
> With some knowlegde in analysis (mathematics), this
> is not difficult, but unfortunately it cannot be 
> assumed, that all authors have such capabilities.

There are actually even more issues involved (like markers, weird UI
hacks, etc.). In Inkscape we would love SVG 2 to allow the last path
segment to be something other than a straight line. So thanks for
bringing this up. (BTW, we never considered explicit support for
/smooth/ closing path commands, but it's a great idea.)

I would suggest, though, to rethink the naming scheme. Essentially you'd
want ANY path command to be able to close a subpath (why allow a cubic
Bézier, but not an arc for example). So if they all get letters, that's
a lot of letters. Instead, I would suggest letting an author "flag" when
a path command should close a subpath.

For example (new syntax followed by old that has at least a similar
appearance, without markers or GUI editing):

M 0,0 L 1,0 L R
 = M 0,0 L 1,0 z
M 0,0 C 1,0 1,1 0,1 C -1,1 -1,0 R
 = M 0,0 C 1,0 1,1 0,1 C -1,1 -1,0 0,0 z
M 0,0 C 1,0 1,1 0,1 C -1,1 R
 = M 0,0 C 1,0 1,1 0,1 C -1,1 -1,0 0,0 z

So the R would normally be used instead of the last coordinate (which
should match the starting point), closing the subpath. Inspired by Olaf
Hoffman's request, one could also imagine using it instead of the second
control point and the final coordinate to imply a smooth closing of the
path.

I would also be fine with special letters for all possible combinations
(probably easier on parsers), but it would start to be a little weird.
Basically you'd (at least) have new commands corresponding to the following:

L R
C x1,y1 R
C x1,y1 x2,y2 R
S R
S x2,y2 R
Q R
Q x1,y1 R
T R
A rx,ry ... sweep-flag R
Received on Monday, 3 December 2012 09:08:43 GMT

This archive was generated by hypermail 2.3.1 : Friday, 8 March 2013 15:54:53 GMT