|
151 | 151 | const bottomRight = $derived(['all', 'bottom', 'right', 'bottom-right'].includes(rounded)); |
152 | 152 | const width = $derived(dimensions.width); |
153 | 153 | const height = $derived(dimensions.height); |
154 | | - const diameter = $derived(2 * radius); |
| 154 | +
|
| 155 | + // Clamp radius to prevent extending beyond bounding box |
| 156 | + const r = $derived(Math.min(radius, width / 2, height / 2)); |
| 157 | + const diameter = $derived(2 * r); |
| 158 | +
|
155 | 159 | const pathData = $derived( |
156 | | - `M${dimensions.x + radius},${dimensions.y} h${width - diameter} |
157 | | - ${topRight ? `a${radius},${radius} 0 0 1 ${radius},${radius}` : `h${radius}v${radius}`} |
| 160 | + `M${dimensions.x + r},${dimensions.y} h${width - diameter} |
| 161 | + ${topRight ? `a${r},${r} 0 0 1 ${r},${r}` : `h${r}v${r}`} |
158 | 162 | v${height - diameter} |
159 | | - ${bottomRight ? `a${radius},${radius} 0 0 1 ${-radius},${radius}` : `v${radius}h${-radius}`} |
| 163 | + ${bottomRight ? `a${r},${r} 0 0 1 ${-r},${r}` : `v${r}h${-r}`} |
160 | 164 | h${diameter - width} |
161 | | - ${bottomLeft ? `a${radius},${radius} 0 0 1 ${-radius},${-radius}` : `h${-radius}v${-radius}`} |
| 165 | + ${bottomLeft ? `a${r},${r} 0 0 1 ${-r},${-r}` : `h${-r}v${-r}`} |
162 | 166 | v${diameter - height} |
163 | | - ${topLeft ? `a${radius},${radius} 0 0 1 ${radius},${-radius}` : `v${-radius}h${radius}`} |
| 167 | + ${topLeft ? `a${r},${r} 0 0 1 ${r},${-r}` : `v${-r}h${r}`} |
164 | 168 | z` |
165 | 169 | .split('\n') |
166 | 170 | .join('') |
|
0 commit comments