[csswg-drafts] [css-borders-4] Hyperellipse (squircle) inner border thickness at 45° corner and cubic dampening (#14902)

noamr has just created a new issue for https://github.com/w3c/csswg-drafts:

== [css-borders-4] Hyperellipse (squircle) inner border thickness at 45° corner and cubic dampening ==
In [`border-aligned-corner-clip-out-path`](https://drafts.csswg.org/css-borders-4/#border-aligned-corner-clip-out-path), for convex hyperellipses (`s > 1`, e.g. `corner-shape: squircle` where `s = 2`), the control-point normals at `Start` and `End` are perpendicular to the box edges, so offsetting by border width $b$ shrinks the radii from $R$ to $R - b$ and reuses the outer `superellipse_parameter` $s$ unchanged.

### Problem
Because a superellipse $(x/R)^p + (y/R)^p = 1$ ($p = 2^s$) has its 45° midpoint at $R \cdot 2^{-1/p}$ from the center, keeping $p$ constant while shrinking $R$ by $b$ moves the 45° point inward by:

$$b \cdot \sqrt{2} \cdot 2^{-1/p} = b \cdot 2^{\frac{1}{2} - \frac{1}{2^s}}$$

For `squircle` ($s = 2, p = 4$), the border is **$2^{1/4} \approx 1.19\times$ thicker** at the 45° corner than along the straight edges (and up to $\sqrt{2} \approx 1.41\times$ thicker as $s \to \infty$). On everyday UI borders (e.g. `1–2px`, or `16px` with `border-radius: 144px`), the corners look noticeably heavier/pinched (see [Chromium issue 585390697](https://issues.chromium.org/issues/585390697)).

### Tradeoff & Proposed `^3` Dampening
Directly solving for the inner curvature $p'$ that preserves exact 45° thickness gives:

$$u_{\text{exact}} = \frac{R \cdot h - b / \sqrt{2}}{R - b}, \qquad h = 2^{-1/2^s}$$

However, without dampening, $u_{\text{exact}}$ reaches $1$ (a sharp 90° square) once:

$$\frac{b}{R} \ge \frac{1 - 2^{-1/2^s}}{1 - 2^{-1/2}} \quad (\approx 0.5432 \text{ for squircle})$$

For thick borders (e.g. `border-radius: 50px; border-width: 30px; corner-shape: squircle`), turning the inner hole into a sharp square sacrifices the squircle character.

Analogous to the cubic `^3` dampening used in `border-radius` spread adjustment, we can dampen the half-corner shift by $w = 1 - \min(1, b / R)^3$:

$$u' = h + \left(1 - \min\left(1, \frac{b}{R}\right)^3\right) \cdot \left(\min(1, u_{\text{exact}}) - h\right)$$

$$p' = \frac{-1}{\log_2(u')}, \qquad s' = \log_2(p')$$

*(For elliptical corners or asymmetric insets, the outer normal at $t = 0.5$ is $(R_s, R_e)/\sqrt{R_s^2 + R_e^2}$ and $(u', v')$ solves $(u')^{p'} + (v')^{p'} = 1$.)*

For `squircle` ($s = 2, R = 100$):

| $b / R$ | Current spec (`45°` thickness) | Uncapped exact | Proposed `1 - (b/R)^3` | Inner $s'$ (proposed) |
|---|---|---|---|---|
| `0.02` | `2.38px` (`1.19×`) | `2.00px` | `2.00px` (`1.00×`) | `2.03` |
| `0.11` | `13.20px` (`1.19×`) | `11.10px` | `11.10px` (`1.00×`) | `2.17` |
| `0.20` | `23.78px` (`1.19×`) | `20.00px` | `20.03px` (`1.00×`) | `2.36` |
| `0.40` | `47.57px` (`1.19×`) | `40.00px` | `40.48px` (`1.01×`) | `3.14` |
| `0.60` | `71.35px` (`1.19×`) | `62.35px` (sharp 90°) | `64.30px` (`1.07×`) | `4.31` (curved) |
| `0.80` | `95.14px` (`1.19×`) | `90.51px` (sharp 90°) | `92.94px` (`1.16×`) | `3.03` (curved) |

This keeps thin and moderate borders visually uniform (`~1.00×` thickness) while smoothly preserving curved inner corners for thick borders.

### Interactive Demo
- Live preview: https://htmlpreview.github.io/?https://gist.githubusercontent.com/noamr/e8f20666f25419f9796004d9d51fbcfb/raw/squircle-border-demo.html
- Gist source: https://gist.github.com/noamr/e8f20666f25419f9796004d9d51fbcfb


Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/14902 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Monday, 30 November 2026 21:57:36 UTC