@ignore
( this: CanvasRenderingContext2D, x: number, y: number, w: number, h: number, radii: unknown, )
| 5 | |
| 6 | /** @ignore */ |
| 7 | function roundRect( |
| 8 | this: CanvasRenderingContext2D, |
| 9 | x: number, |
| 10 | y: number, |
| 11 | w: number, |
| 12 | h: number, |
| 13 | radii: unknown, |
| 14 | ) { |
| 15 | if ( |
| 16 | ![x, y, w, h].every((input) => { |
| 17 | return Number.isFinite(input); |
| 18 | }) |
| 19 | ) { |
| 20 | return; |
| 21 | } |
| 22 | |
| 23 | const parsedRadii = parseRadiiArgument(radii); |
| 24 | |
| 25 | let upperLeft; |
| 26 | let upperRight; |
| 27 | let lowerRight; |
| 28 | let lowerLeft; |
| 29 | |
| 30 | if (parsedRadii.length === 4) { |
| 31 | upperLeft = toCornerPoint(parsedRadii[0]); |
| 32 | upperRight = toCornerPoint(parsedRadii[1]); |
| 33 | lowerRight = toCornerPoint(parsedRadii[2]); |
| 34 | lowerLeft = toCornerPoint(parsedRadii[3]); |
| 35 | } else if (parsedRadii.length === 3) { |
| 36 | upperLeft = toCornerPoint(parsedRadii[0]); |
| 37 | upperRight = toCornerPoint(parsedRadii[1]); |
| 38 | lowerLeft = toCornerPoint(parsedRadii[1]); |
| 39 | lowerRight = toCornerPoint(parsedRadii[2]); |
| 40 | } else if (parsedRadii.length === 2) { |
| 41 | upperLeft = toCornerPoint(parsedRadii[0]); |
| 42 | lowerRight = toCornerPoint(parsedRadii[0]); |
| 43 | upperRight = toCornerPoint(parsedRadii[1]); |
| 44 | lowerLeft = toCornerPoint(parsedRadii[1]); |
| 45 | } else if (parsedRadii.length === 1) { |
| 46 | upperLeft = toCornerPoint(parsedRadii[0]); |
| 47 | upperRight = toCornerPoint(parsedRadii[0]); |
| 48 | lowerRight = toCornerPoint(parsedRadii[0]); |
| 49 | lowerLeft = toCornerPoint(parsedRadii[0]); |
| 50 | } else { |
| 51 | throw new Error( |
| 52 | `${parsedRadii.length} is not a valid size for radii sequence.`, |
| 53 | ); |
| 54 | } |
| 55 | |
| 56 | const corners = [upperLeft, upperRight, lowerRight, lowerLeft]; |
| 57 | const negativeCorner = corners.find(({ x, y }) => { |
| 58 | return x < 0 || y < 0; |
| 59 | }); |
| 60 | //const negativeValue = negativeCorner?.x < 0 ? negativeCorner.x : negativeCorner?.y |
| 61 | |
| 62 | if ( |
| 63 | corners.some(({ x, y }) => { |
| 64 | return !Number.isFinite(x) || !Number.isFinite(y); |
nothing calls this directly
no test coverage detected