(shapes, bridges, cornerRadii, globalRadius, smoothing = 0.6)
| 307 | }; |
| 308 | |
| 309 | export const generateCSSClipPath = (shapes, bridges, cornerRadii, globalRadius, smoothing = 0.6) => { |
| 310 | const padding = 10; |
| 311 | const bb = computeShapesBBox(shapes); |
| 312 | const width = bb.w + padding * 2; |
| 313 | const height = bb.h + padding * 2; |
| 314 | const offsetX = -bb.x + padding; |
| 315 | const offsetY = -bb.y + padding; |
| 316 | |
| 317 | const allPaths = []; |
| 318 | |
| 319 | shapes.forEach(s => { |
| 320 | const corners = cornersFor(cornerRadii, s.id, globalRadius); |
| 321 | allPaths.push(getRoundedRectPath(s.x + offsetX, s.y + offsetY, s.w, s.h, corners)); |
| 322 | }); |
| 323 | |
| 324 | bridges.forEach(b => { |
| 325 | allPaths.push(getBridgePathAt(b.x + offsetX, b.y + offsetY, b.r, b.rotation, smoothing)); |
| 326 | }); |
| 327 | |
| 328 | const combinedPath = allPaths.join(' ').replace(/\s+/g, ' ').trim(); |
| 329 | |
| 330 | return `/* Container dimensions: ${Math.round(width)}px × ${Math.round(height)}px */ |
| 331 | .clipped-element { |
| 332 | clip-path: path('${combinedPath}'); |
| 333 | width: ${Math.round(width)}px; |
| 334 | height: ${Math.round(height)}px; |
| 335 | }`; |
| 336 | }; |
| 337 | |
| 338 | const computeNegativeSpaces = (shapes, bridges, globalRadius, minX, minY, maxX, maxY) => { |
| 339 | const negativeSpaces = []; |
no test coverage detected