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.
@@ -336,29 +336,168 @@ The 'border-radius' shorthand
336
336
See [[CSS3BG]].
337
337
338
338
339
-
Corner Shaping: the 'corner-shape' property
339
+
Corner Shaping
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 <> definition for details.
350
+
351
+
352
+
Rendering 'corner-shape'
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 #11610: 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
+
458
+
459
+
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
+
477
+
Interpolating corner shapes
478
+
479
+
Since a <> can always be expressed by a ''superellipse()'' with an [=superellipse exponent=] variable, interpolating between two
480
+
<>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 superellipse interpolation formula describes how a [=superellipse exponent=] is converted to a value between 0 and 1, and vice versa:
483
+
484
+
485
+
To interpolate a <> |exponent| to an interpolation value between 0 and 1:
486
+
1. If |exponent| is 0, return 0.
487
+
1. If |exponent| is ∞, return 1.
488
+
1. Return 1/(2^(1/|exponent|)).
489
+
490
+
To convert a <> |interpolationValue| back to a [=superellipse exponent=]:
491
+
1. If |interpolationValue| is 0, return 0.
492
+
1. If |interpolationValue| is 1, return ∞.
493
+
1. Return ln(0.5)/ln(|interpolationValue|).
494
+
495
+
496
+
Issue #11608: resolve on this or another interpolation formula.
497
+
498
+
499
+
500
+
362
501
363
502
364
503
For example, the following declarations create a right-pointing next button.
@@ -398,33 +537,6 @@ Corner Shaping: the 'corner-shape' property
398
537
How to allow custom corners? Perhaps a ''path()'' function? Or a ''cubic-bezier()''?
399
538
Something else?
400
539
401
-
402
-
Corner Shape and Size: the 'corners' shorthand
403
-
404
-
405
-
Name: corners
406
-
Value: <<'corner-shape'>> || <<'border-radius'>>
407
-
408
-
409
-
The 'corners' shorthand sets 'corner-shape' and 'border-radius' in the same declaration.
410
-
If either is omitted, it is reset to its initial value.
411
-
412
-
413
-
For example, the following declaration creates a diamond shape.
414
-
corners: angle 50%;
415
-
In UAs that don't support 'corner-shape', the declaration is ignored
416
-
(falls back to a rectangle).
417
-
418
-
419
-
420
-
In this example, the first declaration creates tabs with vertical sides and rounded corners using 'border-radius',
421
-
while the second example makes them trapezoid-shaped in UAs that support 'corners'.
0 commit comments