From 87b428c8ded5de7eb246787d281e57793d4bdfc6 Mon Sep 17 00:00:00 2001 From: khisakuni Date: Thu, 17 Dec 2015 23:17:50 -0800 Subject: [PATCH 1/2] return complement of black and white --- tinycolor.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tinycolor.js b/tinycolor.js index 57c7ac5..dfd612d 100644 --- a/tinycolor.js +++ b/tinycolor.js @@ -604,6 +604,11 @@ function spin(color, amount) { function complement(color) { var hsl = tinycolor(color).toHsl(); + if (hsl.l == 1) { + hsl.l = 0; + } else if (hsl.l == 0) { + hsl.l = 1; + } hsl.h = (hsl.h + 180) % 360; return tinycolor(hsl); } From d25e058f7e7a82dcb3888747255d4be4c42c4d9b Mon Sep 17 00:00:00 2001 From: khisakuni Date: Thu, 17 Dec 2015 23:36:32 -0800 Subject: [PATCH 2/2] compare using === --- tinycolor.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tinycolor.js b/tinycolor.js index dfd612d..1155e2d 100644 --- a/tinycolor.js +++ b/tinycolor.js @@ -604,9 +604,9 @@ function spin(color, amount) { function complement(color) { var hsl = tinycolor(color).toHsl(); - if (hsl.l == 1) { + if (hsl.l === 1) { hsl.l = 0; - } else if (hsl.l == 0) { + } else if (hsl.l === 0) { hsl.l = 1; } hsl.h = (hsl.h + 180) % 360;