MCPcopy Create free account
hub / github.com/DavidHDev/react-bits / addBridge

Function addBridge

src/tools/shape-magic/computeBridges.js:84–99  ·  view source on GitHub ↗
(x, y, r, rotation)

Source from the content-addressed store, hash-verified

82 const bridgeSet = new Set();
83
84 const addBridge = (x, y, r, rotation) => {
85 let offsetY = 0;
86 if (rotation === 0 || rotation === 90) {
87 offsetY = -r;
88 } else if (rotation === 180 || rotation === 270) {
89 offsetY = r;
90 }
91
92 const finalX = x;
93 const finalY = y + offsetY;
94 const key = `${Math.round(finalX)},${Math.round(finalY)},${rotation}`;
95 if (!bridgeSet.has(key)) {
96 bridgeSet.add(key);
97 bridges.push({ id: `bridge-${bridges.length}`, x: finalX, y: finalY, r, rotation });
98 }
99 };
100
101 for (let i = 0; i < shapes.length; i++) {
102 for (let j = 0; j < shapes.length; j++) {

Callers 1

computeBridgesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected