mns-mini-zabor/utils/contrast_color.ts

18 lines
472 B
TypeScript

import { Color } from 'three';
import { type ralTypes } from './../components/ral';
import { getColorHexFromRal } from "~/components/ral"
export const contrastColor = (color: ralTypes) => {
const hex = getColorHexFromRal(color)
if (hex) {
const hsl = { h: 0, s: 0, l: 0 }
new Color(hex).getHSL(hsl)
if (hsl.l < 0.5) {
return '#fff'
} else {
return '#000'
}
} else {
return '#000'
}
}