export function updateGrid()

in scripts/dashboard-importer/src/dashboards/converter/layout/layout_utils.ts [63:84]


export function updateGrid(
  tile: Tile,
  grid: Set<string>, // Grid of occupied string coordinates
): boolean {
  const {xPos, yPos, width, height} = tile;
  for (let x = xPos!; x < xPos! + width!; x++) {
    for (let y = yPos!; y < yPos! + height!; y++) {
      const coordinate = `${x},${y}`;
      if (grid.has(coordinate)) {
        return false;
      }
    }
  }

  for (let x = xPos!; x < xPos! + width!; x++) {
    for (let y = yPos!; y < yPos! + height!; y++) {
      const coordinate = `${x},${y}`;
      grid.add(coordinate);
    }
  }
  return true;
}