From 294b1688225d43e08eca9c72e59b72141c13f712 Mon Sep 17 00:00:00 2001 From: Robert Kossessa Date: Mon, 5 Feb 2024 15:42:01 +0100 Subject: [PATCH] UPD: Custom light color detection --- src/components/common/HSVInput.vue | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/components/common/HSVInput.vue b/src/components/common/HSVInput.vue index 6446551..8c65e3b 100644 --- a/src/components/common/HSVInput.vue +++ b/src/components/common/HSVInput.vue @@ -6,7 +6,7 @@ :style="{backgroundColor: color.hex()}">
@@ -282,6 +282,13 @@ function shake() { }, 5) } +function isDark(color) { + // YIQ equation from http://24ways.org/2010/calculating-color-contrast + const rgb = color.rgb().color; + const yiq = (rgb[0] * 6126 + rgb[1] * 7152 + rgb[2] * 722) / 10000; // Changed r factor from 2126 + return yiq < 128; +} +