diff --git a/src/utils/utils.ts b/src/utils/utils.ts index ce5622c..4ebd7ee 100644 --- a/src/utils/utils.ts +++ b/src/utils/utils.ts @@ -161,12 +161,17 @@ function tempColor(badness: number): [number, number, number] { let saturation = 1.0; let lightness = 0.75; try { - saturation = parseFloat( + const rSaturation = parseFloat( SDFGRenderer.getCssProperty('--overlay-color-saturation') ); - lightness = parseFloat( + if (rSaturation !== undefined && !Number.isNaN(rSaturation)) + saturation = rSaturation; + + const rLightness = parseFloat( SDFGRenderer.getCssProperty('--overlay-color-lightness') ); + if (rLightness !== undefined && !Number.isNaN(rLightness)) + lightness = rLightness; } catch (_ignored) { // Ignored. } diff --git a/tests/unit/utils/collections.test.ts b/tests/unit/utils/collections.test.ts index 7f11091..2046321 100644 --- a/tests/unit/utils/collections.test.ts +++ b/tests/unit/utils/collections.test.ts @@ -1,6 +1,6 @@ // Copyright 2019-2024 ETH Zurich and the DaCe authors. All rights reserved. -import { AccessStack, LinkedStack } from "../../../src/utils/collections"; +import { AccessStack, LinkedStack } from '../../../src/utils/collections'; function testLinkedStackConstruction(): void { const lStack = new LinkedStack(); diff --git a/tests/unit/utils/utils.test.ts b/tests/unit/utils/utils.test.ts new file mode 100644 index 0000000..22c5aee --- /dev/null +++ b/tests/unit/utils/utils.test.ts @@ -0,0 +1,13 @@ +// Copyright 2019-2024 ETH Zurich and the DaCe authors. All rights reserved. + +import { getTempColorHslString } from '../../../src'; + +function testTempColor(): void { + expect(getTempColorHslString(1.0)).toBe('hsl(0,100%,75%)'); + expect(getTempColorHslString(0.0)).toBe('hsl(120,100%,75%)'); + expect(getTempColorHslString(0.5)).toBe('hsl(60,100%,75%)'); +} + +describe('Test utility functions', () => { + test('Badness to temperature color conversion', testTempColor); +});