2 import { topLeft, bottomRight } from '$lib/stores/canvas';
3 import { modulo } from '$lib/math';
4 import { maxSize } from '$lib/config';
5 import MinimapSector from '$lib/components/minimap_sector.svelte';
8 const sectors = Array(gridSize).fill(Array(gridSize).fill());
9 const size = maxSize / gridSize;
11 const isActive = function isActive(x, y, $topLeft) {
12 const pCanvas = modulo($topLeft.x, maxSize);
13 const qCanvas = modulo($topLeft.y, maxSize);
14 const pBoundary = pCanvas + Math.abs($topLeft.x - $bottomRight.x);
15 const qBoundary = qCanvas + Math.abs($topLeft.y - $bottomRight.y);
17 const sectorLeft = size * x;
18 const sectorTop = size * y;
19 const sectorRight = sectorLeft + size;
20 const sectorBottom = sectorTop + size;
22 sectorRight >= pCanvas &&
23 pBoundary >= sectorLeft &&
24 sectorBottom >= qCanvas &&
25 qBoundary >= sectorTop
32 {#each sectors as _, y}
34 {#each sectors[y] as _, x}
35 <MinimapSector x="{x}," y="{y}," {size} isActive={isActive(x, y, $topLeft)} />
44 background-color: #fff;
50 -webkit-font-smoothing: none;
53 border-collapse: collapse;