From 9dcc3b7190083a999eb932f8ca696988ace96da7 Mon Sep 17 00:00:00 2001 From: Josh Junon Date: Tue, 5 Apr 2022 11:08:18 +0200 Subject: [PATCH] update YIQ formula constants (fixes #107, ref chartjs/chartjs-color#2) --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 9d6d637..c97c605 100644 --- a/index.js +++ b/index.js @@ -298,7 +298,7 @@ Color.prototype = { isDark() { // YIQ equation from http://24ways.org/2010/calculating-color-contrast const rgb = this.rgb().color; - const yiq = (rgb[0] * 299 + rgb[1] * 587 + rgb[2] * 114) / 1000; + const yiq = (rgb[0] * 2126 + rgb[1] * 7152 + rgb[2] * 722) / 10_000; return yiq < 128; },