You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[css-borders-4] Specify corner-shape based on superellipse (#11606)
* [css-borders-4] Specify `corner-shape` based on superellipse
This specifies the `corner-shape` group, including:
- general description and interaction with border-radius
- all the individual corners, side shorthands, and overall shorthand
- multiple keywords, and how they translate to a `superellipse()`
- The superellipse formula, and how it is rendered
- How the exponent of the superellipse interpolates
Open issues (will open separately):
- Add a few examples
- Resolve on "straight" vs "none" for the convex angle.
- Resolve on the exact interpolation formula
- Define restrictions for border rendering
Closes#10993
Based on resolution #10993 (comment)
Co-authored-by: Tab Atkins Jr. <[email protected]>
Copy file name to clipboardExpand all lines: css-borders-4/Overview.bs
+155-43
Original file line number
Diff line number
Diff line change
@@ -336,29 +336,168 @@ The 'border-radius' shorthand</h4>
336
336
See [[CSS3BG]].
337
337
338
338
<h3 id=corner-shaping>
339
-
Corner Shaping: the 'corner-shape' property</h3>
339
+
Corner Shaping</h3>
340
+
341
+
By default, non-zero border-radii define a quarter-ellipse that rounds the affected corners.
342
+
However in some cases, other corner shapes are desired.
343
+
The 'corner-shape' property group specifies a reinterpretation of the radii to define other corner shapes.
344
+
345
+
The different shapes applicable to 'corner-shape' can be expressed as different parameters to a superellipse.
346
+
A superellipse is a closed curve resembling an ellipse, and based on its `k` parameter can express all the shapes between a square, an ellipse, and a notch.
347
+
348
+
To allow full expression as well as interpolation, the 'corner-shape' properties can provide its own superellipse parameter using the 'superellipse()' function,
349
+
or use one of the supplied keywords which represent commonly used parameters. See the <<corner-shape-value>> definition for details.
350
+
351
+
<h4 id=corner-shape-rendering>
352
+
Rendering 'corner-shape'</h4>
353
+
'corner-shape' works alongside 'border-radius', and does not have any visual effect with a 'border-radius' of 0.
354
+
It acts as an alteration on top of the default round 'border-radius', and thus can be used as progressive enhancement.
355
+
356
+
Like 'border-radius', 'corner-shape' clips elements according to the [=overflow=] rules, and applies to the rendering of the border.
357
+
Since stroking a superellipse accurately may be computationally intensive, user agents may approximate the path using bezier curves,
358
+
as well as account for sharp edges and overlaps.
359
+
360
+
Issue: 'border-radius' already handles *adjacent* corners overlapping by shrinking the radiuses proportionally.
361
+
A negative ''superellipse()'' parameter allows for *opposite* corners to sometimes overlap, and needs additional restrictions defined.
362
+
363
+
Issue <a href="https://github.com/w3c/csswg-drafts/issues/11610">#11610</a>: check if we need additional rendering restrictions.
Applies to: all elements where 'border-radius' can apply
454
+
Inherited: no
455
+
Computed value: see individual properties
456
+
Animation type: see individual properties
457
+
</pre>
458
+
459
+
<p>The 'corner-*-shape' shorthands set the two 'corner-*-*-shape'
460
+
longhand properties of the related side. If values are given before
461
+
and after the slash, then the values before the slash set the
462
+
horizontal radius and the values after the slash set the vertical radius.
463
+
If there is no slash, then the values set both radii equally.
464
+
The two values for the radii are given in the order
465
+
top-left, top-right for 'corner-top-shape',
466
+
top-right, bottom-right for 'corner-right-shape',
467
+
bottom-left, bottom-right for 'corner-bottom-shape',
468
+
top-left, bottom-left for 'corner-left-shape',
469
+
start-start, start-end for 'corner-block-start-shape',
470
+
end-start, end-end for 'corner-block-end-shape'
471
+
start-start, end-start for 'corner-inline-start-shape',
472
+
and start-end, end-end for 'corner-inline-end-shape'.
473
+
If the second value is omitted it is copied from the first.
474
+
475
+
476
+
<h4 id=corner-shape-interpolation>
477
+
Interpolating corner shapes</h4>
478
+
479
+
Since a <<corner-shape-value>> can always be expressed by a ''superellipse()'' with an [=superellipse exponent=] variable, interpolating between two
480
+
<<corner-shape-value>>s is done by interpolating the [=superellipse exponent=] itself.
481
+
Since it's an exponent, interpolating it linearly would result in an effect where concave corners interpolate at a much higher velocity than convex corners.
482
+
To balance that, the <dfn>superellipse interpolation</dfn> formula describes how a [=superellipse exponent=] is converted to a value between 0 and 1, and vice versa:
0 commit comments