Skip to content

Commit 94f3b18

Browse files
committed
[css-shapes-1] Add xywh() and redefine rect() for <basic-shape> purposes. w3c#7058
1 parent e1981c4 commit 94f3b18

File tree

1 file changed

+96
-29
lines changed

1 file changed

+96
-29
lines changed

css-shapes-1/Overview.bs

Lines changed: 96 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -337,44 +337,103 @@ Supported Shapes</h3>
337337
and are defined here using the
338338
<a href="https://www.w3.org/TR/css3-values/#value-defs">Value Definition Syntax</a>.
339339

340-
<dl>
340+
<dl dfn-for="<basic-shape>">
341341
<dt><dfn>inset()</dfn> =
342342
inset( <<length-percentage>>{1,4} [ round <<'border-radius'>> ]? )
343343
</dt>
344344
<dd>
345-
Defines an inset rectangle.
346-
<ul>
347-
<li>
348-
When all of the first four arguments
349-
are supplied they represent the
350-
<strong>top, right, bottom</strong> and
351-
<strong>left</strong> offsets
352-
from the <a>reference box</a> inward
353-
that define the positions
354-
of the edges
355-
of the inset rectangle.
356-
These arguments follow the syntax
357-
of the 'margin' shorthand,
358-
that let you set all four insets
359-
with one, two or four values.
360-
</li>
361-
<li>
362-
The optional <<'border-radius'>> argument(s)
363-
define rounded corners for the inset rectangle
364-
using the 'border-radius' shorthand syntax.
365-
</li>
366-
</ul>
345+
Defines an inset rectangle
346+
via insets from each edge of the [=reference box=].
347+
348+
If less than four <<length-percentage>> values are provided,
349+
the omitted values default in the same way as the 'margin' shorthand:
350+
an omitted second or third value defaults to the first,
351+
and an omitted fourth value defaults to the second.
352+
353+
The four <<length-percentage>>s
354+
define the position of the top, right, bottom, and left edges of a rectangle,
355+
respectively,
356+
as insets from the corresponding edges of the [=reference box=].
367357

368358
A pair of insets in either dimension
369359
that add up to more than the used dimension
370360
(such as left and right insets of 75% apiece)
371361
use the [[css-backgrounds-3#corner-overlap]] rules
372-
to proportionally reduce the inset effect to 100%.
373-
This will result in a shape edge positioned
374-
within the reference box
375-
(at 50%, in the case of two 75% inset values).
362+
to proportionally reduce the inset effect to 100%.
363+
364+
<div class=example>
365+
For example, specifying ''inset(75% 0 50% 0)''
366+
has the top+bottom edges summing to 125%
367+
of the [=reference box's=] height.
368+
They're proportionaly reduced to sum to 100%,
369+
identical to specifying ''inset(60% 0 40% 0)''.
370+
</div>
371+
372+
The optional <<'border-radius'>> argument(s)
373+
define rounded corners for the rectangle
374+
using the 'border-radius' shorthand syntax.
375+
376+
<dt><dfn>xywh()</dfn> =
377+
xywh( <<length-percentage>>{2} <<length-percentage [0, ∞]>>{2} [ round <<'border-radius'>> ]? )
378+
<dd>
379+
Defines a rectangle
380+
via offsets from the top and left edge of the [=reference box=],
381+
and a specified width and height.
382+
383+
The four <<length-percentages>> define,
384+
respectively,
385+
the inset from the left edge of the [=reference box=],
386+
the inset from the top edge of the [=reference box=],
387+
the width of the rectangle,
388+
and the height of the rectangle.
389+
390+
Note: This syntax is inspired by the <{svg/viewBox}> attribute from SVG.
391+
392+
The optional <<'border-radius'>> argument(s)
393+
define rounded corners for the inset rectangle
394+
using the 'border-radius' shorthand syntax.
395+
396+
<dt><dfn>rect()</dfn> =
397+
rect( [ <<length-percentage>> | auto ]{4} [ round <<'border-radius'>> ]? )
398+
<dd>
399+
Defines a rectangle
400+
via insets from the top and left edges of the [=reference box=].
401+
402+
The four <<length-percentage>>s
403+
define the position of the top, right, bottom, and left edges of a rectangle,
404+
respectively,
405+
as insets from the top edge of the [=reference box=]
406+
(for the first and third values)
407+
or the left edge of the [=reference box=]
408+
(for the second and fourth values).
409+
410+
An <css>auto</css> value makes the edge of the box
411+
coincide with the corresponding edge of the [=reference box=]:
412+
it's equivalent to ''0%''
413+
as the first (top) or fourth (left) value,
414+
and equivalent to ''100%''
415+
as the second (right) or third (bottom) value.
416+
417+
The second (right) and third (bottom) values are floored
418+
by the fourth (left) and second (top) values, respectively.
419+
420+
<div class='example'>
421+
For example, specifying ''rect(10px 0 0 20px)''
422+
would place the bottom edge higher than the top edge,
423+
and the right edge further left than the left edge,
424+
so both are corrected to not cross over the other edge,
425+
identical to specifying ''rect(10px 20px 10px 20px)''.
426+
</div>
427+
428+
Note: This syntax is similar,
429+
but not quite identical,
430+
to the legacy ''rect()'' function
431+
used solely by the 'clip' property.
432+
433+
The optional <<'border-radius'>> argument(s)
434+
define rounded corners for the rectangle
435+
using the 'border-radius' shorthand syntax.)
376436

377-
</dd>
378437
<dt><dfn>circle()</dfn> =
379438
circle( <<shape-radius>>? [ at <<position>> ]? )
380439
</dt>
@@ -516,6 +575,13 @@ Supported Shapes</h3>
516575
</ul>
517576
</dl>
518577

578+
Additionally, the three rectangular shape functions
579+
are grouped into a production for convenience:
580+
581+
<pre class=prod>
582+
<dfn>&lt;basic-shape-rect></dfn> = <<inset()>> | <<rect()>> | <<xywh()>>
583+
</pre>
584+
519585
<h3 id='basic-shape-computed-values'>
520586
Computed Values of Basic Shapes</h3>
521587

@@ -529,7 +595,8 @@ Computed Values of Basic Shapes</h3>
529595
A <<position>> value in ''circle()'' or ''ellipse()'' is computed as a pair of offsets (horizontal then vertical) from the top left origin, each given as a <<length-percentage>>.
530596
</li>
531597
<li>
532-
A <<'border-radius'>> value in ''inset()'' is computed as an expanded list of all eight <<length-percentage>> values.
598+
A <<'border-radius'>> value in a <<basic-shape-rect>> function
599+
is computed as an expanded list of all eight <<length-percentage>> values.
533600
</li>
534601
</ul>
535602

0 commit comments

Comments
 (0)