Skip to content
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

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

Open
noamr opened this issue Jan 30, 2025 · 0 comments
Open

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

noamr opened this issue Jan 30, 2025 · 0 comments

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant