From c318afc6cafe9a3170a9fba0d7a8858ada6c1feb Mon Sep 17 00:00:00 2001 From: pyoor Date: Thu, 6 Apr 2017 21:49:07 +0200 Subject: [PATCH 1/2] Updated jshint to be aware of globals "Random" and "make" --- .jshintrc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.jshintrc b/.jshintrc index ba30a6c..3c71666 100644 --- a/.jshintrc +++ b/.jshintrc @@ -12,5 +12,11 @@ "eqnull": true, "node": true, "maxerr": 2000, - "esversion": 6 -} + "esversion": 6, + "undef": true, + "unused": true, + "globals": { + "Random": true, + "make": true + } +} \ No newline at end of file From 0f4fe5c99c1c7a68ab2b10f1022801c20c4c1e94 Mon Sep 17 00:00:00 2001 From: pyoor Date: Thu, 6 Apr 2017 21:51:04 +0200 Subject: [PATCH 2/2] Initialize "make" directory with "colors.js" module --- make/colors.js | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 make/colors.js diff --git a/make/colors.js b/make/colors.js new file mode 100644 index 0000000..95d7210 --- /dev/null +++ b/make/colors.js @@ -0,0 +1,80 @@ +make.colors = { + colors: function() { + return Random.pick([ + make.colorRGB, + make.colorHSL, + make.colorKeywords + ]); + }, + + colorRGB: function() { + let values; + + switch (Random.number(4)) { + case 0: + // Rgb functional notation + if (Random.bool()) { + // Ints + values = [Random.number(255), Random.number(255), Random.number(255)]; + } else { + // Percents + values = ["%" + Random.number(255), "%" + Random.number(255), "%" + Random.number(255)]; + } + return "rgba(" + values.join(',') + ")"; + case 1: + // Rgba functional notation + values = [Random.number(255), Random.number(255), Random.number(255), Random.float()]; + return "rgba(" + values.join(',') + ")"; + case 2: + // 4 char hex + return "#" + Random.hex(4); + default: + // 8 char hex + return "#" + Random.hex(8); + } + }, + + colorHSL: function() { + let values, opt; + switch(Random.number(4)) { + case 0: + values = [Random.number(255), "%" + Random.number(255), "%" + Random.number(255)]; + return "hsl(" + values.join(',') + ")"; + case 1: + values = [Random.number(255), "%" + Random.number(255), "%" + Random.number(255), "%" + Random.number(255)]; + return "hsl(" + values.join(',') + ")"; + case 2: + opt = Random.pick(['deg', 'rad', 'grad', 'turn']); + values = [Random.number(255) + opt, "%" + Random.number(255), "%" + Random.number(255), "%" + Random.number(255)]; + return "hsl(" + values.join(',') + ")"; + default: + values = [Random.number(255), "%" + Random.number(255), "%" + Random.number(255), Random.float()]; + return "hsl(" + values.join(',') + ")"; + } + }, + + colorKeywords: function() { + return Random.pick([ + "lime", "red", "blue", "invert", "currentColor", "ActiveBorder", "ActiveCaption", + "AppWorkspace", "Background", "ButtonFace", "ButtonHighlight", "ButtonShadow", + "ButtonText", "CaptionText", "GrayText", "Highlight", "HighlightText", + "InactiveBorder", "InactiveCaption", "InactiveCaptionText", "InfoBackground", + "InfoText", "Menu", "MenuText", "Scrollbar", "ThreeDDarkShadow", "ThreeDFace", + "ThreeDHighlight", "ThreeDLightShadow", "ThreeDShadow", "Window", "WindowFrame", + "WindowText", "-moz-ButtonDefault", "-moz-ButtonHoverFace", "-moz-ButtonHoverText", + "-moz-CellHighlight", "-moz-CellHighlightText", "-moz-Combobox", "-moz-ComboboxText", + "-moz-Dialog", "-moz-DialogText", "-moz-dragtargetzone", "-moz-EvenTreeRow", + "-moz-Field", "-moz-FieldText", "-moz-html-CellHighlight", + "-moz-html-CellHighlightText", "-moz-mac-accentdarkestshadow", + "-moz-mac-accentdarkshadow", "-moz-mac-accentface", + "-moz-mac-accentlightesthighlight", "-moz-mac-accentlightshadow", + "-moz-mac-accentregularhighlight", "-moz-mac-accentregularshadow", + "-moz-mac-chrome-active", "-moz-mac-chrome-inactive", "-moz-mac-focusring", + "-moz-mac-menuselect", "-moz-mac-menushadow", "-moz-mac-menutextselect", + "-moz-MenuHover", "-moz-MenuHoverText", "-moz-MenuBarText", "-moz-MenuBarHoverText", + "-moz-nativehyperlinktext", "-moz-OddTreeRow", "-moz-win-communicationstext", + "-moz-win-mediatext", "-moz-activehyperlinktext", "-moz-default-background-color", + "-moz-default-color", "-moz-hyperlinktext", "-moz-visitedhyperlinktext" + ]); + } +}; \ No newline at end of file