mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-23 03:32:19 +00:00
feat(cctv): green count markers that grow with the count and carry a camera icon
A count marker now says what it counts and how much: - Its height grows with the count, from 40 px for two cameras to 58 px for several thousand, with clear fill around the digits. - A small single-camera map icon sits under the top of the ring and the number just below the centre, so the two never touch. The icon is built from the same sprite as a single camera on the map. - Thousands print as 1.7K or 12K in every UI language. - The camera layer is green: count markers and idle single cameras share the colour, the active camera stays gold and live-video cameras violet.
This commit is contained in:
1 parent
aabfa5e084
commit
c536d22ff0
10 files changed
+806
-215
No files matched your search
@@ -9,20 +9,28 @@ import {
|
||||
cellCenter,
|
||||
cellBounds,
|
||||
formatCameraCount,
|
||||
mergeCountCells,
|
||||
} from './cctvCellCounts.js';
|
||||
|
||||
test('camera counts are exact through 999 and compact in the active locale', () => {
|
||||
test('camera counts use the same Latin digits and K notation in every UI language', () => {
|
||||
const previous = getLocale();
|
||||
const examples = [
|
||||
[2, '2'],
|
||||
[999, '999'],
|
||||
[1000, '1K'],
|
||||
[1150, '1.2K'],
|
||||
[1687, '1.7K'],
|
||||
[9960, '10K'],
|
||||
[10000, '10K'],
|
||||
[12345, '12K'],
|
||||
[12500, '13K'],
|
||||
[1000000, '1000K'],
|
||||
];
|
||||
try {
|
||||
for (const locale of ['en', 'fr', 'ja']) {
|
||||
for (const locale of ['en', 'ru', 'ja', 'ar']) {
|
||||
setLocale(locale);
|
||||
for (const n of [2, 999, 1000, 12345]) {
|
||||
const format = new Intl.NumberFormat(
|
||||
locale,
|
||||
n < 1000 ? {} : { notation: 'compact' },
|
||||
);
|
||||
assert.equal(formatCameraCount(n), format.format(n));
|
||||
}
|
||||
for (const [count, label] of examples)
|
||||
assert.equal(formatCameraCount(count), label, `${locale}: ${count}`);
|
||||
}
|
||||
} finally {
|
||||
setLocale(previous);
|
||||
@@ -47,3 +55,42 @@ test('the marker mean weights every mount and the flight bounds cover the outlie
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
test('stadiums merge by their own radii and segment lengths across grid boundaries', () => {
|
||||
const sizes = {
|
||||
2: { width: 28, height: 28 },
|
||||
7350: { width: 80, height: 48 },
|
||||
};
|
||||
const gap = 4;
|
||||
const check = (counts, positions, expected) => {
|
||||
const cells = counts.map((count, i) => ({
|
||||
...createCameraCell(String(i)),
|
||||
count,
|
||||
}));
|
||||
let i = 0;
|
||||
const groups = mergeCountCells(
|
||||
cells,
|
||||
() => positions[i++],
|
||||
(count) => sizes[count],
|
||||
gap,
|
||||
);
|
||||
assert.deepEqual(
|
||||
groups.map((cell) => cell.count),
|
||||
expected,
|
||||
);
|
||||
assert.equal(
|
||||
groups.reduce((sum, cell) => sum + cell.count, 0),
|
||||
counts[0] + counts[1],
|
||||
);
|
||||
};
|
||||
const origin = { x: 35, y: 37 };
|
||||
// Mixed radii sum to 38. At 42 pixels vertically the gap is exactly clear.
|
||||
check([2, 7350], [origin, { x: 35, y: 78 }], [7352]);
|
||||
check([2, 7350], [origin, { x: 35, y: 79 }], [2, 7350]);
|
||||
// The large pill's centre segment extends 16 pixels towards the circle.
|
||||
check([7350, 2], [origin, { x: 92, y: 37 }], [7352]);
|
||||
check([7350, 2], [origin, { x: 92, y: 49 }], [7350, 2]);
|
||||
check([2, 2], [origin, { x: 70, y: 37 }], [2, 2]);
|
||||
// Large pills can reach across a row boundary at their full diameter.
|
||||
check([7350, 7350], [origin, { x: 35, y: 88 }], [14700]);
|
||||
});
|
||||
Reference in new issue
Block a user