-
Notifications
You must be signed in to change notification settings - Fork 715
[css-borders-4] Consider constraining radii for concave corner-shape when opposite corners overlap #12098
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
Sounds reasonable on first thought. Though avoiding overlapping also quickly becomes complex. Should borders also be accounted for? Should different shapes be handled differently (e.g. Also, should there be an option to control this constraint? I assume there are use cases, for which overlapping is actually expected to achieve specific effects for split backgrounds. (Those might also be achievable via Sebastian |
In a previous resolution we concluded on not considering borders here, only the outer contour. It simplifies things a lot. I think this is a question of whether we constrain the radii or the shape to not overlap diagonally in the outer contour. The rest would fall into place.
Since we don't allow it for border-radius currently I think we should stick with that. The edge cases for overlapping borders are sufficiently edgy.
|
Overlapping brings up all kinds of complexities, like whether you're filling the border with an even-odd or non-zero wind rule. I think we have to avoid it. |
I see! I obviously missed that resolution. So yes, that makes it much easier to handle.
I know, but radii on the same axis are also relatively simple to handle.
Right.
Fair enough. If use cases for that come up at some point, we can still discuss it separately.
Just to note, even if we don't allow overlapping for Sebastian |
I actually thought of a third option that has some nice attributes to it: constraint the radius in only one of the dimensions. For the following CSS: border-top-right-radius: 70%;
border-bottom-left-radius: 70%;
corner-shape: notch; where the radius in the next clockwise dimension remains unconstrained, and the radius in the counterclockwise dimension is constrained in such a way that the corners do not overlap. See options below for how this is going to look like. This gives us 3 options. For each one I'll show what CSS it would be equivalent to and how the OP example would look like: Original: border-top-right-radius: 70%;
border-bottom-left-radius: 70%;
corner-shape: notch;
border-top-right-radius: 50%;
border-bottom-left-radius: 50%;
corner-shape: notch;
border-top-right-radius: 70%;
border-bottom-left-radius: 70%;
/* 1.02 is some computed number that puts the diagonal half corners in the same point */
corner-shape: superellipse(-1.02);
border-top-right-radius: 50% 70%;
border-bottom-left-radius: 50% 70%;
corner-shape: notch; |
When we're shrinking adjacent corners, we purposely shrink both radiuses, to keep the corner "shaped" the same. We also shrink both corners the same amount, just because there's no way to know which we should bias towards. I think we should do the same here. That is, I think option 1 is the only reasonable option. Changing the superellipse parameter, or changing only one radius, both change the corner shape in dramatic ways, and I don't think either of those are acceptable outcomes. |
I am fine with this but would like to hear from others (@smfr / @SebastianZ / @LeaVerou / @fantasai ?). |
Happy to resolve to what @tabatkins proposed. |
Agree that constraining the radii makes more sense than changing the shape. But how exactly does the constraining work? Does the superellipse value affect the amount of constraining? If one corner is |
A model we can follow is something as such:
|
Yes, that sounds like a reasonable approach to me. I suspect there's a lot of potential flexibility in what exactly we do, but that algo seems straightforward and thematically consistent with how we shrink adjacent corners. |
@smfr does this seem reasonable to you? An implementation can use bsearch for this or find something more fancy/optimized. |
I've prototyped this: https://noamr.github.io/squircle-testbed/radii-constraint.html I think it looks quite reasonable. |
The following CSS would cause the top-right and bottom-left corner to overlap, even without borders:
Basically anything more concave than this:

would result in the corner collapsing on each other.
Since we constraint radius to not overlap in the ordinary round case, we should probably constraint it (or constraint the shape) in this case as well.
(Brought up by @smfr)
The text was updated successfully, but these errors were encountered: