jquery-asColor
Advanced tools
Comparing version 0.3.4 to 0.3.5
/** | ||
* jQuery asColor v0.3.4 | ||
* jQuery asColor v0.3.5 | ||
* https://github.com/amazingSurge/asColor | ||
@@ -881,3 +881,3 @@ * | ||
var info = { | ||
version:'0.3.4' | ||
version:'0.3.5' | ||
}; | ||
@@ -889,3 +889,3 @@ | ||
return new AsColor(...args); | ||
} | ||
}; | ||
@@ -892,0 +892,0 @@ $.asColor = jQueryAsColor; |
/** | ||
* jQuery asColor v0.3.4 | ||
* jQuery asColor v0.3.5 | ||
* https://github.com/amazingSurge/asColor | ||
@@ -9,5 +9,5 @@ * | ||
(function(global, factory) { | ||
if (typeof define === "function" && define.amd) { | ||
if (typeof define === 'function' && define.amd) { | ||
define('AsColor', ['exports', 'jquery'], factory); | ||
} else if (typeof exports !== "undefined") { | ||
} else if (typeof exports !== 'undefined') { | ||
factory(exports, require('jquery')); | ||
@@ -21,639 +21,714 @@ } else { | ||
} | ||
})(this, | ||
})(this, function(exports, _jquery) { | ||
'use strict'; | ||
function(exports, _jquery) { | ||
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
}); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var _jquery2 = _interopRequireDefault(_jquery); | ||
var _jquery2 = _interopRequireDefault(_jquery); | ||
function _interopRequireDefault(obj) { | ||
return obj && obj.__esModule | ||
? obj | ||
: { | ||
default: obj | ||
}; | ||
} | ||
function _interopRequireDefault(obj) { | ||
return obj && obj.__esModule ? obj : { | ||
default: obj | ||
}; | ||
var _typeof = | ||
typeof Symbol === 'function' && typeof Symbol.iterator === 'symbol' | ||
? function(obj) { | ||
return typeof obj; | ||
} | ||
: function(obj) { | ||
return obj && | ||
typeof Symbol === 'function' && | ||
obj.constructor === Symbol && | ||
obj !== Symbol.prototype | ||
? 'symbol' | ||
: typeof obj; | ||
}; | ||
function _classCallCheck(instance, Constructor) { | ||
if (!(instance instanceof Constructor)) { | ||
throw new TypeError('Cannot call a class as a function'); | ||
} | ||
} | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? | ||
function(obj) { | ||
return typeof obj; | ||
var _createClass = (function() { | ||
function defineProperties(target, props) { | ||
for (var i = 0; i < props.length; i++) { | ||
var descriptor = props[i]; | ||
descriptor.enumerable = descriptor.enumerable || false; | ||
descriptor.configurable = true; | ||
if ('value' in descriptor) descriptor.writable = true; | ||
Object.defineProperty(target, descriptor.key, descriptor); | ||
} | ||
: | ||
function(obj) { | ||
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; | ||
}; | ||
function _classCallCheck(instance, Constructor) { | ||
if (!(instance instanceof Constructor)) { | ||
throw new TypeError("Cannot call a class as a function"); | ||
} | ||
} | ||
var _createClass = function() { | ||
function defineProperties(target, props) { | ||
for (var i = 0; i < props.length; i++) { | ||
var descriptor = props[i]; | ||
descriptor.enumerable = descriptor.enumerable || false; | ||
descriptor.configurable = true; | ||
if ("value" in descriptor) | ||
descriptor.writable = true; | ||
Object.defineProperty(target, descriptor.key, descriptor); | ||
} | ||
} | ||
return function(Constructor, protoProps, staticProps) { | ||
if (protoProps) | ||
defineProperties(Constructor.prototype, protoProps); | ||
if (staticProps) | ||
defineProperties(Constructor, staticProps); | ||
return Constructor; | ||
}; | ||
}(); | ||
var DEFAULTS = { | ||
format: false, | ||
shortenHex: false, | ||
hexUseName: false, | ||
reduceAlpha: false, | ||
alphaConvert: { // or false will disable convert | ||
'RGB': 'RGBA', | ||
'HSL': 'HSLA', | ||
'HEX': 'RGBA', | ||
'NAMESPACE': 'RGBA' | ||
}, | ||
nameDegradation: 'HEX', | ||
invalidValue: '', | ||
zeroAlphaAsTransparent: true | ||
return function(Constructor, protoProps, staticProps) { | ||
if (protoProps) defineProperties(Constructor.prototype, protoProps); | ||
if (staticProps) defineProperties(Constructor, staticProps); | ||
return Constructor; | ||
}; | ||
})(); | ||
function expandHex(hex) { | ||
if (hex.indexOf('#') === 0) { | ||
hex = hex.substr(1); | ||
} | ||
var DEFAULTS = { | ||
format: false, | ||
shortenHex: false, | ||
hexUseName: false, | ||
reduceAlpha: false, | ||
alphaConvert: { | ||
// or false will disable convert | ||
RGB: 'RGBA', | ||
HSL: 'HSLA', | ||
HEX: 'RGBA', | ||
NAMESPACE: 'RGBA' | ||
}, | ||
nameDegradation: 'HEX', | ||
invalidValue: '', | ||
zeroAlphaAsTransparent: true | ||
}; | ||
if (!hex) { | ||
return null; | ||
} | ||
if (hex.length === 3) { | ||
hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2]; | ||
} | ||
return hex.length === 6 ? '#' + hex : null; | ||
function expandHex(hex) { | ||
if (hex.indexOf('#') === 0) { | ||
hex = hex.substr(1); | ||
} | ||
function shrinkHex(hex) { | ||
if (hex.indexOf('#') === 0) { | ||
hex = hex.substr(1); | ||
} | ||
if (hex.length === 6 && hex[0] === hex[1] && hex[2] === hex[3] && hex[4] === hex[5]) { | ||
hex = hex[0] + hex[2] + hex[4]; | ||
} | ||
return '#' + hex; | ||
if (!hex) { | ||
return null; | ||
} | ||
function parseIntFromHex(val) { | ||
return parseInt(val, 16); | ||
if (hex.length === 3) { | ||
hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2]; | ||
} | ||
return hex.length === 6 ? '#' + hex : null; | ||
} | ||
function isPercentage(n) { | ||
return typeof n === 'string' && n.indexOf('%') === n.length - 1; | ||
function shrinkHex(hex) { | ||
if (hex.indexOf('#') === 0) { | ||
hex = hex.substr(1); | ||
} | ||
function conventPercentageToRgb(n) { | ||
return parseInt(Math.round(n.slice(0, -1) * 2.55), 10); | ||
if ( | ||
hex.length === 6 && | ||
hex[0] === hex[1] && | ||
hex[2] === hex[3] && | ||
hex[4] === hex[5] | ||
) { | ||
hex = hex[0] + hex[2] + hex[4]; | ||
} | ||
return '#' + hex; | ||
} | ||
function convertPercentageToFloat(n) { | ||
return parseFloat(n.slice(0, -1) / 100, 10); | ||
} | ||
function parseIntFromHex(val) { | ||
return parseInt(val, 16); | ||
} | ||
function flip(o) { | ||
var flipped = {}; | ||
function isPercentage(n) { | ||
return typeof n === 'string' && n.indexOf('%') === n.length - 1; | ||
} | ||
for (var i in o) { | ||
function conventPercentageToRgb(n) { | ||
return parseInt(Math.round(n.slice(0, -1) * 2.55), 10); | ||
} | ||
if (o.hasOwnProperty(i)) { | ||
flipped[o[i]] = i; | ||
} | ||
function convertPercentageToFloat(n) { | ||
return parseFloat(n.slice(0, -1) / 100, 10); | ||
} | ||
function flip(o) { | ||
var flipped = {}; | ||
for (var i in o) { | ||
if (o.hasOwnProperty(i)) { | ||
flipped[o[i]] = i; | ||
} | ||
return flipped; | ||
} | ||
return flipped; | ||
} | ||
var NAMES = { | ||
aliceblue: 'f0f8ff', | ||
antiquewhite: 'faebd7', | ||
aqua: '0ff', | ||
aquamarine: '7fffd4', | ||
azure: 'f0ffff', | ||
beige: 'f5f5dc', | ||
bisque: 'ffe4c4', | ||
black: '000', | ||
blanchedalmond: 'ffebcd', | ||
blue: '00f', | ||
blueviolet: '8a2be2', | ||
brown: 'a52a2a', | ||
burlywood: 'deb887', | ||
burntsienna: 'ea7e5d', | ||
cadetblue: '5f9ea0', | ||
chartreuse: '7fff00', | ||
chocolate: 'd2691e', | ||
coral: 'ff7f50', | ||
cornflowerblue: '6495ed', | ||
cornsilk: 'fff8dc', | ||
crimson: 'dc143c', | ||
cyan: '0ff', | ||
darkblue: '00008b', | ||
darkcyan: '008b8b', | ||
darkgoldenrod: 'b8860b', | ||
darkgray: 'a9a9a9', | ||
darkgreen: '006400', | ||
darkgrey: 'a9a9a9', | ||
darkkhaki: 'bdb76b', | ||
darkmagenta: '8b008b', | ||
darkolivegreen: '556b2f', | ||
darkorange: 'ff8c00', | ||
darkorchid: '9932cc', | ||
darkred: '8b0000', | ||
darksalmon: 'e9967a', | ||
darkseagreen: '8fbc8f', | ||
darkslateblue: '483d8b', | ||
darkslategray: '2f4f4f', | ||
darkslategrey: '2f4f4f', | ||
darkturquoise: '00ced1', | ||
darkviolet: '9400d3', | ||
deeppink: 'ff1493', | ||
deepskyblue: '00bfff', | ||
dimgray: '696969', | ||
dimgrey: '696969', | ||
dodgerblue: '1e90ff', | ||
firebrick: 'b22222', | ||
floralwhite: 'fffaf0', | ||
forestgreen: '228b22', | ||
fuchsia: 'f0f', | ||
gainsboro: 'dcdcdc', | ||
ghostwhite: 'f8f8ff', | ||
gold: 'ffd700', | ||
goldenrod: 'daa520', | ||
gray: '808080', | ||
green: '008000', | ||
greenyellow: 'adff2f', | ||
grey: '808080', | ||
honeydew: 'f0fff0', | ||
hotpink: 'ff69b4', | ||
indianred: 'cd5c5c', | ||
indigo: '4b0082', | ||
ivory: 'fffff0', | ||
khaki: 'f0e68c', | ||
lavender: 'e6e6fa', | ||
lavenderblush: 'fff0f5', | ||
lawngreen: '7cfc00', | ||
lemonchiffon: 'fffacd', | ||
lightblue: 'add8e6', | ||
lightcoral: 'f08080', | ||
lightcyan: 'e0ffff', | ||
lightgoldenrodyellow: 'fafad2', | ||
lightgray: 'd3d3d3', | ||
lightgreen: '90ee90', | ||
lightgrey: 'd3d3d3', | ||
lightpink: 'ffb6c1', | ||
lightsalmon: 'ffa07a', | ||
lightseagreen: '20b2aa', | ||
lightskyblue: '87cefa', | ||
lightslategray: '789', | ||
lightslategrey: '789', | ||
lightsteelblue: 'b0c4de', | ||
lightyellow: 'ffffe0', | ||
lime: '0f0', | ||
limegreen: '32cd32', | ||
linen: 'faf0e6', | ||
magenta: 'f0f', | ||
maroon: '800000', | ||
mediumaquamarine: '66cdaa', | ||
mediumblue: '0000cd', | ||
mediumorchid: 'ba55d3', | ||
mediumpurple: '9370db', | ||
mediumseagreen: '3cb371', | ||
mediumslateblue: '7b68ee', | ||
mediumspringgreen: '00fa9a', | ||
mediumturquoise: '48d1cc', | ||
mediumvioletred: 'c71585', | ||
midnightblue: '191970', | ||
mintcream: 'f5fffa', | ||
mistyrose: 'ffe4e1', | ||
moccasin: 'ffe4b5', | ||
navajowhite: 'ffdead', | ||
navy: '000080', | ||
oldlace: 'fdf5e6', | ||
olive: '808000', | ||
olivedrab: '6b8e23', | ||
orange: 'ffa500', | ||
orangered: 'ff4500', | ||
orchid: 'da70d6', | ||
palegoldenrod: 'eee8aa', | ||
palegreen: '98fb98', | ||
paleturquoise: 'afeeee', | ||
palevioletred: 'db7093', | ||
papayawhip: 'ffefd5', | ||
peachpuff: 'ffdab9', | ||
peru: 'cd853f', | ||
pink: 'ffc0cb', | ||
plum: 'dda0dd', | ||
powderblue: 'b0e0e6', | ||
purple: '800080', | ||
red: 'f00', | ||
rosybrown: 'bc8f8f', | ||
royalblue: '4169e1', | ||
saddlebrown: '8b4513', | ||
salmon: 'fa8072', | ||
sandybrown: 'f4a460', | ||
seagreen: '2e8b57', | ||
seashell: 'fff5ee', | ||
sienna: 'a0522d', | ||
silver: 'c0c0c0', | ||
skyblue: '87ceeb', | ||
slateblue: '6a5acd', | ||
slategray: '708090', | ||
slategrey: '708090', | ||
snow: 'fffafa', | ||
springgreen: '00ff7f', | ||
steelblue: '4682b4', | ||
tan: 'd2b48c', | ||
teal: '008080', | ||
thistle: 'd8bfd8', | ||
tomato: 'ff6347', | ||
turquoise: '40e0d0', | ||
violet: 'ee82ee', | ||
wheat: 'f5deb3', | ||
white: 'fff', | ||
whitesmoke: 'f5f5f5', | ||
yellow: 'ff0', | ||
yellowgreen: '9acd32' | ||
}; | ||
var NAMES = { | ||
aliceblue: 'f0f8ff', | ||
antiquewhite: 'faebd7', | ||
aqua: '0ff', | ||
aquamarine: '7fffd4', | ||
azure: 'f0ffff', | ||
beige: 'f5f5dc', | ||
bisque: 'ffe4c4', | ||
black: '000', | ||
blanchedalmond: 'ffebcd', | ||
blue: '00f', | ||
blueviolet: '8a2be2', | ||
brown: 'a52a2a', | ||
burlywood: 'deb887', | ||
burntsienna: 'ea7e5d', | ||
cadetblue: '5f9ea0', | ||
chartreuse: '7fff00', | ||
chocolate: 'd2691e', | ||
coral: 'ff7f50', | ||
cornflowerblue: '6495ed', | ||
cornsilk: 'fff8dc', | ||
crimson: 'dc143c', | ||
cyan: '0ff', | ||
darkblue: '00008b', | ||
darkcyan: '008b8b', | ||
darkgoldenrod: 'b8860b', | ||
darkgray: 'a9a9a9', | ||
darkgreen: '006400', | ||
darkgrey: 'a9a9a9', | ||
darkkhaki: 'bdb76b', | ||
darkmagenta: '8b008b', | ||
darkolivegreen: '556b2f', | ||
darkorange: 'ff8c00', | ||
darkorchid: '9932cc', | ||
darkred: '8b0000', | ||
darksalmon: 'e9967a', | ||
darkseagreen: '8fbc8f', | ||
darkslateblue: '483d8b', | ||
darkslategray: '2f4f4f', | ||
darkslategrey: '2f4f4f', | ||
darkturquoise: '00ced1', | ||
darkviolet: '9400d3', | ||
deeppink: 'ff1493', | ||
deepskyblue: '00bfff', | ||
dimgray: '696969', | ||
dimgrey: '696969', | ||
dodgerblue: '1e90ff', | ||
firebrick: 'b22222', | ||
floralwhite: 'fffaf0', | ||
forestgreen: '228b22', | ||
fuchsia: 'f0f', | ||
gainsboro: 'dcdcdc', | ||
ghostwhite: 'f8f8ff', | ||
gold: 'ffd700', | ||
goldenrod: 'daa520', | ||
gray: '808080', | ||
green: '008000', | ||
greenyellow: 'adff2f', | ||
grey: '808080', | ||
honeydew: 'f0fff0', | ||
hotpink: 'ff69b4', | ||
indianred: 'cd5c5c', | ||
indigo: '4b0082', | ||
ivory: 'fffff0', | ||
khaki: 'f0e68c', | ||
lavender: 'e6e6fa', | ||
lavenderblush: 'fff0f5', | ||
lawngreen: '7cfc00', | ||
lemonchiffon: 'fffacd', | ||
lightblue: 'add8e6', | ||
lightcoral: 'f08080', | ||
lightcyan: 'e0ffff', | ||
lightgoldenrodyellow: 'fafad2', | ||
lightgray: 'd3d3d3', | ||
lightgreen: '90ee90', | ||
lightgrey: 'd3d3d3', | ||
lightpink: 'ffb6c1', | ||
lightsalmon: 'ffa07a', | ||
lightseagreen: '20b2aa', | ||
lightskyblue: '87cefa', | ||
lightslategray: '789', | ||
lightslategrey: '789', | ||
lightsteelblue: 'b0c4de', | ||
lightyellow: 'ffffe0', | ||
lime: '0f0', | ||
limegreen: '32cd32', | ||
linen: 'faf0e6', | ||
magenta: 'f0f', | ||
maroon: '800000', | ||
mediumaquamarine: '66cdaa', | ||
mediumblue: '0000cd', | ||
mediumorchid: 'ba55d3', | ||
mediumpurple: '9370db', | ||
mediumseagreen: '3cb371', | ||
mediumslateblue: '7b68ee', | ||
mediumspringgreen: '00fa9a', | ||
mediumturquoise: '48d1cc', | ||
mediumvioletred: 'c71585', | ||
midnightblue: '191970', | ||
mintcream: 'f5fffa', | ||
mistyrose: 'ffe4e1', | ||
moccasin: 'ffe4b5', | ||
navajowhite: 'ffdead', | ||
navy: '000080', | ||
oldlace: 'fdf5e6', | ||
olive: '808000', | ||
olivedrab: '6b8e23', | ||
orange: 'ffa500', | ||
orangered: 'ff4500', | ||
orchid: 'da70d6', | ||
palegoldenrod: 'eee8aa', | ||
palegreen: '98fb98', | ||
paleturquoise: 'afeeee', | ||
palevioletred: 'db7093', | ||
papayawhip: 'ffefd5', | ||
peachpuff: 'ffdab9', | ||
peru: 'cd853f', | ||
pink: 'ffc0cb', | ||
plum: 'dda0dd', | ||
powderblue: 'b0e0e6', | ||
purple: '800080', | ||
red: 'f00', | ||
rosybrown: 'bc8f8f', | ||
royalblue: '4169e1', | ||
saddlebrown: '8b4513', | ||
salmon: 'fa8072', | ||
sandybrown: 'f4a460', | ||
seagreen: '2e8b57', | ||
seashell: 'fff5ee', | ||
sienna: 'a0522d', | ||
silver: 'c0c0c0', | ||
skyblue: '87ceeb', | ||
slateblue: '6a5acd', | ||
slategray: '708090', | ||
slategrey: '708090', | ||
snow: 'fffafa', | ||
springgreen: '00ff7f', | ||
steelblue: '4682b4', | ||
tan: 'd2b48c', | ||
teal: '008080', | ||
thistle: 'd8bfd8', | ||
tomato: 'ff6347', | ||
turquoise: '40e0d0', | ||
violet: 'ee82ee', | ||
wheat: 'f5deb3', | ||
white: 'fff', | ||
whitesmoke: 'f5f5f5', | ||
yellow: 'ff0', | ||
yellowgreen: '9acd32' | ||
}; | ||
/* eslint no-bitwise: "off" */ | ||
var hexNames = flip(NAMES); | ||
/* eslint no-bitwise: "off" */ | ||
var hexNames = flip(NAMES); | ||
var Converter = { | ||
HSLtoRGB: function HSLtoRGB(hsl) { | ||
var h = hsl.h / 360; | ||
var s = hsl.s; | ||
var l = hsl.l; | ||
var m1 = void 0; | ||
var m2 = void 0; | ||
var rgb = void 0; | ||
var Converter = { | ||
HSLtoRGB: function HSLtoRGB(hsl) { | ||
var h = hsl.h / 360; | ||
var s = hsl.s; | ||
var l = hsl.l; | ||
var m1 = void 0; | ||
var m2 = void 0; | ||
var rgb = void 0; | ||
if (l <= 0.5) { | ||
m2 = l * (s + 1); | ||
} else { | ||
m2 = l + s - l * s; | ||
} | ||
m1 = l * 2 - m2; | ||
rgb = { | ||
r: this.hueToRGB(m1, m2, h + 1 / 3), | ||
g: this.hueToRGB(m1, m2, h), | ||
b: this.hueToRGB(m1, m2, h - 1 / 3) | ||
}; | ||
if (typeof hsl.a !== 'undefined') { | ||
rgb.a = hsl.a; | ||
} | ||
if (hsl.l === 0) { | ||
rgb.h = hsl.h; | ||
} | ||
if (hsl.l === 1) { | ||
rgb.h = hsl.h; | ||
} | ||
return rgb; | ||
}, | ||
if (l <= 0.5) { | ||
m2 = l * (s + 1); | ||
} else { | ||
m2 = l + s - l * s; | ||
} | ||
m1 = l * 2 - m2; | ||
rgb = { | ||
r: this.hueToRGB(m1, m2, h + 1 / 3), | ||
g: this.hueToRGB(m1, m2, h), | ||
b: this.hueToRGB(m1, m2, h - 1 / 3) | ||
}; | ||
hueToRGB: function hueToRGB(m1, m2, h) { | ||
var v = void 0; | ||
if (h < 0) { | ||
h += 1; | ||
} else if (h > 1) { | ||
h -= 1; | ||
} | ||
if (h * 6 < 1) { | ||
v = m1 + (m2 - m1) * h * 6; | ||
} else if (h * 2 < 1) { | ||
v = m2; | ||
} else if (h * 3 < 2) { | ||
v = m1 + (m2 - m1) * (2 / 3 - h) * 6; | ||
} else { | ||
v = m1; | ||
} | ||
return Math.round(v * 255); | ||
}, | ||
if (typeof hsl.a !== 'undefined') { | ||
rgb.a = hsl.a; | ||
} | ||
RGBtoHSL: function RGBtoHSL(rgb) { | ||
var r = rgb.r / 255; | ||
var g = rgb.g / 255; | ||
var b = rgb.b / 255; | ||
var min = Math.min(r, g, b); | ||
var max = Math.max(r, g, b); | ||
var diff = max - min; | ||
var add = max + min; | ||
var l = add * 0.5; | ||
var h = void 0; | ||
var s = void 0; | ||
if (hsl.l === 0) { | ||
rgb.h = hsl.h; | ||
} | ||
if (min === max) { | ||
h = 0; | ||
} else if (r === max) { | ||
h = 60 * (g - b) / diff + 360; | ||
} else if (g === max) { | ||
h = 60 * (b - r) / diff + 120; | ||
} else { | ||
h = 60 * (r - g) / diff + 240; | ||
} | ||
if (diff === 0) { | ||
s = 0; | ||
} else if (l <= 0.5) { | ||
s = diff / add; | ||
} else { | ||
s = diff / (2 - add); | ||
} | ||
if (hsl.l === 1) { | ||
rgb.h = hsl.h; | ||
} | ||
return { | ||
h: Math.round(h) % 360, | ||
s: s, | ||
l: l | ||
}; | ||
}, | ||
return rgb; | ||
}, | ||
RGBtoHEX: function RGBtoHEX(rgb) { | ||
var hex = [rgb.r.toString(16), rgb.g.toString(16), rgb.b.toString(16)]; | ||
hueToRGB: function hueToRGB(m1, m2, h) { | ||
var v = void 0; | ||
if (h < 0) { | ||
h += 1; | ||
} else if (h > 1) { | ||
h -= 1; | ||
_jquery2.default.each(hex, function(nr, val) { | ||
if (val.length === 1) { | ||
hex[nr] = '0' + val; | ||
} | ||
}); | ||
return '#' + hex.join(''); | ||
}, | ||
if (h * 6 < 1) { | ||
v = m1 + (m2 - m1) * h * 6; | ||
} else if (h * 2 < 1) { | ||
v = m2; | ||
} else if (h * 3 < 2) { | ||
v = m1 + (m2 - m1) * (2 / 3 - h) * 6; | ||
} else { | ||
v = m1; | ||
} | ||
HSLtoHEX: function HSLtoHEX(hsl) { | ||
var rgb = this.HSLtoRGB(hsl); | ||
return this.RGBtoHEX(rgb); | ||
}, | ||
return Math.round(v * 255); | ||
}, | ||
HSVtoHEX: function HSVtoHEX(hsv) { | ||
var rgb = this.HSVtoRGB(hsv); | ||
return this.RGBtoHEX(rgb); | ||
}, | ||
RGBtoHSL: function RGBtoHSL(rgb) { | ||
var r = rgb.r / 255; | ||
var g = rgb.g / 255; | ||
var b = rgb.b / 255; | ||
var min = Math.min(r, g, b); | ||
var max = Math.max(r, g, b); | ||
var diff = max - min; | ||
var add = max + min; | ||
var l = add * 0.5; | ||
var h = void 0; | ||
var s = void 0; | ||
if (min === max) { | ||
h = 0; | ||
} else if (r === max) { | ||
h = 60 * (g - b) / diff + 360; | ||
} else if (g === max) { | ||
h = 60 * (b - r) / diff + 120; | ||
} else { | ||
h = 60 * (r - g) / diff + 240; | ||
RGBtoHSV: function RGBtoHSV(rgb) { | ||
var r = rgb.r / 255; | ||
var g = rgb.g / 255; | ||
var b = rgb.b / 255; | ||
var max = Math.max(r, g, b); | ||
var min = Math.min(r, g, b); | ||
var h = void 0; | ||
var s = void 0; | ||
var v = max; | ||
var diff = max - min; | ||
s = max === 0 ? 0 : diff / max; | ||
if (max === min) { | ||
h = 0; | ||
} else { | ||
switch (max) { | ||
case r: { | ||
h = (g - b) / diff + (g < b ? 6 : 0); | ||
break; | ||
} | ||
case g: { | ||
h = (b - r) / diff + 2; | ||
break; | ||
} | ||
case b: { | ||
h = (r - g) / diff + 4; | ||
break; | ||
} | ||
default: { | ||
break; | ||
} | ||
} | ||
h /= 6; | ||
} | ||
if (diff === 0) { | ||
s = 0; | ||
} else if (l <= 0.5) { | ||
s = diff / add; | ||
} else { | ||
s = diff / (2 - add); | ||
} | ||
return { | ||
h: Math.round(h * 360), | ||
s: s, | ||
v: v | ||
}; | ||
}, | ||
return { | ||
h: Math.round(h) % 360, | ||
s: s, | ||
l: l | ||
}; | ||
}, | ||
HSVtoRGB: function HSVtoRGB(hsv) { | ||
var r = void 0; | ||
var g = void 0; | ||
var b = void 0; | ||
var h = (hsv.h % 360) / 60; | ||
var s = hsv.s; | ||
var v = hsv.v; | ||
var c = v * s; | ||
var x = c * (1 - Math.abs(h % 2 - 1)); | ||
RGBtoHEX: function RGBtoHEX(rgb) { | ||
var hex = [rgb.r.toString(16), rgb.g.toString(16), rgb.b.toString(16)]; | ||
r = g = b = v - c; | ||
h = ~~h; | ||
_jquery2.default.each(hex, | ||
r += [c, x, 0, 0, x, c][h]; | ||
g += [x, c, c, x, 0, 0][h]; | ||
b += [0, 0, x, c, c, x][h]; | ||
function(nr, val) { | ||
if (val.length === 1) { | ||
hex[nr] = '0' + val; | ||
} | ||
} | ||
); | ||
var rgb = { | ||
r: Math.round(r * 255), | ||
g: Math.round(g * 255), | ||
b: Math.round(b * 255) | ||
}; | ||
return '#' + hex.join(''); | ||
}, | ||
if (typeof hsv.a !== 'undefined') { | ||
rgb.a = hsv.a; | ||
} | ||
HSLtoHEX: function HSLtoHEX(hsl) { | ||
var rgb = this.HSLtoRGB(hsl); | ||
if (hsv.v === 0) { | ||
rgb.h = hsv.h; | ||
} | ||
return this.RGBtoHEX(rgb); | ||
}, | ||
if (hsv.v === 1 && hsv.s === 0) { | ||
rgb.h = hsv.h; | ||
} | ||
HSVtoHEX: function HSVtoHEX(hsv) { | ||
var rgb = this.HSVtoRGB(hsv); | ||
return rgb; | ||
}, | ||
return this.RGBtoHEX(rgb); | ||
}, | ||
HEXtoRGB: function HEXtoRGB(hex) { | ||
if (hex.length === 4) { | ||
hex = expandHex(hex); | ||
} | ||
return { | ||
r: parseIntFromHex(hex.substr(1, 2)), | ||
g: parseIntFromHex(hex.substr(3, 2)), | ||
b: parseIntFromHex(hex.substr(5, 2)) | ||
}; | ||
}, | ||
RGBtoHSV: function RGBtoHSV(rgb) { | ||
var r = rgb.r / 255; | ||
var g = rgb.g / 255; | ||
var b = rgb.b / 255; | ||
var max = Math.max(r, g, b); | ||
var min = Math.min(r, g, b); | ||
var h = void 0; | ||
var s = void 0; | ||
var v = max; | ||
var diff = max - min; | ||
s = max === 0 ? 0 : diff / max; | ||
isNAME: function isNAME(string) { | ||
if (NAMES.hasOwnProperty(string)) { | ||
return true; | ||
} | ||
return false; | ||
}, | ||
if (max === min) { | ||
h = 0; | ||
} else { | ||
switch (max) { | ||
case r: { | ||
h = (g - b) / diff + (g < b ? 6 : 0); | ||
break; | ||
} | ||
case g: { | ||
h = (b - r) / diff + 2; | ||
break; | ||
} | ||
case b: { | ||
h = (r - g) / diff + 4; | ||
break; | ||
} | ||
default: { | ||
break; | ||
} | ||
} | ||
h /= 6; | ||
} | ||
NAMEtoHEX: function NAMEtoHEX(name) { | ||
if (NAMES.hasOwnProperty(name)) { | ||
return '#' + NAMES[name]; | ||
} | ||
return null; | ||
}, | ||
return { | ||
h: Math.round(h * 360), | ||
s: s, | ||
v: v | ||
}; | ||
}, | ||
NAMEtoRGB: function NAMEtoRGB(name) { | ||
var hex = this.NAMEtoHEX(name); | ||
HSVtoRGB: function HSVtoRGB(hsv) { | ||
var r = void 0; | ||
var g = void 0; | ||
var b = void 0; | ||
var h = hsv.h % 360 / 60; | ||
var s = hsv.s; | ||
var v = hsv.v; | ||
var c = v * s; | ||
var x = c * (1 - Math.abs(h % 2 - 1)); | ||
if (hex) { | ||
return this.HEXtoRGB(hex); | ||
} | ||
return null; | ||
}, | ||
r = g = b = v - c; | ||
h = ~~h; | ||
hasNAME: function hasNAME(rgb) { | ||
var hex = this.RGBtoHEX(rgb); | ||
r += [c, x, 0, 0, x, c][h]; | ||
g += [x, c, c, x, 0, 0][h]; | ||
b += [0, 0, x, c, c, x][h]; | ||
hex = shrinkHex(hex); | ||
var rgb = { | ||
r: Math.round(r * 255), | ||
g: Math.round(g * 255), | ||
b: Math.round(b * 255) | ||
}; | ||
if (hex.indexOf('#') === 0) { | ||
hex = hex.substr(1); | ||
} | ||
if (typeof hsv.a !== 'undefined') { | ||
rgb.a = hsv.a; | ||
} | ||
if (hexNames.hasOwnProperty(hex)) { | ||
return hexNames[hex]; | ||
} | ||
return false; | ||
}, | ||
if (hsv.v === 0) { | ||
rgb.h = hsv.h; | ||
} | ||
RGBtoNAME: function RGBtoNAME(rgb) { | ||
var hasName = this.hasNAME(rgb); | ||
if (hasName) { | ||
return hasName; | ||
} | ||
if (hsv.v === 1 && hsv.s === 0) { | ||
rgb.h = hsv.h; | ||
} | ||
return null; | ||
} | ||
}; | ||
return rgb; | ||
}, | ||
var CSS_INTEGER = '[-\\+]?\\d+%?'; | ||
var CSS_NUMBER = '[-\\+]?\\d*\\.\\d+%?'; | ||
var CSS_UNIT = '(?:' + CSS_NUMBER + ')|(?:' + CSS_INTEGER + ')'; | ||
HEXtoRGB: function HEXtoRGB(hex) { | ||
if (hex.length === 4) { | ||
hex = expandHex(hex); | ||
} | ||
var PERMISSIVE_MATCH3 = | ||
'[\\s|\\(]+(' + | ||
CSS_UNIT + | ||
')[,|\\s]+(' + | ||
CSS_UNIT + | ||
')[,|\\s]+(' + | ||
CSS_UNIT + | ||
')\\s*\\)'; | ||
var PERMISSIVE_MATCH4 = | ||
'[\\s|\\(]+(' + | ||
CSS_UNIT + | ||
')[,|\\s]+(' + | ||
CSS_UNIT + | ||
')[,|\\s]+(' + | ||
CSS_UNIT + | ||
')[,|\\s]+(' + | ||
CSS_UNIT + | ||
')\\s*\\)'; | ||
var ColorStrings = { | ||
RGB: { | ||
match: new RegExp('^rgb' + PERMISSIVE_MATCH3 + '$', 'i'), | ||
parse: function parse(result) { | ||
return { | ||
r: parseIntFromHex(hex.substr(1, 2)), | ||
g: parseIntFromHex(hex.substr(3, 2)), | ||
b: parseIntFromHex(hex.substr(5, 2)) | ||
r: isPercentage(result[1]) | ||
? conventPercentageToRgb(result[1]) | ||
: parseInt(result[1], 10), | ||
g: isPercentage(result[2]) | ||
? conventPercentageToRgb(result[2]) | ||
: parseInt(result[2], 10), | ||
b: isPercentage(result[3]) | ||
? conventPercentageToRgb(result[3]) | ||
: parseInt(result[3], 10), | ||
a: 1 | ||
}; | ||
}, | ||
isNAME: function isNAME(string) { | ||
if (NAMES.hasOwnProperty(string)) { | ||
return true; | ||
} | ||
return false; | ||
to: function to(color) { | ||
return 'rgb(' + color.r + ', ' + color.g + ', ' + color.b + ')'; | ||
} | ||
}, | ||
RGBA: { | ||
match: new RegExp('^rgba' + PERMISSIVE_MATCH4 + '$', 'i'), | ||
parse: function parse(result) { | ||
return { | ||
r: isPercentage(result[1]) | ||
? conventPercentageToRgb(result[1]) | ||
: parseInt(result[1], 10), | ||
g: isPercentage(result[2]) | ||
? conventPercentageToRgb(result[2]) | ||
: parseInt(result[2], 10), | ||
b: isPercentage(result[3]) | ||
? conventPercentageToRgb(result[3]) | ||
: parseInt(result[3], 10), | ||
a: isPercentage(result[4]) | ||
? convertPercentageToFloat(result[4]) | ||
: parseFloat(result[4], 10) | ||
}; | ||
}, | ||
to: function to(color) { | ||
return ( | ||
'rgba(' + | ||
color.r + | ||
', ' + | ||
color.g + | ||
', ' + | ||
color.b + | ||
', ' + | ||
color.a + | ||
')' | ||
); | ||
} | ||
}, | ||
HSL: { | ||
match: new RegExp('^hsl' + PERMISSIVE_MATCH3 + '$', 'i'), | ||
parse: function parse(result) { | ||
var hsl = { | ||
h: (result[1] % 360 + 360) % 360, | ||
s: isPercentage(result[2]) | ||
? convertPercentageToFloat(result[2]) | ||
: parseFloat(result[2], 10), | ||
l: isPercentage(result[3]) | ||
? convertPercentageToFloat(result[3]) | ||
: parseFloat(result[3], 10), | ||
a: 1 | ||
}; | ||
NAMEtoHEX: function NAMEtoHEX(name) { | ||
if (NAMES.hasOwnProperty(name)) { | ||
return '#' + NAMES[name]; | ||
} | ||
return null; | ||
return Converter.HSLtoRGB(hsl); | ||
}, | ||
to: function to(color) { | ||
var hsl = Converter.RGBtoHSL(color); | ||
return ( | ||
'hsl(' + | ||
parseInt(hsl.h, 10) + | ||
', ' + | ||
Math.round(hsl.s * 100) + | ||
'%, ' + | ||
Math.round(hsl.l * 100) + | ||
'%)' | ||
); | ||
} | ||
}, | ||
HSLA: { | ||
match: new RegExp('^hsla' + PERMISSIVE_MATCH4 + '$', 'i'), | ||
parse: function parse(result) { | ||
var hsla = { | ||
h: (result[1] % 360 + 360) % 360, | ||
s: isPercentage(result[2]) | ||
? convertPercentageToFloat(result[2]) | ||
: parseFloat(result[2], 10), | ||
l: isPercentage(result[3]) | ||
? convertPercentageToFloat(result[3]) | ||
: parseFloat(result[3], 10), | ||
a: isPercentage(result[4]) | ||
? convertPercentageToFloat(result[4]) | ||
: parseFloat(result[4], 10) | ||
}; | ||
NAMEtoRGB: function NAMEtoRGB(name) { | ||
var hex = this.NAMEtoHEX(name); | ||
if (hex) { | ||
return this.HEXtoRGB(hex); | ||
} | ||
return null; | ||
return Converter.HSLtoRGB(hsla); | ||
}, | ||
hasNAME: function hasNAME(rgb) { | ||
var hex = this.RGBtoHEX(rgb); | ||
hex = shrinkHex(hex); | ||
if (hex.indexOf('#') === 0) { | ||
hex = hex.substr(1); | ||
} | ||
if (hexNames.hasOwnProperty(hex)) { | ||
return hexNames[hex]; | ||
} | ||
return false; | ||
to: function to(color) { | ||
var hsl = Converter.RGBtoHSL(color); | ||
return ( | ||
'hsla(' + | ||
parseInt(hsl.h, 10) + | ||
', ' + | ||
Math.round(hsl.s * 100) + | ||
'%, ' + | ||
Math.round(hsl.l * 100) + | ||
'%, ' + | ||
color.a + | ||
')' | ||
); | ||
} | ||
}, | ||
HEX: { | ||
match: /^#([a-f0-9]{6}|[a-f0-9]{3})$/i, | ||
parse: function parse(result) { | ||
var hex = result[0]; | ||
var rgb = Converter.HEXtoRGB(hex); | ||
return { | ||
r: rgb.r, | ||
g: rgb.g, | ||
b: rgb.b, | ||
a: 1 | ||
}; | ||
}, | ||
to: function to(color, instance) { | ||
var hex = Converter.RGBtoHEX(color); | ||
RGBtoNAME: function RGBtoNAME(rgb) { | ||
var hasName = this.hasNAME(rgb); | ||
if (hasName) { | ||
return hasName; | ||
if (instance) { | ||
if (instance.options.hexUseName) { | ||
var hasName = Converter.hasNAME(color); | ||
if (hasName) { | ||
return hasName; | ||
} | ||
} | ||
if (instance.options.shortenHex) { | ||
hex = shrinkHex(hex); | ||
} | ||
} | ||
return null; | ||
return '' + hex; | ||
} | ||
}; | ||
var CSS_INTEGER = '[-\\+]?\\d+%?'; | ||
var CSS_NUMBER = '[-\\+]?\\d*\\.\\d+%?'; | ||
var CSS_UNIT = '(?:' + CSS_NUMBER + ')|(?:' + CSS_INTEGER + ')'; | ||
var PERMISSIVE_MATCH3 = '[\\s|\\(]+(' + CSS_UNIT + ')[,|\\s]+(' + CSS_UNIT + ')[,|\\s]+(' + CSS_UNIT + ')\\s*\\)'; | ||
var PERMISSIVE_MATCH4 = '[\\s|\\(]+(' + CSS_UNIT + ')[,|\\s]+(' + CSS_UNIT + ')[,|\\s]+(' + CSS_UNIT + ')[,|\\s]+(' + CSS_UNIT + ')\\s*\\)'; | ||
var ColorStrings = { | ||
RGB: { | ||
match: new RegExp('^rgb' + PERMISSIVE_MATCH3 + '$', 'i'), | ||
parse: function parse(result) { | ||
return { | ||
r: isPercentage(result[1]) ? conventPercentageToRgb(result[1]) : parseInt(result[1], 10), | ||
g: isPercentage(result[2]) ? conventPercentageToRgb(result[2]) : parseInt(result[2], 10), | ||
b: isPercentage(result[3]) ? conventPercentageToRgb(result[3]) : parseInt(result[3], 10), | ||
a: 1 | ||
}; | ||
}, | ||
to: function to(color) { | ||
return 'rgb(' + color.r + ', ' + color.g + ', ' + color.b + ')'; | ||
} | ||
}, | ||
TRANSPARENT: { | ||
match: /^transparent$/i, | ||
parse: function parse() { | ||
return { | ||
r: 0, | ||
g: 0, | ||
b: 0, | ||
a: 0 | ||
}; | ||
}, | ||
RGBA: { | ||
match: new RegExp('^rgba' + PERMISSIVE_MATCH4 + '$', 'i'), | ||
parse: function parse(result) { | ||
to: function to() { | ||
return 'transparent'; | ||
} | ||
}, | ||
NAME: { | ||
match: /^\w+$/i, | ||
parse: function parse(result) { | ||
var rgb = Converter.NAMEtoRGB(result[0]); | ||
if (rgb) { | ||
return { | ||
r: isPercentage(result[1]) ? conventPercentageToRgb(result[1]) : parseInt(result[1], 10), | ||
g: isPercentage(result[2]) ? conventPercentageToRgb(result[2]) : parseInt(result[2], 10), | ||
b: isPercentage(result[3]) ? conventPercentageToRgb(result[3]) : parseInt(result[3], 10), | ||
a: isPercentage(result[4]) ? convertPercentageToFloat(result[4]) : parseFloat(result[4], 10) | ||
}; | ||
}, | ||
to: function to(color) { | ||
return 'rgba(' + color.r + ', ' + color.g + ', ' + color.b + ', ' + color.a + ')'; | ||
} | ||
}, | ||
HSL: { | ||
match: new RegExp('^hsl' + PERMISSIVE_MATCH3 + '$', 'i'), | ||
parse: function parse(result) { | ||
var hsl = { | ||
h: (result[1] % 360 + 360) % 360, | ||
s: isPercentage(result[2]) ? convertPercentageToFloat(result[2]) : parseFloat(result[2], 10), | ||
l: isPercentage(result[3]) ? convertPercentageToFloat(result[3]) : parseFloat(result[3], 10), | ||
a: 1 | ||
}; | ||
return Converter.HSLtoRGB(hsl); | ||
}, | ||
to: function to(color) { | ||
var hsl = Converter.RGBtoHSL(color); | ||
return 'hsl(' + parseInt(hsl.h, 10) + ', ' + Math.round(hsl.s * 100) + '%, ' + Math.round(hsl.l * 100) + '%)'; | ||
} | ||
}, | ||
HSLA: { | ||
match: new RegExp('^hsla' + PERMISSIVE_MATCH4 + '$', 'i'), | ||
parse: function parse(result) { | ||
var hsla = { | ||
h: (result[1] % 360 + 360) % 360, | ||
s: isPercentage(result[2]) ? convertPercentageToFloat(result[2]) : parseFloat(result[2], 10), | ||
l: isPercentage(result[3]) ? convertPercentageToFloat(result[3]) : parseFloat(result[3], 10), | ||
a: isPercentage(result[4]) ? convertPercentageToFloat(result[4]) : parseFloat(result[4], 10) | ||
}; | ||
return Converter.HSLtoRGB(hsla); | ||
}, | ||
to: function to(color) { | ||
var hsl = Converter.RGBtoHSL(color); | ||
return 'hsla(' + parseInt(hsl.h, 10) + ', ' + Math.round(hsl.s * 100) + '%, ' + Math.round(hsl.l * 100) + '%, ' + color.a + ')'; | ||
} | ||
}, | ||
HEX: { | ||
match: /^#([a-f0-9]{6}|[a-f0-9]{3})$/i, | ||
parse: function parse(result) { | ||
var hex = result[0]; | ||
var rgb = Converter.HEXtoRGB(hex); | ||
return { | ||
r: rgb.r, | ||
@@ -664,415 +739,390 @@ g: rgb.g, | ||
}; | ||
}, | ||
to: function to(color, instance) { | ||
var hex = Converter.RGBtoHEX(color); | ||
} | ||
if (instance) { | ||
return null; | ||
}, | ||
to: function to(color, instance) { | ||
var name = Converter.RGBtoNAME(color); | ||
if (instance.options.hexUseName) { | ||
var hasName = Converter.hasNAME(color); | ||
if (hasName) { | ||
return hasName; | ||
} | ||
} | ||
if (instance.options.shortenHex) { | ||
hex = shrinkHex(hex); | ||
} | ||
} | ||
return '' + hex; | ||
if (name) { | ||
return name; | ||
} | ||
}, | ||
TRANSPARENT: { | ||
match: /^transparent$/i, | ||
parse: function parse() { | ||
return { | ||
r: 0, | ||
g: 0, | ||
b: 0, | ||
a: 0 | ||
}; | ||
}, | ||
to: function to() { | ||
return 'transparent'; | ||
} | ||
}, | ||
NAME: { | ||
match: /^\w+$/i, | ||
parse: function parse(result) { | ||
var rgb = Converter.NAMEtoRGB(result[0]); | ||
if (rgb) { | ||
return ColorStrings[instance.options.nameDegradation.toUpperCase()].to( | ||
color | ||
); | ||
} | ||
} | ||
}; | ||
return { | ||
r: rgb.r, | ||
g: rgb.g, | ||
b: rgb.b, | ||
a: 1 | ||
}; | ||
} | ||
/* eslint no-extend-native: "off" */ | ||
if (!String.prototype.includes) { | ||
String.prototype.includes = function(search, start) { | ||
'use strict'; | ||
return null; | ||
}, | ||
to: function to(color, instance) { | ||
var name = Converter.RGBtoNAME(color); | ||
if (typeof start !== 'number') { | ||
start = 0; | ||
} | ||
if (name) { | ||
return name; | ||
} | ||
return ColorStrings[instance.options.nameDegradation.toUpperCase()].to(color); | ||
} | ||
if (start + search.length > this.length) { | ||
return false; | ||
} | ||
return this.indexOf(search, start) !== -1; | ||
}; | ||
} | ||
/* eslint no-extend-native: "off" */ | ||
var AsColor = (function() { | ||
function AsColor(string, options) { | ||
_classCallCheck(this, AsColor); | ||
if (!String.prototype.includes) { | ||
String.prototype.includes = function(search, start) { | ||
'use strict'; | ||
if (typeof start !== 'number') { | ||
start = 0; | ||
} | ||
if (start + search.length > this.length) { | ||
return false; | ||
} | ||
return this.indexOf(search, start) !== -1; | ||
if ( | ||
(typeof string === 'undefined' ? 'undefined' : _typeof(string)) === | ||
'object' && | ||
typeof options === 'undefined' | ||
) { | ||
options = string; | ||
string = undefined; | ||
} | ||
; | ||
} | ||
var AsColor = function() { | ||
function AsColor(string, options) { | ||
_classCallCheck(this, AsColor); | ||
if ((typeof string === 'undefined' ? 'undefined' : _typeof(string)) === 'object' && typeof options === 'undefined') { | ||
options = string; | ||
string = undefined; | ||
} | ||
if (typeof options === 'string') { | ||
options = { | ||
format: options | ||
}; | ||
} | ||
this.options = _jquery2.default.extend(true, {}, DEFAULTS, options); | ||
this.value = { | ||
r: 0, | ||
g: 0, | ||
b: 0, | ||
h: 0, | ||
s: 0, | ||
v: 0, | ||
a: 1 | ||
if (typeof options === 'string') { | ||
options = { | ||
format: options | ||
}; | ||
this._format = false; | ||
this._matchFormat = 'HEX'; | ||
this._valid = true; | ||
this.init(string); | ||
} | ||
this.options = _jquery2.default.extend(true, {}, DEFAULTS, options); | ||
this.value = { | ||
r: 0, | ||
g: 0, | ||
b: 0, | ||
h: 0, | ||
s: 0, | ||
v: 0, | ||
a: 1 | ||
}; | ||
this._format = false; | ||
this._matchFormat = 'HEX'; | ||
this._valid = true; | ||
_createClass(AsColor, [{ | ||
key: 'init', | ||
value: function init(string) { | ||
this.format(this.options.format); | ||
this.fromString(string); | ||
this.init(string); | ||
} | ||
return this; | ||
} | ||
}, { | ||
key: 'isValid', | ||
value: function isValid() { | ||
return this._valid; | ||
} | ||
}, { | ||
key: 'val', | ||
value: function val(value) { | ||
if (typeof value === 'undefined') { | ||
return this.toString(); | ||
_createClass( | ||
AsColor, | ||
[ | ||
{ | ||
key: 'init', | ||
value: function init(string) { | ||
this.format(this.options.format); | ||
this.fromString(string); | ||
return this; | ||
} | ||
this.fromString(value); | ||
return this; | ||
} | ||
}, { | ||
key: 'alpha', | ||
value: function alpha(value) { | ||
if (typeof value === 'undefined' || isNaN(value)) { | ||
return this.value.a; | ||
}, | ||
{ | ||
key: 'isValid', | ||
value: function isValid() { | ||
return this._valid; | ||
} | ||
}, | ||
{ | ||
key: 'val', | ||
value: function val(value) { | ||
if (typeof value === 'undefined') { | ||
return this.toString(); | ||
} | ||
this.fromString(value); | ||
return this; | ||
} | ||
}, | ||
{ | ||
key: 'alpha', | ||
value: function alpha(value) { | ||
if (typeof value === 'undefined' || isNaN(value)) { | ||
return this.value.a; | ||
} | ||
value = parseFloat(value); | ||
value = parseFloat(value); | ||
if (value > 1) { | ||
value = 1; | ||
} else if (value < 0) { | ||
value = 0; | ||
if (value > 1) { | ||
value = 1; | ||
} else if (value < 0) { | ||
value = 0; | ||
} | ||
this.value.a = value; | ||
return this; | ||
} | ||
this.value.a = value; | ||
}, | ||
{ | ||
key: 'matchString', | ||
value: function matchString(string) { | ||
return AsColor.matchString(string); | ||
} | ||
}, | ||
{ | ||
key: 'fromString', | ||
value: function fromString(string, updateFormat) { | ||
if (typeof string === 'string') { | ||
string = _jquery2.default.trim(string); | ||
var matched = null; | ||
var rgb = void 0; | ||
this._valid = false; | ||
for (var i in ColorStrings) { | ||
if ((matched = ColorStrings[i].match.exec(string)) !== null) { | ||
rgb = ColorStrings[i].parse(matched); | ||
return this; | ||
} | ||
}, { | ||
key: 'matchString', | ||
value: function matchString(string) { | ||
return AsColor.matchString(string); | ||
} | ||
}, { | ||
key: 'fromString', | ||
value: function fromString(string, updateFormat) { | ||
if (typeof string === 'string') { | ||
string = _jquery2.default.trim(string); | ||
var matched = null; | ||
var rgb = void 0; | ||
this._valid = false; | ||
for (var i in ColorStrings) { | ||
if ((matched = ColorStrings[i].match.exec(string)) !== null) { | ||
rgb = ColorStrings[i].parse(matched); | ||
if (rgb) { | ||
this.set(rgb); | ||
if (i === 'TRANSPARENT') { | ||
i = 'HEX'; | ||
if (rgb) { | ||
this.set(rgb); | ||
if (i === 'TRANSPARENT') { | ||
i = 'HEX'; | ||
} | ||
this._matchFormat = i; | ||
if (updateFormat === true) { | ||
this.format(i); | ||
} | ||
break; | ||
} | ||
this._matchFormat = i; | ||
if (updateFormat === true) { | ||
this.format(i); | ||
} | ||
break; | ||
} | ||
} | ||
} else if ( | ||
(typeof string === 'undefined' | ||
? 'undefined' | ||
: _typeof(string)) === 'object' | ||
) { | ||
this.set(string); | ||
} | ||
} else if ((typeof string === 'undefined' ? 'undefined' : _typeof(string)) === 'object') { | ||
this.set(string); | ||
return this; | ||
} | ||
return this; | ||
} | ||
}, { | ||
key: 'format', | ||
value: function format(_format) { | ||
if (typeof _format === 'string' && (_format = _format.toUpperCase()) && typeof ColorStrings[_format] !== 'undefined') { | ||
if (_format !== 'TRANSPARENT') { | ||
this._format = _format; | ||
} else { | ||
this._format = 'HEX'; | ||
}, | ||
{ | ||
key: 'format', | ||
value: function format(_format) { | ||
if ( | ||
typeof _format === 'string' && | ||
(_format = _format.toUpperCase()) && | ||
typeof ColorStrings[_format] !== 'undefined' | ||
) { | ||
if (_format !== 'TRANSPARENT') { | ||
this._format = _format; | ||
} else { | ||
this._format = 'HEX'; | ||
} | ||
} else if (_format === false) { | ||
this._format = false; | ||
} | ||
} else if (_format === false) { | ||
this._format = false; | ||
if (this._format === false) { | ||
return this._matchFormat; | ||
} | ||
return this._format; | ||
} | ||
if (this._format === false) { | ||
return this._matchFormat; | ||
}, | ||
{ | ||
key: 'toRGBA', | ||
value: function toRGBA() { | ||
return ColorStrings.RGBA.to(this.value, this); | ||
} | ||
return this._format; | ||
} | ||
}, { | ||
key: 'toRGBA', | ||
value: function toRGBA() { | ||
return ColorStrings.RGBA.to(this.value, this); | ||
} | ||
}, { | ||
key: 'toRGB', | ||
value: function toRGB() { | ||
return ColorStrings.RGB.to(this.value, this); | ||
} | ||
}, { | ||
key: 'toHSLA', | ||
value: function toHSLA() { | ||
return ColorStrings.HSLA.to(this.value, this); | ||
} | ||
}, { | ||
key: 'toHSL', | ||
value: function toHSL() { | ||
return ColorStrings.HSL.to(this.value, this); | ||
} | ||
}, { | ||
key: 'toHEX', | ||
value: function toHEX() { | ||
return ColorStrings.HEX.to(this.value, this); | ||
} | ||
}, { | ||
key: 'toNAME', | ||
value: function toNAME() { | ||
return ColorStrings.NAME.to(this.value, this); | ||
} | ||
}, { | ||
key: 'to', | ||
value: function to(format) { | ||
if (typeof format === 'string' && (format = format.toUpperCase()) && typeof ColorStrings[format] !== 'undefined') { | ||
return ColorStrings[format].to(this.value, this); | ||
}, | ||
{ | ||
key: 'toRGB', | ||
value: function toRGB() { | ||
return ColorStrings.RGB.to(this.value, this); | ||
} | ||
return this.toString(); | ||
} | ||
}, { | ||
key: 'toString', | ||
value: function toString() { | ||
var value = this.value; | ||
if (!this._valid) { | ||
value = this.options.invalidValue; | ||
if (typeof value === 'string') { | ||
return value; | ||
} | ||
}, | ||
{ | ||
key: 'toHSLA', | ||
value: function toHSLA() { | ||
return ColorStrings.HSLA.to(this.value, this); | ||
} | ||
if (value.a === 0 && this.options.zeroAlphaAsTransparent) { | ||
return ColorStrings.TRANSPARENT.to(value, this); | ||
}, | ||
{ | ||
key: 'toHSL', | ||
value: function toHSL() { | ||
return ColorStrings.HSL.to(this.value, this); | ||
} | ||
var format = void 0; | ||
if (this._format === false) { | ||
format = this._matchFormat; | ||
} else { | ||
format = this._format; | ||
}, | ||
{ | ||
key: 'toHEX', | ||
value: function toHEX() { | ||
return ColorStrings.HEX.to(this.value, this); | ||
} | ||
if (this.options.reduceAlpha && value.a === 1) { | ||
switch (format) { | ||
case 'RGBA': | ||
format = 'RGB'; | ||
break; | ||
case 'HSLA': | ||
format = 'HSL'; | ||
break; | ||
default: | ||
break; | ||
}, | ||
{ | ||
key: 'toNAME', | ||
value: function toNAME() { | ||
return ColorStrings.NAME.to(this.value, this); | ||
} | ||
}, | ||
{ | ||
key: 'to', | ||
value: function to(format) { | ||
if ( | ||
typeof format === 'string' && | ||
(format = format.toUpperCase()) && | ||
typeof ColorStrings[format] !== 'undefined' | ||
) { | ||
return ColorStrings[format].to(this.value, this); | ||
} | ||
return this.toString(); | ||
} | ||
}, | ||
{ | ||
key: 'toString', | ||
value: function toString() { | ||
var value = this.value; | ||
if (!this._valid) { | ||
value = this.options.invalidValue; | ||
if (value.a !== 1 && format !== 'RGBA' && format !== 'HSLA' && this.options.alphaConvert) { | ||
if (typeof value === 'string') { | ||
return value; | ||
} | ||
} | ||
if (typeof this.options.alphaConvert === 'string') { | ||
format = this.options.alphaConvert; | ||
if (value.a === 0 && this.options.zeroAlphaAsTransparent) { | ||
return ColorStrings.TRANSPARENT.to(value, this); | ||
} | ||
if (typeof this.options.alphaConvert[format] !== 'undefined') { | ||
format = this.options.alphaConvert[format]; | ||
var format = void 0; | ||
if (this._format === false) { | ||
format = this._matchFormat; | ||
} else { | ||
format = this._format; | ||
} | ||
} | ||
return ColorStrings[format].to(value, this); | ||
} | ||
}, { | ||
key: 'get', | ||
value: function get() { | ||
return this.value; | ||
} | ||
}, { | ||
key: 'set', | ||
value: function set(color) { | ||
this._valid = true; | ||
var fromRgb = 0; | ||
var fromHsv = 0; | ||
var hsv = void 0; | ||
var rgb = void 0; | ||
if (this.options.reduceAlpha && value.a === 1) { | ||
switch (format) { | ||
case 'RGBA': | ||
format = 'RGB'; | ||
break; | ||
case 'HSLA': | ||
format = 'HSL'; | ||
break; | ||
default: | ||
break; | ||
} | ||
} | ||
for (var i in color) { | ||
if ('hsv'.includes(i)) { | ||
fromHsv++; | ||
this.value[i] = color[i]; | ||
} else if ('rgb'.includes(i)) { | ||
fromRgb++; | ||
this.value[i] = color[i]; | ||
} else if (i === 'a') { | ||
this.value.a = color.a; | ||
if ( | ||
value.a !== 1 && | ||
format !== 'RGBA' && | ||
format !== 'HSLA' && | ||
this.options.alphaConvert | ||
) { | ||
if (typeof this.options.alphaConvert === 'string') { | ||
format = this.options.alphaConvert; | ||
} | ||
if (typeof this.options.alphaConvert[format] !== 'undefined') { | ||
format = this.options.alphaConvert[format]; | ||
} | ||
} | ||
return ColorStrings[format].to(value, this); | ||
} | ||
}, | ||
{ | ||
key: 'get', | ||
value: function get() { | ||
return this.value; | ||
} | ||
}, | ||
{ | ||
key: 'set', | ||
value: function set(color) { | ||
this._valid = true; | ||
var fromRgb = 0; | ||
var fromHsv = 0; | ||
var hsv = void 0; | ||
var rgb = void 0; | ||
if (fromRgb > fromHsv) { | ||
hsv = Converter.RGBtoHSV(this.value); | ||
for (var i in color) { | ||
if ('hsv'.includes(i)) { | ||
fromHsv++; | ||
this.value[i] = color[i]; | ||
} else if ('rgb'.includes(i)) { | ||
fromRgb++; | ||
this.value[i] = color[i]; | ||
} else if (i === 'a') { | ||
this.value.a = color.a; | ||
} | ||
} | ||
if (fromRgb > fromHsv) { | ||
hsv = Converter.RGBtoHSV(this.value); | ||
if ( | ||
this.value.r === 0 && | ||
this.value.g === 0 && | ||
this.value.b === 0 | ||
) { | ||
// this.value.h = color.h; | ||
} else { | ||
this.value.h = hsv.h; | ||
} | ||
if (this.value.r === 0 && this.value.g === 0 && this.value.b === 0) { | ||
// this.value.h = color.h; | ||
} else { | ||
this.value.h = hsv.h; | ||
this.value.s = hsv.s; | ||
this.value.v = hsv.v; | ||
} else if (fromHsv > fromRgb) { | ||
rgb = Converter.HSVtoRGB(this.value); | ||
this.value.r = rgb.r; | ||
this.value.g = rgb.g; | ||
this.value.b = rgb.b; | ||
} | ||
this.value.s = hsv.s; | ||
this.value.v = hsv.v; | ||
} else if (fromHsv > fromRgb) { | ||
rgb = Converter.HSVtoRGB(this.value); | ||
this.value.r = rgb.r; | ||
this.value.g = rgb.g; | ||
this.value.b = rgb.b; | ||
return this; | ||
} | ||
return this; | ||
} | ||
}], [{ | ||
key: 'matchString', | ||
value: function matchString(string) { | ||
if (typeof string === 'string') { | ||
string = _jquery2.default.trim(string); | ||
var matched = null; | ||
var rgb = void 0; | ||
], | ||
[ | ||
{ | ||
key: 'matchString', | ||
value: function matchString(string) { | ||
if (typeof string === 'string') { | ||
string = _jquery2.default.trim(string); | ||
var matched = null; | ||
var rgb = void 0; | ||
for (var i in ColorStrings) { | ||
if ((matched = ColorStrings[i].match.exec(string)) !== null) { | ||
rgb = ColorStrings[i].parse(matched); | ||
for (var i in ColorStrings) { | ||
if ((matched = ColorStrings[i].match.exec(string)) !== null) { | ||
rgb = ColorStrings[i].parse(matched); | ||
if (rgb) { | ||
return true; | ||
if (rgb) { | ||
return true; | ||
} | ||
} | ||
} | ||
} | ||
return false; | ||
} | ||
return false; | ||
}, | ||
{ | ||
key: 'setDefaults', | ||
value: function setDefaults(options) { | ||
_jquery2.default.extend( | ||
true, | ||
DEFAULTS, | ||
_jquery2.default.isPlainObject(options) && options | ||
); | ||
} | ||
} | ||
}, { | ||
key: 'setDefaults', | ||
value: function setDefaults(options) { | ||
_jquery2.default.extend(true, DEFAULTS, _jquery2.default.isPlainObject(options) && options); | ||
} | ||
}]); | ||
] | ||
); | ||
return AsColor; | ||
}(); | ||
return AsColor; | ||
})(); | ||
var info = { | ||
version: '0.3.4' | ||
}; | ||
var info = { | ||
version: '0.3.5' | ||
}; | ||
var OtherAsColor = _jquery2.default.asColor; | ||
var OtherAsColor = _jquery2.default.asColor; | ||
var jQueryAsColor = function jQueryAsColor() { | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
var jQueryAsColor = function jQueryAsColor() { | ||
for ( | ||
var _len = arguments.length, args = Array(_len), _key = 0; | ||
_key < _len; | ||
_key++ | ||
) { | ||
args[_key] = arguments[_key]; | ||
} | ||
return new (Function.prototype.bind.apply(AsColor, [null].concat(args)))(); | ||
}; | ||
return new (Function.prototype.bind.apply(AsColor, [null].concat(args)))(); | ||
}; | ||
_jquery2.default.asColor = jQueryAsColor; | ||
_jquery2.default.asColor.Constructor = AsColor; | ||
_jquery2.default.asColor = jQueryAsColor; | ||
_jquery2.default.asColor.Constructor = AsColor; | ||
_jquery2.default.extend(_jquery2.default.asColor, { | ||
_jquery2.default.extend( | ||
_jquery2.default.asColor, | ||
{ | ||
matchString: AsColor.matchString, | ||
@@ -1082,11 +1132,12 @@ setDefaults: AsColor.setDefaults, | ||
_jquery2.default.asColor = OtherAsColor; | ||
return jQueryAsColor; | ||
} | ||
}, Converter, info); | ||
}, | ||
Converter, | ||
info | ||
); | ||
var main = _jquery2.default.asColor; | ||
var main = _jquery2.default.asColor; | ||
exports.default = main; | ||
} | ||
); | ||
exports.default = main; | ||
}); |
/** | ||
* jQuery asColor v0.3.4 | ||
* jQuery asColor v0.3.5 | ||
* https://github.com/amazingSurge/asColor | ||
@@ -8,2 +8,3 @@ * | ||
*/ | ||
!function(e,t){if("function"==typeof define&&define.amd)define("AsColor",["exports","jquery"],t);else if("undefined"!=typeof exports)t(exports,require("jquery"));else{var r={exports:{}};t(r.exports,e.jQuery),e.AsColor=r.exports}}(this,function(e,t){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(e){return 0===e.indexOf("#")&&(e=e.substr(1)),e?(3===e.length&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),6===e.length?"#"+e:null):null}function o(e){return 0===e.indexOf("#")&&(e=e.substr(1)),6===e.length&&e[0]===e[1]&&e[2]===e[3]&&e[4]===e[5]&&(e=e[0]+e[2]+e[4]),"#"+e}function i(e){return parseInt(e,16)}function f(e){return"string"==typeof e&&e.indexOf("%")===e.length-1}function u(e){return parseInt(Math.round(2.55*e.slice(0,-1)),10)}function s(e){return parseFloat(e.slice(0,-1)/100,10)}function l(e){var t={};for(var r in e)e.hasOwnProperty(r)&&(t[e[r]]=r);return t}Object.defineProperty(e,"__esModule",{value:!0});var d=r(t),h="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},c=function(){function e(e,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}(),p={format:!1,shortenHex:!1,hexUseName:!1,reduceAlpha:!1,alphaConvert:{RGB:"RGBA",HSL:"HSLA",HEX:"RGBA",NAMESPACE:"RGBA"},nameDegradation:"HEX",invalidValue:"",zeroAlphaAsTransparent:!0},v={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},b=l(v),g={HSLtoRGB:function(e){var t=e.h/360,r=e.s,a=e.l,n=void 0,o=void 0,i=void 0;return o=a<=.5?a*(r+1):a+r-a*r,n=2*a-o,i={r:this.hueToRGB(n,o,t+1/3),g:this.hueToRGB(n,o,t),b:this.hueToRGB(n,o,t-1/3)},"undefined"!=typeof e.a&&(i.a=e.a),0===e.l&&(i.h=e.h),1===e.l&&(i.h=e.h),i},hueToRGB:function(e,t,r){var a=void 0;return r<0?r+=1:r>1&&(r-=1),a=6*r<1?e+(t-e)*r*6:2*r<1?t:3*r<2?e+(t-e)*(2/3-r)*6:e,Math.round(255*a)},RGBtoHSL:function(e){var t=e.r/255,r=e.g/255,a=e.b/255,n=Math.min(t,r,a),o=Math.max(t,r,a),i=o-n,f=o+n,u=.5*f,s=void 0,l=void 0;return s=n===o?0:t===o?60*(r-a)/i+360:r===o?60*(a-t)/i+120:60*(t-r)/i+240,l=0===i?0:u<=.5?i/f:i/(2-f),{h:Math.round(s)%360,s:l,l:u}},RGBtoHEX:function(e){var t=[e.r.toString(16),e.g.toString(16),e.b.toString(16)];return d.default.each(t,function(e,r){1===r.length&&(t[e]="0"+r)}),"#"+t.join("")},HSLtoHEX:function(e){var t=this.HSLtoRGB(e);return this.RGBtoHEX(t)},HSVtoHEX:function(e){var t=this.HSVtoRGB(e);return this.RGBtoHEX(t)},RGBtoHSV:function(e){var t=e.r/255,r=e.g/255,a=e.b/255,n=Math.max(t,r,a),o=Math.min(t,r,a),i=void 0,f=void 0,u=n,s=n-o;if(f=0===n?0:s/n,n===o)i=0;else{switch(n){case t:i=(r-a)/s+(r<a?6:0);break;case r:i=(a-t)/s+2;break;case a:i=(t-r)/s+4}i/=6}return{h:Math.round(360*i),s:f,v:u}},HSVtoRGB:function(e){var t=void 0,r=void 0,a=void 0,n=e.h%360/60,o=e.s,i=e.v,f=i*o,u=f*(1-Math.abs(n%2-1));t=r=a=i-f,n=~~n,t+=[f,u,0,0,u,f][n],r+=[u,f,f,u,0,0][n],a+=[0,0,u,f,f,u][n];var s={r:Math.round(255*t),g:Math.round(255*r),b:Math.round(255*a)};return"undefined"!=typeof e.a&&(s.a=e.a),0===e.v&&(s.h=e.h),1===e.v&&0===e.s&&(s.h=e.h),s},HEXtoRGB:function(e){return 4===e.length&&(e=n(e)),{r:i(e.substr(1,2)),g:i(e.substr(3,2)),b:i(e.substr(5,2))}},isNAME:function(e){return!!v.hasOwnProperty(e)},NAMEtoHEX:function(e){return v.hasOwnProperty(e)?"#"+v[e]:null},NAMEtoRGB:function(e){var t=this.NAMEtoHEX(e);return t?this.HEXtoRGB(t):null},hasNAME:function(e){var t=this.RGBtoHEX(e);return t=o(t),0===t.indexOf("#")&&(t=t.substr(1)),!!b.hasOwnProperty(t)&&b[t]},RGBtoNAME:function(e){var t=this.hasNAME(e);return t?t:null}},y="[-\\+]?\\d+%?",m="[-\\+]?\\d*\\.\\d+%?",k="(?:"+m+")|(?:"+y+")",R="[\\s|\\(]+("+k+")[,|\\s]+("+k+")[,|\\s]+("+k+")\\s*\\)",S="[\\s|\\(]+("+k+")[,|\\s]+("+k+")[,|\\s]+("+k+")[,|\\s]+("+k+")\\s*\\)",H={RGB:{match:new RegExp("^rgb"+R+"$","i"),parse:function(e){return{r:f(e[1])?u(e[1]):parseInt(e[1],10),g:f(e[2])?u(e[2]):parseInt(e[2],10),b:f(e[3])?u(e[3]):parseInt(e[3],10),a:1}},to:function(e){return"rgb("+e.r+", "+e.g+", "+e.b+")"}},RGBA:{match:new RegExp("^rgba"+S+"$","i"),parse:function(e){return{r:f(e[1])?u(e[1]):parseInt(e[1],10),g:f(e[2])?u(e[2]):parseInt(e[2],10),b:f(e[3])?u(e[3]):parseInt(e[3],10),a:f(e[4])?s(e[4]):parseFloat(e[4],10)}},to:function(e){return"rgba("+e.r+", "+e.g+", "+e.b+", "+e.a+")"}},HSL:{match:new RegExp("^hsl"+R+"$","i"),parse:function(e){var t={h:(e[1]%360+360)%360,s:f(e[2])?s(e[2]):parseFloat(e[2],10),l:f(e[3])?s(e[3]):parseFloat(e[3],10),a:1};return g.HSLtoRGB(t)},to:function(e){var t=g.RGBtoHSL(e);return"hsl("+parseInt(t.h,10)+", "+Math.round(100*t.s)+"%, "+Math.round(100*t.l)+"%)"}},HSLA:{match:new RegExp("^hsla"+S+"$","i"),parse:function(e){var t={h:(e[1]%360+360)%360,s:f(e[2])?s(e[2]):parseFloat(e[2],10),l:f(e[3])?s(e[3]):parseFloat(e[3],10),a:f(e[4])?s(e[4]):parseFloat(e[4],10)};return g.HSLtoRGB(t)},to:function(e){var t=g.RGBtoHSL(e);return"hsla("+parseInt(t.h,10)+", "+Math.round(100*t.s)+"%, "+Math.round(100*t.l)+"%, "+e.a+")"}},HEX:{match:/^#([a-f0-9]{6}|[a-f0-9]{3})$/i,parse:function(e){var t=e[0],r=g.HEXtoRGB(t);return{r:r.r,g:r.g,b:r.b,a:1}},to:function(e,t){var r=g.RGBtoHEX(e);if(t){if(t.options.hexUseName){var a=g.hasNAME(e);if(a)return a}t.options.shortenHex&&(r=o(r))}return""+r}},TRANSPARENT:{match:/^transparent$/i,parse:function(){return{r:0,g:0,b:0,a:0}},to:function(){return"transparent"}},NAME:{match:/^\w+$/i,parse:function(e){var t=g.NAMEtoRGB(e[0]);return t?{r:t.r,g:t.g,b:t.b,a:1}:null},to:function(e,t){var r=g.RGBtoNAME(e);return r?r:H[t.options.nameDegradation.toUpperCase()].to(e)}}};String.prototype.includes||(String.prototype.includes=function(e,t){return"number"!=typeof t&&(t=0),!(t+e.length>this.length)&&this.indexOf(e,t)!==-1});var A=function(){function e(t,r){a(this,e),"object"===("undefined"==typeof t?"undefined":h(t))&&"undefined"==typeof r&&(r=t,t=void 0),"string"==typeof r&&(r={format:r}),this.options=d.default.extend(!0,{},p,r),this.value={r:0,g:0,b:0,h:0,s:0,v:0,a:1},this._format=!1,this._matchFormat="HEX",this._valid=!0,this.init(t)}return c(e,[{key:"init",value:function(e){return this.format(this.options.format),this.fromString(e),this}},{key:"isValid",value:function(){return this._valid}},{key:"val",value:function(e){return"undefined"==typeof e?this.toString():(this.fromString(e),this)}},{key:"alpha",value:function(e){return"undefined"==typeof e||isNaN(e)?this.value.a:(e=parseFloat(e),e>1?e=1:e<0&&(e=0),this.value.a=e,this)}},{key:"matchString",value:function(t){return e.matchString(t)}},{key:"fromString",value:function(e,t){if("string"==typeof e){e=d.default.trim(e);var r=null,a=void 0;this._valid=!1;for(var n in H)if(null!==(r=H[n].match.exec(e))&&(a=H[n].parse(r))){this.set(a),"TRANSPARENT"===n&&(n="HEX"),this._matchFormat=n,t===!0&&this.format(n);break}}else"object"===("undefined"==typeof e?"undefined":h(e))&&this.set(e);return this}},{key:"format",value:function(e){return"string"==typeof e&&(e=e.toUpperCase())&&"undefined"!=typeof H[e]?"TRANSPARENT"!==e?this._format=e:this._format="HEX":e===!1&&(this._format=!1),this._format===!1?this._matchFormat:this._format}},{key:"toRGBA",value:function(){return H.RGBA.to(this.value,this)}},{key:"toRGB",value:function(){return H.RGB.to(this.value,this)}},{key:"toHSLA",value:function(){return H.HSLA.to(this.value,this)}},{key:"toHSL",value:function(){return H.HSL.to(this.value,this)}},{key:"toHEX",value:function(){return H.HEX.to(this.value,this)}},{key:"toNAME",value:function(){return H.NAME.to(this.value,this)}},{key:"to",value:function(e){return"string"==typeof e&&(e=e.toUpperCase())&&"undefined"!=typeof H[e]?H[e].to(this.value,this):this.toString()}},{key:"toString",value:function(){var e=this.value;if(!this._valid&&(e=this.options.invalidValue,"string"==typeof e))return e;if(0===e.a&&this.options.zeroAlphaAsTransparent)return H.TRANSPARENT.to(e,this);var t=void 0;if(t=this._format===!1?this._matchFormat:this._format,this.options.reduceAlpha&&1===e.a)switch(t){case"RGBA":t="RGB";break;case"HSLA":t="HSL"}return 1!==e.a&&"RGBA"!==t&&"HSLA"!==t&&this.options.alphaConvert&&("string"==typeof this.options.alphaConvert&&(t=this.options.alphaConvert),"undefined"!=typeof this.options.alphaConvert[t]&&(t=this.options.alphaConvert[t])),H[t].to(e,this)}},{key:"get",value:function(){return this.value}},{key:"set",value:function(e){this._valid=!0;var t=0,r=0,a=void 0,n=void 0;for(var o in e)"hsv".includes(o)?(r++,this.value[o]=e[o]):"rgb".includes(o)?(t++,this.value[o]=e[o]):"a"===o&&(this.value.a=e.a);return t>r?(a=g.RGBtoHSV(this.value),0===this.value.r&&0===this.value.g&&0===this.value.b||(this.value.h=a.h),this.value.s=a.s,this.value.v=a.v):r>t&&(n=g.HSVtoRGB(this.value),this.value.r=n.r,this.value.g=n.g,this.value.b=n.b),this}}],[{key:"matchString",value:function(e){if("string"==typeof e){e=d.default.trim(e);var t=null,r=void 0;for(var a in H)if(null!==(t=H[a].match.exec(e))&&(r=H[a].parse(t)))return!0}return!1}},{key:"setDefaults",value:function(e){d.default.extend(!0,p,d.default.isPlainObject(e)&&e)}}]),e}(),E={version:"0.3.4"},B=d.default.asColor,G=function(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];return new(Function.prototype.bind.apply(A,[null].concat(t)))};d.default.asColor=G,d.default.asColor.Constructor=A,d.default.extend(d.default.asColor,{matchString:A.matchString,setDefaults:A.setDefaults,noConflict:function(){return d.default.asColor=B,G}},g,E);var w=d.default.asColor;e.default=w}); | ||
!function(e,t){if("function"==typeof define&&define.amd)define("AsColor",["exports","jquery"],t);else if("undefined"!=typeof exports)t(exports,require("jquery"));else{var r={exports:{}};t(r.exports,e.jQuery),e.AsColor=r.exports}}(this,function(e,t){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e){return 0===e.indexOf("#")&&(e=e.substr(1)),e?(3===e.length&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),6===e.length?"#"+e:null):null}function n(e){return 0===e.indexOf("#")&&(e=e.substr(1)),6===e.length&&e[0]===e[1]&&e[2]===e[3]&&e[4]===e[5]&&(e=e[0]+e[2]+e[4]),"#"+e}function o(e){return parseInt(e,16)}function i(e){return"string"==typeof e&&e.indexOf("%")===e.length-1}function f(e){return parseInt(Math.round(2.55*e.slice(0,-1)),10)}function u(e){return parseFloat(e.slice(0,-1)/100,10)}Object.defineProperty(e,"__esModule",{value:!0});var s=function(e){return e&&e.__esModule?e:{default:e}}(t),l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},h=function(){function e(e,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}(),d={format:!1,shortenHex:!1,hexUseName:!1,reduceAlpha:!1,alphaConvert:{RGB:"RGBA",HSL:"HSLA",HEX:"RGBA",NAMESPACE:"RGBA"},nameDegradation:"HEX",invalidValue:"",zeroAlphaAsTransparent:!0},c={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},v=function(e){var t={};for(var r in e)e.hasOwnProperty(r)&&(t[e[r]]=r);return t}(c),b={HSLtoRGB:function(e){var t=e.h/360,r=e.s,a=e.l,n=void 0,o=void 0,i=void 0;return o=a<=.5?a*(r+1):a+r-a*r,n=2*a-o,i={r:this.hueToRGB(n,o,t+1/3),g:this.hueToRGB(n,o,t),b:this.hueToRGB(n,o,t-1/3)},void 0!==e.a&&(i.a=e.a),0===e.l&&(i.h=e.h),1===e.l&&(i.h=e.h),i},hueToRGB:function(e,t,r){var a=void 0;return r<0?r+=1:r>1&&(r-=1),a=6*r<1?e+(t-e)*r*6:2*r<1?t:3*r<2?e+(t-e)*(2/3-r)*6:e,Math.round(255*a)},RGBtoHSL:function(e){var t=e.r/255,r=e.g/255,a=e.b/255,n=Math.min(t,r,a),o=Math.max(t,r,a),i=o-n,f=o+n,u=.5*f,s=void 0,l=void 0;return s=n===o?0:t===o?60*(r-a)/i+360:r===o?60*(a-t)/i+120:60*(t-r)/i+240,l=0===i?0:u<=.5?i/f:i/(2-f),{h:Math.round(s)%360,s:l,l:u}},RGBtoHEX:function(e){var t=[e.r.toString(16),e.g.toString(16),e.b.toString(16)];return s.default.each(t,function(e,r){1===r.length&&(t[e]="0"+r)}),"#"+t.join("")},HSLtoHEX:function(e){var t=this.HSLtoRGB(e);return this.RGBtoHEX(t)},HSVtoHEX:function(e){var t=this.HSVtoRGB(e);return this.RGBtoHEX(t)},RGBtoHSV:function(e){var t=e.r/255,r=e.g/255,a=e.b/255,n=Math.max(t,r,a),o=Math.min(t,r,a),i=void 0,f=void 0,u=n,s=n-o;if(f=0===n?0:s/n,n===o)i=0;else{switch(n){case t:i=(r-a)/s+(r<a?6:0);break;case r:i=(a-t)/s+2;break;case a:i=(t-r)/s+4}i/=6}return{h:Math.round(360*i),s:f,v:u}},HSVtoRGB:function(e){var t=void 0,r=void 0,a=void 0,n=e.h%360/60,o=e.s,i=e.v,f=i*o,u=f*(1-Math.abs(n%2-1));t=r=a=i-f,t+=[f,u,0,0,u,f][n=~~n],r+=[u,f,f,u,0,0][n],a+=[0,0,u,f,f,u][n];var s={r:Math.round(255*t),g:Math.round(255*r),b:Math.round(255*a)};return void 0!==e.a&&(s.a=e.a),0===e.v&&(s.h=e.h),1===e.v&&0===e.s&&(s.h=e.h),s},HEXtoRGB:function(e){return 4===e.length&&(e=a(e)),{r:o(e.substr(1,2)),g:o(e.substr(3,2)),b:o(e.substr(5,2))}},isNAME:function(e){return!!c.hasOwnProperty(e)},NAMEtoHEX:function(e){return c.hasOwnProperty(e)?"#"+c[e]:null},NAMEtoRGB:function(e){var t=this.NAMEtoHEX(e);return t?this.HEXtoRGB(t):null},hasNAME:function(e){var t=this.RGBtoHEX(e);return 0===(t=n(t)).indexOf("#")&&(t=t.substr(1)),!!v.hasOwnProperty(t)&&v[t]},RGBtoNAME:function(e){var t=this.hasNAME(e);return t||null}},p="(?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?)",g="[\\s|\\(]+("+p+")[,|\\s]+("+p+")[,|\\s]+("+p+")\\s*\\)",m="[\\s|\\(]+("+p+")[,|\\s]+("+p+")[,|\\s]+("+p+")[,|\\s]+("+p+")\\s*\\)",y={RGB:{match:new RegExp("^rgb"+g+"$","i"),parse:function(e){return{r:i(e[1])?f(e[1]):parseInt(e[1],10),g:i(e[2])?f(e[2]):parseInt(e[2],10),b:i(e[3])?f(e[3]):parseInt(e[3],10),a:1}},to:function(e){return"rgb("+e.r+", "+e.g+", "+e.b+")"}},RGBA:{match:new RegExp("^rgba"+m+"$","i"),parse:function(e){return{r:i(e[1])?f(e[1]):parseInt(e[1],10),g:i(e[2])?f(e[2]):parseInt(e[2],10),b:i(e[3])?f(e[3]):parseInt(e[3],10),a:i(e[4])?u(e[4]):parseFloat(e[4],10)}},to:function(e){return"rgba("+e.r+", "+e.g+", "+e.b+", "+e.a+")"}},HSL:{match:new RegExp("^hsl"+g+"$","i"),parse:function(e){var t={h:(e[1]%360+360)%360,s:i(e[2])?u(e[2]):parseFloat(e[2],10),l:i(e[3])?u(e[3]):parseFloat(e[3],10),a:1};return b.HSLtoRGB(t)},to:function(e){var t=b.RGBtoHSL(e);return"hsl("+parseInt(t.h,10)+", "+Math.round(100*t.s)+"%, "+Math.round(100*t.l)+"%)"}},HSLA:{match:new RegExp("^hsla"+m+"$","i"),parse:function(e){var t={h:(e[1]%360+360)%360,s:i(e[2])?u(e[2]):parseFloat(e[2],10),l:i(e[3])?u(e[3]):parseFloat(e[3],10),a:i(e[4])?u(e[4]):parseFloat(e[4],10)};return b.HSLtoRGB(t)},to:function(e){var t=b.RGBtoHSL(e);return"hsla("+parseInt(t.h,10)+", "+Math.round(100*t.s)+"%, "+Math.round(100*t.l)+"%, "+e.a+")"}},HEX:{match:/^#([a-f0-9]{6}|[a-f0-9]{3})$/i,parse:function(e){var t=e[0],r=b.HEXtoRGB(t);return{r:r.r,g:r.g,b:r.b,a:1}},to:function(e,t){var r=b.RGBtoHEX(e);if(t){if(t.options.hexUseName){var a=b.hasNAME(e);if(a)return a}t.options.shortenHex&&(r=n(r))}return""+r}},TRANSPARENT:{match:/^transparent$/i,parse:function(){return{r:0,g:0,b:0,a:0}},to:function(){return"transparent"}},NAME:{match:/^\w+$/i,parse:function(e){var t=b.NAMEtoRGB(e[0]);return t?{r:t.r,g:t.g,b:t.b,a:1}:null},to:function(e,t){var r=b.RGBtoNAME(e);return r||y[t.options.nameDegradation.toUpperCase()].to(e)}}};String.prototype.includes||(String.prototype.includes=function(e,t){return"number"!=typeof t&&(t=0),!(t+e.length>this.length)&&-1!==this.indexOf(e,t)});var k=function(){function e(t,a){r(this,e),"object"===(void 0===t?"undefined":l(t))&&void 0===a&&(a=t,t=void 0),"string"==typeof a&&(a={format:a}),this.options=s.default.extend(!0,{},d,a),this.value={r:0,g:0,b:0,h:0,s:0,v:0,a:1},this._format=!1,this._matchFormat="HEX",this._valid=!0,this.init(t)}return h(e,[{key:"init",value:function(e){return this.format(this.options.format),this.fromString(e),this}},{key:"isValid",value:function(){return this._valid}},{key:"val",value:function(e){return void 0===e?this.toString():(this.fromString(e),this)}},{key:"alpha",value:function(e){return void 0===e||isNaN(e)?this.value.a:((e=parseFloat(e))>1?e=1:e<0&&(e=0),this.value.a=e,this)}},{key:"matchString",value:function(t){return e.matchString(t)}},{key:"fromString",value:function(e,t){if("string"==typeof e){e=s.default.trim(e);var r=null,a=void 0;this._valid=!1;for(var n in y)if(null!==(r=y[n].match.exec(e))&&(a=y[n].parse(r))){this.set(a),"TRANSPARENT"===n&&(n="HEX"),this._matchFormat=n,!0===t&&this.format(n);break}}else"object"===(void 0===e?"undefined":l(e))&&this.set(e);return this}},{key:"format",value:function(e){return"string"==typeof e&&(e=e.toUpperCase())&&void 0!==y[e]?this._format="TRANSPARENT"!==e?e:"HEX":!1===e&&(this._format=!1),!1===this._format?this._matchFormat:this._format}},{key:"toRGBA",value:function(){return y.RGBA.to(this.value,this)}},{key:"toRGB",value:function(){return y.RGB.to(this.value,this)}},{key:"toHSLA",value:function(){return y.HSLA.to(this.value,this)}},{key:"toHSL",value:function(){return y.HSL.to(this.value,this)}},{key:"toHEX",value:function(){return y.HEX.to(this.value,this)}},{key:"toNAME",value:function(){return y.NAME.to(this.value,this)}},{key:"to",value:function(e){return"string"==typeof e&&(e=e.toUpperCase())&&void 0!==y[e]?y[e].to(this.value,this):this.toString()}},{key:"toString",value:function(){var e=this.value;if(!this._valid&&"string"==typeof(e=this.options.invalidValue))return e;if(0===e.a&&this.options.zeroAlphaAsTransparent)return y.TRANSPARENT.to(e,this);var t=void 0;if(t=!1===this._format?this._matchFormat:this._format,this.options.reduceAlpha&&1===e.a)switch(t){case"RGBA":t="RGB";break;case"HSLA":t="HSL"}return 1!==e.a&&"RGBA"!==t&&"HSLA"!==t&&this.options.alphaConvert&&("string"==typeof this.options.alphaConvert&&(t=this.options.alphaConvert),void 0!==this.options.alphaConvert[t]&&(t=this.options.alphaConvert[t])),y[t].to(e,this)}},{key:"get",value:function(){return this.value}},{key:"set",value:function(e){this._valid=!0;var t=0,r=0,a=void 0,n=void 0;for(var o in e)"hsv".includes(o)?(r++,this.value[o]=e[o]):"rgb".includes(o)?(t++,this.value[o]=e[o]):"a"===o&&(this.value.a=e.a);return t>r?(a=b.RGBtoHSV(this.value),0===this.value.r&&0===this.value.g&&0===this.value.b||(this.value.h=a.h),this.value.s=a.s,this.value.v=a.v):r>t&&(n=b.HSVtoRGB(this.value),this.value.r=n.r,this.value.g=n.g,this.value.b=n.b),this}}],[{key:"matchString",value:function(e){if("string"==typeof e){e=s.default.trim(e);var t=null;for(var r in y)if(null!==(t=y[r].match.exec(e))&&y[r].parse(t))return!0}return!1}},{key:"setDefaults",value:function(e){s.default.extend(!0,d,s.default.isPlainObject(e)&&e)}}]),e}(),R={version:"0.3.5"},S=s.default.asColor,H=function(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];return new(Function.prototype.bind.apply(k,[null].concat(t)))};s.default.asColor=H,s.default.asColor.Constructor=k,s.default.extend(s.default.asColor,{matchString:k.matchString,setDefaults:k.setDefaults,noConflict:function(){return s.default.asColor=S,H}},b,R);var A=s.default.asColor;e.default=A}); | ||
//# sourceMappingURL=jquery-asColor.min.js.map |
@@ -5,3 +5,3 @@ { | ||
"description": "A jquery plugin used to parse css color string and convent it to other color formats. It support rgb, rgba, hex, hsl, hsla.", | ||
"version": "0.3.4", | ||
"version": "0.3.5", | ||
"homepage": "https://github.com/amazingSurge/asColor", | ||
@@ -33,2 +33,3 @@ "author": { | ||
"main": "dist/jquery-asColor.js", | ||
"module": "dist/jquery-asColor.es.js", | ||
"files": [ | ||
@@ -51,3 +52,3 @@ "dist", | ||
"devDependencies": { | ||
"argv": "*", | ||
"yargs": "*", | ||
"babel-core": "*", | ||
@@ -64,3 +65,4 @@ "babel-eslint": "*", | ||
"del": "*", | ||
"esformatter": "*", | ||
"prettier": "*", | ||
"gulp-nf-prettier": "*", | ||
"graceful-fs": "*", | ||
@@ -77,3 +79,2 @@ "gulp": "github:gulpjs/gulp#4.0", | ||
"gulp-if": "*", | ||
"gulp-jshint": "*", | ||
"gulp-notify": "*", | ||
@@ -90,4 +91,4 @@ "gulp-plumber": "*", | ||
"inquirer": "*", | ||
"semver": "*", | ||
"isparta": "*", | ||
"jshint": "*", | ||
"karma": "*", | ||
@@ -94,0 +95,0 @@ "karma-babel-preprocessor": "*", |
@@ -45,2 +45,7 @@ # [jQuery asColor](https://github.com/amazingSurge/jquery-asColor) ![bower][bower-image] [![NPM version][npm-image]][npm-url] [![Dependency Status][daviddm-image]][daviddm-url] [![prs-welcome]](#contributing) | ||
#### Install From Yarn | ||
```sh | ||
yarn add jquery-asColor | ||
``` | ||
#### Build From Source | ||
@@ -47,0 +52,0 @@ If you want build from source: |
export default { | ||
version:'0.3.4' | ||
version:'0.3.5' | ||
}; |
135164
15
2745
278