// All material copyright ESRI, All Rights Reserved, unless otherwise specified.
// See http://js.arcgis.com/3.23/esri/copyright.txt for details.
//>>built
define("esri/dijit/geoenrichment/utils/ColorUtil",["dojo/_base/Color","dojox/color/Palette"],function(g,k){function h(a,b,c){return Math.round((a&255)*(1-c)+(b&255)*c)}var e={toCSSColor:function(a,b,c){"string"!=typeof a||/^0x/i.test(a)||(a=g.fromString(a));if(a instanceof g)return b||1==a.a?a.toHex():a.toCss(!0);if(null==a||isNaN(a))return c?e.toCSSColor(c,b):"#000000";a="00000"+Number(a).toString(16);return"#"+a.substr(a.length-6)},toColor:function(a,b){return"object"==typeof a?(new g).setColor(a):
g.fromString(e.toCSSColor(a,!1,b))},transform:function(a,b){var c=new k;c.colors=[new g(a)];return c.transform({use:"hsv",dh:b.dh||0,ds:b.ds||0,dv:b.dv||0}).colors[0]},generateAnalogousColorScheme:function(a,b,c){return k.generators.analogous({base:a,high:b,low:c}).colors},generateGradient:function(a,b){a=a.map(e.toRGBColor);var c=[];if(0==a.length-1||1==b){for(var f=a[0],d=0;d<b;d++)c.push(f);return c}f=1/(b-1);for(d=0;d<b;d++)c.push(e.getGradientRGBColor(a,d*f));return c},getGradientRGBColor:function(a,
b,c){var f=a.length-1,d=1>f||0>=b?0:1<=b?f:-1;if(0<=d)return a[d];b*=f;d=Math.floor(b);d==f&&d--;return e.mixRGBColors(a[d],a[d+1],b-d,c)},mixRGBColors:function(a,b,c,e){1<c?c=1:0>c&&(c=0);var d=h(a,b,c),f=h(a>>8,b>>8,c),g=h(a>>16,b>>16,c);return((e?h(a>>24,b>>24,c):0)<<24)+(g<<16)+(f<<8)+d},toRGBColor:function(a,b){a=e.toCSSColor(a,!0,b);return parseInt("0x"+a.substr(1))},getContrastColor:function(a,b,c,f){return e.isLightColor(a,f)?e.toColor(b,"#000000"):e.toColor(c,"#FFFFFF")},isLightColor:function(a,
b){b=void 0===b?128:b;a=e.toRGBColor(a);return(299*(a>>16&255)+587*(a>>8&255)+114*(a&255))/1E3>=b},compareColors:function(a,b){return e.toCSSColor(a).toLowerCase()==e.toCSSColor(b).toLowerCase()},isTransparent:function(a){a=e.toCSSColor(a);return"rgba(0,0,0,0)"===a.toLowerCase().replace(/\s/g,"")},generateRandomColor:function(a){function b(){return c+Math.round((e-c)*Math.random())}a=a||{};var c=a.min||0,e=a.max||255,d=a.randomizeAlpha?b():1;return a.grayScheme?(a=b(),new g([a,a,a,d])):new g([b(),
b(),b(),d])}};return e});