(address)
| 315 | }; |
| 316 | |
| 317 | export 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 | }; |
no test coverage detected