Skip to content

[css-borders-4] Interpolation of corner-shape superellipsis #11608

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
noamr opened this issue Jan 30, 2025 · 2 comments · Fixed by #12033
Closed

[css-borders-4] Interpolation of corner-shape superellipsis #11608

noamr opened this issue Jan 30, 2025 · 2 comments · Fixed by #12033

Comments

@noamr
Copy link
Collaborator

noamr commented Jan 30, 2025

Follow up on #10993

We are defining corner-shape as different variations on superellipse(exponent), which allows us to animate the exponent.
However, animating the exponent linearly would result in varying velocity - high velocity when concave, and low velocity when convex.
The visual result would be, for example, that a linear animation between notch and straight would start very fast and would seem like it's slowing down towards straight.

Proposing to use the following formula (also used in the draft) to balance this: intersect the superellipse with the given k, with a diagonal straight line that slices the corner. This would make it so that a "linear" animation would be linear from the point of view of the center of the curve.

The formula looks like this (k is the exponent):

// superellipse formula
y=(1 - x^k))^(1 / k)

// straight diagonal line formula
y=x

// combining them together
x=(1 - x^k))^(1 / k)

// solving for k
1 / (2^(1 / k))

This formula conveniently maps a k between 0 and infinity to a number between 0 and 1, and we can decide that 0 always maps for 0 and infinity also maps to 1.

