Skip to content

Commit 67fcc4a

Browse files
committed
Add a draw() shape syntax, which accepts shape-segments equivalent to
SVG path segments. Fixes #5674
1 parent 8ca0c84 commit 67fcc4a

File tree

1 file changed

+78
-4
lines changed

1 file changed

+78
-4
lines changed

css-shapes-1/Overview.bs

Lines changed: 78 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ Supported Shapes</h3>
449449

450450
</dd>
451451
<dt><dfn>path()</dfn> =
452-
path( [<<'fill-rule'>>,]? <<string>> )
452+
path( [<<'fill-rule'>>,]? <<string>>)
453453
</dt>
454454
<dd dfn-type=value dfn-for="path()">
455455
<ul>
@@ -480,11 +480,33 @@ Supported Shapes</h3>
480480
if it is not present in the string
481481
for properties that require a closed loop
482482
(such as 'shape-outside' and 'clip-path').
483+
<dt><dfn>draw()</dfn> =
484+
draw( [<<'fill-rule'>>,]? from <<coordinate-pair>>, <<draw-segment>>#])
485+
</dt>
486+
<dd dfn-type=value dfn-for="shape()">
487+
<ul>
488+
<li>
489+
<<'fill-rule'>> -
490+
The filling rule used
491+
to determine the interior
492+
of the path.
493+
See <a href="https://www.w3.org/TR/SVG/painting.html#FillRuleProperty">fill-rule</a> property
494+
in SVG for details.
495+
Possible values are ''nonzero''
496+
or ''evenodd''.
497+
Default value when omitted is ''nonzero''.
498+
<li>
499+
The <<coordinate-pair>> represents the initial point of the path.
500+
<li>
501+
The sequence of <dfn><<draw-segment>></dfn>s represent segments of an <a href="https://www.w3.org/TR/SVG11/paths.html#PathData">SVG Path</a>.
502+
</ul>
483503
</dl>
484504

485505
The arguments not defined above are defined as follows:
486506

487507
<dl>
508+
<dt><dfn><<coordinate-pair>></dfn> = <<length-percentage>>{2}
509+
<dd>Defines a pair of coordinates x & y.
488510
<dt><dfn><<shape-radius>></dfn> = <<length-percentage>> | closest-side | farthest-side
489511
<dd>
490512
Defines a radius for a circle or ellipse. If omitted it defaults to closest-side.
@@ -512,10 +534,62 @@ Supported Shapes</h3>
512534
this is the farthest side
513535
in the radius dimension.
514536
</ul>
515-
</dl>
537+
<dt><dfn><<draw-segment>></dfn> = <<move-segment>> | <<line-segment>> | <<perpendicular-line-segment>> |
538+
<<curve-segment>> | <<smooth-segment>> | <<arc-segment>> | close
539+
<dd>
540+
Defines a single path segment. Every path segment corresponds to an SVG path segment.
541+
<dt><dfn><<segment-offset-reference>></dfn> = to | by
542+
<dd>
543+
Represents the reference from which offsets are computed in <<draw-segment>>s.
544+
When ''to'' is present, the coordinates are relative to the top-left origin of the <a>reference box</a>.
545+
Otherwise ''by'' is present, the coordinates are relative to the end position of the previous segment.
546+
547+
Note:
548+
<<percentage>> values are always computed relative to the <a>reference box</a>, regardless of how offsets are computed.
549+
<dd>
516550

517-
<h3 id='basic-shape-computed-values'>
518-
Computed Values of Basic Shapes</h3>
551+
<dt><dfn><<move-segment>></dfn> = move <<segment-offset-reference>> <<coordinate-pair>>
552+
<dd>
553+
Corresponds to a <a href="">moveto</a> segment.
554+
<dt><dfn><<line-segment>></dfn> = line <<segment-offset-reference>> <<coordinate-pair>>
555+
<dd>
556+
Corresponds to a <a href="">lineto</a> segment.
557+
<dt><dfn><<perpendicular-line-segment>></dfn> = [horizontal|vertical] <<segment-offset-reference>> <<length-percentage>>
558+
<dd>
559+
Corresponds to a <a href="">horizontal</a> or <a href="">vertical</a> segment.
560+
<dt><dfn><<curve-segment>></dfn> = curve <<segment-offset-reference>> <<coordinate-pair>> via <<coordinate-pair>>{1,2}
561+
<dd>
562+
Corresponds to a <a href="">quadratic curve</a> segment if one <<coordinate-pair>> is provided,
563+
otherwise corresponds to a <a href="">cubic curve</a> segment.
564+
<dt><dfn><<smooth-segment>></dfn> = smooth <<segment-offset-reference>> <<coordinate-pair>> [via <<coordinate-pair>>]?
565+
<dd>
566+
Corresponds to a <a href="">smooth cubic curve</a> segment if a <<coordinate-pair>> is provided,
567+
otherwise corresponds to a <a href="">smooth quadratic curve</a> segment.
568+
<dt><dfn><<arc-segment>></dfn> = arc <<segment-offset-reference>> <<coordinate-pair>> [[radius <<length-percentage>>{1,2}] && <<arc-large>> && <<arc-sweep>> && <<angle>>?]
569+
<dd>
570+
Corresponds to an <a href="">arc</a> segment, with a given radius, x-axis rotation <<angle>>, <a href="">large</a> and <a href="">sweep</a> flags.
571+
<dt><dfn><<arc-large>></dfn> = [large | small]?
572+
<dd>
573+
If ''small'' is set, the arc's <a href="">large</a> flag is set to 0.
574+
If ''large'' is set, the arc's <a href="">large</a> flag is set to 1.
575+
If it is not set, the automatic value is used.
576+
<dt><dfn><<arc-sweep>></dfn> = [cw | ccw]?
577+
<dd>
578+
If ''ccw'' is set, the arc's <a href="">sweep</a> flag is set to 0.
579+
If ''cw'' is set, the arc's <a href="">sweep</a> flag is set to 1.
580+
If it is not set, the automatic value is used.
581+
<dt>close
582+
<dd>
583+
Corrsepponds to a <a href="">closepath</a> segment.
584+
</dl>
585+
<h3 id='basic-shape-computed-values'>Closing paths</h3>
586+
For ''path()'' and ''draw()'' shapes, the UA must close the derived path
587+
with an implicit closepath command ("z" or "Z")
588+
if it is not present in the path segments or string
589+
for properties that require a closed loop
590+
(such as 'shape-outside' and 'clip-path').
591+
592+
<h3 id='basic-shape-computed-values'>Computed Values of Basic Shapes</h3>
519593

520594
The values in a <<basic-shape>> function are computed as specified, with these exceptions:
521595

0 commit comments

Comments
 (0)