-
Notifications
You must be signed in to change notification settings - Fork 702
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] Specify how borders are rendered for corner-shape
#11610
Comments
corner-shape
for rendering edge casescorner-shape
This sets the infrastructure for rendering corner-shape, by storing 4-float "CornerCurvature" on a FloatRoundedRect. Currently only the special-case for "bevel" is handled, with the idea of iterating on the different aspects of rendering as we go along. To properly render bevel (and any other curvature that's lower than round), drawing a straight line from the outer/inner sides doesn't create the right effect, because the diagonal distance between those lines doesn't match the border width. To correct that, while maintaining rendering within the initial corners, the outer corner is shrunk to the point where the resulting diagonal quad has a width equal to the border-width (or interpolating between two border-widths). See open spec issue: w3c/csswg-drafts#11610 Removed existing hand-coded SVG tests, and generating the refs using a canvas polyfill instead. This polyfill can be amended later on as we polish the spec. Bug: 394059604 Change-Id: I9fb76dd7dc557ed10c40adecbb9f68f672de1acc Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6250197 Reviewed-by: Philip Rogers <[email protected]> Commit-Queue: Noam Rosenthal <[email protected]> Reviewed-by: Fredrik Söderquist <[email protected]> Cr-Commit-Position: refs/heads/main@{#1421457}
This sets the infrastructure for rendering corner-shape, by storing 4-float "CornerCurvature" on a FloatRoundedRect. Currently only the special-case for "bevel" is handled, with the idea of iterating on the different aspects of rendering as we go along. To properly render bevel (and any other curvature that's lower than round), drawing a straight line from the outer/inner sides doesn't create the right effect, because the diagonal distance between those lines doesn't match the border width. To correct that, while maintaining rendering within the initial corners, the outer corner is shrunk to the point where the resulting diagonal quad has a width equal to the border-width (or interpolating between two border-widths). See open spec issue: w3c/csswg-drafts#11610 Removed existing hand-coded SVG tests, and generating the refs using a canvas polyfill instead. This polyfill can be amended later on as we polish the spec. Bug: 394059604 Change-Id: I9fb76dd7dc557ed10c40adecbb9f68f672de1acc Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6250197 Reviewed-by: Philip Rogers <[email protected]> Commit-Queue: Noam Rosenthal <[email protected]> Reviewed-by: Fredrik Söderquist <[email protected]> Cr-Commit-Position: refs/heads/main@{#1421457}
This sets the infrastructure for rendering corner-shape, by storing 4-float "CornerCurvature" on a FloatRoundedRect. Currently only the special-case for "bevel" is handled, with the idea of iterating on the different aspects of rendering as we go along. To properly render bevel (and any other curvature that's lower than round), drawing a straight line from the outer/inner sides doesn't create the right effect, because the diagonal distance between those lines doesn't match the border width. To correct that, while maintaining rendering within the initial corners, the outer corner is shrunk to the point where the resulting diagonal quad has a width equal to the border-width (or interpolating between two border-widths). See open spec issue: w3c/csswg-drafts#11610 Removed existing hand-coded SVG tests, and generating the refs using a canvas polyfill instead. This polyfill can be amended later on as we polish the spec. Bug: 394059604 Change-Id: I9fb76dd7dc557ed10c40adecbb9f68f672de1acc Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6250197 Reviewed-by: Philip Rogers <[email protected]> Commit-Queue: Noam Rosenthal <[email protected]> Reviewed-by: Fredrik Söderquist <[email protected]> Cr-Commit-Position: refs/heads/main@{#1421457}
I created a codepen that renders Basically, to achieve the effect where the thickness of the border is equal to the relevant This becomes very apparent with And also with Or scoop: In the prototype, the outer radius is reduced in a number that's a function of the corresponding border and the curvature. (It still looks a bit off at around scoop though, so we're not done with the formula) |
I have a hand full of examples of partial bordered and a couple of others from the giant use case thread: |
Thanks, I wonder how these use case translate to the specifics of border rendering? |
In this example I notice that the thicker right border's width is maintained through the entirety of the top-right angled corner. The width of the drawn border does not transition from the |
There is no current semantic for defining where the corner gets the |
I've drawn up some diagrams of how I think bevel and scoop should be rendered. Note that with uneven border widths, you can't think of rendering the border as stroking a path; it has to be inner and outer paths computed separately. BevelThe goal is to have the bevel section maintain the border width. Naively joining the points you'd use for Proposed algorithm for computing the inner border edge:
ScoopThe goal here again is to maintain the width of the scoop section, and also to have the inner scoop edge prescribe an ellipse around the outer box corner (this looks better than perpendicular joins at the inner edges). Proposed algorithm for computing the inner border edge:
|
The formula in the codepen is sort of what you wrote for bevel. It's equivalent to reducing the outer radius by |
A focused discussion for the WG here is whether concave corner borders (scoop/notch) can be allowed to overlap each other. The alternative is to shrink the outer radius and create some kind of join. I believe the latter is a reasonable constraints for corners, however some use cases will not be possible (a sharp "star" using scoops where the borders overlap). Note that this would be possible with This prototype attempts to solve the join problem to appear consistent with the existing rounded/square shapes. |
Hm, I notice in your prototype that the point on the border's outer edge that looks like it starts the corner stays constant while the border is convex, but moves slightly closer to the corner as it becomes concave. I presume this is what Simon was referring to. @smfr, in your diagrams, could you indicate exactly what parts are intended to correspond to the specified radiuses? I presume it's the length of the outer dashed sides? |
Yes, this is intentional. It creates an effect where |
@smfr I looked at the bevel formula and generalized it to any superellipse, by using the approximate tangent. It looks something like this:
|
Update: I changed the algorithm in the prototype to modify the inner radius instead, but constrain the radius so that it doesn't overlap (effectively shrinking the outer radius when close to 50%). |
…only Automatic update from web-platform-tests Rendering of corner-shape: bevel This sets the infrastructure for rendering corner-shape, by storing 4-float "CornerCurvature" on a FloatRoundedRect. Currently only the special-case for "bevel" is handled, with the idea of iterating on the different aspects of rendering as we go along. To properly render bevel (and any other curvature that's lower than round), drawing a straight line from the outer/inner sides doesn't create the right effect, because the diagonal distance between those lines doesn't match the border width. To correct that, while maintaining rendering within the initial corners, the outer corner is shrunk to the point where the resulting diagonal quad has a width equal to the border-width (or interpolating between two border-widths). See open spec issue: w3c/csswg-drafts#11610 Removed existing hand-coded SVG tests, and generating the refs using a canvas polyfill instead. This polyfill can be amended later on as we polish the spec. Bug: 394059604 Change-Id: I9fb76dd7dc557ed10c40adecbb9f68f672de1acc Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6250197 Reviewed-by: Philip Rogers <[email protected]> Commit-Queue: Noam Rosenthal <[email protected]> Reviewed-by: Fredrik Söderquist <[email protected]> Cr-Commit-Position: refs/heads/main@{#1421457} -- wpt-commits: cd546585e048de3c88ffdaa7f83e23f4a0dba932 wpt-pr: 50777
…only Automatic update from web-platform-tests Rendering of corner-shape: bevel This sets the infrastructure for rendering corner-shape, by storing 4-float "CornerCurvature" on a FloatRoundedRect. Currently only the special-case for "bevel" is handled, with the idea of iterating on the different aspects of rendering as we go along. To properly render bevel (and any other curvature that's lower than round), drawing a straight line from the outer/inner sides doesn't create the right effect, because the diagonal distance between those lines doesn't match the border width. To correct that, while maintaining rendering within the initial corners, the outer corner is shrunk to the point where the resulting diagonal quad has a width equal to the border-width (or interpolating between two border-widths). See open spec issue: w3c/csswg-drafts#11610 Removed existing hand-coded SVG tests, and generating the refs using a canvas polyfill instead. This polyfill can be amended later on as we polish the spec. Bug: 394059604 Change-Id: I9fb76dd7dc557ed10c40adecbb9f68f672de1acc Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6250197 Reviewed-by: Philip Rogers <[email protected]> Commit-Queue: Noam Rosenthal <[email protected]> Reviewed-by: Fredrik Söderquist <[email protected]> Cr-Commit-Position: refs/heads/main@{#1421457} -- wpt-commits: cd546585e048de3c88ffdaa7f83e23f4a0dba932 wpt-pr: 50777
…only Automatic update from web-platform-tests Rendering of corner-shape: bevel This sets the infrastructure for rendering corner-shape, by storing 4-float "CornerCurvature" on a FloatRoundedRect. Currently only the special-case for "bevel" is handled, with the idea of iterating on the different aspects of rendering as we go along. To properly render bevel (and any other curvature that's lower than round), drawing a straight line from the outer/inner sides doesn't create the right effect, because the diagonal distance between those lines doesn't match the border width. To correct that, while maintaining rendering within the initial corners, the outer corner is shrunk to the point where the resulting diagonal quad has a width equal to the border-width (or interpolating between two border-widths). See open spec issue: w3c/csswg-drafts#11610 Removed existing hand-coded SVG tests, and generating the refs using a canvas polyfill instead. This polyfill can be amended later on as we polish the spec. Bug: 394059604 Change-Id: I9fb76dd7dc557ed10c40adecbb9f68f672de1acc Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6250197 Reviewed-by: Philip Rogers <pdrchromium.org> Commit-Queue: Noam Rosenthal <nrosenthalchromium.org> Reviewed-by: Fredrik Söderquist <fsopera.com> Cr-Commit-Position: refs/heads/main{#1421457} -- wpt-commits: cd546585e048de3c88ffdaa7f83e23f4a0dba932 wpt-pr: 50777 UltraBlame original commit: 402b0e16cc0e1dafd266edb84ae86e3516159e06
…only Automatic update from web-platform-tests Rendering of corner-shape: bevel This sets the infrastructure for rendering corner-shape, by storing 4-float "CornerCurvature" on a FloatRoundedRect. Currently only the special-case for "bevel" is handled, with the idea of iterating on the different aspects of rendering as we go along. To properly render bevel (and any other curvature that's lower than round), drawing a straight line from the outer/inner sides doesn't create the right effect, because the diagonal distance between those lines doesn't match the border width. To correct that, while maintaining rendering within the initial corners, the outer corner is shrunk to the point where the resulting diagonal quad has a width equal to the border-width (or interpolating between two border-widths). See open spec issue: w3c/csswg-drafts#11610 Removed existing hand-coded SVG tests, and generating the refs using a canvas polyfill instead. This polyfill can be amended later on as we polish the spec. Bug: 394059604 Change-Id: I9fb76dd7dc557ed10c40adecbb9f68f672de1acc Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6250197 Reviewed-by: Philip Rogers <pdrchromium.org> Commit-Queue: Noam Rosenthal <nrosenthalchromium.org> Reviewed-by: Fredrik Söderquist <fsopera.com> Cr-Commit-Position: refs/heads/main{#1421457} -- wpt-commits: cd546585e048de3c88ffdaa7f83e23f4a0dba932 wpt-pr: 50777 UltraBlame original commit: 402b0e16cc0e1dafd266edb84ae86e3516159e06
…only Automatic update from web-platform-tests Rendering of corner-shape: bevel This sets the infrastructure for rendering corner-shape, by storing 4-float "CornerCurvature" on a FloatRoundedRect. Currently only the special-case for "bevel" is handled, with the idea of iterating on the different aspects of rendering as we go along. To properly render bevel (and any other curvature that's lower than round), drawing a straight line from the outer/inner sides doesn't create the right effect, because the diagonal distance between those lines doesn't match the border width. To correct that, while maintaining rendering within the initial corners, the outer corner is shrunk to the point where the resulting diagonal quad has a width equal to the border-width (or interpolating between two border-widths). See open spec issue: w3c/csswg-drafts#11610 Removed existing hand-coded SVG tests, and generating the refs using a canvas polyfill instead. This polyfill can be amended later on as we polish the spec. Bug: 394059604 Change-Id: I9fb76dd7dc557ed10c40adecbb9f68f672de1acc Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6250197 Reviewed-by: Philip Rogers <pdrchromium.org> Commit-Queue: Noam Rosenthal <nrosenthalchromium.org> Reviewed-by: Fredrik Söderquist <fsopera.com> Cr-Commit-Position: refs/heads/main{#1421457} -- wpt-commits: cd546585e048de3c88ffdaa7f83e23f4a0dba932 wpt-pr: 50777 UltraBlame original commit: 402b0e16cc0e1dafd266edb84ae86e3516159e06
…only Automatic update from web-platform-tests Rendering of corner-shape: bevel This sets the infrastructure for rendering corner-shape, by storing 4-float "CornerCurvature" on a FloatRoundedRect. Currently only the special-case for "bevel" is handled, with the idea of iterating on the different aspects of rendering as we go along. To properly render bevel (and any other curvature that's lower than round), drawing a straight line from the outer/inner sides doesn't create the right effect, because the diagonal distance between those lines doesn't match the border width. To correct that, while maintaining rendering within the initial corners, the outer corner is shrunk to the point where the resulting diagonal quad has a width equal to the border-width (or interpolating between two border-widths). See open spec issue: w3c/csswg-drafts#11610 Removed existing hand-coded SVG tests, and generating the refs using a canvas polyfill instead. This polyfill can be amended later on as we polish the spec. Bug: 394059604 Change-Id: I9fb76dd7dc557ed10c40adecbb9f68f672de1acc Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6250197 Reviewed-by: Philip Rogers <[email protected]> Commit-Queue: Noam Rosenthal <[email protected]> Reviewed-by: Fredrik Söderquist <[email protected]> Cr-Commit-Position: refs/heads/main@{#1421457} -- wpt-commits: cd546585e048de3c88ffdaa7f83e23f4a0dba932 wpt-pr: 50777
After many iterations together with @smfr and @fserb, I think we have a good model:
Would love to get a resolution on this soon! Feel free to play with the different options on https://noamr.github.io/squircle-testbed/corner-shape.html |
That definitely feels pretty good to me when I play around with it a little, and your description matches how I think they should work. While we still need to define the diagonal-corner overlap avoidance rules (which your demo mostly avoids, by limiting the radiuses to half the half the side size), I like the shape of this chunk of the rules. (By the way, there's a rendering bug if some of the corners are zero radius.) |
@noamr Sorry for the late reply. This looks very nice, I see that there are two Mode options at the bottom, does the actual implementation of Blink use the bezier curve approximation as well? |
Currently in canary, blink uses the bezier curve approximation and the web platform tests use point-by-point superellipse. |
Follow-up on #10993
corner-shape
cannot be naturally stroked in the same way as ordinary rounded corners or a stroke path, and some details need to be defined.For example, how should stroking bevel/notch look like? Do the inner border collapse into each other, or stay confined within the corner?
The text was updated successfully, but these errors were encountered: