diff options
author | jcardus <asklocation.net@gmail.com> | 2024-06-16 23:16:57 +0100 |
---|---|---|
committer | jcardus <asklocation.net@gmail.com> | 2024-06-16 23:16:57 +0100 |
commit | 11dffdeba76e8d906385eb1f6af5ceeda2b90edf (patch) | |
tree | b68ac197d8cc95b4bd837c34a86ca14b110287f8 /src | |
parent | 9c946ca3513157b430d5871297180d680024b7ac (diff) | |
download | trackermap-web-11dffdeba76e8d906385eb1f6af5ceeda2b90edf.tar.gz trackermap-web-11dffdeba76e8d906385eb1f6af5ceeda2b90edf.tar.bz2 trackermap-web-11dffdeba76e8d906385eb1f6af5ceeda2b90edf.zip |
simplify interpolateColor
Diffstat (limited to 'src')
-rw-r--r-- | src/common/util/colors.js | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/common/util/colors.js b/src/common/util/colors.js index a0f6d52a..d8cbf9fd 100644 --- a/src/common/util/colors.js +++ b/src/common/util/colors.js @@ -1,17 +1,17 @@ -import { hexToRgb, rgbToHex, decomposeColor } from '@mui/material'; +import { decomposeColor } from '@mui/material'; export const interpolateColor = (color1, color2, factor) => { if (factor > 1) factor = 1; if (factor < 0) factor = 0; - const c1 = decomposeColor(hexToRgb(color1)).values; - const c2 = decomposeColor(hexToRgb(color2)).values; + const c1 = decomposeColor(color1).values; + const c2 = decomposeColor(color2).values; const r = Math.round(c1[0] + factor * (c2[0] - c1[0])); const g = Math.round(c1[1] + factor * (c2[1] - c1[1])); const b = Math.round(c1[2] + factor * (c2[2] - c1[2])); - return rgbToHex(`rgb(${r}, ${g}, ${b})`); + return `rgb(${r}, ${g}, ${b})`; }; export const getSpeedColor = (speed, max) => interpolateColor('#FFFF00', '#FF0000', speed / max); |