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] Apply corner-shape syntax resolutions
- Use `square` instead of `straight`
- Use the log2 version for the `superellipse()` parameter
- Interpolate symetrically from the middle.
Closes#11607Closes#11608Closes#11609
* Remove cruft
* Fix math
* small fix
* small fix
* nits
* add note about symmetry
* Add some example for rendering
* Add figure
* Update css-borders-4/Overview.bs
* nits
---------
Co-authored-by: Tab Atkins Jr. <jackalmage@gmail.com>
Border radii define a convex elliptical curve at the corner. Equivalent to <css>superellipse(2)</css>.
377
+
Border radii define a convex elliptical curve at the corner. Equivalent to <css>superellipse(1)</css>.
377
378
378
379
Note: this is the initial value of 'corner-shape' properties, as elements with 'border-radius' would be rounded.
379
380
380
381
<dt><dfn>scoop</dfn>
381
-
<dd>Border radii define a concave elliptical curve at the corner. Equivalent to <css>superellipse(0.5)</css>.
382
+
<dd>Border radii define a concave elliptical curve at the corner. Equivalent to <css>superellipse(-1)</css>.
382
383
<dt><dfn>bevel</dfn>
383
-
<dd>Border radii define a diagonal slice at the corner. Equivalent to <css>superellipse(1)</css>.
384
+
<dd>Border radii define a diagonal slice at the corner. Equivalent to <css>superellipse(0)</css>.
384
385
<dt><dfn>notch</dfn>
385
-
<dd>Border radii define a concave 90deg angle at the corner. Equivalent to <css>superellipse(0)</css>.
386
-
<dt><dfn>straight</dfn>
386
+
<dd>Border radii define a concave 90deg angle at the corner. Equivalent to <css>superellipse(-infinity)</css>.
387
+
<dt><dfn>square</dfn>
387
388
<dd>Border radii define a convex 90deg angle at the corner.
388
389
This would have the same visual effect as a 'border-radius' of 0. This is different from having a 'border-radius' of 0 when animating.
389
390
Equivalent to <css>superellipse(infinity)</css>.
390
391
<dt><dfn>squircle</dfn>
391
-
<dd>Border radii define a convex curve between an ellipse and an convex angle, equivalent to <css>superellipse(4)</css>.
392
+
<dd>Border radii define a convex curve between an ellipse and an convex angle, equivalent to <css>superellipse(2)</css>.
392
393
</dl>
393
394
394
-
Issue <a href="https://github.com/w3c/csswg-drafts/issues/11607">#11607</a>: resolve on ''straight'' vs <css>none</css>.
395
+
The <dfn>superellipse( <<number>> | infinity | -infinity )</dfn> function describes the <dfn>superellipse parameter</dfn> of the corner.
396
+
It is a number between <css>-infinity</css> and <css>infinity</css>, with <css>-infinity</css> corresponding to a straight concave corner,
397
+
<css>infinity</css> corresponding to a square convex corner.
395
398
396
-
The <dfn>superellipse( <<number>> | infinity )</dfn> function describes the curvature of the corner.
397
-
It accepts a <dfn>superellipse exponent</dfn>, which defines the curvature of the corner, or the exponent of the formula.
398
-
The [=superellipse exponent=] accepts values between 0 (a straight concave angle) and <css>infinity</css> (a straight convex angle),
399
-
with the values in between representing the curvatures in between.
400
-
401
-
The ''superellipse()'' formula can be described in cartesian coordinates, as follows,
402
-
where <code>a</code> is the horizontal ''border-radius''
403
-
<code>b</code> is the vertical ''border-radius'', and <code>k</code> is the [=superellipse exponent=]:
399
+
The <dfn>canonical superellipse formula</dfn> can be described in Cartesian coordinates, as follows,
400
+
where <code>s</code> is the [=superellipse parameter=]:
404
401
405
402
<pre>
406
-
|x/a|^k + |y/b|^k = 1
403
+
k = 2<sup>abs(|s|)</sup>
404
+
x<sup>k</sup> + y<sup>k</sup> = 1
407
405
</pre>
408
406
407
+
The resulting |x| and |y| are later projected to CSS coordinates by scaling based on the 'border-radius' properties,
408
+
inversed if the [=superellipse parameter=] is negative. This creates symmetry between convex and concave shapes of the same absolute
409
+
[=superellipse parameter=].
410
+
411
+
<aside class=example>
412
+
The ''<self-position>/start'' and ''<self-position>/end'' keywords
413
+
are <a>flow-relative</a>:
414
+
they use the <a>writing mode</a> to determine which side to align to.
415
+
416
+
<figure>
417
+
<img src="images/superellipse-param.svg"
418
+
width="320" height="240"
419
+
style="background: white; padding: 8px;"
420
+
title="rendering of different superellipse parameter values"
421
+
alt="Rendering of different superellipse parameter values.">
422
+
<figcaption>
423
+
Rendering examples of different ''superellipse()'' values.
424
+
</figcaption>
425
+
</figure>
426
+
</aside>
427
+
428
+
429
+
<img src="images/superellipse-param.svg" alt="A diagram showing how superellipse values translate to curvature">
430
+
431
+
432
+
409
433
<h4 id=corner-shape-shorthand>
410
434
Corner Shaping: the 'corner-shape' and 'corner-*-shape' properties</h4>
411
435
@@ -474,66 +498,52 @@ Corner Shaping: the 'corner-shape' and 'corner-*-shape' properties</h4>
474
498
<h4 id=corner-shape-interpolation>
475
499
Interpolating corner shapes</h4>
476
500
477
-
Since a <<corner-shape-value>> can always be expressed by a ''superellipse()'' with an [=superellipse exponent=] variable, interpolating between two
478
-
<<corner-shape-value>>s is done by interpolating the [=superellipse exponent=] itself.
479
-
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.
480
-
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:
Since a <<corner-shape-value>> can always be expressed by a ''superellipse()'' with an [=superellipse parameter=] variable, interpolating between two
502
+
<<corner-shape-value>>s is done by interpolating the [=superellipse parameter=] itself.
503
+
Since it uses a <code>log2</code>, interpolating it linearly would result in an effect where concave corners interpolate at a much higher velocity than convex corners.
504
+
To balance that, the <dfn>superellipse interpolation</dfn> formula describes how a [=superellipse parameter=] is converted to a value between 0 and 1, and vice versa:
493
505
494
-
<a href="https://github.com/w3c/csswg-drafts/issues/11608">Issue #11608</a>: resolve on this or another interpolation formula.
0 commit comments