From 2ecb647f8169800844301cb67952addf97d70478 Mon Sep 17 00:00:00 2001 From: Dmytro Ohorodnykov Date: Tue, 1 Sep 2026 15:59:43 +0300 Subject: [PATCH 1/2] fixed color brightness calculation --- src/colors.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/colors.ts b/src/colors.ts index e9a0a5e..dd9997f 100644 --- a/src/colors.ts +++ b/src/colors.ts @@ -58,9 +58,11 @@ export class Color { return `rgba(${c},${this.a})`; } - /** Get the brightness of this color. */ + /** Get the brightness of this color. + * docs: https://www.w3.org/WAI/WCAG22/Techniques/general/G145 + */ get brightness() { - return (this.r * 299 + this.g * 587 + this.g * 114) / 1000; + return (this.r * 299 + this.g * 587 + this.b * 114) / 1000; } /** Converts this color to an HSL array. */ From bc13fb7b6c7432005fc7d4d3fd757df20eacc754 Mon Sep 17 00:00:00 2001 From: Dmytro Ohorodnykov Date: Tue, 1 Sep 2026 16:12:02 +0300 Subject: [PATCH 2/2] tiny fix --- src/colors.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/colors.ts b/src/colors.ts index dd9997f..6a48a3a 100644 --- a/src/colors.ts +++ b/src/colors.ts @@ -58,7 +58,7 @@ export class Color { return `rgba(${c},${this.a})`; } - /** Get the brightness of this color. + /** Gets the brightness of this color. * docs: https://www.w3.org/WAI/WCAG22/Techniques/general/G145 */ get brightness() {