drawCircle "+(+new Date-g)+"ms")},e.drawMask=function(){function c(a,b,c){for(var d=1/a,e=1/b,f=0;b>=f;++f)for(var g=1-f*e,h=0;a>=h;++h){var i=1-h*d,j=1-2*Math.min(g*i,(1-g)*i),k=j>0?.5*(2*g-1+j)/j:0;c(h,f,k,j)}}var d=+new Date,f=2*e.square,g=e.square;if(e.ctxMask.getImageData){var h=Math.floor(f/2),i=document.createElement("canvas");i.width=i.height=h+1;var j=i.getContext("2d"),k=j.getImageData(0,0,h+1,h+1),l=0;c(h,h,function(a,b,c,d){k.data[l++]=k.data[l++]=k.data[l++]=255*c,k.data[l++]=255*d}),j.putImageData(k,0,0),e.ctxMask.drawImage(i,0,0,h+1,h+1,-g,-g,2*g,2*g)}else if(navigator.userAgent.match(/msie/i)){var m,n,o=6,p=Math.floor(f/o);c(p,6,function(b,c,d,f){if(0==b&&(m=n,n=[]),d=Math.round(255*d),f=Math.round(255*f),c>0){var h=m[b][0],i=m[b][1],j=e.packDX(h,i),k=e.packDX(d,f),l=Math.round(e.mid+(.333*(c-1)-1)*g),q=Math.round(e.mid+(.333*c-1)*g);a("
").css({position:"absolute",filter:"progid:DXImageTransform.Microsoft.Gradient(StartColorStr="+j+", EndColorStr="+k+", GradientType=0)",top:l,height:q-l,left:e.mid+(b*o-g-1),width:o-(b==p?Math.round(o/2):0)}).appendTo(e.cnvMask)}n.push([d,f])})}else{var h=Math.floor(f/2);c(h,h,function(a,b,c,d){c=Math.round(255*c),e.ctxMask.fillStyle="rgba("+c+", "+c+", "+c+", "+d+")",e.ctxMask.fillRect(2*a-g-1,2*b-g-1,2,2)})}b&&a("body").append("
drawMask "+(+new Date-d)+"ms")},e.drawMarkers=function(){var a=d.width,b=Math.ceil(e.markerSize/4),c=e.markerSize-b+1,f=6.28*e.hsl[0],g=Math.sin(f)*e.radius,h=-Math.cos(f)*e.radius,j=2*e.square*(.5-e.hsl[1]),k=2*e.square*(.5-e.hsl[2]),l=e.invert?"#fff":"#000",m=e.invert?"#000":"#fff",n=[{x:g,y:h,r:c,c:"#000",lw:b+1},{x:g,y:h,r:e.markerSize,c:"#fff",lw:b},{x:j,y:k,r:c,c:m,lw:b+1},{x:j,y:k,r:e.markerSize,c:l,lw:b}];e.ctxOverlay.clearRect(-e.mid,-e.mid,a,a);for(i in n){var o=n[i];e.ctxOverlay.lineWidth=o.lw,e.ctxOverlay.strokeStyle=o.c,e.ctxOverlay.beginPath(),e.ctxOverlay.arc(o.x,o.y,o.r,0,2*Math.PI,!0),e.ctxOverlay.stroke()}},e.updateDisplay=function(){e.invert=.3*e.rgb[0]+.59*e.rgb[1]+.11*e.rgb[2]<=.6,e.solidFill.css("backgroundColor",e.pack(e.HSLToRGB([e.hsl[0],1,.5]))),e.drawMarkers(),"object"==typeof e.callback?(a(e.callback).css({backgroundColor:e.color,color:e.invert?"#fff":"#000"}),a(e.callback).each(function(){"string"==typeof this.value&&this.value!=e.color&&(this.value=e.color)})):"function"==typeof e.callback&&e.callback.call(e,e.color)},e.widgetCoords=function(a){return{x:a.pageX-e.offset.left-e.mid,y:a.pageY-e.offset.top-e.mid}},e.mousedown=function(b){a._farbtastic.dragging||(a(document).bind("mousemove",e.mousemove).bind("mouseup",e.mouseup),a._farbtastic.dragging=!0),e.offset=a(c).offset();var d=e.widgetCoords(b);return e.circleDrag=Math.max(Math.abs(d.x),Math.abs(d.y))>e.square+2,e.mousemove(b),!1},e.mousemove=function(a){var b=e.widgetCoords(a);if(e.circleDrag){var c=Math.atan2(b.x,-b.y)/6.28;e.setHSL([(c+1)%1,e.hsl[1],e.hsl[2]])}else{var d=Math.max(0,Math.min(1,-(b.x/e.square/2)+.5)),f=Math.max(0,Math.min(1,-(b.y/e.square/2)+.5));e.setHSL([e.hsl[0],d,f])}return!1},e.mouseup=function(){a(document).unbind("mousemove",e.mousemove),a(document).unbind("mouseup",e.mouseup),a._farbtastic.dragging=!1},e.dec2hex=function(a){return(16>a?"0":"")+a.toString(16)},e.packDX=function(a,b){return"#"+e.dec2hex(b)+e.dec2hex(a)+e.dec2hex(a)+e.dec2hex(a)},e.pack=function(a){var b=Math.round(255*a[0]),c=Math.round(255*a[1]),d=Math.round(255*a[2]);return"#"+e.dec2hex(b)+e.dec2hex(c)+e.dec2hex(d)},e.unpack=function(a){function b(b){return parseInt(a.substring(b,b+2),16)/255}function b(b){return parseInt(a.substring(b,b+1),16)/15}return 7==a.length?[b(1),b(3),b(5)]:4==a.length?[b(1),b(2),b(3)]:void 0},e.HSLToRGB=function(a){var b,c,d=a[0],e=a[1],f=a[2];return c=.5>=f?f*(e+1):f+e-f*e,b=2*f-c,[this.hueToRGB(b,c,d+.33333),this.hueToRGB(b,c,d),this.hueToRGB(b,c,d-.33333)]},e.hueToRGB=function(a,b,c){return c=(c+1)%1,1>6*c?a+(b-a)*c*6:1>2*c?b:2>3*c?a+(b-a)*(.66666-c)*6:a},e.RGBToHSL=function(a){var b=a[0],c=a[1],d=a[2],e=Math.min(b,c,d),f=Math.max(b,c,d),g=f-e,h=0,i=0,j=(e+f)/2;return j>0&&1>j&&(i=g/(.5>j?2*j:2-2*j)),g>0&&(f==b&&f!=c&&(h+=(c-d)/g),f==c&&f!=d&&(h+=2+(d-b)/g),f==d&&f!=b&&(h+=4+(b-c)/g),h/=6),[h,i,j]},d.callback||(d={callback:d}),d=a.extend({width:300,wheelWidth:(d.width||300)/10,callback:null,color:"#808080"},d),e.initWidget(),a("canvas.farbtastic-overlay",c).mousedown(e.mousedown),d.callback&&e.linkTo(d.callback),e.setColor("#808080"),e.setColor(d.color)}}(jQuery);
//# sourceMappingURL=../../maps/libs/farbtastic.js.map