octo-deno/make/colors.js

81 lines
3.4 KiB
JavaScript
Raw Normal View History

make.colors = {
2017-04-22 20:07:29 +00:00
colors: function () {
2017-04-13 02:14:02 +00:00
return random.pick([
2017-04-22 19:02:38 +00:00
make.colors.colorRGB,
make.colors.colorHSL,
make.colors.colorKeywords
]);
},
2017-04-22 20:07:29 +00:00
colorRGB: function () {
let values;
2017-04-22 20:07:29 +00:00
2017-04-13 02:14:02 +00:00
switch (random.number(4)) {
case 0:
// Rgb functional notation
2017-04-13 02:14:02 +00:00
if (random.bool()) {
// Ints
2017-04-13 02:14:02 +00:00
values = [random.number(255), random.number(255), random.number(255)];
} else {
// Percents
2017-04-13 02:14:02 +00:00
values = ["%" + random.number(255), "%" + random.number(255), "%" + random.number(255)];
}
return "rgba(" + values.join(',') + ")";
case 1:
// Rgba functional notation
2017-04-13 02:14:02 +00:00
values = [random.number(255), random.number(255), random.number(255), random.float()];
return "rgba(" + values.join(',') + ")";
case 2:
// 4 char hex
2017-04-13 02:14:02 +00:00
return "#" + random.hex(4);
default:
// 8 char hex
2017-04-13 02:14:02 +00:00
return "#" + random.hex(8);
}
},
2017-04-22 20:07:29 +00:00
colorHSL: function () {
let values, opt;
2017-04-13 13:20:58 +00:00
2017-04-22 20:07:29 +00:00
switch (random.number(4)) {
case 0:
2017-04-13 02:14:02 +00:00
values = [random.number(255), "%" + random.number(255), "%" + random.number(255)];
return "hsl(" + values.join(',') + ")";
case 1:
2017-04-13 02:14:02 +00:00
values = [random.number(255), "%" + random.number(255), "%" + random.number(255), "%" + random.number(255)];
return "hsl(" + values.join(',') + ")";
case 2:
2017-04-13 02:14:02 +00:00
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:
2017-04-13 02:14:02 +00:00
values = [random.number(255), "%" + random.number(255), "%" + random.number(255), random.float()];
return "hsl(" + values.join(',') + ")";
}
},
2017-04-22 20:07:29 +00:00
colorKeywords: function () {
2017-04-13 02:14:02 +00:00
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"
]);
}
};