| Current Path : /etc/kibana/node_modules/tinygradient/ |
| Current File : //etc/kibana/node_modules/tinygradient/tinygradient.min.js |
/*!
* TinyGradient 0.4.3
* Copyright 2014-2018 Damien "Mistic" Sorel (http://www.strangeplanet.fr)
* Licensed under MIT (http://opensource.org/licenses/MIT)
*/
!function(a,b){"undefined"!=typeof module&&module.exports?module.exports=b(require("tinycolor2")):"function"==typeof define&&define.amd?define(["tinycolor2"],b):a.tinygradient=b(a.tinycolor)}(this,function(a){"use strict";function b(a,b,c){var d={};for(var e in a)a.hasOwnProperty(e)&&(d[e]=0===c?0:(b[e]-a[e])/c);return d}function c(a,b,c,d){var e={};for(var f in b)b.hasOwnProperty(f)&&(e[f]=a[f]*c+b[f],e[f]=e[f]<0?e[f]+d[f]:1!==d[f]?e[f]%d[f]:e[f]);return e}function d(d,e,f){for(var g,i=d.color.toRgb(),j=e.color.toRgb(),k=[d.color],l=b(i,j,f),m=1;m<f;m++)g=c(l,i,m,h),k.push(a(g));return k}function e(d,e,f,g){var h,j,k=d.color.toHsv(),l=e.color.toHsv(),m=[d.color],n=b(k,l,f);h=k.h<=l.h&&!g||k.h>=l.h&&g?l.h-k.h:g?360-l.h+k.h:360-k.h+l.h,n.h=Math.pow(-1,g?1:0)*Math.abs(h)/f;for(var o=1;o<f;o++)j=c(n,k,o,i),m.push(a(j));return m}function f(a,b){var c=a.length;if(b=parseInt(b),isNaN(b)||b<2)throw new Error("Invalid number of steps (< 2)");if(b<c)throw new Error("Number of steps cannot be inferior to number of stops");for(var d=[],e=1;e<c;e++){var f=(b-1)*(a[e].pos-a[e-1].pos);d.push(Math.max(1,Math.round(f)))}for(var g=1,h=c-1;h--;)g+=d[h];for(;g!==b;)if(g<b){var i=Math.min.apply(null,d);d[d.indexOf(i)]++,g++}else{var j=Math.max.apply(null,d);d[d.indexOf(j)]--,g--}return d}function g(d,e,f,g){if(e<0||e>1)throw new Error("Position must be between 0 and 1");for(var h,i,j=0,k=d.length;j<k-1;j++)if(e>=d[j].pos&&e<d[j+1].pos){h=d[j],i=d[j+1];break}h||(h=i=d[d.length-1]);var l=b(h.color[f](),i.color[f](),100*(i.pos-h.pos)),m=c(l,h.color[f](),Math.round(100*(e-h.pos)),g);return a(m)}var h={r:256,g:256,b:256,a:1},i={h:360,s:1,v:1,a:1},j=function(b){if(1===arguments.length){if(!(arguments[0]instanceof Array))throw new Error('"stops" is not an array');b=arguments[0]}else b=Array.prototype.slice.call(arguments);if(!(this instanceof j))return new j(b);if(b.length<2)throw new Error("Invalid number of stops (< 2)");var c=void 0!==b[0].pos,d=b.length,e=-1;this.stops=b.map(function(b,f){var g=void 0!==b.pos;if(c^g)throw new Error("Cannot mix positionned and not posionned color stops");if(g){if(b={color:a(b.color),pos:b.pos},b.pos<0||b.pos>1)throw new Error("Color stops positions must be between 0 and 1");if(b.pos<=e)throw new Error("Color stops positions are not ordered");e=b.pos}else b={color:a(b),pos:f/(d-1)};return b}),0!==this.stops[0].pos&&this.stops.unshift({color:this.stops[0].color,pos:0}),1!==this.stops[this.stops.length-1].pos&&this.stops.push({color:this.stops[this.stops.length-1].color,pos:1})};j.prototype.reverse=function(){var a=[];return this.stops.forEach(function(b){a.push({color:b.color,pos:1-b.pos})}),new j(a.reverse())},j.prototype.rgb=function(a){for(var b=f(this.stops,a),c=[],e=0,g=this.stops.length;e<g-1;e++)c=c.concat(d(this.stops[e],this.stops[e+1],b[e]));return c.push(this.stops[g-1].color),c},j.prototype.hsv=function(a,b){for(var c,g,h,i=f(this.stops,a),j=b===!0,k="string"==typeof b,l=[],m=0,n=this.stops.length;m<n-1;m++)c=this.stops[m].color.toHsv(),g=this.stops[m+1].color.toHsv(),k&&(h=c.h<g.h&&g.h-c.h<180||c.h>g.h&&c.h-g.h>180),l=0===c.s||0===g.s?l.concat(d(this.stops[m],this.stops[m+1],i[m])):l.concat(e(this.stops[m],this.stops[m+1],i[m],"long"===b&&h||"short"===b&&!h||!k&&j));return l.push(this.stops[n-1].color),l},j.prototype.css=function(a,b){a=a||"linear",b=b||("linear"===a?"to right":"ellipse at center");var c=a+"-gradient("+b;return this.stops.forEach(function(a){c+=", "+a.color.toRgbString()+" "+100*a.pos+"%"}),c+=")"},j.prototype.rgbAt=function(a){return g(this.stops,a,"toRgb",h)},j.prototype.hsvAt=function(a){return g(this.stops,a,"toHsv",i)};var k={rgb:1,hsv:2,css:2,rgbAt:1,hsvAt:1};return Object.keys(k).forEach(function(a){j[a]=function(){var b=Array.prototype.slice.call(arguments),c=b.splice(-k[a]),d=new j(b);return d[a].apply(d,c)}}),j});