Edit File by line
/home/barbar84/www/wp-inclu.../js/dist
File: blocks.js
_applyCombination: function(fn, args) {
[13000] Fix | Delete
return fn.apply(null, [this].concat([].slice.call(args)));
[13001] Fix | Delete
},
[13002] Fix | Delete
analogous: function() {
[13003] Fix | Delete
return this._applyCombination(analogous, arguments);
[13004] Fix | Delete
},
[13005] Fix | Delete
complement: function() {
[13006] Fix | Delete
return this._applyCombination(complement, arguments);
[13007] Fix | Delete
},
[13008] Fix | Delete
monochromatic: function() {
[13009] Fix | Delete
return this._applyCombination(monochromatic, arguments);
[13010] Fix | Delete
},
[13011] Fix | Delete
splitcomplement: function() {
[13012] Fix | Delete
return this._applyCombination(splitcomplement, arguments);
[13013] Fix | Delete
},
[13014] Fix | Delete
triad: function() {
[13015] Fix | Delete
return this._applyCombination(triad, arguments);
[13016] Fix | Delete
},
[13017] Fix | Delete
tetrad: function() {
[13018] Fix | Delete
return this._applyCombination(tetrad, arguments);
[13019] Fix | Delete
}
[13020] Fix | Delete
};
[13021] Fix | Delete
[13022] Fix | Delete
// If input is an object, force 1 into "1.0" to handle ratios properly
[13023] Fix | Delete
// String input requires "1.0" as input, so 1 will be treated as 1
[13024] Fix | Delete
tinycolor.fromRatio = function(color, opts) {
[13025] Fix | Delete
if (typeof color == "object") {
[13026] Fix | Delete
var newColor = {};
[13027] Fix | Delete
for (var i in color) {
[13028] Fix | Delete
if (color.hasOwnProperty(i)) {
[13029] Fix | Delete
if (i === "a") {
[13030] Fix | Delete
newColor[i] = color[i];
[13031] Fix | Delete
}
[13032] Fix | Delete
else {
[13033] Fix | Delete
newColor[i] = convertToPercentage(color[i]);
[13034] Fix | Delete
}
[13035] Fix | Delete
}
[13036] Fix | Delete
}
[13037] Fix | Delete
color = newColor;
[13038] Fix | Delete
}
[13039] Fix | Delete
[13040] Fix | Delete
return tinycolor(color, opts);
[13041] Fix | Delete
};
[13042] Fix | Delete
[13043] Fix | Delete
// Given a string or object, convert that input to RGB
[13044] Fix | Delete
// Possible string inputs:
[13045] Fix | Delete
//
[13046] Fix | Delete
// "red"
[13047] Fix | Delete
// "#f00" or "f00"
[13048] Fix | Delete
// "#ff0000" or "ff0000"
[13049] Fix | Delete
// "#ff000000" or "ff000000"
[13050] Fix | Delete
// "rgb 255 0 0" or "rgb (255, 0, 0)"
[13051] Fix | Delete
// "rgb 1.0 0 0" or "rgb (1, 0, 0)"
[13052] Fix | Delete
// "rgba (255, 0, 0, 1)" or "rgba 255, 0, 0, 1"
[13053] Fix | Delete
// "rgba (1.0, 0, 0, 1)" or "rgba 1.0, 0, 0, 1"
[13054] Fix | Delete
// "hsl(0, 100%, 50%)" or "hsl 0 100% 50%"
[13055] Fix | Delete
// "hsla(0, 100%, 50%, 1)" or "hsla 0 100% 50%, 1"
[13056] Fix | Delete
// "hsv(0, 100%, 100%)" or "hsv 0 100% 100%"
[13057] Fix | Delete
//
[13058] Fix | Delete
function inputToRGB(color) {
[13059] Fix | Delete
[13060] Fix | Delete
var rgb = { r: 0, g: 0, b: 0 };
[13061] Fix | Delete
var a = 1;
[13062] Fix | Delete
var s = null;
[13063] Fix | Delete
var v = null;
[13064] Fix | Delete
var l = null;
[13065] Fix | Delete
var ok = false;
[13066] Fix | Delete
var format = false;
[13067] Fix | Delete
[13068] Fix | Delete
if (typeof color == "string") {
[13069] Fix | Delete
color = stringInputToObject(color);
[13070] Fix | Delete
}
[13071] Fix | Delete
[13072] Fix | Delete
if (typeof color == "object") {
[13073] Fix | Delete
if (isValidCSSUnit(color.r) && isValidCSSUnit(color.g) && isValidCSSUnit(color.b)) {
[13074] Fix | Delete
rgb = rgbToRgb(color.r, color.g, color.b);
[13075] Fix | Delete
ok = true;
[13076] Fix | Delete
format = String(color.r).substr(-1) === "%" ? "prgb" : "rgb";
[13077] Fix | Delete
}
[13078] Fix | Delete
else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.v)) {
[13079] Fix | Delete
s = convertToPercentage(color.s);
[13080] Fix | Delete
v = convertToPercentage(color.v);
[13081] Fix | Delete
rgb = hsvToRgb(color.h, s, v);
[13082] Fix | Delete
ok = true;
[13083] Fix | Delete
format = "hsv";
[13084] Fix | Delete
}
[13085] Fix | Delete
else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.l)) {
[13086] Fix | Delete
s = convertToPercentage(color.s);
[13087] Fix | Delete
l = convertToPercentage(color.l);
[13088] Fix | Delete
rgb = hslToRgb(color.h, s, l);
[13089] Fix | Delete
ok = true;
[13090] Fix | Delete
format = "hsl";
[13091] Fix | Delete
}
[13092] Fix | Delete
[13093] Fix | Delete
if (color.hasOwnProperty("a")) {
[13094] Fix | Delete
a = color.a;
[13095] Fix | Delete
}
[13096] Fix | Delete
}
[13097] Fix | Delete
[13098] Fix | Delete
a = boundAlpha(a);
[13099] Fix | Delete
[13100] Fix | Delete
return {
[13101] Fix | Delete
ok: ok,
[13102] Fix | Delete
format: color.format || format,
[13103] Fix | Delete
r: mathMin(255, mathMax(rgb.r, 0)),
[13104] Fix | Delete
g: mathMin(255, mathMax(rgb.g, 0)),
[13105] Fix | Delete
b: mathMin(255, mathMax(rgb.b, 0)),
[13106] Fix | Delete
a: a
[13107] Fix | Delete
};
[13108] Fix | Delete
}
[13109] Fix | Delete
[13110] Fix | Delete
[13111] Fix | Delete
// Conversion Functions
[13112] Fix | Delete
// --------------------
[13113] Fix | Delete
[13114] Fix | Delete
// `rgbToHsl`, `rgbToHsv`, `hslToRgb`, `hsvToRgb` modified from:
[13115] Fix | Delete
// <http://mjijackson.com/2008/02/rgb-to-hsl-and-rgb-to-hsv-color-model-conversion-algorithms-in-javascript>
[13116] Fix | Delete
[13117] Fix | Delete
// `rgbToRgb`
[13118] Fix | Delete
// Handle bounds / percentage checking to conform to CSS color spec
[13119] Fix | Delete
// <http://www.w3.org/TR/css3-color/>
[13120] Fix | Delete
// *Assumes:* r, g, b in [0, 255] or [0, 1]
[13121] Fix | Delete
// *Returns:* { r, g, b } in [0, 255]
[13122] Fix | Delete
function rgbToRgb(r, g, b){
[13123] Fix | Delete
return {
[13124] Fix | Delete
r: bound01(r, 255) * 255,
[13125] Fix | Delete
g: bound01(g, 255) * 255,
[13126] Fix | Delete
b: bound01(b, 255) * 255
[13127] Fix | Delete
};
[13128] Fix | Delete
}
[13129] Fix | Delete
[13130] Fix | Delete
// `rgbToHsl`
[13131] Fix | Delete
// Converts an RGB color value to HSL.
[13132] Fix | Delete
// *Assumes:* r, g, and b are contained in [0, 255] or [0, 1]
[13133] Fix | Delete
// *Returns:* { h, s, l } in [0,1]
[13134] Fix | Delete
function rgbToHsl(r, g, b) {
[13135] Fix | Delete
[13136] Fix | Delete
r = bound01(r, 255);
[13137] Fix | Delete
g = bound01(g, 255);
[13138] Fix | Delete
b = bound01(b, 255);
[13139] Fix | Delete
[13140] Fix | Delete
var max = mathMax(r, g, b), min = mathMin(r, g, b);
[13141] Fix | Delete
var h, s, l = (max + min) / 2;
[13142] Fix | Delete
[13143] Fix | Delete
if(max == min) {
[13144] Fix | Delete
h = s = 0; // achromatic
[13145] Fix | Delete
}
[13146] Fix | Delete
else {
[13147] Fix | Delete
var d = max - min;
[13148] Fix | Delete
s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
[13149] Fix | Delete
switch(max) {
[13150] Fix | Delete
case r: h = (g - b) / d + (g < b ? 6 : 0); break;
[13151] Fix | Delete
case g: h = (b - r) / d + 2; break;
[13152] Fix | Delete
case b: h = (r - g) / d + 4; break;
[13153] Fix | Delete
}
[13154] Fix | Delete
[13155] Fix | Delete
h /= 6;
[13156] Fix | Delete
}
[13157] Fix | Delete
[13158] Fix | Delete
return { h: h, s: s, l: l };
[13159] Fix | Delete
}
[13160] Fix | Delete
[13161] Fix | Delete
// `hslToRgb`
[13162] Fix | Delete
// Converts an HSL color value to RGB.
[13163] Fix | Delete
// *Assumes:* h is contained in [0, 1] or [0, 360] and s and l are contained [0, 1] or [0, 100]
[13164] Fix | Delete
// *Returns:* { r, g, b } in the set [0, 255]
[13165] Fix | Delete
function hslToRgb(h, s, l) {
[13166] Fix | Delete
var r, g, b;
[13167] Fix | Delete
[13168] Fix | Delete
h = bound01(h, 360);
[13169] Fix | Delete
s = bound01(s, 100);
[13170] Fix | Delete
l = bound01(l, 100);
[13171] Fix | Delete
[13172] Fix | Delete
function hue2rgb(p, q, t) {
[13173] Fix | Delete
if(t < 0) t += 1;
[13174] Fix | Delete
if(t > 1) t -= 1;
[13175] Fix | Delete
if(t < 1/6) return p + (q - p) * 6 * t;
[13176] Fix | Delete
if(t < 1/2) return q;
[13177] Fix | Delete
if(t < 2/3) return p + (q - p) * (2/3 - t) * 6;
[13178] Fix | Delete
return p;
[13179] Fix | Delete
}
[13180] Fix | Delete
[13181] Fix | Delete
if(s === 0) {
[13182] Fix | Delete
r = g = b = l; // achromatic
[13183] Fix | Delete
}
[13184] Fix | Delete
else {
[13185] Fix | Delete
var q = l < 0.5 ? l * (1 + s) : l + s - l * s;
[13186] Fix | Delete
var p = 2 * l - q;
[13187] Fix | Delete
r = hue2rgb(p, q, h + 1/3);
[13188] Fix | Delete
g = hue2rgb(p, q, h);
[13189] Fix | Delete
b = hue2rgb(p, q, h - 1/3);
[13190] Fix | Delete
}
[13191] Fix | Delete
[13192] Fix | Delete
return { r: r * 255, g: g * 255, b: b * 255 };
[13193] Fix | Delete
}
[13194] Fix | Delete
[13195] Fix | Delete
// `rgbToHsv`
[13196] Fix | Delete
// Converts an RGB color value to HSV
[13197] Fix | Delete
// *Assumes:* r, g, and b are contained in the set [0, 255] or [0, 1]
[13198] Fix | Delete
// *Returns:* { h, s, v } in [0,1]
[13199] Fix | Delete
function rgbToHsv(r, g, b) {
[13200] Fix | Delete
[13201] Fix | Delete
r = bound01(r, 255);
[13202] Fix | Delete
g = bound01(g, 255);
[13203] Fix | Delete
b = bound01(b, 255);
[13204] Fix | Delete
[13205] Fix | Delete
var max = mathMax(r, g, b), min = mathMin(r, g, b);
[13206] Fix | Delete
var h, s, v = max;
[13207] Fix | Delete
[13208] Fix | Delete
var d = max - min;
[13209] Fix | Delete
s = max === 0 ? 0 : d / max;
[13210] Fix | Delete
[13211] Fix | Delete
if(max == min) {
[13212] Fix | Delete
h = 0; // achromatic
[13213] Fix | Delete
}
[13214] Fix | Delete
else {
[13215] Fix | Delete
switch(max) {
[13216] Fix | Delete
case r: h = (g - b) / d + (g < b ? 6 : 0); break;
[13217] Fix | Delete
case g: h = (b - r) / d + 2; break;
[13218] Fix | Delete
case b: h = (r - g) / d + 4; break;
[13219] Fix | Delete
}
[13220] Fix | Delete
h /= 6;
[13221] Fix | Delete
}
[13222] Fix | Delete
return { h: h, s: s, v: v };
[13223] Fix | Delete
}
[13224] Fix | Delete
[13225] Fix | Delete
// `hsvToRgb`
[13226] Fix | Delete
// Converts an HSV color value to RGB.
[13227] Fix | Delete
// *Assumes:* h is contained in [0, 1] or [0, 360] and s and v are contained in [0, 1] or [0, 100]
[13228] Fix | Delete
// *Returns:* { r, g, b } in the set [0, 255]
[13229] Fix | Delete
function hsvToRgb(h, s, v) {
[13230] Fix | Delete
[13231] Fix | Delete
h = bound01(h, 360) * 6;
[13232] Fix | Delete
s = bound01(s, 100);
[13233] Fix | Delete
v = bound01(v, 100);
[13234] Fix | Delete
[13235] Fix | Delete
var i = Math.floor(h),
[13236] Fix | Delete
f = h - i,
[13237] Fix | Delete
p = v * (1 - s),
[13238] Fix | Delete
q = v * (1 - f * s),
[13239] Fix | Delete
t = v * (1 - (1 - f) * s),
[13240] Fix | Delete
mod = i % 6,
[13241] Fix | Delete
r = [v, q, p, p, t, v][mod],
[13242] Fix | Delete
g = [t, v, v, q, p, p][mod],
[13243] Fix | Delete
b = [p, p, t, v, v, q][mod];
[13244] Fix | Delete
[13245] Fix | Delete
return { r: r * 255, g: g * 255, b: b * 255 };
[13246] Fix | Delete
}
[13247] Fix | Delete
[13248] Fix | Delete
// `rgbToHex`
[13249] Fix | Delete
// Converts an RGB color to hex
[13250] Fix | Delete
// Assumes r, g, and b are contained in the set [0, 255]
[13251] Fix | Delete
// Returns a 3 or 6 character hex
[13252] Fix | Delete
function rgbToHex(r, g, b, allow3Char) {
[13253] Fix | Delete
[13254] Fix | Delete
var hex = [
[13255] Fix | Delete
pad2(mathRound(r).toString(16)),
[13256] Fix | Delete
pad2(mathRound(g).toString(16)),
[13257] Fix | Delete
pad2(mathRound(b).toString(16))
[13258] Fix | Delete
];
[13259] Fix | Delete
[13260] Fix | Delete
// Return a 3 character hex if possible
[13261] Fix | Delete
if (allow3Char && hex[0].charAt(0) == hex[0].charAt(1) && hex[1].charAt(0) == hex[1].charAt(1) && hex[2].charAt(0) == hex[2].charAt(1)) {
[13262] Fix | Delete
return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0);
[13263] Fix | Delete
}
[13264] Fix | Delete
[13265] Fix | Delete
return hex.join("");
[13266] Fix | Delete
}
[13267] Fix | Delete
[13268] Fix | Delete
// `rgbaToHex`
[13269] Fix | Delete
// Converts an RGBA color plus alpha transparency to hex
[13270] Fix | Delete
// Assumes r, g, b are contained in the set [0, 255] and
[13271] Fix | Delete
// a in [0, 1]. Returns a 4 or 8 character rgba hex
[13272] Fix | Delete
function rgbaToHex(r, g, b, a, allow4Char) {
[13273] Fix | Delete
[13274] Fix | Delete
var hex = [
[13275] Fix | Delete
pad2(mathRound(r).toString(16)),
[13276] Fix | Delete
pad2(mathRound(g).toString(16)),
[13277] Fix | Delete
pad2(mathRound(b).toString(16)),
[13278] Fix | Delete
pad2(convertDecimalToHex(a))
[13279] Fix | Delete
];
[13280] Fix | Delete
[13281] Fix | Delete
// Return a 4 character hex if possible
[13282] 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)) {
[13283] Fix | Delete
return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0) + hex[3].charAt(0);
[13284] Fix | Delete
}
[13285] Fix | Delete
[13286] Fix | Delete
return hex.join("");
[13287] Fix | Delete
}
[13288] Fix | Delete
[13289] Fix | Delete
// `rgbaToArgbHex`
[13290] Fix | Delete
// Converts an RGBA color to an ARGB Hex8 string
[13291] Fix | Delete
// Rarely used, but required for "toFilter()"
[13292] Fix | Delete
function rgbaToArgbHex(r, g, b, a) {
[13293] Fix | Delete
[13294] Fix | Delete
var hex = [
[13295] Fix | Delete
pad2(convertDecimalToHex(a)),
[13296] Fix | Delete
pad2(mathRound(r).toString(16)),
[13297] Fix | Delete
pad2(mathRound(g).toString(16)),
[13298] Fix | Delete
pad2(mathRound(b).toString(16))
[13299] Fix | Delete
];
[13300] Fix | Delete
[13301] Fix | Delete
return hex.join("");
[13302] Fix | Delete
}
[13303] Fix | Delete
[13304] Fix | Delete
// `equals`
[13305] Fix | Delete
// Can be called with any tinycolor input
[13306] Fix | Delete
tinycolor.equals = function (color1, color2) {
[13307] Fix | Delete
if (!color1 || !color2) { return false; }
[13308] Fix | Delete
return tinycolor(color1).toRgbString() == tinycolor(color2).toRgbString();
[13309] Fix | Delete
};
[13310] Fix | Delete
[13311] Fix | Delete
tinycolor.random = function() {
[13312] Fix | Delete
return tinycolor.fromRatio({
[13313] Fix | Delete
r: mathRandom(),
[13314] Fix | Delete
g: mathRandom(),
[13315] Fix | Delete
b: mathRandom()
[13316] Fix | Delete
});
[13317] Fix | Delete
};
[13318] Fix | Delete
[13319] Fix | Delete
[13320] Fix | Delete
// Modification Functions
[13321] Fix | Delete
// ----------------------
[13322] Fix | Delete
// Thanks to less.js for some of the basics here
[13323] Fix | Delete
// <https://github.com/cloudhead/less.js/blob/master/lib/less/functions.js>
[13324] Fix | Delete
[13325] Fix | Delete
function desaturate(color, amount) {
[13326] Fix | Delete
amount = (amount === 0) ? 0 : (amount || 10);
[13327] Fix | Delete
var hsl = tinycolor(color).toHsl();
[13328] Fix | Delete
hsl.s -= amount / 100;
[13329] Fix | Delete
hsl.s = clamp01(hsl.s);
[13330] Fix | Delete
return tinycolor(hsl);
[13331] Fix | Delete
}
[13332] Fix | Delete
[13333] Fix | Delete
function saturate(color, amount) {
[13334] Fix | Delete
amount = (amount === 0) ? 0 : (amount || 10);
[13335] Fix | Delete
var hsl = tinycolor(color).toHsl();
[13336] Fix | Delete
hsl.s += amount / 100;
[13337] Fix | Delete
hsl.s = clamp01(hsl.s);
[13338] Fix | Delete
return tinycolor(hsl);
[13339] Fix | Delete
}
[13340] Fix | Delete
[13341] Fix | Delete
function greyscale(color) {
[13342] Fix | Delete
return tinycolor(color).desaturate(100);
[13343] Fix | Delete
}
[13344] Fix | Delete
[13345] Fix | Delete
function lighten (color, amount) {
[13346] Fix | Delete
amount = (amount === 0) ? 0 : (amount || 10);
[13347] Fix | Delete
var hsl = tinycolor(color).toHsl();
[13348] Fix | Delete
hsl.l += amount / 100;
[13349] Fix | Delete
hsl.l = clamp01(hsl.l);
[13350] Fix | Delete
return tinycolor(hsl);
[13351] Fix | Delete
}
[13352] Fix | Delete
[13353] Fix | Delete
function brighten(color, amount) {
[13354] Fix | Delete
amount = (amount === 0) ? 0 : (amount || 10);
[13355] Fix | Delete
var rgb = tinycolor(color).toRgb();
[13356] Fix | Delete
rgb.r = mathMax(0, mathMin(255, rgb.r - mathRound(255 * - (amount / 100))));
[13357] Fix | Delete
rgb.g = mathMax(0, mathMin(255, rgb.g - mathRound(255 * - (amount / 100))));
[13358] Fix | Delete
rgb.b = mathMax(0, mathMin(255, rgb.b - mathRound(255 * - (amount / 100))));
[13359] Fix | Delete
return tinycolor(rgb);
[13360] Fix | Delete
}
[13361] Fix | Delete
[13362] Fix | Delete
function darken (color, amount) {
[13363] Fix | Delete
amount = (amount === 0) ? 0 : (amount || 10);
[13364] Fix | Delete
var hsl = tinycolor(color).toHsl();
[13365] Fix | Delete
hsl.l -= amount / 100;
[13366] Fix | Delete
hsl.l = clamp01(hsl.l);
[13367] Fix | Delete
return tinycolor(hsl);
[13368] Fix | Delete
}
[13369] Fix | Delete
[13370] Fix | Delete
// Spin takes a positive or negative amount within [-360, 360] indicating the change of hue.
[13371] Fix | Delete
// Values outside of this range will be wrapped into this range.
[13372] Fix | Delete
function spin(color, amount) {
[13373] Fix | Delete
var hsl = tinycolor(color).toHsl();
[13374] Fix | Delete
var hue = (hsl.h + amount) % 360;
[13375] Fix | Delete
hsl.h = hue < 0 ? 360 + hue : hue;
[13376] Fix | Delete
return tinycolor(hsl);
[13377] Fix | Delete
}
[13378] Fix | Delete
[13379] Fix | Delete
// Combination Functions
[13380] Fix | Delete
// ---------------------
[13381] Fix | Delete
// Thanks to jQuery xColor for some of the ideas behind these
[13382] Fix | Delete
// <https://github.com/infusion/jQuery-xcolor/blob/master/jquery.xcolor.js>
[13383] Fix | Delete
[13384] Fix | Delete
function complement(color) {
[13385] Fix | Delete
var hsl = tinycolor(color).toHsl();
[13386] Fix | Delete
hsl.h = (hsl.h + 180) % 360;
[13387] Fix | Delete
return tinycolor(hsl);
[13388] Fix | Delete
}
[13389] Fix | Delete
[13390] Fix | Delete
function triad(color) {
[13391] Fix | Delete
var hsl = tinycolor(color).toHsl();
[13392] Fix | Delete
var h = hsl.h;
[13393] Fix | Delete
return [
[13394] Fix | Delete
tinycolor(color),
[13395] Fix | Delete
tinycolor({ h: (h + 120) % 360, s: hsl.s, l: hsl.l }),
[13396] Fix | Delete
tinycolor({ h: (h + 240) % 360, s: hsl.s, l: hsl.l })
[13397] Fix | Delete
];
[13398] Fix | Delete
}
[13399] Fix | Delete
[13400] Fix | Delete
function tetrad(color) {
[13401] Fix | Delete
var hsl = tinycolor(color).toHsl();
[13402] Fix | Delete
var h = hsl.h;
[13403] Fix | Delete
return [
[13404] Fix | Delete
tinycolor(color),
[13405] Fix | Delete
tinycolor({ h: (h + 90) % 360, s: hsl.s, l: hsl.l }),
[13406] Fix | Delete
tinycolor({ h: (h + 180) % 360, s: hsl.s, l: hsl.l }),
[13407] Fix | Delete
tinycolor({ h: (h + 270) % 360, s: hsl.s, l: hsl.l })
[13408] Fix | Delete
];
[13409] Fix | Delete
}
[13410] Fix | Delete
[13411] Fix | Delete
function splitcomplement(color) {
[13412] Fix | Delete
var hsl = tinycolor(color).toHsl();
[13413] Fix | Delete
var h = hsl.h;
[13414] Fix | Delete
return [
[13415] Fix | Delete
tinycolor(color),
[13416] Fix | Delete
tinycolor({ h: (h + 72) % 360, s: hsl.s, l: hsl.l}),
[13417] Fix | Delete
tinycolor({ h: (h + 216) % 360, s: hsl.s, l: hsl.l})
[13418] Fix | Delete
];
[13419] Fix | Delete
}
[13420] Fix | Delete
[13421] Fix | Delete
function analogous(color, results, slices) {
[13422] Fix | Delete
results = results || 6;
[13423] Fix | Delete
slices = slices || 30;
[13424] Fix | Delete
[13425] Fix | Delete
var hsl = tinycolor(color).toHsl();
[13426] Fix | Delete
var part = 360 / slices;
[13427] Fix | Delete
var ret = [tinycolor(color)];
[13428] Fix | Delete
[13429] Fix | Delete
for (hsl.h = ((hsl.h - (part * results >> 1)) + 720) % 360; --results; ) {
[13430] Fix | Delete
hsl.h = (hsl.h + part) % 360;
[13431] Fix | Delete
ret.push(tinycolor(hsl));
[13432] Fix | Delete
}
[13433] Fix | Delete
return ret;
[13434] Fix | Delete
}
[13435] Fix | Delete
[13436] Fix | Delete
function monochromatic(color, results) {
[13437] Fix | Delete
results = results || 6;
[13438] Fix | Delete
var hsv = tinycolor(color).toHsv();
[13439] Fix | Delete
var h = hsv.h, s = hsv.s, v = hsv.v;
[13440] Fix | Delete
var ret = [];
[13441] Fix | Delete
var modification = 1 / results;
[13442] Fix | Delete
[13443] Fix | Delete
while (results--) {
[13444] Fix | Delete
ret.push(tinycolor({ h: h, s: s, v: v}));
[13445] Fix | Delete
v = (v + modification) % 1;
[13446] Fix | Delete
}
[13447] Fix | Delete
[13448] Fix | Delete
return ret;
[13449] Fix | Delete
}
[13450] Fix | Delete
[13451] Fix | Delete
// Utility Functions
[13452] Fix | Delete
// ---------------------
[13453] Fix | Delete
[13454] Fix | Delete
tinycolor.mix = function(color1, color2, amount) {
[13455] Fix | Delete
amount = (amount === 0) ? 0 : (amount || 50);
[13456] Fix | Delete
[13457] Fix | Delete
var rgb1 = tinycolor(color1).toRgb();
[13458] Fix | Delete
var rgb2 = tinycolor(color2).toRgb();
[13459] Fix | Delete
[13460] Fix | Delete
var p = amount / 100;
[13461] Fix | Delete
[13462] Fix | Delete
var rgba = {
[13463] Fix | Delete
r: ((rgb2.r - rgb1.r) * p) + rgb1.r,
[13464] Fix | Delete
g: ((rgb2.g - rgb1.g) * p) + rgb1.g,
[13465] Fix | Delete
b: ((rgb2.b - rgb1.b) * p) + rgb1.b,
[13466] Fix | Delete
a: ((rgb2.a - rgb1.a) * p) + rgb1.a
[13467] Fix | Delete
};
[13468] Fix | Delete
[13469] Fix | Delete
return tinycolor(rgba);
[13470] Fix | Delete
};
[13471] Fix | Delete
[13472] Fix | Delete
[13473] Fix | Delete
// Readability Functions
[13474] Fix | Delete
// ---------------------
[13475] Fix | Delete
// <http://www.w3.org/TR/2008/REC-WCAG20-20081211/#contrast-ratiodef (WCAG Version 2)
[13476] Fix | Delete
[13477] Fix | Delete
// `contrast`
[13478] Fix | Delete
// Analyze the 2 colors and returns the color contrast defined by (WCAG Version 2)
[13479] Fix | Delete
tinycolor.readability = function(color1, color2) {
[13480] Fix | Delete
var c1 = tinycolor(color1);
[13481] Fix | Delete
var c2 = tinycolor(color2);
[13482] Fix | Delete
return (Math.max(c1.getLuminance(),c2.getLuminance())+0.05) / (Math.min(c1.getLuminance(),c2.getLuminance())+0.05);
[13483] Fix | Delete
};
[13484] Fix | Delete
[13485] Fix | Delete
// `isReadable`
[13486] Fix | Delete
// Ensure that foreground and background color combinations meet WCAG2 guidelines.
[13487] Fix | Delete
// The third argument is an optional Object.
[13488] Fix | Delete
// the 'level' property states 'AA' or 'AAA' - if missing or invalid, it defaults to 'AA';
[13489] Fix | Delete
// the 'size' property states 'large' or 'small' - if missing or invalid, it defaults to 'small'.
[13490] Fix | Delete
// If the entire object is absent, isReadable defaults to {level:"AA",size:"small"}.
[13491] Fix | Delete
[13492] Fix | Delete
// *Example*
[13493] Fix | Delete
// tinycolor.isReadable("#000", "#111") => false
[13494] Fix | Delete
// tinycolor.isReadable("#000", "#111",{level:"AA",size:"large"}) => false
[13495] Fix | Delete
tinycolor.isReadable = function(color1, color2, wcag2) {
[13496] Fix | Delete
var readability = tinycolor.readability(color1, color2);
[13497] Fix | Delete
var wcag2Parms, out;
[13498] Fix | Delete
[13499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function