@ctrl/tinycolor
Advanced tools
Comparing version 1.2.0 to 2.0.0
@@ -1173,3 +1173,4 @@ /** | ||
} | ||
function fromLegacyRandom() { | ||
/** old random function */ | ||
function legacyRandom() { | ||
return new TinyColor({ | ||
@@ -1182,80 +1183,4 @@ r: Math.random(), | ||
/** | ||
* @hidden | ||
*/ | ||
const bounds = [ | ||
{ | ||
name: 'monochrome', | ||
hueRange: null, | ||
lowerBounds: [[0, 0], [100, 0]], | ||
}, | ||
{ | ||
name: 'red', | ||
hueRange: [-26, 18], | ||
lowerBounds: [ | ||
[20, 100], | ||
[30, 92], | ||
[40, 89], | ||
[50, 85], | ||
[60, 78], | ||
[70, 70], | ||
[80, 60], | ||
[90, 55], | ||
[100, 50], | ||
], | ||
}, | ||
{ | ||
name: 'orange', | ||
hueRange: [19, 46], | ||
lowerBounds: [[20, 100], [30, 93], [40, 88], [50, 86], [60, 85], [70, 70], [100, 70]], | ||
}, | ||
{ | ||
name: 'yellow', | ||
hueRange: [47, 62], | ||
lowerBounds: [[25, 100], [40, 94], [50, 89], [60, 86], [70, 84], [80, 82], [90, 80], [100, 75]], | ||
}, | ||
{ | ||
name: 'green', | ||
hueRange: [63, 178], | ||
lowerBounds: [[30, 100], [40, 90], [50, 85], [60, 81], [70, 74], [80, 64], [90, 50], [100, 40]], | ||
}, | ||
{ | ||
name: 'blue', | ||
hueRange: [179, 257], | ||
lowerBounds: [ | ||
[20, 100], | ||
[30, 86], | ||
[40, 80], | ||
[50, 74], | ||
[60, 60], | ||
[70, 52], | ||
[80, 44], | ||
[90, 39], | ||
[100, 35], | ||
], | ||
}, | ||
{ | ||
name: 'purple', | ||
hueRange: [258, 282], | ||
lowerBounds: [ | ||
[20, 100], | ||
[30, 87], | ||
[40, 79], | ||
[50, 70], | ||
[60, 65], | ||
[70, 59], | ||
[80, 52], | ||
[90, 45], | ||
[100, 42], | ||
], | ||
}, | ||
{ | ||
name: 'pink', | ||
hueRange: [283, 334], | ||
lowerBounds: [[20, 100], [30, 90], [40, 86], [60, 84], [80, 80], [90, 75], [100, 73]], | ||
}, | ||
]; | ||
// randomColor by David Merfield under the CC0 license | ||
function fromRandom(options = {}) { | ||
function random(options = {}) { | ||
// Check if we need to generate multiple colors | ||
@@ -1274,3 +1199,3 @@ if (options.count !== undefined && options.count !== null) { | ||
} | ||
colors.push(fromRandom(options)); | ||
colors.push(random(options)); | ||
} | ||
@@ -1418,4 +1343,79 @@ options.count = totalColors; | ||
} | ||
/** | ||
* @hidden | ||
*/ | ||
const bounds = [ | ||
{ | ||
name: 'monochrome', | ||
hueRange: null, | ||
lowerBounds: [[0, 0], [100, 0]], | ||
}, | ||
{ | ||
name: 'red', | ||
hueRange: [-26, 18], | ||
lowerBounds: [ | ||
[20, 100], | ||
[30, 92], | ||
[40, 89], | ||
[50, 85], | ||
[60, 78], | ||
[70, 70], | ||
[80, 60], | ||
[90, 55], | ||
[100, 50], | ||
], | ||
}, | ||
{ | ||
name: 'orange', | ||
hueRange: [19, 46], | ||
lowerBounds: [[20, 100], [30, 93], [40, 88], [50, 86], [60, 85], [70, 70], [100, 70]], | ||
}, | ||
{ | ||
name: 'yellow', | ||
hueRange: [47, 62], | ||
lowerBounds: [[25, 100], [40, 94], [50, 89], [60, 86], [70, 84], [80, 82], [90, 80], [100, 75]], | ||
}, | ||
{ | ||
name: 'green', | ||
hueRange: [63, 178], | ||
lowerBounds: [[30, 100], [40, 90], [50, 85], [60, 81], [70, 74], [80, 64], [90, 50], [100, 40]], | ||
}, | ||
{ | ||
name: 'blue', | ||
hueRange: [179, 257], | ||
lowerBounds: [ | ||
[20, 100], | ||
[30, 86], | ||
[40, 80], | ||
[50, 74], | ||
[60, 60], | ||
[70, 52], | ||
[80, 44], | ||
[90, 39], | ||
[100, 35], | ||
], | ||
}, | ||
{ | ||
name: 'purple', | ||
hueRange: [258, 282], | ||
lowerBounds: [ | ||
[20, 100], | ||
[30, 87], | ||
[40, 79], | ||
[50, 70], | ||
[60, 65], | ||
[70, 59], | ||
[80, 52], | ||
[90, 45], | ||
[100, 42], | ||
], | ||
}, | ||
{ | ||
name: 'pink', | ||
hueRange: [283, 334], | ||
lowerBounds: [[20, 100], [30, 90], [40, 86], [60, 84], [80, 80], [90, 75], [100, 73]], | ||
}, | ||
]; | ||
export { names, TinyColor, readability, isReadable, mostReadable, toMsFilter, fromRatio, fromLegacyRandom, inputToRGB, stringInputToObject, isValidCSSUnit, fromRandom }; | ||
export { TinyColor, names, readability, isReadable, mostReadable, toMsFilter, fromRatio, legacyRandom, inputToRGB, stringInputToObject, isValidCSSUnit, random, bounds }; | ||
//# sourceMappingURL=tinycolor.es2015.js.map |
@@ -1,2 +0,2 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.tinycolor={})}(this,function(t){"use strict";function e(t,e){(function(t){return"string"==typeof t&&-1!==t.indexOf(".")&&1===parseFloat(t)})(t)&&(t="100%");const r=function(t){return"string"==typeof t&&-1!==t.indexOf("%")}(t);return t=360===e?t:Math.min(e,Math.max(0,parseFloat(t))),r&&(t=parseInt(String(t*e),10)/100),Math.abs(t-e)<1e-6?1:t=360===e?(t<0?t%e+e:t%e)/parseFloat(String(e)):t%e/parseFloat(String(e))}function r(t){return Math.min(1,Math.max(0,t))}function n(t){return t=parseFloat(t),(isNaN(t)||t<0||t>1)&&(t=1),t}function a(t){return t<=1?100*+t+"%":t}function o(t){return 1===t.length?"0"+t:""+t}function s(t,r,n){t=e(t,255),r=e(r,255),n=e(n,255);const a=Math.max(t,r,n),o=Math.min(t,r,n);let s=0,i=0;const h=(a+o)/2;if(a===o)s=i=0;else{const e=a-o;switch(i=h>.5?e/(2-a-o):e/(a+o),a){case t:s=(r-n)/e+(r<n?6:0);break;case r:s=(n-t)/e+2;break;case n:s=(t-r)/e+4}s/=6}return{h:s,s:i,l:h}}function i(t,r,n){t=e(t,255),r=e(r,255),n=e(n,255);const a=Math.max(t,r,n),o=Math.min(t,r,n);let s=0;const i=a,h=a-o,f=0===a?0:h/a;if(a===o)s=0;else{switch(a){case t:s=(r-n)/h+(r<n?6:0);break;case r:s=(n-t)/h+2;break;case n:s=(t-r)/h+4}s/=6}return{h:s,s:f,v:i}}function h(t,e,r,n){const a=[o(Math.round(t).toString(16)),o(Math.round(e).toString(16)),o(Math.round(r).toString(16))];return n&&a[0].charAt(0)===a[0].charAt(1)&&a[1].charAt(0)===a[1].charAt(1)&&a[2].charAt(0)===a[2].charAt(1)?a[0].charAt(0)+a[1].charAt(0)+a[2].charAt(0):a.join("")}function f(t,e,r,n){return[o(u(n)),o(Math.round(t).toString(16)),o(Math.round(e).toString(16)),o(Math.round(r).toString(16))].join("")}function u(t){return Math.round(255*parseFloat(t)).toString(16)}function l(t){return c(t)/255}function c(t){return parseInt(t,16)}const d={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",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:"#ff00ff",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:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",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",rebeccapurple:"#663399",red:"#ff0000",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:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"};function g(t){let r={r:0,g:0,b:0},o=1,s=null,i=null,h=null,f=!1,u=!1;var l,c,d;return"string"==typeof t&&(t=M(t)),"object"==typeof t&&(x(t.r)&&x(t.g)&&x(t.b)?(l=t.r,c=t.g,d=t.b,r={r:255*e(l,255),g:255*e(c,255),b:255*e(d,255)},f=!0,u="%"===String(t.r).substr(-1)?"prgb":"rgb"):x(t.h)&&x(t.s)&&x(t.v)?(s=a(t.s),i=a(t.v),r=function(t,r,n){t=6*e(t,360),r=e(r,100),n=e(n,100);const a=Math.floor(t),o=t-a,s=n*(1-r),i=n*(1-o*r),h=n*(1-(1-o)*r),f=a%6;return{r:255*[n,i,s,s,h,n][f],g:255*[h,n,n,i,s,s][f],b:255*[s,s,h,n,n,i][f]}}(t.h,s,i),f=!0,u="hsv"):x(t.h)&&x(t.s)&&x(t.l)&&(s=a(t.s),h=a(t.l),r=function(t,r,n){let a,o,s;function i(t,e,r){return r<0&&(r+=1),r>1&&(r-=1),r<1/6?t+6*(e-t)*r:r<.5?e:r<2/3?t+(e-t)*(2/3-r)*6:t}if(t=e(t,360),r=e(r,100),n=e(n,100),0===r)a=o=s=n;else{const e=n<.5?n*(1+r):n+r-n*r,h=2*n-e;a=i(h,e,t+1/3),o=i(h,e,t),s=i(h,e,t-1/3)}return{r:255*a,g:255*o,b:255*s}}(t.h,s,h),f=!0,u="hsl"),t.hasOwnProperty("a")&&(o=t.a)),o=n(o),{ok:f,format:t.format||u,r:Math.min(255,Math.max(r.r,0)),g:Math.min(255,Math.max(r.g,0)),b:Math.min(255,Math.max(r.b,0)),a:o}}const b="(?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?)",m=`[\\s|\\(]+(${b})[,|\\s]+(${b})[,|\\s]+(${b})\\s*\\)?`,p=`[\\s|\\(]+(${b})[,|\\s]+(${b})[,|\\s]+(${b})[,|\\s]+(${b})\\s*\\)?`,w={CSS_UNIT:new RegExp(b),rgb:new RegExp("rgb"+m),rgba:new RegExp("rgba"+p),hsl:new RegExp("hsl"+m),hsla:new RegExp("hsla"+p),hsv:new RegExp("hsv"+m),hsva:new RegExp("hsva"+p),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/};function M(t){if(0===(t=t.trim().toLowerCase()).length)return!1;let e=!1;if(d[t])t=d[t],e=!0;else if("transparent"===t)return{r:0,g:0,b:0,a:0,format:"name"};let r=w.rgb.exec(t);return r?{r:r[1],g:r[2],b:r[3]}:(r=w.rgba.exec(t))?{r:r[1],g:r[2],b:r[3],a:r[4]}:(r=w.hsl.exec(t))?{h:r[1],s:r[2],l:r[3]}:(r=w.hsla.exec(t))?{h:r[1],s:r[2],l:r[3],a:r[4]}:(r=w.hsv.exec(t))?{h:r[1],s:r[2],v:r[3]}:(r=w.hsva.exec(t))?{h:r[1],s:r[2],v:r[3],a:r[4]}:(r=w.hex8.exec(t))?{r:c(r[1]),g:c(r[2]),b:c(r[3]),a:l(r[4]),format:e?"name":"hex8"}:(r=w.hex6.exec(t))?{r:c(r[1]),g:c(r[2]),b:c(r[3]),format:e?"name":"hex"}:(r=w.hex4.exec(t))?{r:c(r[1]+r[1]),g:c(r[2]+r[2]),b:c(r[3]+r[3]),a:l(r[4]+r[4]),format:e?"name":"hex8"}:!!(r=w.hex3.exec(t))&&{r:c(r[1]+r[1]),g:c(r[2]+r[2]),b:c(r[3]+r[3]),format:e?"name":"hex"}}function x(t){return!!w.CSS_UNIT.exec(String(t))}class y{constructor(t="",e={}){if(t instanceof y)return t;this.originalInput=t;const r=g(t);this.originalInput=t,this.r=r.r,this.g=r.g,this.b=r.b,this.a=r.a,this.roundA=Math.round(100*this.a)/100,this.format=e.format||r.format,this.gradientType=e.gradientType,this.r<1&&(this.r=Math.round(this.r)),this.g<1&&(this.g=Math.round(this.g)),this.b<1&&(this.b=Math.round(this.b)),this.isValid=r.ok}isDark(){return this.getBrightness()<128}isLight(){return!this.isDark()}getBrightness(){const t=this.toRgb();return(299*t.r+587*t.g+114*t.b)/1e3}getLuminance(){const t=this.toRgb();let e,r,n;const a=t.r/255,o=t.g/255,s=t.b/255;return.2126*(e=a<=.03928?a/12.92:Math.pow((a+.055)/1.055,2.4))+.7152*(r=o<=.03928?o/12.92:Math.pow((o+.055)/1.055,2.4))+.0722*(n=s<=.03928?s/12.92:Math.pow((s+.055)/1.055,2.4))}setAlpha(t){return this.a=n(t),this.roundA=Math.round(100*this.a)/100,this}toHsv(){const t=i(this.r,this.g,this.b);return{h:360*t.h,s:t.s,v:t.v,a:this.a}}toHsvString(){const t=i(this.r,this.g,this.b),e=Math.round(360*t.h),r=Math.round(100*t.s),n=Math.round(100*t.v);return 1===this.a?`hsv(${e}, ${r}%, ${n}%)`:`hsva(${e}, ${r}%, ${n}%, ${this.roundA})`}toHsl(){const t=s(this.r,this.g,this.b);return{h:360*t.h,s:t.s,l:t.l,a:this.a}}toHslString(){const t=s(this.r,this.g,this.b),e=Math.round(360*t.h),r=Math.round(100*t.s),n=Math.round(100*t.l);return 1===this.a?`hsl(${e}, ${r}%, ${n}%)`:`hsla(${e}, ${r}%, ${n}%, ${this.roundA})`}toHex(t=!1){return h(this.r,this.g,this.b,t)}toHexString(t=!1){return"#"+this.toHex(t)}toHex8(t=!1){return function(t,e,r,n,a){const s=[o(Math.round(t).toString(16)),o(Math.round(e).toString(16)),o(Math.round(r).toString(16)),o(u(n))];return a&&s[0].charAt(0)===s[0].charAt(1)&&s[1].charAt(0)===s[1].charAt(1)&&s[2].charAt(0)===s[2].charAt(1)&&s[3].charAt(0)===s[3].charAt(1)?s[0].charAt(0)+s[1].charAt(0)+s[2].charAt(0)+s[3].charAt(0):s.join("")}(this.r,this.g,this.b,this.a,t)}toHex8String(t=!1){return"#"+this.toHex8(t)}toRgb(){return{r:Math.round(this.r),g:Math.round(this.g),b:Math.round(this.b),a:this.a}}toRgbString(){const t=Math.round(this.r),e=Math.round(this.g),r=Math.round(this.b);return 1===this.a?`rgb(${t}, ${e}, ${r})`:`rgba(${t}, ${e}, ${r}, ${this.roundA})`}toPercentageRgb(){const t=t=>Math.round(100*e(t,255))+"%";return{r:t(this.r),g:t(this.g),b:t(this.b),a:this.a}}toPercentageRgbString(){const t=t=>Math.round(100*e(t,255));return 1===this.a?`rgb(${t(this.r)}%, ${t(this.g)}%, ${t(this.b)}%)`:`rgba(${t(this.r)}%, ${t(this.g)}%, ${t(this.b)}%, ${this.roundA})`}toName(){if(0===this.a)return"transparent";if(this.a<1)return!1;const t="#"+h(this.r,this.g,this.b,!1);for(const e of Object.keys(d))if(d[e]===t)return e;return!1}toString(t){const e=!!t;t=t||this.format;let r=!1;const n=this.a<1&&this.a>=0;return e||!n||!t.startsWith("hex")&&"name"!==t?("rgb"===t&&(r=this.toRgbString()),"prgb"===t&&(r=this.toPercentageRgbString()),"hex"!==t&&"hex6"!==t||(r=this.toHexString()),"hex3"===t&&(r=this.toHexString(!0)),"hex4"===t&&(r=this.toHex8String(!0)),"hex8"===t&&(r=this.toHex8String()),"name"===t&&(r=this.toName()),"hsl"===t&&(r=this.toHslString()),"hsv"===t&&(r=this.toHsvString()),r||this.toHexString()):"name"===t&&0===this.a?this.toName():this.toRgbString()}clone(){return new y(this.toString())}lighten(t=10){const e=this.toHsl();return e.l+=t/100,e.l=r(e.l),new y(e)}brighten(t=10){const e=this.toRgb();return e.r=Math.max(0,Math.min(255,e.r-Math.round(-t/100*255))),e.g=Math.max(0,Math.min(255,e.g-Math.round(-t/100*255))),e.b=Math.max(0,Math.min(255,e.b-Math.round(-t/100*255))),new y(e)}darken(t=10){const e=this.toHsl();return e.l-=t/100,e.l=r(e.l),new y(e)}tint(t=10){return this.mix("white",t)}shade(t=10){return this.mix("black",t)}desaturate(t=10){const e=this.toHsl();return e.s-=t/100,e.s=r(e.s),new y(e)}saturate(t=10){const e=this.toHsl();return e.s+=t/100,e.s=r(e.s),new y(e)}greyscale(){return this.desaturate(100)}spin(t){const e=this.toHsl(),r=(e.h+t)%360;return e.h=r<0?360+r:r,new y(e)}mix(t,e=50){const r=this.toRgb(),n=new y(t).toRgb(),a=e/100,o={r:(n.r-r.r)*a+r.r,g:(n.g-r.g)*a+r.g,b:(n.b-r.b)*a+r.b,a:(n.a-r.a)*a+r.a};return new y(o)}analogous(t=6,e=30){const r=this.toHsl(),n=360/e,a=[this];for(r.h=(r.h-(n*t>>1)+720)%360;--t;)r.h=(r.h+n)%360,a.push(new y(r));return a}complement(){const t=this.toHsl();return t.h=(t.h+180)%360,new y(t)}monochromatic(t=6){const e=this.toHsv(),r=e.h,n=e.s;let a=e.v;const o=[],s=1/t;for(;t--;)o.push(new y({h:r,s:n,v:a})),a=(a+s)%1;return o}splitcomplement(){const t=this.toHsl(),e=t.h;return[this,new y({h:(e+72)%360,s:t.s,l:t.l}),new y({h:(e+216)%360,s:t.s,l:t.l})]}triad(){return this.polyad(3)}tetrad(){return this.polyad(4)}polyad(t){const e=this.toHsl(),r=e.h,n=[this],a=360/t;for(let o=1;o<t;o++)n.push(new y({h:(r+o*a)%360,s:e.s,l:e.l}));return n}equals(t){return this.toRgbString()===new y(t).toRgbString()}}function A(t,e){const r=new y(t),n=new y(e);return(Math.max(r.getLuminance(),n.getLuminance())+.05)/(Math.min(r.getLuminance(),n.getLuminance())+.05)}function k(t,e,r={level:"AA",size:"small"}){const n=A(t,e);switch((r.level||"AA")+(r.size||"small")){case"AAsmall":case"AAAlarge":return n>=4.5;case"AAlarge":return n>=3;case"AAAsmall":return n>=7}return!1}const v=[{name:"monochrome",hueRange:null,lowerBounds:[[0,0],[100,0]]},{name:"red",hueRange:[-26,18],lowerBounds:[[20,100],[30,92],[40,89],[50,85],[60,78],[70,70],[80,60],[90,55],[100,50]]},{name:"orange",hueRange:[19,46],lowerBounds:[[20,100],[30,93],[40,88],[50,86],[60,85],[70,70],[100,70]]},{name:"yellow",hueRange:[47,62],lowerBounds:[[25,100],[40,94],[50,89],[60,86],[70,84],[80,82],[90,80],[100,75]]},{name:"green",hueRange:[63,178],lowerBounds:[[30,100],[40,90],[50,85],[60,81],[70,74],[80,64],[90,50],[100,40]]},{name:"blue",hueRange:[179,257],lowerBounds:[[20,100],[30,86],[40,80],[50,74],[60,60],[70,52],[80,44],[90,39],[100,35]]},{name:"purple",hueRange:[258,282],lowerBounds:[[20,100],[30,87],[40,79],[50,70],[60,65],[70,59],[80,52],[90,45],[100,42]]},{name:"pink",hueRange:[283,334],lowerBounds:[[20,100],[30,90],[40,86],[60,84],[80,80],[90,75],[100,73]]}];function R(t){t>=334&&t<=360&&(t-=360);for(const e of v){const r=S(e);if(r.hueRange&&t>=r.hueRange[0]&&t<=r.hueRange[1])return r}throw Error("Color not found")}function $(t,e){if(void 0===e)return Math.floor(t[0]+Math.random()*(t[1]+1-t[0]));{const r=t[1]||1,n=t[0]||0,a=(e=(9301*e+49297)%233280)/233280;return Math.floor(n+a*(r-n))}}function S(t){const e=t.lowerBounds[0][0],r=t.lowerBounds[t.lowerBounds.length-1][0],n=t.lowerBounds[t.lowerBounds.length-1][1],a=t.lowerBounds[0][1];return{name:t.name,hueRange:t.hueRange,lowerBounds:t.lowerBounds,saturationRange:[e,r],brightnessRange:[n,a]}}t.names=d,t.TinyColor=y,t.readability=A,t.isReadable=k,t.mostReadable=function t(e,r,n={includeFallbackColors:!1,level:"AA",size:"small"}){let a=null,o=0;const s=n.includeFallbackColors,i=n.level,h=n.size;for(const t of r){const r=A(e,t);r>o&&(o=r,a=new y(t))}return k(e,a,{level:i,size:h})||!s?a:(n.includeFallbackColors=!1,t(e,["#fff","#000"],n))},t.toMsFilter=function(t,e){const r=new y(t),n="#"+f(r.r,r.g,r.b,r.a);let a=n;const o=r.gradientType?"GradientType = 1, ":"";if(e){const t=new y(e);a="#"+f(t.r,t.g,t.b,t.a)}return`progid:DXImageTransform.Microsoft.gradient(${o}startColorstr=${n},endColorstr=${a})`},t.fromRatio=function(t,e){const r={r:a(t.r),g:a(t.g),b:a(t.b)};return void 0!==t.a&&(r.a=+t.a),new y(r,e)},t.fromLegacyRandom=function(){return new y({r:Math.random(),g:Math.random(),b:Math.random()})},t.inputToRGB=g,t.stringInputToObject=M,t.isValidCSSUnit=x,t.fromRandom=function t(e={}){if(void 0!==e.count&&null!==e.count){const r=e.count,n=[];for(e.count=void 0;r>n.length;)e.count=null,e.seed&&(e.seed+=1),n.push(t(e));return e.count=r,n}const r=function(t,e){let r=$(function(t){const e=parseInt(t,10);if(!Number.isNaN(e)&&e<360&&e>0)return[e,e];if("string"==typeof t){const e=v.find(e=>e.name===t);if(e){const t=S(e);if(t.hueRange)return t.hueRange}const r=new y(t);if(r.isValid){const t=r.toHsv().h;return[t,t]}}return[0,360]}(t),e);return r<0&&(r=360+r),r}(e.hue,e.seed),n=function(t,e){if("monochrome"===e.hue)return 0;if("random"===e.luminosity)return $([0,100],e.seed);const r=R(t).saturationRange;let n=r[0],a=r[1];switch(e.luminosity){case"bright":n=55;break;case"dark":n=a-10;break;case"light":a=55}return $([n,a],e.seed)}(r,e),a={h:r,s:n,v:function(t,e,r){let n=function(t,e){const r=R(t).lowerBounds;for(let t=0;t<r.length-1;t++){const n=r[t][0],a=r[t][1],o=r[t+1][0],s=r[t+1][1];if(e>=n&&e<=o){const t=(s-a)/(o-n),r=a-t*n;return t*e+r}}return 0}(t,e),a=100;switch(r.luminosity){case"dark":a=n+20;break;case"light":n=(a+n)/2;break;case"random":n=0,a=100}return $([n,a],r.seed)}(r,n,e)};return void 0!==e.alpha&&(a.a=e.alpha),new y(a)},Object.defineProperty(t,"__esModule",{value:!0})}); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.tinycolor={})}(this,function(t){"use strict";function e(t,e){(function(t){return"string"==typeof t&&-1!==t.indexOf(".")&&1===parseFloat(t)})(t)&&(t="100%");const r=function(t){return"string"==typeof t&&-1!==t.indexOf("%")}(t);return t=360===e?t:Math.min(e,Math.max(0,parseFloat(t))),r&&(t=parseInt(String(t*e),10)/100),Math.abs(t-e)<1e-6?1:t=360===e?(t<0?t%e+e:t%e)/parseFloat(String(e)):t%e/parseFloat(String(e))}function r(t){return Math.min(1,Math.max(0,t))}function n(t){return t=parseFloat(t),(isNaN(t)||t<0||t>1)&&(t=1),t}function a(t){return t<=1?100*+t+"%":t}function s(t){return 1===t.length?"0"+t:""+t}function o(t,r,n){t=e(t,255),r=e(r,255),n=e(n,255);const a=Math.max(t,r,n),s=Math.min(t,r,n);let o=0,i=0;const h=(a+s)/2;if(a===s)o=i=0;else{const e=a-s;switch(i=h>.5?e/(2-a-s):e/(a+s),a){case t:o=(r-n)/e+(r<n?6:0);break;case r:o=(n-t)/e+2;break;case n:o=(t-r)/e+4}o/=6}return{h:o,s:i,l:h}}function i(t,r,n){t=e(t,255),r=e(r,255),n=e(n,255);const a=Math.max(t,r,n),s=Math.min(t,r,n);let o=0;const i=a,h=a-s,f=0===a?0:h/a;if(a===s)o=0;else{switch(a){case t:o=(r-n)/h+(r<n?6:0);break;case r:o=(n-t)/h+2;break;case n:o=(t-r)/h+4}o/=6}return{h:o,s:f,v:i}}function h(t,e,r,n){const a=[s(Math.round(t).toString(16)),s(Math.round(e).toString(16)),s(Math.round(r).toString(16))];return n&&a[0].charAt(0)===a[0].charAt(1)&&a[1].charAt(0)===a[1].charAt(1)&&a[2].charAt(0)===a[2].charAt(1)?a[0].charAt(0)+a[1].charAt(0)+a[2].charAt(0):a.join("")}function f(t,e,r,n){return[s(u(n)),s(Math.round(t).toString(16)),s(Math.round(e).toString(16)),s(Math.round(r).toString(16))].join("")}function u(t){return Math.round(255*parseFloat(t)).toString(16)}function l(t){return c(t)/255}function c(t){return parseInt(t,16)}const d={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",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:"#ff00ff",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:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",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",rebeccapurple:"#663399",red:"#ff0000",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:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"};function g(t){let r={r:0,g:0,b:0},s=1,o=null,i=null,h=null,f=!1,u=!1;var l,c,d;return"string"==typeof t&&(t=M(t)),"object"==typeof t&&(x(t.r)&&x(t.g)&&x(t.b)?(l=t.r,c=t.g,d=t.b,r={r:255*e(l,255),g:255*e(c,255),b:255*e(d,255)},f=!0,u="%"===String(t.r).substr(-1)?"prgb":"rgb"):x(t.h)&&x(t.s)&&x(t.v)?(o=a(t.s),i=a(t.v),r=function(t,r,n){t=6*e(t,360),r=e(r,100),n=e(n,100);const a=Math.floor(t),s=t-a,o=n*(1-r),i=n*(1-s*r),h=n*(1-(1-s)*r),f=a%6;return{r:255*[n,i,o,o,h,n][f],g:255*[h,n,n,i,o,o][f],b:255*[o,o,h,n,n,i][f]}}(t.h,o,i),f=!0,u="hsv"):x(t.h)&&x(t.s)&&x(t.l)&&(o=a(t.s),h=a(t.l),r=function(t,r,n){let a,s,o;function i(t,e,r){return r<0&&(r+=1),r>1&&(r-=1),r<1/6?t+6*(e-t)*r:r<.5?e:r<2/3?t+(e-t)*(2/3-r)*6:t}if(t=e(t,360),r=e(r,100),n=e(n,100),0===r)a=s=o=n;else{const e=n<.5?n*(1+r):n+r-n*r,h=2*n-e;a=i(h,e,t+1/3),s=i(h,e,t),o=i(h,e,t-1/3)}return{r:255*a,g:255*s,b:255*o}}(t.h,o,h),f=!0,u="hsl"),t.hasOwnProperty("a")&&(s=t.a)),s=n(s),{ok:f,format:t.format||u,r:Math.min(255,Math.max(r.r,0)),g:Math.min(255,Math.max(r.g,0)),b:Math.min(255,Math.max(r.b,0)),a:s}}const b="(?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?)",m=`[\\s|\\(]+(${b})[,|\\s]+(${b})[,|\\s]+(${b})\\s*\\)?`,p=`[\\s|\\(]+(${b})[,|\\s]+(${b})[,|\\s]+(${b})[,|\\s]+(${b})\\s*\\)?`,w={CSS_UNIT:new RegExp(b),rgb:new RegExp("rgb"+m),rgba:new RegExp("rgba"+p),hsl:new RegExp("hsl"+m),hsla:new RegExp("hsla"+p),hsv:new RegExp("hsv"+m),hsva:new RegExp("hsva"+p),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/};function M(t){if(0===(t=t.trim().toLowerCase()).length)return!1;let e=!1;if(d[t])t=d[t],e=!0;else if("transparent"===t)return{r:0,g:0,b:0,a:0,format:"name"};let r=w.rgb.exec(t);return r?{r:r[1],g:r[2],b:r[3]}:(r=w.rgba.exec(t))?{r:r[1],g:r[2],b:r[3],a:r[4]}:(r=w.hsl.exec(t))?{h:r[1],s:r[2],l:r[3]}:(r=w.hsla.exec(t))?{h:r[1],s:r[2],l:r[3],a:r[4]}:(r=w.hsv.exec(t))?{h:r[1],s:r[2],v:r[3]}:(r=w.hsva.exec(t))?{h:r[1],s:r[2],v:r[3],a:r[4]}:(r=w.hex8.exec(t))?{r:c(r[1]),g:c(r[2]),b:c(r[3]),a:l(r[4]),format:e?"name":"hex8"}:(r=w.hex6.exec(t))?{r:c(r[1]),g:c(r[2]),b:c(r[3]),format:e?"name":"hex"}:(r=w.hex4.exec(t))?{r:c(r[1]+r[1]),g:c(r[2]+r[2]),b:c(r[3]+r[3]),a:l(r[4]+r[4]),format:e?"name":"hex8"}:!!(r=w.hex3.exec(t))&&{r:c(r[1]+r[1]),g:c(r[2]+r[2]),b:c(r[3]+r[3]),format:e?"name":"hex"}}function x(t){return!!w.CSS_UNIT.exec(String(t))}class y{constructor(t="",e={}){if(t instanceof y)return t;this.originalInput=t;const r=g(t);this.originalInput=t,this.r=r.r,this.g=r.g,this.b=r.b,this.a=r.a,this.roundA=Math.round(100*this.a)/100,this.format=e.format||r.format,this.gradientType=e.gradientType,this.r<1&&(this.r=Math.round(this.r)),this.g<1&&(this.g=Math.round(this.g)),this.b<1&&(this.b=Math.round(this.b)),this.isValid=r.ok}isDark(){return this.getBrightness()<128}isLight(){return!this.isDark()}getBrightness(){const t=this.toRgb();return(299*t.r+587*t.g+114*t.b)/1e3}getLuminance(){const t=this.toRgb();let e,r,n;const a=t.r/255,s=t.g/255,o=t.b/255;return.2126*(e=a<=.03928?a/12.92:Math.pow((a+.055)/1.055,2.4))+.7152*(r=s<=.03928?s/12.92:Math.pow((s+.055)/1.055,2.4))+.0722*(n=o<=.03928?o/12.92:Math.pow((o+.055)/1.055,2.4))}setAlpha(t){return this.a=n(t),this.roundA=Math.round(100*this.a)/100,this}toHsv(){const t=i(this.r,this.g,this.b);return{h:360*t.h,s:t.s,v:t.v,a:this.a}}toHsvString(){const t=i(this.r,this.g,this.b),e=Math.round(360*t.h),r=Math.round(100*t.s),n=Math.round(100*t.v);return 1===this.a?`hsv(${e}, ${r}%, ${n}%)`:`hsva(${e}, ${r}%, ${n}%, ${this.roundA})`}toHsl(){const t=o(this.r,this.g,this.b);return{h:360*t.h,s:t.s,l:t.l,a:this.a}}toHslString(){const t=o(this.r,this.g,this.b),e=Math.round(360*t.h),r=Math.round(100*t.s),n=Math.round(100*t.l);return 1===this.a?`hsl(${e}, ${r}%, ${n}%)`:`hsla(${e}, ${r}%, ${n}%, ${this.roundA})`}toHex(t=!1){return h(this.r,this.g,this.b,t)}toHexString(t=!1){return"#"+this.toHex(t)}toHex8(t=!1){return function(t,e,r,n,a){const o=[s(Math.round(t).toString(16)),s(Math.round(e).toString(16)),s(Math.round(r).toString(16)),s(u(n))];return a&&o[0].charAt(0)===o[0].charAt(1)&&o[1].charAt(0)===o[1].charAt(1)&&o[2].charAt(0)===o[2].charAt(1)&&o[3].charAt(0)===o[3].charAt(1)?o[0].charAt(0)+o[1].charAt(0)+o[2].charAt(0)+o[3].charAt(0):o.join("")}(this.r,this.g,this.b,this.a,t)}toHex8String(t=!1){return"#"+this.toHex8(t)}toRgb(){return{r:Math.round(this.r),g:Math.round(this.g),b:Math.round(this.b),a:this.a}}toRgbString(){const t=Math.round(this.r),e=Math.round(this.g),r=Math.round(this.b);return 1===this.a?`rgb(${t}, ${e}, ${r})`:`rgba(${t}, ${e}, ${r}, ${this.roundA})`}toPercentageRgb(){const t=t=>Math.round(100*e(t,255))+"%";return{r:t(this.r),g:t(this.g),b:t(this.b),a:this.a}}toPercentageRgbString(){const t=t=>Math.round(100*e(t,255));return 1===this.a?`rgb(${t(this.r)}%, ${t(this.g)}%, ${t(this.b)}%)`:`rgba(${t(this.r)}%, ${t(this.g)}%, ${t(this.b)}%, ${this.roundA})`}toName(){if(0===this.a)return"transparent";if(this.a<1)return!1;const t="#"+h(this.r,this.g,this.b,!1);for(const e of Object.keys(d))if(d[e]===t)return e;return!1}toString(t){const e=!!t;t=t||this.format;let r=!1;const n=this.a<1&&this.a>=0;return e||!n||!t.startsWith("hex")&&"name"!==t?("rgb"===t&&(r=this.toRgbString()),"prgb"===t&&(r=this.toPercentageRgbString()),"hex"!==t&&"hex6"!==t||(r=this.toHexString()),"hex3"===t&&(r=this.toHexString(!0)),"hex4"===t&&(r=this.toHex8String(!0)),"hex8"===t&&(r=this.toHex8String()),"name"===t&&(r=this.toName()),"hsl"===t&&(r=this.toHslString()),"hsv"===t&&(r=this.toHsvString()),r||this.toHexString()):"name"===t&&0===this.a?this.toName():this.toRgbString()}clone(){return new y(this.toString())}lighten(t=10){const e=this.toHsl();return e.l+=t/100,e.l=r(e.l),new y(e)}brighten(t=10){const e=this.toRgb();return e.r=Math.max(0,Math.min(255,e.r-Math.round(-t/100*255))),e.g=Math.max(0,Math.min(255,e.g-Math.round(-t/100*255))),e.b=Math.max(0,Math.min(255,e.b-Math.round(-t/100*255))),new y(e)}darken(t=10){const e=this.toHsl();return e.l-=t/100,e.l=r(e.l),new y(e)}tint(t=10){return this.mix("white",t)}shade(t=10){return this.mix("black",t)}desaturate(t=10){const e=this.toHsl();return e.s-=t/100,e.s=r(e.s),new y(e)}saturate(t=10){const e=this.toHsl();return e.s+=t/100,e.s=r(e.s),new y(e)}greyscale(){return this.desaturate(100)}spin(t){const e=this.toHsl(),r=(e.h+t)%360;return e.h=r<0?360+r:r,new y(e)}mix(t,e=50){const r=this.toRgb(),n=new y(t).toRgb(),a=e/100,s={r:(n.r-r.r)*a+r.r,g:(n.g-r.g)*a+r.g,b:(n.b-r.b)*a+r.b,a:(n.a-r.a)*a+r.a};return new y(s)}analogous(t=6,e=30){const r=this.toHsl(),n=360/e,a=[this];for(r.h=(r.h-(n*t>>1)+720)%360;--t;)r.h=(r.h+n)%360,a.push(new y(r));return a}complement(){const t=this.toHsl();return t.h=(t.h+180)%360,new y(t)}monochromatic(t=6){const e=this.toHsv(),r=e.h,n=e.s;let a=e.v;const s=[],o=1/t;for(;t--;)s.push(new y({h:r,s:n,v:a})),a=(a+o)%1;return s}splitcomplement(){const t=this.toHsl(),e=t.h;return[this,new y({h:(e+72)%360,s:t.s,l:t.l}),new y({h:(e+216)%360,s:t.s,l:t.l})]}triad(){return this.polyad(3)}tetrad(){return this.polyad(4)}polyad(t){const e=this.toHsl(),r=e.h,n=[this],a=360/t;for(let s=1;s<t;s++)n.push(new y({h:(r+s*a)%360,s:e.s,l:e.l}));return n}equals(t){return this.toRgbString()===new y(t).toRgbString()}}function A(t,e){const r=new y(t),n=new y(e);return(Math.max(r.getLuminance(),n.getLuminance())+.05)/(Math.min(r.getLuminance(),n.getLuminance())+.05)}function k(t,e,r={level:"AA",size:"small"}){const n=A(t,e);switch((r.level||"AA")+(r.size||"small")){case"AAsmall":case"AAAlarge":return n>=4.5;case"AAlarge":return n>=3;case"AAAsmall":return n>=7}return!1}function v(t){t>=334&&t<=360&&(t-=360);for(const e of S){const r=$(e);if(r.hueRange&&t>=r.hueRange[0]&&t<=r.hueRange[1])return r}throw Error("Color not found")}function R(t,e){if(void 0===e)return Math.floor(t[0]+Math.random()*(t[1]+1-t[0]));{const r=t[1]||1,n=t[0]||0,a=(e=(9301*e+49297)%233280)/233280;return Math.floor(n+a*(r-n))}}function $(t){const e=t.lowerBounds[0][0],r=t.lowerBounds[t.lowerBounds.length-1][0],n=t.lowerBounds[t.lowerBounds.length-1][1],a=t.lowerBounds[0][1];return{name:t.name,hueRange:t.hueRange,lowerBounds:t.lowerBounds,saturationRange:[e,r],brightnessRange:[n,a]}}const S=[{name:"monochrome",hueRange:null,lowerBounds:[[0,0],[100,0]]},{name:"red",hueRange:[-26,18],lowerBounds:[[20,100],[30,92],[40,89],[50,85],[60,78],[70,70],[80,60],[90,55],[100,50]]},{name:"orange",hueRange:[19,46],lowerBounds:[[20,100],[30,93],[40,88],[50,86],[60,85],[70,70],[100,70]]},{name:"yellow",hueRange:[47,62],lowerBounds:[[25,100],[40,94],[50,89],[60,86],[70,84],[80,82],[90,80],[100,75]]},{name:"green",hueRange:[63,178],lowerBounds:[[30,100],[40,90],[50,85],[60,81],[70,74],[80,64],[90,50],[100,40]]},{name:"blue",hueRange:[179,257],lowerBounds:[[20,100],[30,86],[40,80],[50,74],[60,60],[70,52],[80,44],[90,39],[100,35]]},{name:"purple",hueRange:[258,282],lowerBounds:[[20,100],[30,87],[40,79],[50,70],[60,65],[70,59],[80,52],[90,45],[100,42]]},{name:"pink",hueRange:[283,334],lowerBounds:[[20,100],[30,90],[40,86],[60,84],[80,80],[90,75],[100,73]]}];t.TinyColor=y,t.names=d,t.readability=A,t.isReadable=k,t.mostReadable=function t(e,r,n={includeFallbackColors:!1,level:"AA",size:"small"}){let a=null,s=0;const o=n.includeFallbackColors,i=n.level,h=n.size;for(const t of r){const r=A(e,t);r>s&&(s=r,a=new y(t))}return k(e,a,{level:i,size:h})||!o?a:(n.includeFallbackColors=!1,t(e,["#fff","#000"],n))},t.toMsFilter=function(t,e){const r=new y(t),n="#"+f(r.r,r.g,r.b,r.a);let a=n;const s=r.gradientType?"GradientType = 1, ":"";if(e){const t=new y(e);a="#"+f(t.r,t.g,t.b,t.a)}return`progid:DXImageTransform.Microsoft.gradient(${s}startColorstr=${n},endColorstr=${a})`},t.fromRatio=function(t,e){const r={r:a(t.r),g:a(t.g),b:a(t.b)};return void 0!==t.a&&(r.a=+t.a),new y(r,e)},t.legacyRandom=function(){return new y({r:Math.random(),g:Math.random(),b:Math.random()})},t.inputToRGB=g,t.stringInputToObject=M,t.isValidCSSUnit=x,t.random=function t(e={}){if(void 0!==e.count&&null!==e.count){const r=e.count,n=[];for(e.count=void 0;r>n.length;)e.count=null,e.seed&&(e.seed+=1),n.push(t(e));return e.count=r,n}const r=function(t,e){let r=R(function(t){const e=parseInt(t,10);if(!Number.isNaN(e)&&e<360&&e>0)return[e,e];if("string"==typeof t){const e=S.find(e=>e.name===t);if(e){const t=$(e);if(t.hueRange)return t.hueRange}const r=new y(t);if(r.isValid){const t=r.toHsv().h;return[t,t]}}return[0,360]}(t),e);return r<0&&(r=360+r),r}(e.hue,e.seed),n=function(t,e){if("monochrome"===e.hue)return 0;if("random"===e.luminosity)return R([0,100],e.seed);const r=v(t).saturationRange;let n=r[0],a=r[1];switch(e.luminosity){case"bright":n=55;break;case"dark":n=a-10;break;case"light":a=55}return R([n,a],e.seed)}(r,e),a={h:r,s:n,v:function(t,e,r){let n=function(t,e){const r=v(t).lowerBounds;for(let t=0;t<r.length-1;t++){const n=r[t][0],a=r[t][1],s=r[t+1][0],o=r[t+1][1];if(e>=n&&e<=s){const t=(o-a)/(s-n),r=a-t*n;return t*e+r}}return 0}(t,e),a=100;switch(r.luminosity){case"dark":a=n+20;break;case"light":n=(a+n)/2;break;case"random":n=0,a=100}return R([n,a],r.seed)}(r,n,e)};return void 0!==e.alpha&&(a.a=e.alpha),new y(a)},t.bounds=S,Object.defineProperty(t,"__esModule",{value:!0})}); | ||
//# sourceMappingURL=tinycolor.umd.min.js.map |
/** | ||
* @hidden | ||
*/ | ||
declare const names: { | ||
export declare const names: { | ||
[key: string]: string; | ||
}; | ||
export default names; |
@@ -7,3 +7,3 @@ "use strict"; | ||
*/ | ||
const names = { | ||
exports.names = { | ||
aliceblue: '#f0f8ff', | ||
@@ -158,3 +158,2 @@ antiquewhite: '#faebd7', | ||
}; | ||
exports.default = names; | ||
//# sourceMappingURL=css-color-names.js.map |
@@ -104,4 +104,4 @@ "use strict"; | ||
let named = false; | ||
if (css_color_names_1.default[color]) { | ||
color = css_color_names_1.default[color]; | ||
if (css_color_names_1.names[color]) { | ||
color = css_color_names_1.names[color]; | ||
named = true; | ||
@@ -108,0 +108,0 @@ } |
@@ -13,2 +13,3 @@ import { TinyColor } from './index'; | ||
export declare function fromRatio(ratio: RatioInput, opts?: any): TinyColor; | ||
export declare function fromLegacyRandom(): TinyColor; | ||
/** old random function */ | ||
export declare function legacyRandom(): TinyColor; |
@@ -21,3 +21,4 @@ "use strict"; | ||
exports.fromRatio = fromRatio; | ||
function fromLegacyRandom() { | ||
/** old random function */ | ||
function legacyRandom() { | ||
return new index_1.TinyColor({ | ||
@@ -29,3 +30,3 @@ r: Math.random(), | ||
} | ||
exports.fromLegacyRandom = fromLegacyRandom; | ||
exports.legacyRandom = legacyRandom; | ||
//# sourceMappingURL=from-ratio.js.map |
@@ -211,4 +211,4 @@ "use strict"; | ||
const hex = '#' + conversion_1.rgbToHex(this.r, this.g, this.b, false); | ||
for (const key of Object.keys(css_color_names_1.default)) { | ||
if (css_color_names_1.default[key] === hex) { | ||
for (const key of Object.keys(css_color_names_1.names)) { | ||
if (css_color_names_1.names[key] === hex) { | ||
return key; | ||
@@ -215,0 +215,0 @@ } |
@@ -0,1 +1,7 @@ | ||
/** | ||
* A representation of additive color mixing. | ||
* Projection of primary color lights on a white screen shows secondary | ||
* colors where two overlap; the combination of all three of red, green, | ||
* and blue in equal intensities makes white. | ||
*/ | ||
export interface RGB { | ||
@@ -2,0 +8,0 @@ r: number | string; |
{ | ||
"name": "@ctrl/tinycolor", | ||
"version": "1.2.0", | ||
"version": "2.0.0", | ||
"description": "Fast, small color manipulation and conversion for JavaScript", | ||
@@ -47,3 +47,3 @@ "author": "Scott Cooper <scttcper@gmail.com>", | ||
"@types/jest": "22.2.3", | ||
"@types/node": "10.0.4", | ||
"@types/node": "10.0.6", | ||
"commitizen": "2.9.6", | ||
@@ -54,3 +54,2 @@ "cz-conventional-changelog": "2.1.0", | ||
"npm-run-all": "4.1.3", | ||
"prettier": "1.12.1", | ||
"rimraf": "2.6.2", | ||
@@ -61,3 +60,3 @@ "rollup": "0.58.2", | ||
"rollup-plugin-uglify": "3.0.0", | ||
"semantic-release": "15.3.1", | ||
"semantic-release": "15.4.0", | ||
"travis-deploy-once": "5.0.0", | ||
@@ -64,0 +63,0 @@ "ts-jest": "22.4.5", |
export * from './index'; | ||
export { default as names } from './css-color-names'; | ||
export * from './css-color-names'; | ||
export * from './readability'; | ||
@@ -4,0 +4,0 @@ export * from './to-ms-filter'; |
@@ -7,4 +7,3 @@ "use strict"; | ||
__export(require("./index")); | ||
var css_color_names_1 = require("./css-color-names"); | ||
exports.names = css_color_names_1.default; | ||
__export(require("./css-color-names")); | ||
__export(require("./readability")); | ||
@@ -11,0 +10,0 @@ __export(require("./to-ms-filter")); |
@@ -11,3 +11,15 @@ import { TinyColor } from './index'; | ||
} | ||
export declare function fromRandom(options?: RandomOptions): TinyColor; | ||
export declare function fromRandom(options?: RandomCountOptions): TinyColor[]; | ||
export declare function random(options?: RandomOptions): TinyColor; | ||
export declare function random(options?: RandomCountOptions): TinyColor[]; | ||
/** | ||
* @hidden | ||
*/ | ||
export interface ColorBound { | ||
name: string; | ||
hueRange: [number, number] | null; | ||
lowerBounds: [number, number][]; | ||
} | ||
/** | ||
* @hidden | ||
*/ | ||
export declare const bounds: ColorBound[]; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
// randomColor by David Merfield under the CC0 license | ||
// https://github.com/davidmerfield/randomColor/ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const color_bounds_1 = require("./color-bounds"); | ||
const index_1 = require("./index"); | ||
function fromRandom(options = {}) { | ||
function random(options = {}) { | ||
// Check if we need to generate multiple colors | ||
@@ -21,3 +20,3 @@ if (options.count !== undefined && options.count !== null) { | ||
} | ||
colors.push(fromRandom(options)); | ||
colors.push(random(options)); | ||
} | ||
@@ -40,3 +39,3 @@ options.count = totalColors; | ||
} | ||
exports.fromRandom = fromRandom; | ||
exports.random = random; | ||
function pickHue(hue, seed) { | ||
@@ -113,3 +112,3 @@ const hueRange = getHueRange(hue); | ||
if (typeof colorInput === 'string') { | ||
const namedColor = color_bounds_1.bounds.find(n => n.name === colorInput); | ||
const namedColor = exports.bounds.find(n => n.name === colorInput); | ||
if (namedColor) { | ||
@@ -134,3 +133,3 @@ const color = defineColor(namedColor); | ||
} | ||
for (const bound of color_bounds_1.bounds) { | ||
for (const bound of exports.bounds) { | ||
const color = defineColor(bound); | ||
@@ -169,2 +168,77 @@ if (color.hueRange && hue >= color.hueRange[0] && hue <= color.hueRange[1]) { | ||
} | ||
/** | ||
* @hidden | ||
*/ | ||
exports.bounds = [ | ||
{ | ||
name: 'monochrome', | ||
hueRange: null, | ||
lowerBounds: [[0, 0], [100, 0]], | ||
}, | ||
{ | ||
name: 'red', | ||
hueRange: [-26, 18], | ||
lowerBounds: [ | ||
[20, 100], | ||
[30, 92], | ||
[40, 89], | ||
[50, 85], | ||
[60, 78], | ||
[70, 70], | ||
[80, 60], | ||
[90, 55], | ||
[100, 50], | ||
], | ||
}, | ||
{ | ||
name: 'orange', | ||
hueRange: [19, 46], | ||
lowerBounds: [[20, 100], [30, 93], [40, 88], [50, 86], [60, 85], [70, 70], [100, 70]], | ||
}, | ||
{ | ||
name: 'yellow', | ||
hueRange: [47, 62], | ||
lowerBounds: [[25, 100], [40, 94], [50, 89], [60, 86], [70, 84], [80, 82], [90, 80], [100, 75]], | ||
}, | ||
{ | ||
name: 'green', | ||
hueRange: [63, 178], | ||
lowerBounds: [[30, 100], [40, 90], [50, 85], [60, 81], [70, 74], [80, 64], [90, 50], [100, 40]], | ||
}, | ||
{ | ||
name: 'blue', | ||
hueRange: [179, 257], | ||
lowerBounds: [ | ||
[20, 100], | ||
[30, 86], | ||
[40, 80], | ||
[50, 74], | ||
[60, 60], | ||
[70, 52], | ||
[80, 44], | ||
[90, 39], | ||
[100, 35], | ||
], | ||
}, | ||
{ | ||
name: 'purple', | ||
hueRange: [258, 282], | ||
lowerBounds: [ | ||
[20, 100], | ||
[30, 87], | ||
[40, 79], | ||
[50, 70], | ||
[60, 65], | ||
[70, 59], | ||
[80, 52], | ||
[90, 45], | ||
[100, 42], | ||
], | ||
}, | ||
{ | ||
name: 'pink', | ||
hueRange: [283, 334], | ||
lowerBounds: [[20, 100], [30, 90], [40, 86], [60, 84], [80, 80], [90, 75], [100, 73]], | ||
}, | ||
]; | ||
//# sourceMappingURL=random.js.map |
@@ -12,6 +12,6 @@ # tinycolor [![npm](https://img.shields.io/npm/v/%40ctrl%2Ftinycolor.svg?maxAge=3600)](https://www.npmjs.com/package/%40ctrl%2Ftinycolor) [![build status](https://img.shields.io/travis/TypeCtrl/tinycolor.svg)](https://travis-ci.org/TypeCtrl/tinycolor) [![coverage status](https://codecov.io/gh/typectrl/tinycolor/branch/master/graph/badge.svg)](https://codecov.io/gh/typectrl/tinycolor) | ||
* `tinycolor` is now exported as a class called `TinyColor` | ||
* new `fromRandom`, an implementation of [randomColor](https://github.com/davidmerfield/fromRandom/) by David Merfield that returns a TinyColor object | ||
* new `random`, an implementation of [randomColor](https://github.com/davidmerfield/randomColor/) by David Merfield that returns a TinyColor object | ||
* several functions moved out of the tinycolor class and are no longer `TinyColor.<function>` | ||
* `readability`, `fromRatio` moved out | ||
* `random` moved out and renamed to `fromLegacyRandom` | ||
* `random` moved out and renamed to `legacyRandom` | ||
* `toFilter` has been moved out and renamed to `toMsFilter` | ||
@@ -527,3 +527,3 @@ * `mix`, `equals` use the current TinyColor object as the first parameter | ||
### fromRandom | ||
### random | ||
@@ -542,8 +542,8 @@ Returns a random TinyColor object. This is an implementation of [randomColor](https://github.com/davidmerfield/randomColor/) by David Merfield. | ||
```ts | ||
import { fromRandom } from '@ctrl/tinycolor'; | ||
import { random } from '@ctrl/tinycolor'; | ||
// Returns a TinyColor for an attractive color | ||
fromRandom(); | ||
random(); | ||
// Returns an array of ten green colors | ||
fromRandom({ | ||
random({ | ||
count: 10, | ||
@@ -554,3 +554,3 @@ hue: 'green', | ||
// Returns a TinyColor object in a light blue | ||
fromRandom({ | ||
random({ | ||
luminosity: 'light', | ||
@@ -561,3 +561,3 @@ hue: 'blue', | ||
// Returns a TinyColor object in a 'truly random' color | ||
fromRandom({ | ||
random({ | ||
luminosity: 'random', | ||
@@ -568,3 +568,3 @@ hue: 'random', | ||
// Returns a dark RGB color with specified alpha | ||
fromRandom({ | ||
random({ | ||
luminosity: 'dark', | ||
@@ -571,0 +571,0 @@ alpha: 0.5, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
22
3445
346199
40