@noamr noamr changed the title [css-borders-4] Interpolation of `corner-shape exponent [css-borders-4] Interpolation of corner-shape superellipsis Jan 30, 2025
@astearns astearns moved this to FTF agenda items in CSSWG April 2025 meeting agenda Mar 24, 2025
@astearns astearns moved this from FTF agenda items to Tuesday Morning in CSSWG April 2025 meeting agenda Mar 27, 2025
smfr added a commit to smfr/squircle-testbed that referenced this issue Mar 30, 2025
According to something like w3c/csswg-drafts#11608
@smfr
Copy link
Contributor

smfr commented Mar 31, 2025

Visualization using the above (with some tweaks):
https://noamr.github.io/squircle-testbed/corner-visualizer/corner-animation.html

@css-meeting-bot
Copy link
Member

The CSS Working Group just discussed [css-borders-4] Interpolation of `corner-shape` superellipsis, and agreed to the following:

  • RESOLVED: interpolate linearly across the corner diagonal and compute the parameter backwards from that
The full IRC log of that discussion <TabAtkins> noamr: this shoudln't be contentious
<TabAtkins> noamr: let me show how it interpolates
<TabAtkins> noamr: the interpolation takes the "half corner", th emiddle point, put it on the diagonal line and interpolate *that*. work backwards to get the superellipse parameter
<TabAtkins> noamr: otherwise any interpolation in the paramter space itself would spend too much time in the extreme values
<fantasai> TabAtkins: This does sound like the most reasonable interpolation method
<TabAtkins> astearns: any indication from Simon?
<TabAtkins> noamr: he did this visualization.
<TabAtkins> noamr: everything i'm presenting here I worked together with Simon
<TabAtkins> ack
<astearns> ack TabAtkins
<TabAtkins> fantasai: TAb, you mentioned the "effectively square" is 10 or so on both sides
<TabAtkins> fantasai: above 10
<TabAtkins> fantasai: it basically doesn't do much?
<TabAtkins> noamr: it's basically equivlanent unless your screen is enormous
<TabAtkins> fantasai: should we declare that 10 gets rounded to a sharp corner?
<TabAtkins> fantasai: so the CSS range is effectively -10 to 10?
<TabAtkins> astearns: if your shape is very large you might get a jump
<TabAtkins> noamr: shouldn't have it as part of interpolation
<TabAtkins> noamr: the animation would appear to be faster in the middle if we did that
<TabAtkins> noamr: in the current chrome prototype we *do* clamp to 10/-10, it makes the math easier
<TabAtkins> noamr: but not sure it's useful in the specs
<TabAtkins> fantasai: the reason it might be useful is, it's harder for the authro to know that to get an actually sharp corner they need to use a much bigger value
<fantasai> TabAtkins: The interpolation behavior defined here is that we don't interpolate the parameter, we interpolate the diagonal line.
<fantasai> TabAtkins: so you get a linear interpolation through the diagonal space
<fantasai> TabAtkins: so you get a visually smooth value instead of changing speed
<fantasai> fantasai: Would it make sense to make that the parameter?
<fantasai> TabAtkins: No, because then squircles and other common values would be weird numbers.
<TabAtkins> noamr: yeah, round is sqrt(2)/2
<TabAtkins> astearns: any other comments/question?
<TabAtkins> astearns: so proposed is we interpolate linearly across the corner diagonal and compute the parameter backwards from that
<TabAtkins> astearns: objection?
<TabAtkins> RESOLVED: interpolate linearly across the corner diagonal and compute the parameter backwards from that

noamr added a commit to noamr/csswg-drafts that referenced this issue Apr 1, 2025
- Use `square` instead of `straight`
- Use the log2 version for the `superellipse()` parameter
- Interpolate symetrically from the middle.

Closes w3c#11607
Closes w3c#11608
Closes w3c#11609
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Apr 3, 2025
Interpolate superellipse values as per CSSWG resolution:
w3c/csswg-drafts#11608 (comment)

The values are converted to a linear range by converting
the superellipse to its half corner's X, which interpolates
on a diagonal line across the corner.

The simplified formula
(see w3c/csswg-drafts#12033) is
0.5^(0.5^(param)), and adjusted to be symmetrical for
convex/concave.

Implemented all of this in CSSSuperellipseInterpolationType,
and added an appropriate corner-shape-interpolation test.

R=fs@opera.com
CC=​pdr@chromium.org

Bug: 3940596
Change-Id: I552ace6cce40b5e41afd300df1ddcb4d2082c7a2
Fixed: 3940596
aarongable pushed a commit to chromium/chromium that referenced this issue Apr 3, 2025
Interpolate superellipse values as per CSSWG resolution:
w3c/csswg-drafts#11608 (comment)

The values are converted to a linear range by converting
the superellipse to its half corner's X, which interpolates
on a diagonal line across the corner.

The simplified formula
(see w3c/csswg-drafts#12033) is
0.5^(0.5^(param)), and adjusted to be symmetrical for
convex/concave.

Implemented all of this in CSSSuperellipseInterpolationType,
and added an appropriate corner-shape-interpolation test.

R=fs@opera.com
CC=​pdr@chromium.org

Bug: 394059605
Change-Id: I552ace6cce40b5e41afd300df1ddcb4d2082c7a2
Fixed: 394059605
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6425902
Commit-Queue: Noam Rosenthal <nrosenthal@chromium.org>
Reviewed-by: Fredrik Söderquist <fs@opera.com>
Cr-Commit-Position: refs/heads/main@{#1442117}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Apr 3, 2025
Interpolate superellipse values as per CSSWG resolution:
w3c/csswg-drafts#11608 (comment)

The values are converted to a linear range by converting
the superellipse to its half corner's X, which interpolates
on a diagonal line across the corner.

The simplified formula
(see w3c/csswg-drafts#12033) is
0.5^(0.5^(param)), and adjusted to be symmetrical for
convex/concave.

Implemented all of this in CSSSuperellipseInterpolationType,
and added an appropriate corner-shape-interpolation test.

R=fs@opera.com
CC=​pdr@chromium.org

Bug: 3940596
Change-Id: I552ace6cce40b5e41afd300df1ddcb4d2082c7a2
Fixed: 3940596
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6425902
Commit-Queue: Noam Rosenthal <nrosenthal@chromium.org>
Reviewed-by: Fredrik Söderquist <fs@opera.com>
Cr-Commit-Position: refs/heads/main@{#1442117}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Apr 3, 2025
Interpolate superellipse values as per CSSWG resolution:
w3c/csswg-drafts#11608 (comment)

The values are converted to a linear range by converting
the superellipse to its half corner's X, which interpolates
on a diagonal line across the corner.

The simplified formula
(see w3c/csswg-drafts#12033) is
0.5^(0.5^(param)), and adjusted to be symmetrical for
convex/concave.

Implemented all of this in CSSSuperellipseInterpolationType,
and added an appropriate corner-shape-interpolation test.

R=fs@opera.com
CC=​pdr@chromium.org

Bug: 3940596
Change-Id: I552ace6cce40b5e41afd300df1ddcb4d2082c7a2
Fixed: 3940596
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6425902
Commit-Queue: Noam Rosenthal <nrosenthal@chromium.org>
Reviewed-by: Fredrik Söderquist <fs@opera.com>
Cr-Commit-Position: refs/heads/main@{#1442117}
ChunMinChang pushed a commit to ChunMinChang/gecko-dev that referenced this issue Apr 7, 2025
Automatic update from web-platform-tests
Corner-shape: interpolation

Interpolate superellipse values as per CSSWG resolution:
w3c/csswg-drafts#11608 (comment)

The values are converted to a linear range by converting
the superellipse to its half corner's X, which interpolates
on a diagonal line across the corner.

The simplified formula
(see w3c/csswg-drafts#12033) is
0.5^(0.5^(param)), and adjusted to be symmetrical for
convex/concave.

Implemented all of this in CSSSuperellipseInterpolationType,
and added an appropriate corner-shape-interpolation test.

R=fs@opera.com
CC=​pdr@chromium.org

Bug: 394059605
Change-Id: I552ace6cce40b5e41afd300df1ddcb4d2082c7a2
Fixed: 394059605
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6425902
Commit-Queue: Noam Rosenthal <nrosenthal@chromium.org>
Reviewed-by: Fredrik Söderquist <fs@opera.com>
Cr-Commit-Position: refs/heads/main@{#1442117}

--

wpt-commits: 90fcc6fd8576c63aa20e9e63ebc840ad61d27b48
wpt-pr: 51829
i3roly pushed a commit to i3roly/firefox-dynasty that referenced this issue Apr 8, 2025
Automatic update from web-platform-tests
Corner-shape: interpolation

Interpolate superellipse values as per CSSWG resolution:
w3c/csswg-drafts#11608 (comment)

The values are converted to a linear range by converting
the superellipse to its half corner's X, which interpolates
on a diagonal line across the corner.

The simplified formula
(see w3c/csswg-drafts#12033) is
0.5^(0.5^(param)), and adjusted to be symmetrical for
convex/concave.

Implemented all of this in CSSSuperellipseInterpolationType,
and added an appropriate corner-shape-interpolation test.

R=fs@opera.com
CC=​pdr@chromium.org

Bug: 394059605
Change-Id: I552ace6cce40b5e41afd300df1ddcb4d2082c7a2
Fixed: 394059605
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6425902
Commit-Queue: Noam Rosenthal <nrosenthal@chromium.org>
Reviewed-by: Fredrik Söderquist <fs@opera.com>
Cr-Commit-Position: refs/heads/main@{#1442117}

--

wpt-commits: 90fcc6fd8576c63aa20e9e63ebc840ad61d27b48
wpt-pr: 51829
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this issue Apr 8, 2025
Automatic update from web-platform-tests
Corner-shape: interpolation

Interpolate superellipse values as per CSSWG resolution:
w3c/csswg-drafts#11608 (comment)

The values are converted to a linear range by converting
the superellipse to its half corner's X, which interpolates
on a diagonal line across the corner.

The simplified formula
(see w3c/csswg-drafts#12033) is
0.5^(0.5^(param)), and adjusted to be symmetrical for
convex/concave.

Implemented all of this in CSSSuperellipseInterpolationType,
and added an appropriate corner-shape-interpolation test.

R=fsopera.com
CC=​pdrchromium.org

Bug: 394059605
Change-Id: I552ace6cce40b5e41afd300df1ddcb4d2082c7a2
Fixed: 394059605
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6425902
Commit-Queue: Noam Rosenthal <nrosenthalchromium.org>
Reviewed-by: Fredrik Söderquist <fsopera.com>
Cr-Commit-Position: refs/heads/main{#1442117}

--

wpt-commits: 90fcc6fd8576c63aa20e9e63ebc840ad61d27b48
wpt-pr: 51829

UltraBlame original commit: 87d46cad4a23d8628bdf2e9ae278a8f657553c62
globau pushed a commit to globau/firefox-test that referenced this issue Apr 8, 2025
Automatic update from web-platform-tests
Corner-shape: interpolation

Interpolate superellipse values as per CSSWG resolution:
w3c/csswg-drafts#11608 (comment)

The values are converted to a linear range by converting
the superellipse to its half corner's X, which interpolates
on a diagonal line across the corner.

The simplified formula
(see w3c/csswg-drafts#12033) is
0.5^(0.5^(param)), and adjusted to be symmetrical for
convex/concave.

Implemented all of this in CSSSuperellipseInterpolationType,
and added an appropriate corner-shape-interpolation test.

R=fs@opera.com
CC=​pdr@chromium.org

Bug: 394059605
Change-Id: I552ace6cce40b5e41afd300df1ddcb4d2082c7a2
Fixed: 394059605
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6425902
Commit-Queue: Noam Rosenthal <nrosenthal@chromium.org>
Reviewed-by: Fredrik Söderquist <fs@opera.com>
Cr-Commit-Position: refs/heads/main@{#1442117}

--

wpt-commits: 90fcc6fd8576c63aa20e9e63ebc840ad61d27b48
wpt-pr: 51829
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this issue Apr 8, 2025
Automatic update from web-platform-tests
Corner-shape: interpolation

Interpolate superellipse values as per CSSWG resolution:
w3c/csswg-drafts#11608 (comment)

The values are converted to a linear range by converting
the superellipse to its half corner's X, which interpolates
on a diagonal line across the corner.

The simplified formula
(see w3c/csswg-drafts#12033) is
0.5^(0.5^(param)), and adjusted to be symmetrical for
convex/concave.

Implemented all of this in CSSSuperellipseInterpolationType,
and added an appropriate corner-shape-interpolation test.

R=fsopera.com
CC=​pdrchromium.org

Bug: 394059605
Change-Id: I552ace6cce40b5e41afd300df1ddcb4d2082c7a2
Fixed: 394059605
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6425902
Commit-Queue: Noam Rosenthal <nrosenthalchromium.org>
Reviewed-by: Fredrik Söderquist <fsopera.com>
Cr-Commit-Position: refs/heads/main{#1442117}

--

wpt-commits: 90fcc6fd8576c63aa20e9e63ebc840ad61d27b48
wpt-pr: 51829

UltraBlame original commit: 87d46cad4a23d8628bdf2e9ae278a8f657553c62
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this issue Apr 8, 2025
Automatic update from web-platform-tests
Corner-shape: interpolation

Interpolate superellipse values as per CSSWG resolution:
w3c/csswg-drafts#11608 (comment)

The values are converted to a linear range by converting
the superellipse to its half corner's X, which interpolates
on a diagonal line across the corner.

The simplified formula
(see w3c/csswg-drafts#12033) is
0.5^(0.5^(param)), and adjusted to be symmetrical for
convex/concave.

Implemented all of this in CSSSuperellipseInterpolationType,
and added an appropriate corner-shape-interpolation test.

R=fsopera.com
CC=​pdrchromium.org

Bug: 394059605
Change-Id: I552ace6cce40b5e41afd300df1ddcb4d2082c7a2
Fixed: 394059605
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6425902
Commit-Queue: Noam Rosenthal <nrosenthalchromium.org>
Reviewed-by: Fredrik Söderquist <fsopera.com>
Cr-Commit-Position: refs/heads/main{#1442117}

--

wpt-commits: 90fcc6fd8576c63aa20e9e63ebc840ad61d27b48
wpt-pr: 51829

UltraBlame original commit: 87d46cad4a23d8628bdf2e9ae278a8f657553c62
jamienicol pushed a commit to jamienicol/gecko that referenced this issue Apr 9, 2025
Automatic update from web-platform-tests
Corner-shape: interpolation

Interpolate superellipse values as per CSSWG resolution:
w3c/csswg-drafts#11608 (comment)

The values are converted to a linear range by converting
the superellipse to its half corner's X, which interpolates
on a diagonal line across the corner.

The simplified formula
(see w3c/csswg-drafts#12033) is
0.5^(0.5^(param)), and adjusted to be symmetrical for
convex/concave.

Implemented all of this in CSSSuperellipseInterpolationType,
and added an appropriate corner-shape-interpolation test.

R=fs@opera.com
CC=​pdr@chromium.org

Bug: 394059605
Change-Id: I552ace6cce40b5e41afd300df1ddcb4d2082c7a2
Fixed: 394059605
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6425902
Commit-Queue: Noam Rosenthal <nrosenthal@chromium.org>
Reviewed-by: Fredrik Söderquist <fs@opera.com>
Cr-Commit-Position: refs/heads/main@{#1442117}

--

wpt-commits: 90fcc6fd8576c63aa20e9e63ebc840ad61d27b48
wpt-pr: 51829
@noamr noamr closed this as completed in 61108aa May 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Tuesday Morning
Development

Successfully merging a pull request may close this issue.

3 participants