FIX: LED Colors (in hsv now)

This commit is contained in:
Robert Kossessa
2024-05-20 16:28:09 +02:00
parent 7d062af366
commit bc3caf7764

View File

@@ -2,8 +2,8 @@ import Color from 'color'
export const colorToLED = (color: Color) => {
if (!color) return null
const l = color.lightness()
if (l < 0.5) return color.lightness(0)
const nl = 1 - Math.pow(l / 50 - 1, 4)
return color.lightness(nl * 35 + 20)
const l = color.value()
if (l < 1) return color
const nl = 1 - Math.pow(l / 100 - 1, 2)
return color.value(nl * 70 + 30)
}