-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathjcanvas.min.js
39 lines (39 loc) · 17 KB
/
jcanvas.min.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/*
jCanvas v6.0
Copyright 2012, Caleb Evans
Licensed under the MIT license
*/
(function(d,Q,Z,O,$,o,C,f,s){var K,L,R,S,T,U;function x(){}function A(c){c?w(aa,c):A.prefs=aa=x.prototype=w({},M);return this}function F(c,a){c.fillStyle=a.fillStyle;c.strokeStyle=a.strokeStyle;c.lineWidth=a.strokeWidth;a.rounded?(c.lineCap="round",c.lineJoin="round"):(c.lineCap=a.strokeCap,c.lineJoin=a.strokeJoin,c.miterLimit=a.miterLimit);c.shadowOffsetX=a.shadowX;c.shadowOffsetY=a.shadowY;c.shadowBlur=a.shadowBlur;c.shadowColor=a.shadowColor;c.globalAlpha=a.opacity;c.globalCompositeOperation=a.compositing}
function v(c){return c&&c.getContext?c.getContext("2d"):f}function I(c,a){a.closed&&c.closePath();c.fill();"transparent"!==a.fillStyle&&(c.shadowColor="transparent");c.stroke();a.closed||c.closePath();a._toRad&&c.restore();a.mask&&(a.autosave&&c.save(),c.clip())}function ba(c,a){if(!a.translateX&&!a.translateY&&(a.x||a.y))a.translateX=a.x,a.translateY=a.y;a.translate&&(a.translateX=a.translateY=a.translate);c.translate(a.translateX,a.translateY)}function ca(c,a){1!==a.scale&&(a.scaleX=a.scaleY=a.scale);
c.translate(a.x,a.y);c.scale(a.scaleX,a.scaleY);c.translate(-a.x,-a.y)}function da(c,a){a._toRad=a.inDegrees?z/180:1;a.rotate=a.rotate||a.angle;c.translate(a.x,a.y);c.rotate(a.rotate*a._toRad);c.translate(-a.x,-a.y)}function E(c,a,b,e,i){b._toRad=b.inDegrees?z/180:1;a.save();i=i||e;!c&&!b.fromCenter&&(b.x+=e/2,b.y+=i/2);(b.rotate||b.angle)&&da(a,b);(1!==b.scale||1!==b.scaleX||1!==b.scaleY)&&ca(a,b);(b.translate||b.translateX||b.translateY)&&ba(a,b)}function P(c){var a;K===c?a=L:((a=d.data(c,"jCanvas"))||
(a=d.data(c,"jCanvas",{layers:[],intersects:[],drag:{},event:{}})),K=c,L=a);return a}function ea(c,a,b){b&&b.visible&&(b.method===d.fn.draw?b.fn.call(c[0],a):b.method&&b.method.call(c,b))}function D(c,a,b){var e,i,g,B="function"===typeof a,n,a=a||{};if(a.layer&&!a._layer){e=d(c);i=e.getLayers();B&&(a={method:d.fn.draw,fn:a});a=w(new x,a);if(!B){a.method=d.fn[a.method]||b;n=P(c);for(g in A.events)A.events.hasOwnProperty(g)&&a[g]&&(A.events[g](e,n),a._event=o);if(a.draggable){a._event=o;c=["mousedown",
"mousemove","mouseup"];for(b=0;b<c.length;b+=1)g=c[b],A.events[g](e,n);n.mouseout||(e.bind("mouseout.jCanvas",function(){n.drag={};e.drawLayers()}),n.mouseout=o)}}a.layer=o;a._layer=o;a.index===s&&(a.index=i.length);i.splice(a.index,0,a)}}function fa(c){var a;for(a=0;a<H.length;a+=1)c[H[a]]=c["_"+H[a]]}function ga(c){var a;for(a=0;a<H.length;a+=1)c["_"+H[a]]=c[H[a]],V[H[a]]=1}function ha(c){var a,b,e=[],i=1;c.match(/^#?[a-z0-9]+$/i)&&("transparent"===c&&(c="rgba(0,0,0,0)"),b=Q.head,a=b.style.color,
b.style.color=c,c=d.css(b,"color"),b.style.color=a);c.match(/^rgb/i)&&(e=c.match(/[0-9]+/gi),c.match(/%/gi)&&(i=2.55),e[0]*=i,e[1]*=i,e[2]*=i,e[3]=e[3]!==s?$(e[3]):1);return e}function ka(c){var a=3,b;"object"!==typeof c.start&&(c.start=ha(c.start),c.end=ha(c.end));c.now=[];if(1!==c.start[3]||1!==c.end[3])a=4;for(b=0;b<a;b+=1)c.now[b]=c.start[b]+(c.end[b]-c.start[b])*c.pos,3>b&&(c.now[b]=N(c.now[b]));1!==c.start[3]||1!==c.end[3]?c.now="rgba("+c.now.join(",")+")":(c.now.slice(0,3),c.now="rgb("+c.now.join(",")+
")");c.elem.nodeName?c.elem.style[c.prop]=c.now:c.elem[c.prop]=c.now}function J(c){A.events[c]=function(a,b){var e="mouseover"===c||"mouseout"===c?"mousemove":c,i=b.event;b[e]||(a.bind(e+".jCanvas",function(b){i.x=b.offsetX;i.y=b.offsetY;i.type=e;a.drawLayers(o);b.preventDefault()}),b[e]=o)}}function G(c,a,b){var c=P(c),e=c.event,a=a.isPointInPath(e.x,e.y);b.mouseX=e.x;b.mouseY=e.y;!a&&(b._hovered&&!b._fired)&&(b._mousedout=o);a&&c.intersects.push(b)}function ia(c,a,b){var e,i=/\b(\d*\.?\d*)\w\w\b/gi;
if(R===b.text&&S===b.font)b.width=T,b.height=U;else{b.width=a.measureText(b.text).width;a=c.style.fontSize;if(e=b.font.match(i))c.style.fontSize=b.font.match(i)[0];b.height=$(d.css(c,"fontSize"));c.style.fontSize=a}}var M,aa,w=d.extend,N=O.round,z=O.PI,ja=O.sin,W=O.cos,la=d.event.fix;U=T=S=R=L=K=void 0;var H,V;d.fn.jCanvas=A;A.version="6.0";A.events={};M={angle:0,align:"center",autosave:o,baseline:"middle",bringToFront:C,ccw:C,closed:C,compositing:"source-over",cornerRadius:0,cropFromCenter:o,draggable:!1,
each:f,end:360,fillStyle:"transparent",font:"12pt sans-serif",fromCenter:o,height:f,inDegrees:o,load:f,mask:C,method:f,miterLimit:10,opacity:1,projection:0,r1:f,r2:f,radius:0,repeat:"repeat",rotate:0,rounded:C,scale:1,scaleX:1,scaleY:1,shadowBlur:0,shadowColor:"transparent",shadowX:0,shadowY:0,sHeight:f,sides:3,source:"",start:0,strokeCap:"butt",strokeJoin:"miter",strokeStyle:"transparent",strokeWidth:1,sWidth:f,sx:f,sy:f,text:"",translate:0,translateX:0,translateY:0,visible:o,width:f,x:0,y:0};A();
A.extend=function(c){M=w(M,c.props);A();c.name&&(d.fn[c.name]=function(a){var b,e,i=w(new x,a);for(b=0;b<this.length;b+=1)if(a=this[b],e=v(a))F(e,i),c.fn.call(a,e,i);return this});return d.fn[c.name]};d.fn.getLayers=function(){var c=this[0];return!c||!c.getContext?[]:P(c).layers};d.fn.getLayer=function(c){var a=this.getLayers(),b;if(!c||!c.layer){if("string"===typeof c)for(b=0;b<a.length;b+=1)if(a[b].name===c){c=b;break}c=a[c||0]}return c};d.fn.setLayer=function(c,a){var b,e;c||(a=c,c=0);for(b=0;b<
this.length;b+=1)e=d(this[b]).getLayer(c),w(e,a);return this};d.fn.removeLayer=function(c){var a,b,e,i,g=typeof c;for(a=0;a<this.length;a+=1){b=d(this[a]).getLayers();if("string"===g)for(i=0;i<b.length;i+=1){if(b[i].name===c){e=i;break}}else e="number"===g?c:"";b[e]&&b.splice(e,1)}return this};d.fn.removeLayers=function(){var c,a;for(a=0;a<this.length;a+=1)c=d(this[a]).getLayers(),c.length=0;return this};d.fn.getLayerGroup=function(c){var a=this.getLayers(),b=[],e;if(c!==s)for(e=0;e<a.length;e+=1)a[e].group===
c&&b.push(a[e]);return b};d.fn.setLayerGroup=function(c,a){var b,e,i;for(b=0;b<this.length;b+=1){e=d(this[b]).getLayers();for(i=0;i<e.length;i+=1)e[i].group===c&&w(e[i],a)}return this};d.fn.removeLayerGroup=function(c){var a,b,e;if(c!==s)for(a=0;a<this.length;a+=1){b=d(this[a]).getLayers();for(e=0;e<b.length;e+=1)b[e].group===c&&(b.splice(e,1),e-=1)}return this};d.fn.drawLayer=function(c){var a,b,e,i;for(a=0;a<this.length;a+=1)e=d(this[a]),b=v(this[a]),i=e.getLayer(c),ea(e,b,i);return this};d.fn.drawLayers=
function(c){var a,b,e,i,g,B,n;for(b=0;b<this.length;b+=1)if(a=d(this[b]),e=v(this[b])){e.clearRect(0,0,this[b].width,this[b].height);K===this[b]?n=L:(n=P(this[b]),K=this[b],L=n);i=n.layers;for(B=0;B<i.length;B+=1)if(g=i[B],g.index=B,c&&(g._fired=C),ea(a,e,g),g._mousedout)g._mousedout=C,g._fired=o,g._hovered=C,g.mouseout&&g.mouseout.call(this[b],g);g=n.intersects[n.intersects.length-1]||{};a=n.event;a=a.type;B=g[a];e=n.drag;if(g._event){if((g.mouseover||g.mouseout)&&!g._hovered&&!g._fired)g._fired=
o,g._hovered=o,g.mouseover&&g.mouseover.call(this[b],g);B&&!g._fired&&(g._fired=o,B.call(this[b],g));g.draggable&&"mousedown"===a&&(g.bringToFront&&(i.splice(g.index,1),g.index=i.push(g)),e.layer=g,e.dragging=o,e.startX=g.x,e.startY=g.y,e.endX=g.mouseX,e.endY=g.mouseY,g.dragstart&&g.dragstart.call(this[b],g))}if(e.layer&&(e.dragging&&"mouseup"===a&&(e.layer.dragstop&&e.layer.dragstop.call(this[b],e.layer),n.drag={}),e.dragging&&"mousemove"===a))e.layer.x=e.layer.mouseX-(e.endX-e.startX),e.layer.y=
e.layer.mouseY-(e.endY-e.startY),e.layer.drag&&e.layer.drag.call(this[b],e.layer)}n.intersects=[];return this};d.fn.addLayer=function(c){var a,b,c=c||{};for(a=0;a<this.length;a+=1)if(b=v(this[a]))c.layer=o,D(this[a],c);return this};H=["width","height","opacity"];V={};d.fn.animateLayer=function(){function c(a,b){return function(){fa(b);a.drawLayers();g[4]&&g[4].call(a[0],b)}}function a(a,b){return function(c,e){fa(b);a.drawLayers();g[5]&&g[5].call(a[0],c,e,b)}}var b,e,i,g=[].slice.call(arguments,0);
"object"===typeof g[0]&&!g[0].layer&&g.unshift(0);"object"===typeof g[2]?(g.splice(2,0,g[2].duration||f),g.splice(3,0,g[3].easing||f),g.splice(4,0,g[4].complete||f),g.splice(5,0,g[5].step||f)):(g[2]===s?(g.splice(2,0,f),g.splice(3,0,f),g.splice(4,0,f)):"function"===typeof g[2]&&(g.splice(2,0,f),g.splice(3,0,f)),g[3]===s)?(g[3]=f,g.splice(4,0,f)):"function"===typeof g[3]&&g.splice(3,0,f);for(e=0;e<this.length;e+=1)if(b=d(this[e]),i=v(this[e]))if((i=b.getLayer(g[0]))&&i.method!==d.fn.draw)ga(i),ga(g[1]),
i.style=V,d(i).animate(g[1],{duration:g[2],easing:d.easing[g[3]]?g[3]:f,complete:c(b,i),step:a(b,i)});return this};d.fn.animateLayerGroup=function(c){var a,b,e=[].slice.call(arguments,0),i,g;for(b=0;b<this.length;b+=1){a=d(this[b]);i=a.getLayerGroup(c);for(g=0;g<i.length;g+=1)a.animateLayer.apply(a,[i[g]].concat(e.slice(1)))}};d.fn.delayLayer=function(c,a){var b,e,a=a||0;for(b=0;b<this.length;b+=1)e=d(this[b]).getLayer(c),d(e).delay(a);return this};d.fn.delayLayerGroup=function(c,a){var b,e,i,g,a=
a||0;for(e=0;e<this.length;e+=1){b=d(this[e]);i=b.getLayerGroup(c);for(g=0;g<i.length;g+=1)b.delayLayer.call(b,c,a)}};d.fn.stopLayer=function(c,a){var b,e;for(b=0;b<this.length;b+=1)e=d(this[b]).getLayer(c),d(e).stop(a);return this};d.fn.stopLayerGroup=function(c,a){var b,e,i,g;for(e=0;e<this.length;e+=1){b=d(this[e]);i=b.getLayerGroup(c);for(g=0;g<i.length;g+=1)b.stopLayer.call(b,c,a)}};(function(c){var a;for(a=0;a<c.length;a+=1)d.fx.step[c[a]]=ka})("color backgroundColor borderColor borderTopColor borderRightColor borderBottomColor borderLeftColor fillStyle outlineColor strokeStyle shadowColor".split(" "));
J("click");J("dblclick");J("mousedown");J("mouseup");J("mousemove");J("mouseover");J("mouseout");d.event.fix=function(c){var a,c=la.call(d.event,c);if(c.pageX!==s&&c.offsetX===s&&(a=d(c.target).offset()))c.offsetX=c.pageX-a.left,c.offsetY=c.pageY-a.top;return c};d.fn.draw=function a(b){var e,i,b=b||{};"function"===typeof b&&(b={fn:b});for(e=0;e<this.length;e+=1)if((i=v(this[e]))&&b.fn)D(this[e],b,a),b.fn.call(this[e],i);return this};d.fn.clearCanvas=function(a){for(var b,e=w(new x,a),a=0;a<this.length;a+=
1)if(b=v(this[a]))E(a,b,e,e.width,e.height),!e.x||!e.y||!e.width||!e.height?b.clearRect(0,0,this[a].width,this[a].height):b.clearRect(e.x-e.width/2,e.y-e.height/2,e.width,e.height);return this};d.fn.saveCanvas=function(){var a,b;for(a=0;a<this.length;a+=1)(b=v(this[a]))&&b.save();return this};d.fn.restoreCanvas=function(){var a,b;for(a=0;a<this.length;a+=1)(b=v(this[a]))&&b.restore();return this};d.fn.translateCanvas=function(a){for(var b,e=w(new x,a),a=0;a<this.length;a+=1)if(b=v(this[a]))e.autosave&&
b.save(),ba(b,e);return this};d.fn.scaleCanvas=function(a){for(var b,e=w(new x,a),a=0;a<this.length;a+=1)if(b=v(this[a]))e.autosave&&b.save(),ca(b,e);return this};d.fn.rotateCanvas=function(a){for(var b,e=w(new x,a),a=0;a<this.length;a+=1)if(b=v(this[a]))e.autosave&&b.save(),da(b,e);return this};d.fn.drawRect=function b(e){var i,g,d=w(new x,e),n,y,r,t,j;for(i=0;i<this.length;i+=1)if(g=v(this[i]))D(this[i],e,b),F(g,d),E(i,g,d,d.width,d.height),g.beginPath(),n=d.x-d.width/2,y=d.y-d.height/2,(j=d.cornerRadius)?
(d.closed=o,r=d.x+d.width/2,t=d.y+d.height/2,0>r-n-2*j&&(j=(r-n)/2),0>t-y-2*j&&(j=(t-y)/2),g.moveTo(n+j,y),g.lineTo(r-j,y),g.arc(r-j,y+j,j,3*z/2,2*z,C),g.lineTo(r,t-j),g.arc(r-j,t-j,j,0,z/2,C),g.lineTo(n+j,t),g.arc(n+j,t-j,j,z/2,z,C),g.lineTo(n,y+j),g.arc(n+j,y+j,j,z,3*z/2,C)):g.rect(n,y,d.width,d.height),d._event&&G(this[i],g,e),I(g,d);return this};d.fn.drawArc=function e(d){var g,f,n=w(new x,d),d=d||{};!n.inDegrees&&360===n.end&&(d.end=n.end=2*z);for(g=0;g<this.length;g+=1)if(f=v(this[g]))D(this[g],
d,e),F(f,n),E(g,f,n,2*n.radius),f.beginPath(),f.arc(n.x,n.y,n.radius,n.start*n._toRad-z/2,n.end*n._toRad-z/2,n.ccw),n._event&&G(this[g],f,d),I(f,n);return this};d.fn.drawEllipse=function i(g){var d,n,f=w(new x,g),r=4*f.width/3,t=f.height;f.closed=o;for(d=0;d<this.length;d+=1)if(n=v(this[d]))D(this[d],g,i),F(n,f),E(d,n,f,f.width,f.height),n.beginPath(),n.moveTo(f.x,f.y-t/2),n.bezierCurveTo(f.x-r/2,f.y-t/2,f.x-r/2,f.y+t/2,f.x,f.y+t/2),n.bezierCurveTo(f.x+r/2,f.y+t/2,f.x+r/2,f.y-t/2,f.x,f.y-t/2),f._event&&
G(this[d],n,g),I(n,f);return this};d.fn.drawPolygon=function g(d){var f,y,r=w(new x,d),t=2*z/r.sides,j=z/r.sides,l=j+z/2,m=r.radius*W(t/2),p,q,k;r.closed=o;for(f=0;f<this.length;f+=1)if(y=v(this[f])){D(this[f],d,g);F(y,r);E(f,y,r,2*r.radius);y.beginPath();for(k=0;k<r.sides;k+=1)p=r.x+N(r.radius*W(l)),q=r.y+N(r.radius*ja(l)),y.lineTo(p,q),r.projection&&(p=r.x+N((m+m*r.projection)*W(l+j)),q=r.y+N((m+m*r.projection)*ja(l+j)),y.lineTo(p,q)),l+=t;r._event&&G(this[f],y,d);I(y,r)}return this};d.fn.drawLine=
function B(d){var f,r,t=w(new x,d),j,l,m;for(f=0;f<this.length;f+=1)if(r=v(this[f])){D(this[f],d,B);F(r,t);E(f,r,t,0);j=1;for(r.beginPath();o;)if(l=t["x"+j],m=t["y"+j],l!==s&&m!==s)r.lineTo(l,m),j+=1;else break;t._event&&G(this[f],r,d);I(r,t)}return this};d.fn.drawQuad=function n(d){var f,t,j=w(new x,d),l,m,p,q,k;for(f=0;f<this.length;f+=1)if(t=v(this[f])){D(this[f],d,n);F(t,j);E(f,t,j,0);l=2;t.beginPath();for(t.moveTo(j.x1,j.y1);o;)if(m=j["x"+l],p=j["y"+l],q=j["cx"+(l-1)],k=j["cy"+(l-1)],m!==s&&
p!==s&&q!==s&&k!==s)t.quadraticCurveTo(q,k,m,p),l+=1;else break;j._event&&G(this[f],t,d);I(t,j)}return this};d.fn.drawBezier=function y(d){var f,j,l=w(new x,d),m,p,q,k,h,u,X,Y;for(f=0;f<this.length;f+=1)if(j=v(this[f])){D(this[f],d,y);F(j,l);E(f,j,l,0);m=2;p=1;j.beginPath();for(j.moveTo(l.x1,l.y1);o;)if(q=l["x"+m],k=l["y"+m],h=l["cx"+p],u=l["cy"+p],X=l["cx"+(p+1)],Y=l["cy"+(p+1)],q!==s&&k!==s&&h!==s&&u!==s&&X!==s&&Y!==s)j.bezierCurveTo(h,u,X,Y,q,k),m+=1,p+=2;else break;l._event&&G(this[f],j,d);I(j,
l)}return this};d.fn.drawText=function r(f){var j,l,m=w(new x,f);for(j=0;j<this.length;j+=1)if(d(this[j]),l=v(this[j]))(D(this[j],f,r),F(l,m),l.textBaseline=m.baseline,l.textAlign=m.align,l.font=m.font,ia(this[j],l,m),E(j,l,m,m.width,m.height),l.fillText(m.text,m.x,m.y),"transparent"!==m.fillStyle&&(l.shadowColor="transparent"),l.strokeText(m.text,m.x,m.y),m._event)?(l.beginPath(),l.rect(m.x-m.width/2,m.y-m.height/2,m.width,m.height),l.restore(),G(this[j],l,f),l.closePath()):l.restore();R=m.text;
S=m.font;T=m.width;U=m.height;return this};d.fn.measureText=function(d){var f;f=d&&"object"!==typeof d?this.getLayer(d):w(new x,d);(d=v(this[0]))&&ia(this[0],d,f);return f};d.fn.drawImage=function t(d){function l(l,t,k){return function(){t||((s=u.width/u.height,h.width===f&&h.sWidth===f&&(d.width=h.width=h.sWidth=u.width),h.height===f&&h.sHeight===f&&(d.height=h.height=h.sHeight=u.height),h.width===f&&h.sWidth!==f&&(h.width=h.sWidth),h.height===f&&h.sHeight!==f&&(h.height=h.sHeight),h.sWidth===f&&
h.width!==f&&(d.sWidth=h.sWidth=u.width),h.sHeight===f&&h.height!==f&&(d.sHeight=h.sHeight=u.height),h.sx===f&&(h.sx=h.cropFromCenter?u.width/2:0),h.sy===f&&(h.sy=h.cropFromCenter?u.height/2:0),h.cropFromCenter||(h.sx+=h.sWidth/2,h.sy+=h.sHeight/2),h.sx+h.sWidth/2>u.width&&(h.sx=u.width-h.sWidth/2),0>h.sx-h.sWidth/2&&(h.sx=h.sWidth/2),0>h.sy-h.sHeight/2&&(h.sy=h.sHeight/2),h.sy+h.sHeight/2>u.height&&(h.sy=u.height-h.sHeight/2),h.width!==f&&h.height===f)?d.height=h.height=h.width/s:h.width===f&&h.height!==
f?d.width=h.width=h.height*s:h.width===f&&h.height===f&&(d.width=h.width=u.width,d.height=h.height=u.height));E(t,k,h,h.width,h.height);k.drawImage(u,h.sx-h.sWidth/2,h.sy-h.sHeight/2,h.sWidth,h.sHeight,h.x-h.width/2,h.y-h.height/2,h.width,h.height);h._event?(k.beginPath(),k.rect(h.x-h.width/2,h.y-h.height/2,h.width,h.height),k.restore(),G(m[t],k,d),k.closePath()):k.restore();h.load&&h.load.call(l,d)}}var m=this,p,q,k,h=w(new x,d),u,o,s;o=h.source.getContext;h.source.src||o?(u=h.source,h.width=u.width,
h.height=u.height):h.source&&(u=new Z,u.src=h.source);for(q=0;q<m.length;q+=1)if(p=m[q],k=v(m[q]))D(m[q],d,t),F(k,h),u&&(u.complete||o?l(p,q,k)():u.onload=l(p,q,k));return m};d.fn.createPattern=d.fn.pattern=function(d){function j(){k=m.createPattern(q,p.repeat);p.load&&p.load.call(l[0],k)}var l=this,m,p=w(new x,d),q,k;(m=v(l[0]))?"function"===typeof p.source?(q=Q.createElement("canvas"),q.width=p.width,q.height=p.height,d=v(q),p.source.call(q,d),j()):(d=p.source.getContext,p.source.src||d?q=p.source:
(q=new Z,q.src=p.source),q.complete||d?j():q.onload=j):k=f;return k};d.fn.createGradient=d.fn.gradient=function(d){var j,d=w(new x,d),l=[],m,p,q,k,h,u,o;if(j=v(this[0])){d.x1=d.x1||0;d.y1=d.y1||0;d.x2=d.x2||0;d.y2=d.y2||0;j=d.r1!==f||d.r2!==f?j.createRadialGradient(d.x1,d.y1,d.r1,d.x2,d.y2,d.r2):j.createLinearGradient(d.x1,d.y1,d.x2,d.y2);for(k=1;d["c"+k]!==s;k+=1)d["s"+k]!==s?l.push(d["s"+k]):l.push(f);m=l.length;l[0]===f&&(l[0]=0);l[m-1]===f&&(l[m-1]=1);for(k=0;k<m;k+=1){if(l[k]!==f){u=1;o=0;p=
l[k];for(h=k+1;h<m;h+=1)if(l[h]!==f){q=l[h];break}else u+=1;p>q&&(l[h]=l[k])}else l[k]===f&&(o+=1,l[k]=p+o*((q-p)/u));j.addColorStop(l[k],d["c"+(k+1)])}}else j=f;return j};d.fn.setPixels=function j(d){var f,p,q,k=w(new x,d),h={},u,o,s,z;for(p=0;p<this.length;p+=1)if(f=this[p],q=v(f)){D(this[p],d,j);E(p,q,k,k.width,k.height);if(!k.x||!k.y||!k.width||!k.height)k.width=f.width,k.height=f.height,k.x=k.width/2,k.y=k.height/2;u=q.getImageData(k.x-k.width/2,k.y-k.height/2,k.width,k.height);o=u.data;z=o.length;
h=[];if(k.each)for(s=0;s<z;s+=4)h.r=o[s],h.g=o[s+1],h.b=o[s+2],h.a=o[s+3],k.each.call(f,h),o[s]=h.r,o[s+1]=h.g,o[s+2]=h.b,o[s+3]=h.a;q.putImageData(u,k.x-k.width/2,k.y-k.height/2);q.restore()}return this};d.fn.getCanvasImage=function(d,l){var m=this[0];return m&&m.toDataURL?m.toDataURL("image/"+d,l):f};d.support.canvas=Q.createElement("canvas").getContext!==s;A.defaults=M;d.jCanvas=A})(jQuery,document,Image,Math,parseFloat,!0,!1,null);