Qix-/color

Fix luminosity by removing underscore #231

theill posted onGitHub

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch color@4.0.1 for the project I'm working on.

I got an error when trying to call the luminosity because of the underscore. Seems to have been added by mistake?

Here is the diff that solved my problem:

diff --git a/node_modules/color/index.js b/node_modules/color/index.js
index fe8fb60..3c53107 100644
--- a/node_modules/color/index.js
+++ b/node_modules/color/index.js
@@ -251,10 +251,10 @@ Color.prototype = {
         // http://www.w3.org/TR/WCAG20/#relativeluminancedef
         const rgb = this.rgb().color;

-        const lum = [];
+    const lum = [];
         for (const [i, element] of rgb.entries()) {
             const chan = element / 255;
-            lum[i] = (chan <= 0.039_28) ? chan / 12.92 : ((chan + 0.055) / 1.055) ** 2.4;
+            lum[i] = (chan <= 0.03928) ? chan / 12.92 : ((chan + 0.055) / 1.055) ** 2.4;
         }

         return 0.2126 * lum[0] + 0.7152 * lum[1] + 0.0722 * lum[2];

<em>This issue body was partially generated by patch-package.</em>


Fund this Issue

$0.00
Funded

Pull requests