-
Notifications
You must be signed in to change notification settings - Fork 708
[css-borders-4] Resolve on range for superellipse
parameters
#11609
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
Comments
|
Actually, that makes me wonder if we need more detail on how the superellipse is computed, given a corner size (in pixels). It would be weird for a corner to appear sharp on a small box, but still slightly rounded on a large box because of how the math works out. We need math that is size-independent. |
This is addressed in the draft |
You mean when we describe it as bezier curves? For the cartesian equation this shouldn't matter. |
I strongly prefer the log2-scaled version of the superellipse parameter, so the symmetric inny and outy shapes use the same parameters, just negated; in general, it makes the "stuff poking out more than angle" and "stuff poking in more than angle" have the same value range and same value meaning, which is a lot easier to understand and use imo. It also happens to make the most significant values even simpler - 0, 1, 2, inf.
You get a (mathematically) sharp corner at infinity and -infinity (or infinity and 0, in the current spec). And that's stable regardless of box size. Any value short of those endpoints will produce a curve with some extremely high curvature, so at a sufficiently large border-radius it will indeed appear curved rather than sharp. |
Thanks! I tend to agree. |
@smfr with my proposed formula for interpolation applied on these values it would look like this:
The formula is intersecting the diagonal with the superellipse function, which resolves to this (given
|
An advantage for using the current spec'ed version (without |
The spec needs to say how to map the 0-1 range to a k value, so you need to describe the inverse of
And this is actually mapping I think the animation logic also needs to preserve symmetry by saying that if the fraction |
Sure, the spec currently specifies this for the regular k, it's not too difficult to add the log(2) bit. function s_for_v(v) {
const is_concave = v < 0.5;
const k = ln(0.5) / ln(is_concave ? 1 - v : v);
const s = Math.log2(k);
return is_concave ? -s : s;
}
Agreed about symmetry. |
The CSS Working Group just discussed
The full IRC log of that discussion<TabAtkins> noamr: this and the next issue will resolve togheter<TabAtkins> noamr: smfr and i have been working hard on the details for corner-shape. several questions to resolve <TabAtkins> noamr: one is about the superellipse paramter <TabAtkins> noamr: as you might recall, we have corner-shape keywords, but can also give it a number via a super-ellipse function <TabAtkins> noamr: in the spec righ tnow, the number gives the exponent of the curvature <TabAtkins> noamr: there was a proposal to use the log2 of that <TabAtkins> noamr: if i go all the way to concave, k=0, log2=-inf <TabAtkins> noamr: middle, bevel, k=1, log2=0 <TabAtkins> noamr: full sharp convex, k=inf, log=inf <TabAtkins> noamr: round, k=2, log2=1 <TabAtkins> noamr: squircle, k=4, log2=2 <TabAtkins> noamr: there's a table in the issue <TabAtkins> noamr: so the log2 version goes from -inf to inf, and maybe a bit more friendly <TabAtkins> noamr: k version goes 0-inf <astearns> https://noamr.github.io/squircle-testbed/corner-visualizer/corner-animation.html <TabAtkins> noamr: advantage of k version, when people talk about super-ellipses in other contexts they're usually talking just about the k version <TabAtkins> noamr: but i don't feel strongly about either <TabAtkins> q+ <astearns> ack TabAtkins <fantasai> TabAtkins: I do feel strongly that the log2 version is better here, because the shapes are symmetrical across the bevel <fantasai> TabAtkins: It also makes the range of useful values more reasonable. Going out to log2=10 makes it effectively a sharp corner, and the range past there is infinite <fantasai> TabAtkins: Same thing applies in negative direction. <fantasai> TabAtkins: This is easy to work with. <fantasai> TabAtkins: in the straight K version, sharp corner is a non-obvious fraction slightly above zero... <fantasai> TabAtkins: Symmetry really helps out with usability. Can put a note in the spec that k in academic papers is usually different, but for authors they won't care. We should prioritize usability for authors, and log2 variant gets us there <TabAtkins> fantasai: +1 <bramus> +1 <TabAtkins> noamr: literature could be Figma, for example <TabAtkins> noamr: author tooling can expose it too <Kurt> q+ <astearns> ack Kurt <TabAtkins> Kurt: does this mean specifcying infinity you need to use calc()? <TabAtkins> noamr: no, can just have an infinity keyword <TabAtkins> noamr: that's in the spec right now for positive infinity <TabAtkins> noamr: i think people are okay with this not aligning with other tools i'm okay with going with log2 <TabAtkins> s/think people/think if people/ <TabAtkins> astearns: so it sounds like proposed is to use log2 range? <TabAtkins> jensimmons: would like to know what smfr thinks? <TabAtkins> noamr: he's commented on the issues, he doesn't have a strong opinion <TabAtkins> q+ <fantasai> TabAtkins: There's an interpolation issue later on... <lea> weak agree for the log2 version from me too <fantasai> TabAtkins: Other reason I really like log2, when we do interpolation, making sure that works symmetrically requires doing log2 anyway <fantasai> TabAtkins: so exposing more directly to authors is a good thing <TabAtkins> noamr: yeah, the interpolation function si clsoe to log2 <TabAtkins> astearns: so it sounds like people are moderate to weakly in favor of log2 <TabAtkins> fantasai: i think tab's arguments are convincing to me <TabAtkins> astearns: so proposed reoslution is to use the log2 range <TabAtkins> RESOLVED: Use the log2 range for the superellipse parameter |
The number for the CSS exposed superellipse() function should be the log2(k) where k is the curvature exponent. Changed all the tests to take that into account. Applied the fix only in the CSS layer, where the value is converted to the curvature exponent when creating the ContouredRect for painting. See CSSWG resolution: w3c/csswg-drafts#11609 (comment) R=fs@opera.com Fixed: 407749391 Bug: 407749391 Change-Id: I0abb08eede485153782176c9e75888f82aae1727
The number for the CSS exposed superellipse() function should be the log2(k) where k is the curvature exponent. Changed all the tests to take that into account. Applied the fix only in the CSS layer, where the value is converted to the curvature exponent when creating the ContouredRect for painting. See CSSWG resolution: w3c/csswg-drafts#11609 (comment) R=fs@opera.com Fixed: 407749391 Bug: 407749391 Change-Id: I0abb08eede485153782176c9e75888f82aae1727 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6425306 Commit-Queue: Noam Rosenthal <nrosenthal@chromium.org> Reviewed-by: Fredrik Söderquist <fs@opera.com> Cr-Commit-Position: refs/heads/main@{#1442020}
The number for the CSS exposed superellipse() function should be the log2(k) where k is the curvature exponent. Changed all the tests to take that into account. Applied the fix only in the CSS layer, where the value is converted to the curvature exponent when creating the ContouredRect for painting. See CSSWG resolution: w3c/csswg-drafts#11609 (comment) R=fs@opera.com Fixed: 407749391 Bug: 407749391 Change-Id: I0abb08eede485153782176c9e75888f82aae1727 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6425306 Commit-Queue: Noam Rosenthal <nrosenthal@chromium.org> Reviewed-by: Fredrik Söderquist <fs@opera.com> Cr-Commit-Position: refs/heads/main@{#1442020}
The number for the CSS exposed superellipse() function should be the log2(k) where k is the curvature exponent. Changed all the tests to take that into account. Applied the fix only in the CSS layer, where the value is converted to the curvature exponent when creating the ContouredRect for painting. See CSSWG resolution: w3c/csswg-drafts#11609 (comment) R=fs@opera.com Fixed: 407749391 Bug: 407749391 Change-Id: I0abb08eede485153782176c9e75888f82aae1727 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6425306 Commit-Queue: Noam Rosenthal <nrosenthal@chromium.org> Reviewed-by: Fredrik Söderquist <fs@opera.com> Cr-Commit-Position: refs/heads/main@{#1442020}
…perellipse, a=testonly Automatic update from web-platform-tests corner-shape: use the log2 variant of superellipse The number for the CSS exposed superellipse() function should be the log2(k) where k is the curvature exponent. Changed all the tests to take that into account. Applied the fix only in the CSS layer, where the value is converted to the curvature exponent when creating the ContouredRect for painting. See CSSWG resolution: w3c/csswg-drafts#11609 (comment) R=fs@opera.com Fixed: 407749391 Bug: 407749391 Change-Id: I0abb08eede485153782176c9e75888f82aae1727 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6425306 Commit-Queue: Noam Rosenthal <nrosenthal@chromium.org> Reviewed-by: Fredrik Söderquist <fs@opera.com> Cr-Commit-Position: refs/heads/main@{#1442020} -- wpt-commits: ea49709e5880c8133249d919c72d67798afc31ec wpt-pr: 51823
…perellipse, a=testonly Automatic update from web-platform-tests corner-shape: use the log2 variant of superellipse The number for the CSS exposed superellipse() function should be the log2(k) where k is the curvature exponent. Changed all the tests to take that into account. Applied the fix only in the CSS layer, where the value is converted to the curvature exponent when creating the ContouredRect for painting. See CSSWG resolution: w3c/csswg-drafts#11609 (comment) R=fs@opera.com Fixed: 407749391 Bug: 407749391 Change-Id: I0abb08eede485153782176c9e75888f82aae1727 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6425306 Commit-Queue: Noam Rosenthal <nrosenthal@chromium.org> Reviewed-by: Fredrik Söderquist <fs@opera.com> Cr-Commit-Position: refs/heads/main@{#1442020} -- wpt-commits: ea49709e5880c8133249d919c72d67798afc31ec wpt-pr: 51823
…perellipse, a=testonly Automatic update from web-platform-tests corner-shape: use the log2 variant of superellipse The number for the CSS exposed superellipse() function should be the log2(k) where k is the curvature exponent. Changed all the tests to take that into account. Applied the fix only in the CSS layer, where the value is converted to the curvature exponent when creating the ContouredRect for painting. See CSSWG resolution: w3c/csswg-drafts#11609 (comment) R=fsopera.com Fixed: 407749391 Bug: 407749391 Change-Id: I0abb08eede485153782176c9e75888f82aae1727 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6425306 Commit-Queue: Noam Rosenthal <nrosenthalchromium.org> Reviewed-by: Fredrik Söderquist <fsopera.com> Cr-Commit-Position: refs/heads/main{#1442020} -- wpt-commits: ea49709e5880c8133249d919c72d67798afc31ec wpt-pr: 51823 UltraBlame original commit: b71898345a83581a976c59bff18b4182b7185f91
…perellipse, a=testonly Automatic update from web-platform-tests corner-shape: use the log2 variant of superellipse The number for the CSS exposed superellipse() function should be the log2(k) where k is the curvature exponent. Changed all the tests to take that into account. Applied the fix only in the CSS layer, where the value is converted to the curvature exponent when creating the ContouredRect for painting. See CSSWG resolution: w3c/csswg-drafts#11609 (comment) R=fs@opera.com Fixed: 407749391 Bug: 407749391 Change-Id: I0abb08eede485153782176c9e75888f82aae1727 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6425306 Commit-Queue: Noam Rosenthal <nrosenthal@chromium.org> Reviewed-by: Fredrik Söderquist <fs@opera.com> Cr-Commit-Position: refs/heads/main@{#1442020} -- wpt-commits: ea49709e5880c8133249d919c72d67798afc31ec wpt-pr: 51823
…perellipse, a=testonly Automatic update from web-platform-tests corner-shape: use the log2 variant of superellipse The number for the CSS exposed superellipse() function should be the log2(k) where k is the curvature exponent. Changed all the tests to take that into account. Applied the fix only in the CSS layer, where the value is converted to the curvature exponent when creating the ContouredRect for painting. See CSSWG resolution: w3c/csswg-drafts#11609 (comment) R=fsopera.com Fixed: 407749391 Bug: 407749391 Change-Id: I0abb08eede485153782176c9e75888f82aae1727 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6425306 Commit-Queue: Noam Rosenthal <nrosenthalchromium.org> Reviewed-by: Fredrik Söderquist <fsopera.com> Cr-Commit-Position: refs/heads/main{#1442020} -- wpt-commits: ea49709e5880c8133249d919c72d67798afc31ec wpt-pr: 51823 UltraBlame original commit: b71898345a83581a976c59bff18b4182b7185f91
…perellipse, a=testonly Automatic update from web-platform-tests corner-shape: use the log2 variant of superellipse The number for the CSS exposed superellipse() function should be the log2(k) where k is the curvature exponent. Changed all the tests to take that into account. Applied the fix only in the CSS layer, where the value is converted to the curvature exponent when creating the ContouredRect for painting. See CSSWG resolution: w3c/csswg-drafts#11609 (comment) R=fsopera.com Fixed: 407749391 Bug: 407749391 Change-Id: I0abb08eede485153782176c9e75888f82aae1727 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6425306 Commit-Queue: Noam Rosenthal <nrosenthalchromium.org> Reviewed-by: Fredrik Söderquist <fsopera.com> Cr-Commit-Position: refs/heads/main{#1442020} -- wpt-commits: ea49709e5880c8133249d919c72d67798afc31ec wpt-pr: 51823 UltraBlame original commit: b71898345a83581a976c59bff18b4182b7185f91
…perellipse, a=testonly Automatic update from web-platform-tests corner-shape: use the log2 variant of superellipse The number for the CSS exposed superellipse() function should be the log2(k) where k is the curvature exponent. Changed all the tests to take that into account. Applied the fix only in the CSS layer, where the value is converted to the curvature exponent when creating the ContouredRect for painting. See CSSWG resolution: w3c/csswg-drafts#11609 (comment) R=fs@opera.com Fixed: 407749391 Bug: 407749391 Change-Id: I0abb08eede485153782176c9e75888f82aae1727 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6425306 Commit-Queue: Noam Rosenthal <nrosenthal@chromium.org> Reviewed-by: Fredrik Söderquist <fs@opera.com> Cr-Commit-Position: refs/heads/main@{#1442020} -- wpt-commits: ea49709e5880c8133249d919c72d67798afc31ec wpt-pr: 51823
Follow up on #10993
The initial draft for
corner-shape
andsuperellipse
uses the following parameters:We can also use the
log2
version of this:notch -> -inf
scoop -> -1
bevel -> 0
round -> 1
squircle -> 2
straight -> inf
This would have an effect on the formula in #11608 as well.
The text was updated successfully, but these errors were encountered: