Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove support for segment-completing close path #398

Merged
merged 2 commits into from
Aug 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions master/changes.html
Original file line number Diff line number Diff line change
Expand Up @@ -433,10 +433,6 @@ <h3 id="coords">Coordinate Systems, Transformations and Units chapter (owner: Bo
<h3 id="paths">Paths chapter (owner: ericwilligers)</h3>

<ul>
<li>Allow <strong>Z</strong> or <strong>z</strong> to fill in
missing path coordinate data in the previous command with the
coordinate of the initial point in the subpath.</li>

<li>Define <a>'path'</a>, <a>'polygon'</a> and <a>'polyline'</a> elements with no data set (empty or zero valid commands) to not render.</li>

<!--
Expand Down
118 changes: 30 additions & 88 deletions master/paths.html
Original file line number Diff line number Diff line change
Expand Up @@ -340,32 +340,31 @@ <h3 id="PathDataMovetoCommands">The <strong>"moveto"</strong> commands</h3>
<h3 id="PathDataClosePathCommand">The <strong>"closepath"</strong> command</h3>

<p>The "closepath" (<strong>Z</strong> or <strong>z</strong>)
must end the current subpath by connecting it back to its <a>initial point</a>
in either of two ways:
ends the current subpath by connecting it back to its <a>initial point</a>.
An automatic
straight line is drawn from the current point to the <a>initial point</a>
of the current subpath. This <a>path segment</a> may be of zero
length.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original text also said what the next initial point is when "closepath" is not followed by a moveto.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, IMO it is important to keep the original sentence that a lineto to the initial point is not the same as specifying a closepath.

Maybe we should copy those sentences over: https://www.w3.org/TR/SVG11/paths.html#PathDataClosePathCommand

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The sentences have now been copied.

</p>

<ol>
<li>
If the previous command is <q>complete</q>, that is that all the
required coordinate data has been supplied, then an automatic
straight line must be drawn from the current point to the <a>initial point</a>
of the current subpath. This <a>path segment</a> may be of zero
length.
</li>
<li class='ready-for-wider-review'>
If the previous command is a <a href="paths.html#PathDataLinetoCommands">"lineto"</a>,
<a href="paths.html#PathDataCubicBezierCommands">"curveto"</a>,
<a href="paths.html#PathDataCubicBezierCommands">"smooth curveto"</a>,
<a href="paths.html#PathDataQuadraticBezierCommands">"quadratic Bézier curveto"</a>,
<a href="paths.html#PathDataQuadraticBezierCommands">"smooth quadratic Bézier curveto"</a>,
or <a href="paths.html#PathDataEllipticalArcCommands">"elliptical arc"</a>,
that is missing required coordinate data,
then this is a <dfn id="TermSegment-CompletingClosePath">segment-completing close path command</dfn>.
No additional path segment is generated by the command; instead,
the <a>initial point</a> for this subpath must be used
in place of each missing <var>(x,y)</var> coordinate to complete the previous segment.
</li>
</ol>
<p>If a "closepath" is followed immediately by a "moveto", then the
"moveto" identifies the start point of the next subpath.
If a "closepath" is followed immediately by any other command, then
the next subpath starts at the same initial point as the current
subpath.</p>

<p>When a subpath ends in a "closepath," it differs in behavior
from what happens when "manually" closing a subpath via a
"lineto" command in how <a href="painting.html#StrokeLinejoinProperty"><span class="prop-name">‘stroke-linejoin’</span></a>
and <a href="painting.html#StrokeLinecapProperty"><span class="prop-name">‘stroke-linecap’</span></a> are implemented. With "closepath", the end of the final segment
of the subpath is "joined" with the start of the initial
segment of the subpath using the current value of <a href="painting.html#StrokeLinejoinProperty"><span class="prop-name">‘stroke-linejoin’</span></a>.
If you instead "manually" close the subpath via a "lineto"
command, the start of the first segment and the end of the last
segment are not joined but instead are each capped using the
current value of <a href="painting.html#StrokeLinecapProperty"><span class="prop-name">‘stroke-linecap’</span></a>.
At the end of the command, the new current point is set to the
initial point of the current subpath.</p>

<table class="PathDataTable">
<tr>
Expand All @@ -386,22 +385,6 @@ <h3 id="PathDataClosePathCommand">The <strong>"closepath"</strong> command</h3>
</tr>
</table>

<p class="note">
SVG 2 adds the ability to fill in missing coordinate data with
the <strong>Z</strong> or <strong>z</strong> command to avoid the
need to add a zero length (or very short in the case of relative
paths with rounding errors) <a>path segment</a> to close a subpath. This
can effect the number of markers drawn and their orientation at
the beginning/end of a closed subpath.
</p>
<p class="annotation">
The use of <strong>Z</strong> or <strong>z</strong> to replace
missing coordinate data with the coordinate of the <a>initial point</a> in
a subpath was resolved at the
<a href="http://www.w3.org/2015/02/12-svg-minutes.html#item04">Sydney
(2015)</a> meeting.
</p>

<p>A <dfn id="TermClosedSubpath">closed subpath</dfn> must be closed with a
"closepath" command, this "joins" the first and last <a>path segments</a>.
Any other path is an <dfn id="TermOpenSubpath">open subpath</dfn>.</p>
Expand All @@ -421,39 +404,6 @@ <h3 id="PathDataClosePathCommand">The <strong>"closepath"</strong> command</h3>
other command, then the next subpath must start at the same <a>initial point</a>
as the current subpath.</p>

<p>Examples:</p>
<ul>
<li>
m 100,100 50,0 0,50 z:

Implicit <strong>l</strong> command complete, <strong>z</strong> causes a
straight line to be drawn resulting in a closed triangular path.
</li>
<li>
m 100,100 a 50,50 0 0 1 100,0 z:

<strong>a</strong> command complete, <strong>z</strong> causes a
straight line to be drawn resulting in a closed semi-circular path.
</li>
<li>
m 100,100 a 50,50 0 0 1 100,0 50,50 0 0 1 z:

Second set of coordinates for the <strong>a</strong> command
missing final point, <strong>z</strong> causes <a>initial point</a> to
be used as final point resulting in a closed circular path.
</li>
<li>
m 100,100 a 50,50 0 0 1 100,0 c z:

<strong>c</strong> command missing three coordinates,
<strong>z</strong> causes <a>initial point</a> to be used as coordinate
data for all <strong>c</strong> coordinates resulting in a
closed semi-circle. Visually <strong>c</strong>
<strong>z</strong> is the same as <strong>z</strong> but may be
useful in animating path data.
</li>
</ul>

<h3 id="PathDataLinetoCommands">The <strong>"lineto"</strong> commands</h3>

<p>The various "lineto" commands draw straight lines from the
Expand Down Expand Up @@ -833,13 +783,13 @@ <h3 id="PathDataBNF">The grammar for path data</h3>
| elliptical_arc

moveto::=
( "M" | "m" ) wsp* coordinate_pair_sequence wsp* closepath?
( "M" | "m" ) wsp* coordinate_pair_sequence

closepath::=
("Z" | "z")

lineto::=
("L"|"l") wsp* (coordinate_pair_sequence | closepath)
("L"|"l") wsp* coordinate_pair_sequence

horizontal_lineto::=
("H"|"h") wsp* coordinate_sequence
Expand All @@ -848,35 +798,31 @@ <h3 id="PathDataBNF">The grammar for path data</h3>
("V"|"v") wsp* coordinate_sequence

curveto::=
("C"|"c") wsp* (curveto_coordinate_sequence | (coordinate_pair_sequence? closepath))
("C"|"c") wsp* curveto_coordinate_sequence

curveto_coordinate_sequence::=
coordinate_pair_triplet
| (coordinate_pair_triplet comma_wsp? curveto_coordinate_sequence)

smooth_curveto::=
("S"|"s") wsp* (smooth_curveto_coordinate_sequence
| (coordinate_pair_sequence? closepath))
("S"|"s") wsp* smooth_curveto_coordinate_sequence

smooth_curveto_coordinate_sequence::=
coordinate_pair_double
| (coordinate_pair_double comma_wsp? smooth_curveto_coordinate_sequence)

quadratic_bezier_curveto::=
("Q"|"q") wsp*
(quadratic_bezier_curveto_coordinate_sequence | (coordinate_pair_sequence? closepath))
("Q"|"q") wsp* quadratic_bezier_curveto_coordinate_sequence

quadratic_bezier_curveto_coordinate_sequence::=
coordinate_pair_double
| (coordinate_pair_double comma_wsp? quadratic_bezier_curveto_coordinate_sequence)

smooth_quadratic_bezier_curveto::=
("T"|"t") wsp* (coordinate_pair_sequence | closepath)
("T"|"t") wsp* coordinate_pair_sequence

elliptical_arc::=
( "A" | "a" ) wsp*
(elliptical_arc_argument_sequence
| (elliptical_arc_argument_sequence? elliptical_arc_closing_argument))
( "A" | "a" ) wsp* elliptical_arc_argument_sequence

elliptical_arc_argument_sequence::=
elliptical_arc_argument
Expand All @@ -886,10 +832,6 @@ <h3 id="PathDataBNF">The grammar for path data</h3>
number comma_wsp? number comma_wsp? number comma_wsp
flag comma_wsp? flag comma_wsp? coordinate_pair

elliptical_arc_closing_argument::=
number comma_wsp? number comma_wsp? number comma_wsp
flag comma_wsp? flag comma_wsp? closepath

coordinate_pair_double::=
coordinate_pair comma_wsp? coordinate_pair

Expand Down