18 lines
473 B
TypeScript
18 lines
473 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.45) {
|
|
return '#fff'
|
|
} else {
|
|
return '#000'
|
|
}
|
|
} else {
|
|
return '#000'
|
|
}
|
|
} |