* Parse border radius from the provided options
(arc: ArcElement, innerRadius: number, outerRadius: number, angleDelta: number)
| 64 | * Parse border radius from the provided options |
| 65 | */ |
| 66 | function parseBorderRadius(arc: ArcElement, innerRadius: number, outerRadius: number, angleDelta: number) { |
| 67 | const o = toRadiusCorners(arc.options.borderRadius); |
| 68 | const halfThickness = (outerRadius - innerRadius) / 2; |
| 69 | const innerLimit = Math.min(halfThickness, angleDelta * innerRadius / 2); |
| 70 | |
| 71 | // Outer limits are complicated. We want to compute the available angular distance at |
| 72 | // a radius of outerRadius - borderRadius because for small angular distances, this term limits. |
| 73 | // We compute at r = outerRadius - borderRadius because this circle defines the center of the border corners. |
| 74 | // |
| 75 | // If the borderRadius is large, that value can become negative. |
| 76 | // This causes the outer borders to lose their radius entirely, which is rather unexpected. To solve that, if borderRadius > outerRadius |
| 77 | // we know that the thickness term will dominate and compute the limits at that point |
| 78 | const computeOuterLimit = (val) => { |
| 79 | const outerArcLimit = (outerRadius - Math.min(halfThickness, val)) * angleDelta / 2; |
| 80 | return _limitValue(val, 0, Math.min(halfThickness, outerArcLimit)); |
| 81 | }; |
| 82 | |
| 83 | return { |
| 84 | outerStart: computeOuterLimit(o.outerStart), |
| 85 | outerEnd: computeOuterLimit(o.outerEnd), |
| 86 | innerStart: _limitValue(o.innerStart, 0, innerLimit), |
| 87 | innerEnd: _limitValue(o.innerEnd, 0, innerLimit), |
| 88 | }; |
| 89 | } |
| 90 | |
| 91 | /** |
| 92 | * Convert (r, 𝜃) to (x, y) |
no test coverage detected