UPD: Match the LED colors more closely

This commit is contained in:
Robert Kossessa
2024-05-20 14:35:20 +02:00
parent 298b7f2eff
commit 7d062af366
3 changed files with 13 additions and 2 deletions

View File

@@ -0,0 +1,9 @@
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)
}

View File

@@ -9,7 +9,7 @@
'bg-black/20': keyObject.pressed 'bg-black/20': keyObject.pressed
}" }"
class="flex aspect-square flex-1 items-center justify-center rounded-[2px] outline-2 transition-all" class="flex aspect-square flex-1 items-center justify-center rounded-[2px] outline-2 transition-all"
:style="`box-shadow: 0 10px 40px -2px ${keyObject.color.hex()}`" :style="`box-shadow: 0 10px 40px -2px ${colorToLED(keyObject.color)?.hex()}`"
@click="$emit('select', key)" @click="$emit('select', key)"
> >
<span <span
@@ -23,6 +23,7 @@
<script setup> <script setup>
import Color from 'color' import Color from 'color'
import { colorToLED } from '@renderer/colorToLED'
defineProps({ defineProps({
keys: { keys: {

View File

@@ -19,13 +19,14 @@
:r="ledRadius" :r="ledRadius"
:cx="size / 2" :cx="size / 2"
:cy="padding + ledRadius" :cy="padding + ledRadius"
:fill="leds[index - 1]?.hex()" :fill="colorToLED(leds[index - 1])?.hex()"
/> />
</svg> </svg>
</template> </template>
<script setup> <script setup>
import { computed, ref, watch } from 'vue' import { computed, ref, watch } from 'vue'
import Color from 'color' import Color from 'color'
import { colorToLED } from '@renderer/colorToLED'
import { useDeviceStore } from '@renderer/deviceStore' import { useDeviceStore } from '@renderer/deviceStore'
const deviceStore = useDeviceStore() const deviceStore = useDeviceStore()