Edit File by line
/home/barbar84/www/wp-inclu.../js/dist
File: components.js
[48500] Fix | Delete
// `rgbaToHex`
[48501] Fix | Delete
// Converts an RGBA color plus alpha transparency to hex
[48502] Fix | Delete
// Assumes r, g, b are contained in the set [0, 255] and
[48503] Fix | Delete
// a in [0, 1]. Returns a 4 or 8 character rgba hex
[48504] Fix | Delete
function rgbaToHex(r, g, b, a, allow4Char) {
[48505] Fix | Delete
[48506] Fix | Delete
var hex = [
[48507] Fix | Delete
pad2(mathRound(r).toString(16)),
[48508] Fix | Delete
pad2(mathRound(g).toString(16)),
[48509] Fix | Delete
pad2(mathRound(b).toString(16)),
[48510] Fix | Delete
pad2(convertDecimalToHex(a))
[48511] Fix | Delete
];
[48512] Fix | Delete
[48513] Fix | Delete
// Return a 4 character hex if possible
[48514] Fix | Delete
if (allow4Char && hex[0].charAt(0) == hex[0].charAt(1) && hex[1].charAt(0) == hex[1].charAt(1) && hex[2].charAt(0) == hex[2].charAt(1) && hex[3].charAt(0) == hex[3].charAt(1)) {
[48515] Fix | Delete
return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0) + hex[3].charAt(0);
[48516] Fix | Delete
}
[48517] Fix | Delete
[48518] Fix | Delete
return hex.join("");
[48519] Fix | Delete
}
[48520] Fix | Delete
[48521] Fix | Delete
// `rgbaToArgbHex`
[48522] Fix | Delete
// Converts an RGBA color to an ARGB Hex8 string
[48523] Fix | Delete
// Rarely used, but required for "toFilter()"
[48524] Fix | Delete
function rgbaToArgbHex(r, g, b, a) {
[48525] Fix | Delete
[48526] Fix | Delete
var hex = [
[48527] Fix | Delete
pad2(convertDecimalToHex(a)),
[48528] Fix | Delete
pad2(mathRound(r).toString(16)),
[48529] Fix | Delete
pad2(mathRound(g).toString(16)),
[48530] Fix | Delete
pad2(mathRound(b).toString(16))
[48531] Fix | Delete
];
[48532] Fix | Delete
[48533] Fix | Delete
return hex.join("");
[48534] Fix | Delete
}
[48535] Fix | Delete
[48536] Fix | Delete
// `equals`
[48537] Fix | Delete
// Can be called with any tinycolor input
[48538] Fix | Delete
tinycolor.equals = function (color1, color2) {
[48539] Fix | Delete
if (!color1 || !color2) { return false; }
[48540] Fix | Delete
return tinycolor(color1).toRgbString() == tinycolor(color2).toRgbString();
[48541] Fix | Delete
};
[48542] Fix | Delete
[48543] Fix | Delete
tinycolor.random = function() {
[48544] Fix | Delete
return tinycolor.fromRatio({
[48545] Fix | Delete
r: mathRandom(),
[48546] Fix | Delete
g: mathRandom(),
[48547] Fix | Delete
b: mathRandom()
[48548] Fix | Delete
});
[48549] Fix | Delete
};
[48550] Fix | Delete
[48551] Fix | Delete
[48552] Fix | Delete
// Modification Functions
[48553] Fix | Delete
// ----------------------
[48554] Fix | Delete
// Thanks to less.js for some of the basics here
[48555] Fix | Delete
// <https://github.com/cloudhead/less.js/blob/master/lib/less/functions.js>
[48556] Fix | Delete
[48557] Fix | Delete
function desaturate(color, amount) {
[48558] Fix | Delete
amount = (amount === 0) ? 0 : (amount || 10);
[48559] Fix | Delete
var hsl = tinycolor(color).toHsl();
[48560] Fix | Delete
hsl.s -= amount / 100;
[48561] Fix | Delete
hsl.s = clamp01(hsl.s);
[48562] Fix | Delete
return tinycolor(hsl);
[48563] Fix | Delete
}
[48564] Fix | Delete
[48565] Fix | Delete
function saturate(color, amount) {
[48566] Fix | Delete
amount = (amount === 0) ? 0 : (amount || 10);
[48567] Fix | Delete
var hsl = tinycolor(color).toHsl();
[48568] Fix | Delete
hsl.s += amount / 100;
[48569] Fix | Delete
hsl.s = clamp01(hsl.s);
[48570] Fix | Delete
return tinycolor(hsl);
[48571] Fix | Delete
}
[48572] Fix | Delete
[48573] Fix | Delete
function greyscale(color) {
[48574] Fix | Delete
return tinycolor(color).desaturate(100);
[48575] Fix | Delete
}
[48576] Fix | Delete
[48577] Fix | Delete
function lighten (color, amount) {
[48578] Fix | Delete
amount = (amount === 0) ? 0 : (amount || 10);
[48579] Fix | Delete
var hsl = tinycolor(color).toHsl();
[48580] Fix | Delete
hsl.l += amount / 100;
[48581] Fix | Delete
hsl.l = clamp01(hsl.l);
[48582] Fix | Delete
return tinycolor(hsl);
[48583] Fix | Delete
}
[48584] Fix | Delete
[48585] Fix | Delete
function brighten(color, amount) {
[48586] Fix | Delete
amount = (amount === 0) ? 0 : (amount || 10);
[48587] Fix | Delete
var rgb = tinycolor(color).toRgb();
[48588] Fix | Delete
rgb.r = mathMax(0, mathMin(255, rgb.r - mathRound(255 * - (amount / 100))));
[48589] Fix | Delete
rgb.g = mathMax(0, mathMin(255, rgb.g - mathRound(255 * - (amount / 100))));
[48590] Fix | Delete
rgb.b = mathMax(0, mathMin(255, rgb.b - mathRound(255 * - (amount / 100))));
[48591] Fix | Delete
return tinycolor(rgb);
[48592] Fix | Delete
}
[48593] Fix | Delete
[48594] Fix | Delete
function darken (color, amount) {
[48595] Fix | Delete
amount = (amount === 0) ? 0 : (amount || 10);
[48596] Fix | Delete
var hsl = tinycolor(color).toHsl();
[48597] Fix | Delete
hsl.l -= amount / 100;
[48598] Fix | Delete
hsl.l = clamp01(hsl.l);
[48599] Fix | Delete
return tinycolor(hsl);
[48600] Fix | Delete
}
[48601] Fix | Delete
[48602] Fix | Delete
// Spin takes a positive or negative amount within [-360, 360] indicating the change of hue.
[48603] Fix | Delete
// Values outside of this range will be wrapped into this range.
[48604] Fix | Delete
function spin(color, amount) {
[48605] Fix | Delete
var hsl = tinycolor(color).toHsl();
[48606] Fix | Delete
var hue = (hsl.h + amount) % 360;
[48607] Fix | Delete
hsl.h = hue < 0 ? 360 + hue : hue;
[48608] Fix | Delete
return tinycolor(hsl);
[48609] Fix | Delete
}
[48610] Fix | Delete
[48611] Fix | Delete
// Combination Functions
[48612] Fix | Delete
// ---------------------
[48613] Fix | Delete
// Thanks to jQuery xColor for some of the ideas behind these
[48614] Fix | Delete
// <https://github.com/infusion/jQuery-xcolor/blob/master/jquery.xcolor.js>
[48615] Fix | Delete
[48616] Fix | Delete
function complement(color) {
[48617] Fix | Delete
var hsl = tinycolor(color).toHsl();
[48618] Fix | Delete
hsl.h = (hsl.h + 180) % 360;
[48619] Fix | Delete
return tinycolor(hsl);
[48620] Fix | Delete
}
[48621] Fix | Delete
[48622] Fix | Delete
function triad(color) {
[48623] Fix | Delete
var hsl = tinycolor(color).toHsl();
[48624] Fix | Delete
var h = hsl.h;
[48625] Fix | Delete
return [
[48626] Fix | Delete
tinycolor(color),
[48627] Fix | Delete
tinycolor({ h: (h + 120) % 360, s: hsl.s, l: hsl.l }),
[48628] Fix | Delete
tinycolor({ h: (h + 240) % 360, s: hsl.s, l: hsl.l })
[48629] Fix | Delete
];
[48630] Fix | Delete
}
[48631] Fix | Delete
[48632] Fix | Delete
function tetrad(color) {
[48633] Fix | Delete
var hsl = tinycolor(color).toHsl();
[48634] Fix | Delete
var h = hsl.h;
[48635] Fix | Delete
return [
[48636] Fix | Delete
tinycolor(color),
[48637] Fix | Delete
tinycolor({ h: (h + 90) % 360, s: hsl.s, l: hsl.l }),
[48638] Fix | Delete
tinycolor({ h: (h + 180) % 360, s: hsl.s, l: hsl.l }),
[48639] Fix | Delete
tinycolor({ h: (h + 270) % 360, s: hsl.s, l: hsl.l })
[48640] Fix | Delete
];
[48641] Fix | Delete
}
[48642] Fix | Delete
[48643] Fix | Delete
function splitcomplement(color) {
[48644] Fix | Delete
var hsl = tinycolor(color).toHsl();
[48645] Fix | Delete
var h = hsl.h;
[48646] Fix | Delete
return [
[48647] Fix | Delete
tinycolor(color),
[48648] Fix | Delete
tinycolor({ h: (h + 72) % 360, s: hsl.s, l: hsl.l}),
[48649] Fix | Delete
tinycolor({ h: (h + 216) % 360, s: hsl.s, l: hsl.l})
[48650] Fix | Delete
];
[48651] Fix | Delete
}
[48652] Fix | Delete
[48653] Fix | Delete
function analogous(color, results, slices) {
[48654] Fix | Delete
results = results || 6;
[48655] Fix | Delete
slices = slices || 30;
[48656] Fix | Delete
[48657] Fix | Delete
var hsl = tinycolor(color).toHsl();
[48658] Fix | Delete
var part = 360 / slices;
[48659] Fix | Delete
var ret = [tinycolor(color)];
[48660] Fix | Delete
[48661] Fix | Delete
for (hsl.h = ((hsl.h - (part * results >> 1)) + 720) % 360; --results; ) {
[48662] Fix | Delete
hsl.h = (hsl.h + part) % 360;
[48663] Fix | Delete
ret.push(tinycolor(hsl));
[48664] Fix | Delete
}
[48665] Fix | Delete
return ret;
[48666] Fix | Delete
}
[48667] Fix | Delete
[48668] Fix | Delete
function monochromatic(color, results) {
[48669] Fix | Delete
results = results || 6;
[48670] Fix | Delete
var hsv = tinycolor(color).toHsv();
[48671] Fix | Delete
var h = hsv.h, s = hsv.s, v = hsv.v;
[48672] Fix | Delete
var ret = [];
[48673] Fix | Delete
var modification = 1 / results;
[48674] Fix | Delete
[48675] Fix | Delete
while (results--) {
[48676] Fix | Delete
ret.push(tinycolor({ h: h, s: s, v: v}));
[48677] Fix | Delete
v = (v + modification) % 1;
[48678] Fix | Delete
}
[48679] Fix | Delete
[48680] Fix | Delete
return ret;
[48681] Fix | Delete
}
[48682] Fix | Delete
[48683] Fix | Delete
// Utility Functions
[48684] Fix | Delete
// ---------------------
[48685] Fix | Delete
[48686] Fix | Delete
tinycolor.mix = function(color1, color2, amount) {
[48687] Fix | Delete
amount = (amount === 0) ? 0 : (amount || 50);
[48688] Fix | Delete
[48689] Fix | Delete
var rgb1 = tinycolor(color1).toRgb();
[48690] Fix | Delete
var rgb2 = tinycolor(color2).toRgb();
[48691] Fix | Delete
[48692] Fix | Delete
var p = amount / 100;
[48693] Fix | Delete
[48694] Fix | Delete
var rgba = {
[48695] Fix | Delete
r: ((rgb2.r - rgb1.r) * p) + rgb1.r,
[48696] Fix | Delete
g: ((rgb2.g - rgb1.g) * p) + rgb1.g,
[48697] Fix | Delete
b: ((rgb2.b - rgb1.b) * p) + rgb1.b,
[48698] Fix | Delete
a: ((rgb2.a - rgb1.a) * p) + rgb1.a
[48699] Fix | Delete
};
[48700] Fix | Delete
[48701] Fix | Delete
return tinycolor(rgba);
[48702] Fix | Delete
};
[48703] Fix | Delete
[48704] Fix | Delete
[48705] Fix | Delete
// Readability Functions
[48706] Fix | Delete
// ---------------------
[48707] Fix | Delete
// <http://www.w3.org/TR/2008/REC-WCAG20-20081211/#contrast-ratiodef (WCAG Version 2)
[48708] Fix | Delete
[48709] Fix | Delete
// `contrast`
[48710] Fix | Delete
// Analyze the 2 colors and returns the color contrast defined by (WCAG Version 2)
[48711] Fix | Delete
tinycolor.readability = function(color1, color2) {
[48712] Fix | Delete
var c1 = tinycolor(color1);
[48713] Fix | Delete
var c2 = tinycolor(color2);
[48714] Fix | Delete
return (Math.max(c1.getLuminance(),c2.getLuminance())+0.05) / (Math.min(c1.getLuminance(),c2.getLuminance())+0.05);
[48715] Fix | Delete
};
[48716] Fix | Delete
[48717] Fix | Delete
// `isReadable`
[48718] Fix | Delete
// Ensure that foreground and background color combinations meet WCAG2 guidelines.
[48719] Fix | Delete
// The third argument is an optional Object.
[48720] Fix | Delete
// the 'level' property states 'AA' or 'AAA' - if missing or invalid, it defaults to 'AA';
[48721] Fix | Delete
// the 'size' property states 'large' or 'small' - if missing or invalid, it defaults to 'small'.
[48722] Fix | Delete
// If the entire object is absent, isReadable defaults to {level:"AA",size:"small"}.
[48723] Fix | Delete
[48724] Fix | Delete
// *Example*
[48725] Fix | Delete
// tinycolor.isReadable("#000", "#111") => false
[48726] Fix | Delete
// tinycolor.isReadable("#000", "#111",{level:"AA",size:"large"}) => false
[48727] Fix | Delete
tinycolor.isReadable = function(color1, color2, wcag2) {
[48728] Fix | Delete
var readability = tinycolor.readability(color1, color2);
[48729] Fix | Delete
var wcag2Parms, out;
[48730] Fix | Delete
[48731] Fix | Delete
out = false;
[48732] Fix | Delete
[48733] Fix | Delete
wcag2Parms = validateWCAG2Parms(wcag2);
[48734] Fix | Delete
switch (wcag2Parms.level + wcag2Parms.size) {
[48735] Fix | Delete
case "AAsmall":
[48736] Fix | Delete
case "AAAlarge":
[48737] Fix | Delete
out = readability >= 4.5;
[48738] Fix | Delete
break;
[48739] Fix | Delete
case "AAlarge":
[48740] Fix | Delete
out = readability >= 3;
[48741] Fix | Delete
break;
[48742] Fix | Delete
case "AAAsmall":
[48743] Fix | Delete
out = readability >= 7;
[48744] Fix | Delete
break;
[48745] Fix | Delete
}
[48746] Fix | Delete
return out;
[48747] Fix | Delete
[48748] Fix | Delete
};
[48749] Fix | Delete
[48750] Fix | Delete
// `mostReadable`
[48751] Fix | Delete
// Given a base color and a list of possible foreground or background
[48752] Fix | Delete
// colors for that base, returns the most readable color.
[48753] Fix | Delete
// Optionally returns Black or White if the most readable color is unreadable.
[48754] Fix | Delete
// *Example*
[48755] Fix | Delete
// tinycolor.mostReadable(tinycolor.mostReadable("#123", ["#124", "#125"],{includeFallbackColors:false}).toHexString(); // "#112255"
[48756] Fix | Delete
// tinycolor.mostReadable(tinycolor.mostReadable("#123", ["#124", "#125"],{includeFallbackColors:true}).toHexString(); // "#ffffff"
[48757] Fix | Delete
// tinycolor.mostReadable("#a8015a", ["#faf3f3"],{includeFallbackColors:true,level:"AAA",size:"large"}).toHexString(); // "#faf3f3"
[48758] Fix | Delete
// tinycolor.mostReadable("#a8015a", ["#faf3f3"],{includeFallbackColors:true,level:"AAA",size:"small"}).toHexString(); // "#ffffff"
[48759] Fix | Delete
tinycolor.mostReadable = function(baseColor, colorList, args) {
[48760] Fix | Delete
var bestColor = null;
[48761] Fix | Delete
var bestScore = 0;
[48762] Fix | Delete
var readability;
[48763] Fix | Delete
var includeFallbackColors, level, size ;
[48764] Fix | Delete
args = args || {};
[48765] Fix | Delete
includeFallbackColors = args.includeFallbackColors ;
[48766] Fix | Delete
level = args.level;
[48767] Fix | Delete
size = args.size;
[48768] Fix | Delete
[48769] Fix | Delete
for (var i= 0; i < colorList.length ; i++) {
[48770] Fix | Delete
readability = tinycolor.readability(baseColor, colorList[i]);
[48771] Fix | Delete
if (readability > bestScore) {
[48772] Fix | Delete
bestScore = readability;
[48773] Fix | Delete
bestColor = tinycolor(colorList[i]);
[48774] Fix | Delete
}
[48775] Fix | Delete
}
[48776] Fix | Delete
[48777] Fix | Delete
if (tinycolor.isReadable(baseColor, bestColor, {"level":level,"size":size}) || !includeFallbackColors) {
[48778] Fix | Delete
return bestColor;
[48779] Fix | Delete
}
[48780] Fix | Delete
else {
[48781] Fix | Delete
args.includeFallbackColors=false;
[48782] Fix | Delete
return tinycolor.mostReadable(baseColor,["#fff", "#000"],args);
[48783] Fix | Delete
}
[48784] Fix | Delete
};
[48785] Fix | Delete
[48786] Fix | Delete
[48787] Fix | Delete
// Big List of Colors
[48788] Fix | Delete
// ------------------
[48789] Fix | Delete
// <http://www.w3.org/TR/css3-color/#svg-color>
[48790] Fix | Delete
var names = tinycolor.names = {
[48791] Fix | Delete
aliceblue: "f0f8ff",
[48792] Fix | Delete
antiquewhite: "faebd7",
[48793] Fix | Delete
aqua: "0ff",
[48794] Fix | Delete
aquamarine: "7fffd4",
[48795] Fix | Delete
azure: "f0ffff",
[48796] Fix | Delete
beige: "f5f5dc",
[48797] Fix | Delete
bisque: "ffe4c4",
[48798] Fix | Delete
black: "000",
[48799] Fix | Delete
blanchedalmond: "ffebcd",
[48800] Fix | Delete
blue: "00f",
[48801] Fix | Delete
blueviolet: "8a2be2",
[48802] Fix | Delete
brown: "a52a2a",
[48803] Fix | Delete
burlywood: "deb887",
[48804] Fix | Delete
burntsienna: "ea7e5d",
[48805] Fix | Delete
cadetblue: "5f9ea0",
[48806] Fix | Delete
chartreuse: "7fff00",
[48807] Fix | Delete
chocolate: "d2691e",
[48808] Fix | Delete
coral: "ff7f50",
[48809] Fix | Delete
cornflowerblue: "6495ed",
[48810] Fix | Delete
cornsilk: "fff8dc",
[48811] Fix | Delete
crimson: "dc143c",
[48812] Fix | Delete
cyan: "0ff",
[48813] Fix | Delete
darkblue: "00008b",
[48814] Fix | Delete
darkcyan: "008b8b",
[48815] Fix | Delete
darkgoldenrod: "b8860b",
[48816] Fix | Delete
darkgray: "a9a9a9",
[48817] Fix | Delete
darkgreen: "006400",
[48818] Fix | Delete
darkgrey: "a9a9a9",
[48819] Fix | Delete
darkkhaki: "bdb76b",
[48820] Fix | Delete
darkmagenta: "8b008b",
[48821] Fix | Delete
darkolivegreen: "556b2f",
[48822] Fix | Delete
darkorange: "ff8c00",
[48823] Fix | Delete
darkorchid: "9932cc",
[48824] Fix | Delete
darkred: "8b0000",
[48825] Fix | Delete
darksalmon: "e9967a",
[48826] Fix | Delete
darkseagreen: "8fbc8f",
[48827] Fix | Delete
darkslateblue: "483d8b",
[48828] Fix | Delete
darkslategray: "2f4f4f",
[48829] Fix | Delete
darkslategrey: "2f4f4f",
[48830] Fix | Delete
darkturquoise: "00ced1",
[48831] Fix | Delete
darkviolet: "9400d3",
[48832] Fix | Delete
deeppink: "ff1493",
[48833] Fix | Delete
deepskyblue: "00bfff",
[48834] Fix | Delete
dimgray: "696969",
[48835] Fix | Delete
dimgrey: "696969",
[48836] Fix | Delete
dodgerblue: "1e90ff",
[48837] Fix | Delete
firebrick: "b22222",
[48838] Fix | Delete
floralwhite: "fffaf0",
[48839] Fix | Delete
forestgreen: "228b22",
[48840] Fix | Delete
fuchsia: "f0f",
[48841] Fix | Delete
gainsboro: "dcdcdc",
[48842] Fix | Delete
ghostwhite: "f8f8ff",
[48843] Fix | Delete
gold: "ffd700",
[48844] Fix | Delete
goldenrod: "daa520",
[48845] Fix | Delete
gray: "808080",
[48846] Fix | Delete
green: "008000",
[48847] Fix | Delete
greenyellow: "adff2f",
[48848] Fix | Delete
grey: "808080",
[48849] Fix | Delete
honeydew: "f0fff0",
[48850] Fix | Delete
hotpink: "ff69b4",
[48851] Fix | Delete
indianred: "cd5c5c",
[48852] Fix | Delete
indigo: "4b0082",
[48853] Fix | Delete
ivory: "fffff0",
[48854] Fix | Delete
khaki: "f0e68c",
[48855] Fix | Delete
lavender: "e6e6fa",
[48856] Fix | Delete
lavenderblush: "fff0f5",
[48857] Fix | Delete
lawngreen: "7cfc00",
[48858] Fix | Delete
lemonchiffon: "fffacd",
[48859] Fix | Delete
lightblue: "add8e6",
[48860] Fix | Delete
lightcoral: "f08080",
[48861] Fix | Delete
lightcyan: "e0ffff",
[48862] Fix | Delete
lightgoldenrodyellow: "fafad2",
[48863] Fix | Delete
lightgray: "d3d3d3",
[48864] Fix | Delete
lightgreen: "90ee90",
[48865] Fix | Delete
lightgrey: "d3d3d3",
[48866] Fix | Delete
lightpink: "ffb6c1",
[48867] Fix | Delete
lightsalmon: "ffa07a",
[48868] Fix | Delete
lightseagreen: "20b2aa",
[48869] Fix | Delete
lightskyblue: "87cefa",
[48870] Fix | Delete
lightslategray: "789",
[48871] Fix | Delete
lightslategrey: "789",
[48872] Fix | Delete
lightsteelblue: "b0c4de",
[48873] Fix | Delete
lightyellow: "ffffe0",
[48874] Fix | Delete
lime: "0f0",
[48875] Fix | Delete
limegreen: "32cd32",
[48876] Fix | Delete
linen: "faf0e6",
[48877] Fix | Delete
magenta: "f0f",
[48878] Fix | Delete
maroon: "800000",
[48879] Fix | Delete
mediumaquamarine: "66cdaa",
[48880] Fix | Delete
mediumblue: "0000cd",
[48881] Fix | Delete
mediumorchid: "ba55d3",
[48882] Fix | Delete
mediumpurple: "9370db",
[48883] Fix | Delete
mediumseagreen: "3cb371",
[48884] Fix | Delete
mediumslateblue: "7b68ee",
[48885] Fix | Delete
mediumspringgreen: "00fa9a",
[48886] Fix | Delete
mediumturquoise: "48d1cc",
[48887] Fix | Delete
mediumvioletred: "c71585",
[48888] Fix | Delete
midnightblue: "191970",
[48889] Fix | Delete
mintcream: "f5fffa",
[48890] Fix | Delete
mistyrose: "ffe4e1",
[48891] Fix | Delete
moccasin: "ffe4b5",
[48892] Fix | Delete
navajowhite: "ffdead",
[48893] Fix | Delete
navy: "000080",
[48894] Fix | Delete
oldlace: "fdf5e6",
[48895] Fix | Delete
olive: "808000",
[48896] Fix | Delete
olivedrab: "6b8e23",
[48897] Fix | Delete
orange: "ffa500",
[48898] Fix | Delete
orangered: "ff4500",
[48899] Fix | Delete
orchid: "da70d6",
[48900] Fix | Delete
palegoldenrod: "eee8aa",
[48901] Fix | Delete
palegreen: "98fb98",
[48902] Fix | Delete
paleturquoise: "afeeee",
[48903] Fix | Delete
palevioletred: "db7093",
[48904] Fix | Delete
papayawhip: "ffefd5",
[48905] Fix | Delete
peachpuff: "ffdab9",
[48906] Fix | Delete
peru: "cd853f",
[48907] Fix | Delete
pink: "ffc0cb",
[48908] Fix | Delete
plum: "dda0dd",
[48909] Fix | Delete
powderblue: "b0e0e6",
[48910] Fix | Delete
purple: "800080",
[48911] Fix | Delete
rebeccapurple: "663399",
[48912] Fix | Delete
red: "f00",
[48913] Fix | Delete
rosybrown: "bc8f8f",
[48914] Fix | Delete
royalblue: "4169e1",
[48915] Fix | Delete
saddlebrown: "8b4513",
[48916] Fix | Delete
salmon: "fa8072",
[48917] Fix | Delete
sandybrown: "f4a460",
[48918] Fix | Delete
seagreen: "2e8b57",
[48919] Fix | Delete
seashell: "fff5ee",
[48920] Fix | Delete
sienna: "a0522d",
[48921] Fix | Delete
silver: "c0c0c0",
[48922] Fix | Delete
skyblue: "87ceeb",
[48923] Fix | Delete
slateblue: "6a5acd",
[48924] Fix | Delete
slategray: "708090",
[48925] Fix | Delete
slategrey: "708090",
[48926] Fix | Delete
snow: "fffafa",
[48927] Fix | Delete
springgreen: "00ff7f",
[48928] Fix | Delete
steelblue: "4682b4",
[48929] Fix | Delete
tan: "d2b48c",
[48930] Fix | Delete
teal: "008080",
[48931] Fix | Delete
thistle: "d8bfd8",
[48932] Fix | Delete
tomato: "ff6347",
[48933] Fix | Delete
turquoise: "40e0d0",
[48934] Fix | Delete
violet: "ee82ee",
[48935] Fix | Delete
wheat: "f5deb3",
[48936] Fix | Delete
white: "fff",
[48937] Fix | Delete
whitesmoke: "f5f5f5",
[48938] Fix | Delete
yellow: "ff0",
[48939] Fix | Delete
yellowgreen: "9acd32"
[48940] Fix | Delete
};
[48941] Fix | Delete
[48942] Fix | Delete
// Make it easy to access colors via `hexNames[hex]`
[48943] Fix | Delete
var hexNames = tinycolor.hexNames = flip(names);
[48944] Fix | Delete
[48945] Fix | Delete
[48946] Fix | Delete
// Utilities
[48947] Fix | Delete
// ---------
[48948] Fix | Delete
[48949] Fix | Delete
// `{ 'name1': 'val1' }` becomes `{ 'val1': 'name1' }`
[48950] Fix | Delete
function flip(o) {
[48951] Fix | Delete
var flipped = { };
[48952] Fix | Delete
for (var i in o) {
[48953] Fix | Delete
if (o.hasOwnProperty(i)) {
[48954] Fix | Delete
flipped[o[i]] = i;
[48955] Fix | Delete
}
[48956] Fix | Delete
}
[48957] Fix | Delete
return flipped;
[48958] Fix | Delete
}
[48959] Fix | Delete
[48960] Fix | Delete
// Return a valid alpha value [0,1] with all invalid values being set to 1
[48961] Fix | Delete
function boundAlpha(a) {
[48962] Fix | Delete
a = parseFloat(a);
[48963] Fix | Delete
[48964] Fix | Delete
if (isNaN(a) || a < 0 || a > 1) {
[48965] Fix | Delete
a = 1;
[48966] Fix | Delete
}
[48967] Fix | Delete
[48968] Fix | Delete
return a;
[48969] Fix | Delete
}
[48970] Fix | Delete
[48971] Fix | Delete
// Take input from [0, n] and return it as [0, 1]
[48972] Fix | Delete
function bound01(n, max) {
[48973] Fix | Delete
if (isOnePointZero(n)) { n = "100%"; }
[48974] Fix | Delete
[48975] Fix | Delete
var processPercent = isPercentage(n);
[48976] Fix | Delete
n = mathMin(max, mathMax(0, parseFloat(n)));
[48977] Fix | Delete
[48978] Fix | Delete
// Automatically convert percentage into number
[48979] Fix | Delete
if (processPercent) {
[48980] Fix | Delete
n = parseInt(n * max, 10) / 100;
[48981] Fix | Delete
}
[48982] Fix | Delete
[48983] Fix | Delete
// Handle floating point rounding errors
[48984] Fix | Delete
if ((Math.abs(n - max) < 0.000001)) {
[48985] Fix | Delete
return 1;
[48986] Fix | Delete
}
[48987] Fix | Delete
[48988] Fix | Delete
// Convert into [0, 1] range if it isn't already
[48989] Fix | Delete
return (n % max) / parseFloat(max);
[48990] Fix | Delete
}
[48991] Fix | Delete
[48992] Fix | Delete
// Force a number between 0 and 1
[48993] Fix | Delete
function clamp01(val) {
[48994] Fix | Delete
return mathMin(1, mathMax(0, val));
[48995] Fix | Delete
}
[48996] Fix | Delete
[48997] Fix | Delete
// Parse a base-16 hex value into a base-10 integer
[48998] Fix | Delete
function parseIntFromHex(val) {
[48999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function