Last active
September 19, 2015 17:42
-
-
Save Maxim-Filimonov/48c4ec6a3430fa7d8d2b to your computer and use it in GitHub Desktop.
Revisions
-
Maxim-Filimonov revised this gist
Sep 14, 2015 . No changes.There are no files selected for viewing
-
Maxim-Filimonov created this gist
Sep 14, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,7 @@ // Functional var log = function(tag,val) { console.log(tag, val); return val; } var isLightBackground = function(color) { // 765 - max distance log("color:",color); return log("result:", log("distance:", xcolor.distance(color, 'white')) < (765/2)); }; This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,7 @@ // Original // Function determines is background light enough to show dark logo. var isLightBackground = function(color) { // 765 - max distance return xcolor.distance(color, 'white') < (765/2); }; // The task is to add some logs to see what are results getting returned This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,6 @@ var R = require('ramda'); var log = R.curry(function(tag,val) { console.log(tag, val); return val; }); var distanceFromWhiteColor = R.flip(x.color.distance)('white'); var isLightDistance = R.lt(765/2); var isLightBackground = R.compose(log("result:"), isLighterDistance, log("distance:"), distanceFromWhiteColor, log("color:")); This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,11 @@ var isLightBackground = function(color) { console.log("color:", color); var distance = xcolor.distance(color, 'white'); console.log("distance:", distance); // 765 - max distance var isLight = distance < (765/2)); console.log("result:", isLight); return isLight; };