MCPcopy Create free account
hub / github.com/TodePond/ScreenPond / tryToSurroundScreens

Function tryToSurroundScreens

source/pick.js:317–346  ·  view source on GitHub ↗
(address)

Source from the content-addressed store, hash-verified

315};
316
317export const tryToSurroundScreens = (address) => {
318 const { colour } = address;
319 const screen = getScreenFromAddress(address);
320
321 const surroundedScreensSet = new Set();
322 const length = colour.screens.length;
323
324 for (let i = 0; i < length; i++) {
325 const child = colour.screens[i];
326 if (child === screen) continue;
327
328 const mappedChildCorners = getMappedPositions(
329 child.corners,
330 screen.corners
331 );
332 const insideScreen = mappedChildCorners.every((corner) =>
333 isMappedPositionInCorners(corner)
334 );
335
336 if (!insideScreen) continue;
337 surroundedScreensSet.add(child);
338 const newChild = makeScreen(child.colour, mappedChildCorners);
339 addScreen(screen.colour, newChild);
340 }
341
342 removeScreensSet(colour, surroundedScreensSet);
343
344 const newAddress = getAddressFromScreen(screen, colour);
345 return newAddress;
346};

Callers 1

hand.jsFile · 0.90

Calls 7

getScreenFromAddressFunction · 0.90
getMappedPositionsFunction · 0.90
makeScreenFunction · 0.90
addScreenFunction · 0.90
removeScreensSetFunction · 0.90
getAddressFromScreenFunction · 0.90

Tested by

no test coverage detected