(x, y, w, h, corners)
| 63 | }; |
| 64 | |
| 65 | export const getRoundedRectPath = (x, y, w, h, corners) => { |
| 66 | const { tl, tr, br, bl } = corners; |
| 67 | |
| 68 | const maxR = Math.min(w / 2, h / 2); |
| 69 | const rtl = Math.min(tl, maxR); |
| 70 | const rtr = Math.min(tr, maxR); |
| 71 | const rbr = Math.min(br, maxR); |
| 72 | const rbl = Math.min(bl, maxR); |
| 73 | |
| 74 | return ` |
| 75 | M ${x + rtl} ${y} |
| 76 | L ${x + w - rtr} ${y} |
| 77 | ${rtr > 0 ? `A ${rtr} ${rtr} 0 0 1 ${x + w} ${y + rtr}` : `L ${x + w} ${y}`} |
| 78 | L ${x + w} ${y + h - rbr} |
| 79 | ${rbr > 0 ? `A ${rbr} ${rbr} 0 0 1 ${x + w - rbr} ${y + h}` : `L ${x + w} ${y + h}`} |
| 80 | L ${x + bl} ${y + h} |
| 81 | ${rbl > 0 ? `A ${rbl} ${rbl} 0 0 1 ${x} ${y + h - rbl}` : `L ${x} ${y + h}`} |
| 82 | L ${x} ${y + rtl} |
| 83 | ${rtl > 0 ? `A ${rtl} ${rtl} 0 0 1 ${x + rtl} ${y}` : `L ${x} ${y}`} |
| 84 | Z |
| 85 | ` |
| 86 | .trim() |
| 87 | .replace(/\s+/g, ' '); |
| 88 | }; |
| 89 | |
| 90 | const cornersFor = (cornerRadii, id, globalRadius) => |
| 91 | cornerRadii[id] || { tl: globalRadius, tr: globalRadius, br: globalRadius, bl: globalRadius }; |
no outgoing calls
no test coverage detected