(x, y, r, rotation = 0, smoothing = 0.6)
| 22 | // user space as the shape paths -- otherwise a userSpaceOnUse gradient would be |
| 23 | // sampled in each bridge's translated local space and render the wrong color. |
| 24 | export const getBridgePathAt = (x, y, r, rotation = 0, smoothing = 0.6) => { |
| 25 | const s = Math.max(0, Math.min(1, smoothing)); |
| 26 | const k1 = 0.45 + 0.5 * s; |
| 27 | const k2 = 0.05 + 0.25 * s; |
| 28 | |
| 29 | let c1y, c2x, c2y, ex, ey; |
| 30 | switch (rotation) { |
| 31 | case 90: |
| 32 | c1y = r * k1; |
| 33 | c2x = -r * k2; |
| 34 | c2y = r; |
| 35 | ex = -r; |
| 36 | ey = r; |
| 37 | break; |
| 38 | case 180: |
| 39 | c1y = -r * k1; |
| 40 | c2x = -r * k2; |
| 41 | c2y = -r; |
| 42 | ex = -r; |
| 43 | ey = -r; |
| 44 | break; |
| 45 | case 270: |
| 46 | c1y = -r * k1; |
| 47 | c2x = r * k2; |
| 48 | c2y = -r; |
| 49 | ex = r; |
| 50 | ey = -r; |
| 51 | break; |
| 52 | case 0: |
| 53 | default: |
| 54 | c1y = r * k1; |
| 55 | c2x = r * k2; |
| 56 | c2y = r; |
| 57 | ex = r; |
| 58 | ey = r; |
| 59 | break; |
| 60 | } |
| 61 | |
| 62 | return `M ${x} ${y} C ${x} ${y + c1y} ${x + c2x} ${y + c2y} ${x + ex} ${y + ey} H ${x} Z`; |
| 63 | }; |
| 64 | |
| 65 | export const getRoundedRectPath = (x, y, w, h, corners) => { |
| 66 | const { tl, tr, br, bl } = corners; |
no outgoing calls
no test coverage detected