From e6d6a2b59d323cc687656c692fdcc1c7b212cb4b Mon Sep 17 00:00:00 2001 From: Muhammad Muzzammil Date: Sat, 13 Apr 2019 16:38:51 +0530 Subject: [PATCH] Add isColorLight function https://github.com/muhammadmuzzammil1998/shiny-octo-doodle/blob/master/JavaScript/isColorLight.js --- components/Themes/index.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/components/Themes/index.js b/components/Themes/index.js index 7952f15..fca1278 100644 --- a/components/Themes/index.js +++ b/components/Themes/index.js @@ -103,6 +103,20 @@ class Themes extends React.PureComponent { ...themes ] + let isColorLight = color => { + var r, g, b, hsp + color = +("0x" + color.slice(1).replace(color.length < 5 && /./g, '$&$&')) + r = color >> 16 + g = color >> 8 & 255 + b = color & 255; + hsp = Math.sqrt( + 0.299 * (r * r) + + 0.587 * (g * g) + + 0.114 * (b * b) + ) + return hsp > 127.5 + } + return (