mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
The viewshed palette is renderer colours from a new hslColor in render/color, which computes as the renderer's own fromHsl does (the CSS HSL reading now goes through it). The volume primitive builder moves, unchanged, into the camera layer's rendering part, which converts each record's palette to Cesium colours once and draws the lines and volumes with them as before. Tests check the palette against the renderer's colours exactly. cctvViewshed leaves the allow-list.
47 lines
1.4 KiB
JavaScript
47 lines
1.4 KiB
JavaScript
import assert from 'node:assert/strict';
|
|
import test from 'node:test';
|
|
import { hexColor } from './color.js';
|
|
|
|
test('hex colours become renderer colours at the given alpha', () => {
|
|
assert.deepEqual(hexColor('#ff8000'), [1, 128 / 255, 0, 1]);
|
|
assert.deepEqual(hexColor('#000000', 0.25), [0, 0, 0, 0.25]);
|
|
});
|
|
|
|
test('CSS colours read as the default renderer reads them', async () => {
|
|
const Cesium = await import('cesium');
|
|
const { cssColor } = await import('./color.js');
|
|
for (const css of [
|
|
'#39d5ff',
|
|
' #8fffd2 ',
|
|
'#abc',
|
|
'#abcd',
|
|
'#11223344',
|
|
'rgb(10, 20, 30)',
|
|
'rgba(10,20,30,0.5)',
|
|
'rgb(10% 20% 30% / 0.25)',
|
|
'hsl(120, 50%, 25%)',
|
|
'hsla(300, 100%, 75%, 0.4)',
|
|
'hsl(30, 0%, 40%)',
|
|
]) {
|
|
const c = Cesium.Color.fromCssColorString(css);
|
|
assert.deepEqual(cssColor(css), [c.red, c.green, c.blue, c.alpha], css);
|
|
}
|
|
assert.equal(cssColor('not a colour'), null);
|
|
assert.equal(cssColor(undefined), null);
|
|
});
|
|
|
|
test('HSL colours read as the default renderer computes them', async () => {
|
|
const Cesium = await import('cesium');
|
|
const { hslColor } = await import('./color.js');
|
|
for (const [h, s, l, a] of [
|
|
[0, 0.85, 0.6, 0.12],
|
|
[0.3819660112501051, 0.9, 0.65, 0.85],
|
|
[0.7639320225002102, 0.9, 0.7, 1],
|
|
[1.25, 0.5, 0.25, 0.4],
|
|
[0.5, 0, 0.4, 1],
|
|
]) {
|
|
const c = Cesium.Color.fromHsl(h, s, l, a);
|
|
assert.deepEqual(hslColor(h, s, l, a), [c.red, c.green, c.blue, c.alpha]);
|
|
}
|
|
});
|