|\/|\?]/g.test(t)}function g(t){if(!n.a.str(t))return[];var e,r=[],i=t.length,o="";for(e=0;eh&&(a=h/2),t.save(),t.translate(e,r),o.drawRoundRectPath(t,n,i,a),t.fillStyle=c,t.fill(),t.lineWidth=u,t.strokeStyle=s,t.stroke(),t.restore()}},a=Object(n.b)(!0,i,o);function c(t,e){var r=Object(n.e)(t),i=r.iw,o=r.ih,c=Object(n.b)(!0,{x:0,y:0,width:"100%",height:"100%",radius:0},e),u=c.width,s=c.height,h=c.x,f=c.y,d=c.radius;(u=Object(n.d)(i,u))>i&&(u=i),(s=Object(n.d)(o,s))>o&&(s=o),h=Object(n.k)(i,u,h,"pos"),f=Object(n.k)(o,s,f,"pos"),d=Object(n.d)(i,d);var l=a.create(u,s),p=l[0],g=l[1];return p.width=u,p.height=s,a.drawRoundRect(g,0,0,u,s,d),g.globalCompositeOperation="source-in",g.drawImage(t,-h,-f,i,o),{cvs:p,ctx:g}}var u=function(){function t(t){void 0===t&&(t={}),this.queue=[],this.fn={success:function(){},error:function(t){}},this.data={textId:0,text:{},bgConfig:null},this._defaultFontFamily="helvetica neue,hiragino sans gb,Microsoft YaHei,arial,tahoma,sans-serif",this.ops=Object(n.b)({width:500,height:500,backgroundColor:""},t),this._init()}return t.prototype._init=function(){var t,e=this.ops,r=e.width,n=e.height,i=e.backgroundColor;t=a.create(r,n),this.cvs=t[0],this.ctx=t[1],i&&this._setBgColor(i)},t.prototype.background=function(t,e){var r=this;return void 0===e&&(e={type:"origin"}),t||this.data.bgConfig?(t?(e.image=t,this.data.bgConfig=e):this.data.bgConfig&&(e=this.data.bgConfig),this.queue.push((function(){e.color&&r._setBgColor(e.color),a.getImage(e.image).then((function(t){return r._background(t,e)})).catch(r.fn.error)})),this):(Object(n.i)("the init background must has a image."),this)},t.prototype._setBgColor=function(t){this.ctx.fillStyle=t,this.ctx.fillRect(0,0,this.cvs.width,this.cvs.height)},t.prototype._getBgAlign=function(t,e,r,i){var o;return n.g.str(t)?"50%"===t||"center"===t?o=Math.abs((e-r/i)/2):"100%"===t?o=Math.abs(e-r/i):"0%"===t&&(o=0):o=n.g.num(t)?t:0,o},t.prototype._background=function(t,e){var r,i,o,a,c,u,s,h,f,d=Object(n.e)(t),l=d.iw,p=d.ih,g=l/p,v=this.cvs.width/this.cvs.height;switch(e.type){case"crop":g>v?(o=p*v,a=p,f=this.cvs.height/p):(a=(o=l)/v,f=this.cvs.width/l),r=this._getBgAlign(e.left,l,this.cvs.width,f),i=this._getBgAlign(e.top,p,this.cvs.height,f),u=c=0,h=this.cvs.height,s=this.cvs.width;break;case"contain":i=r=0,o=l,a=p,g>v?(h=(s=this.cvs.width)/g,c=e.left||0,u=e.top||0===e.top?e.top:(this.cvs.height-h)/2):(s=(h=this.cvs.height)*g,u=e.top||0,c=e.left||0===e.left?e.left:(this.cvs.width-s)/2);break;case"origin":this.cvs.width=l,this.cvs.height=p,r=i=0,o=l,a=p,c=u=0,s=this.cvs.width,h=this.cvs.height;break;default:return void Object(n.i)("background type error!")}this.ctx.drawImage(t,r,i,o,a,c,u,s,h),this._next()},t.prototype.rect=function(t){var e=this;return void 0===t&&(t={}),this.queue.push((function(){var r=e.cvs,i=r.width,o=r.height,c=t.fillColor,u=void 0===c?"#fff":c,s=t.strokeColor,h=void 0===s?u:s,f=t.strokeWidth,d=void 0===f?0:f,l=t.radius,p=void 0===l?0:l,g=t.width,v=void 0===g?100:g,y=t.height,b=void 0===y?100:y,x=t.x,m=void 0===x?0:x,w=t.y,j=void 0===w?0:w;v=Object(n.k)(i,0,v,"pos")-2*d,b=Object(n.k)(o,0,b,"pos")-2*d,m=Object(n.k)(i,v,m,"pos")+(Object(n.f)(m,"right")?-d:d),j=Object(n.k)(o,b,j,"pos")+(Object(n.f)(j,"bottom")?-d:d),a.drawRoundRect(e.ctx,m,j,v,b,p,u,d,h),e._resetCtx()._next()})),this},t.prototype.circle=function(t){var e=this;return void 0===t&&(t={}),this.queue.push((function(){var r=t.fillColor,i=void 0===r?"#fff":r,o=t.strokeColor,a=void 0===o?i:o,c=t.strokeWidth,u=void 0===c?0:c,s=e.cvs,h=s.width,f=s.height,d=t.x,l=void 0===d?0:d,p=t.y,g=void 0===p?0:p,v=t.radius,y=void 0===v?100:v,b=Object(n.k)(h,0,y,"pos")-2*u;l=Object(n.k)(h,2*b,l,"pos")+b+(Object(n.f)(l,"right")?-u:u),g=Object(n.k)(f,2*b,g,"pos")+b+(Object(n.f)(g,"bottom")?-u:u),e.ctx.beginPath(),e.ctx.arc(l,g,b,0,2*Math.PI,!1),e.ctx.fillStyle=i,e.ctx.fill(),e.ctx.strokeStyle=a,e.ctx.lineWidth=u,e.ctx.stroke(),e.ctx.closePath(),e._resetCtx()._next()})),this},t.prototype._resetCtx=function(){return this.ctx.setTransform(1,0,0,1,0,0),this},t.prototype.watermark=function(t,e){if(void 0===e&&(e={}),!t)return Object(n.i)("there is not image of watermark."),this;var r=e.width,i=void 0===r?"40%":r,o=e.pos,a=void 0===o?"rightbottom":o,c=e.margin,u=void 0===c?20:c,s={x:0,y:0,scale:1,rotate:0};switch(a){case"leftTop":s.x="left:"+u,s.y="top:"+u;break;case"leftBottom":s.x="left:"+u,s.y="bottom:"+u;break;case"rightTop":s.x="right:"+u,s.y="top:"+u;break;case"rightBottom":s.x="right:"+u,s.y="bottom:"+u}return this.add(t,{width:i,pos:s}),this},t.prototype.add=function(t,e){var r=this,i={width:"100%",crop:{x:0,y:0,width:"100%",height:"100%",radius:0},pos:{x:0,y:0,scale:1,rotate:0}};return(n.g.arr(t)?t:[{image:t,options:e}]).map((function(t){var e=t.image,o=t.options;r.queue.push((function(){a.getImage(e).then((function(t){r._add(t,r._handleOps(t,Object(n.b)(!0,i,o)))})).catch(r.fn.error)}))})),this},t.prototype._add=function(t,e){var r,i=e.crop,o=e.pos,u=e.width;0===u&&Object(n.j)("the width of mc-element is zero");var s,h,f,d,l=Object(n.e)(t),p=l.iw,g=l.ih,v=i.width,y=i.height,b=i.radius;(v!==p||y!==g||b>0)&&(t=c(t,i).cvs);var x,m,w,j,_,O,k=v/y,I=p>g?p/g:g/p,C=1.4*I>5?5:1.4*I,M=a.create(Math.round(v*C),Math.round(y*C)),S=M[0],P=M[1],q=Object(n.a)()&&(S.width>2096||S.height>2096)?2096:4096,T=k>1?q/S.width:q/S.height;x=-Math.round(v/2),m=-Math.round(y/2),w=v,j=Math.round(v/k),(S.width>q||S.height>q)&&T&&(r=[S.width,S.height,x,m,w,j].map((function(t){return Math.round(t*T)})),S.width=r[0],S.height=r[1],x=r[2],m=r[3],w=r[4],j=r[5]),P.translate(S.width/2,S.height/2),P.rotate(o.rotate),P.drawImage(t,x,m,w,j),f=Math.round(u*C),d=Math.round(f/k),O=(_=(C-1)*u/2)/k,s=Math.round(o.x+f*(1-o.scale)/2-_),h=Math.round(o.y+d*(1-o.scale)/2-O),f*=o.scale,d*=o.scale,this.ctx.drawImage(S,s,h,f,d),this._next()},t.prototype._getRotate=function(t){return n.g.str(t)?parseFloat(t)*Math.PI/180:n.g.num(t)?t*Math.PI/180:0},t.prototype._handleOps=function(t,e){var r,i,o=this.cvs,a=o.width,c=o.height,u=Object(n.e)(t),s=u.iw,h=u.ih,f=s/h,d=Object(n.k)(a,s,e.width,"pos"),l=Object(n.k)(a,s,e.crop.width,"crop"),p=Object(n.k)(c,h,e.crop.height,"crop"),g={width:l,height:p,x:Object(n.k)(s,l,e.crop.x,"crop"),y:Object(n.k)(h,p,e.crop.y,"crop"),radius:Object(n.d)(l,e.crop.radius)};g.x>s&&(g.x=s),g.y>h&&(g.y=h),r=s-g.x,i=h-g.y,g.width>r&&(g.width=r),g.height>i&&(g.height=i);var v=e.pos,y=v.x,b=v.y,x=v.rotate,m=v.scale,w=void 0===m?1:m;return{width:d,crop:g,pos:{x:Object(n.k)(a,d,y,"pos"),y:Object(n.k)(c,d/f,b,"pos"),scale:w,rotate:this._getRotate(x)}}},t.prototype._createStyle=function(t,e){return{font:t+"px "+this._defaultFontFamily,lineHeight:e,color:"#000",type:"fill",lineWidth:1,wordBreak:!0,shadow:{color:null,blur:0,offsetX:0,offsetY:0}}},t.prototype.text=function(t,e){var r=this;void 0===e&&(e={});var i=this.cvs.width/20;return this.queue.push((function(){var o,a=Object(n.b)(!0,{width:300,align:"left",smallStyle:r._createStyle(.8*i,.9*i),normalStyle:r._createStyle(i,1.1*i),largeStyle:r._createStyle(1.3*i,1.4*i),pos:{x:0,y:0,rotate:0}},e),c=r._parse(String(t)),u=0;c.map((function(t){t.size>u&&(u=t.size,o=t.type)}));var s=parseInt(a[o+"Style"].font);s&&a.width|/),r=[],n=0;n|<\/b>/.test(i)){var o=/<\/s>/.test(i)?"":"",a=/<\/s>/.test(i)?"small":"large",c=e[n].split(o);r.push({type:a,text:c[0],size:"small"===a?0:2}),c[1]&&r.push({type:"normal",text:c[1],size:1})}else e[n]&&r.push({text:e[n],type:"normal",size:1})}return r},t.prototype._text=function(t,e){var r=this;this.data.textId++,this.data.text[this.data.textId]={};var i,o=e.width=Object(n.k)(this.cvs.width,0,e.width,"pos"),c=1,u=0,s=this._getLineHeight(t,e),h=Object(n.k)(this.cvs.width,o,0,"pos"),f=Object(n.k)(this.cvs.height,0,0,"pos")+s;this.data.text[this.data.textId][c]={data:[],lineWidth:0},t.map((function(t){i=e[t.type+"Style"],r.ctx.font=i.font;var a=r.ctx.measureText(t.text).width,d=t.text.replace(/
/g,"|");if(u+a>o||Object(n.f)(d,"|")){i.wordBreak||(d=Object(n.h)(d));for(var l=0,p=d.length;lo||"|"===g)||(h=u=0,f+=s,c+=1,r.data.text[r.data.textId][c]={data:[],lineWidth:0},"|"!==g))(v=r.data.text[r.data.textId][c]).data.push({context:g,x:h,y:f,style:i,width:a}),h+=a,v.lineWidth=u+=a}}else{var v;(v=r.data.text[r.data.textId][c]).data.push({context:d,x:h,y:f,style:i,width:a}),h+=a,v.lineWidth=u+=a}}));var d=a.create(o,this._getTextRectHeight(c)),l=d[0],p=d[1],g=l.height,v=l.width,y=Object(n.k)(this.cvs.width,v,e.pos.x,"pos"),b=Object(n.k)(this.cvs.height,g,e.pos.y,"pos");Object(n.c)(this.data.text[this.data.textId],(function(t,n){var i=0;n.lineWidthn&&(n=r)})),n},t.prototype._fillText=function(t,e){var r=e.context,i=e.x,o=e.y,a=e.style,c=a.align,u=a.lineWidth,s=a.shadow,h=a.font,f=a.gradient,d=a.lineHeight,l=s.color,p=s.blur,g=s.offsetX,v=s.offsetY;if(t.font=h,t.textAlign=c,t.textBaseline="alphabetic",t.lineWidth=u,t.shadowColor=l,t.shadowBlur=p,t.shadowOffsetX=g,t.shadowOffsetY=v,f){var y=f.type,b=f.colorStop,x=void 0,m=void 0,w=void 0,j=void 0;1===y?(x=i,m=o,w=i+e.width,j=o):(x=i,m=o-d,w=i,j=o);var _=t.createLinearGradient(x,m,w,j),O=b.length||0;Object(n.c)(b,(function(t,e){_.addColorStop(1/O*(+t+1),e)})),t[a.type+"Style"]=_}else t[a.type+"Style"]=a.color;t[a.type+"Text"](r,i,o),this._resetCtx()},t.prototype._getTextRectHeight=function(t){var e=this.data.text[this.data.textId][t].data[0];return e.y+e.style.lineHeight},t.prototype.draw=function(t){var e=this;return void 0===t&&(t={}),new Promise((function(r,i){var o={type:"jpeg",quality:.9,exportType:"base64",success:function(t){},error:function(t){}};n.g.fn(t)?o.success=t:"jpg"===(o=Object(n.b)(!0,o,t)).type&&(o.type="jpeg"),e.fn.error=function(t){o.error(t),i(t)},e.fn.success=function(){"canvas"===o.exportType?(o.success(e.cvs),r(e.cvs)):setTimeout((function(){var t=e.cvs.toDataURL("image/"+o.type,o.quality);o.success(t),r(t)}),0)},e._next()}))},t.prototype._next=function(){if(this.queue.length>0){this.ctx.save();var t=this.queue.shift();t&&t(),this.ctx.restore()}else this.fn.success()},t.prototype.clear=function(){return this.ctx.clearRect(0,0,this.cvs.width,this.cvs.height),this},t}();
2 | /*! *****************************************************************************
3 | Copyright (c) Microsoft Corporation.
4 |
5 | Permission to use, copy, modify, and/or distribute this software for any
6 | purpose with or without fee is hereby granted.
7 |
8 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
9 | REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
10 | AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
11 | INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
12 | LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
13 | OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
14 | PERFORMANCE OF THIS SOFTWARE.
15 | ***************************************************************************** */function s(t,e,r,n){return new(r||(r=Promise))((function(i,o){function a(t){try{u(n.next(t))}catch(t){o(t)}}function c(t){try{u(n.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(a,c)}u((n=n.apply(t,e||[])).next())}))}function h(t,e){var r,n,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,n=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0){var r=e.queue.shift();r&&(t=e.before(t),r(e._next,t),e.isFirst=!1)}else e.end(t),e.queue=[]};var r=t||{},n=r.before,i=void 0===n?function(t){return t}:n,o=r.after,a=void 0===o?function(t){return t}:o;this.before=i,this.after=a}return t.prototype.push=function(t){d.a.fn(t)&&this.queue.push(t)},t.prototype.perform=function(t,e){this.end=t,this._next(e)},t}();!function(){function t(){this._queue=new l}t.prototype.line=function(t){var e=this;return this._queue.push((function(r,n){setTimeout((function(){return s(e,void 0,void 0,(function(){var e;return h(this,(function(i){return e=t(n),d.a.promise(e)?e.then(r):r(e),[2]}))}))}),0)})),this},t.prototype.start=function(t,e){this._queue.perform(t,e)}}();function p(t){return(p="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var g=[512,512,456,512,328,456,335,512,405,328,271,456,388,335,292,512,454,405,364,328,298,271,496,456,420,388,360,335,312,292,273,512,482,454,428,405,383,364,345,328,312,298,284,271,259,496,475,456,437,420,404,388,374,360,347,335,323,312,302,292,282,273,265,512,497,482,468,454,441,428,417,405,394,383,373,364,354,345,337,328,320,312,305,298,291,284,278,271,265,259,507,496,485,475,465,456,446,437,428,420,412,404,396,388,381,374,367,360,354,347,341,335,329,323,318,312,307,302,297,292,287,282,278,273,269,265,261,512,505,497,489,482,475,468,461,454,447,441,435,428,422,417,411,405,399,394,389,383,378,373,368,364,359,354,350,345,341,337,332,328,324,320,316,312,309,305,301,298,294,291,287,284,281,278,274,271,268,265,262,259,257,507,501,496,491,485,480,475,470,465,460,456,451,446,442,437,433,428,424,420,416,412,408,404,400,396,392,388,385,381,377,374,370,367,363,360,357,354,350,347,344,341,338,335,332,329,326,323,320,318,315,312,310,307,304,302,299,297,294,292,289,287,285,282,280,278,275,273,271,269,267,265,263,261,259],v=[9,11,12,13,13,14,14,15,15,15,15,16,16,16,16,17,17,17,17,17,17,17,18,18,18,18,18,18,18,18,18,19,19,19,19,19,19,19,19,19,19,19,19,19,19,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24];function y(t,e,r,n,i){if("string"==typeof t&&(t=document.getElementById(t)),!t||"object"!==p(t)||!("getContext"in t))throw new TypeError("Expecting canvas with `getContext` method in processCanvasRGB(A) calls!");var o=t.getContext("2d");try{return o.getImageData(e,r,n,i)}catch(t){throw new Error("unable to access image data: "+t)}}function b(t,e,r,n,i,o){if(!(isNaN(o)||o<1)){o|=0;var a=y(t,e,r,n,i);a=function(t,e,r,n,i,o){var a,c,u,s,h,f,d,l,p,y,b,m,w,j,_,O,k,I,C,M,S,P,q,T,R,D=t.data,N=2*o+1,W=n-1,B=i-1,A=o+1,E=A*(A+1)/2,H=new x,F=H;for(u=1;u>Y,0!==q?(q=255/q,D[f]=(l*G>>Y)*q,D[f+1]=(p*G>>Y)*q,D[f+2]=(y*G>>Y)*q):D[f]=D[f+1]=D[f+2]=0,l-=m,p-=w,y-=j,b-=_,m-=z.r,w-=z.g,j-=z.b,_-=z.a,s=d+((s=a+o+1)>Y,q>0?(q=255/q,D[s]=(l*G>>Y)*q,D[s+1]=(p*G>>Y)*q,D[s+2]=(y*G>>Y)*q):D[s]=D[s+1]=D[s+2]=0,l-=m,p-=w,y-=j,b-=_,m-=z.r,w-=z.g,j-=z.b,_-=z.a,s=a+((s=c+A)b&&(c=b),n=0;n<_;n++){for((o=(i=n*e)+e)>y&&(o=y),l=p=g=v=0,d=(o-i)*(c-a),s=a;s=j))for(o=n*w,f=-e;f<=e;f++)(i=c+f)<0||i>=w||(d=O[a=o+i<<2],v=(l=O[a+1])*r>>8,y=(p=O[a+2])*r>>8,P[g=d*r>>8]+=d,q[v]+=l,T[y]+=p,C[g]+=1,M[v]+=1,S[y]+=1);for(b=x=m=0,s=1;sC[b]&&(b=s),M[s]>M[x]&&(x=s),S[s]>S[m]&&(m=s);I[R]=P[b]/C[b]|0,I[R+1]=q[x]/M[x]|0,I[R+2]=T[m]/S[m]|0,I[R+3]=O[R+3],R+=4}return _.putImageData(k,0,0),[t,_]}var k=function(){function t(t){this._image=t,this._queue=new l,this.clear()}return t.prototype.clear=function(){return this._getImage()._drawCanvas(),this},t.prototype._drawCanvas=function(){return this._run((function(t){var e=Object(n.e)(t),r=e.iw,i=e.ih,o=a.create(r,i),c=o[0],u=o[1];return u.drawImage(t,0,0,r,i),{cvs:c,ctx:u}}))},t.prototype._getImage=function(){var t=this;return this._run((function(){return new Promise((function(e){return s(t,void 0,void 0,(function(){var t=this;return h(this,(function(r){return n.g.str(this._image)?a.getImage(this._image).then((function(r){return e(t._image=r)})).catch(this._error):e(this._image),[2]}))}))}))}))},t.prototype._run=function(t){var e=this;return this._queue.push((function(r,i){setTimeout((function(){return s(e,void 0,void 0,(function(){var e;return h(this,(function(o){return e=t(i),n.g.promise(e)?e.then(r):r(e),[2]}))}))}),0)})),this},t.prototype.draw=function(t){var e=this;return void 0===t&&(t={}),new Promise((function(r,i){var o={type:"jpeg",quality:1,exportType:"base64",success:function(t){},error:function(t){}};n.g.fn(t)?o.success=t:"jpg"===(o=Object(n.b)(!0,o,t)).type&&(o.type="jpeg");var a=o.exportType,c=o.type,u=o.quality,s=o.success,h=o.error,f=function(t){s(t),r(t),e.clear()};e._error=function(t){h(t),i(t)},e._queue.perform((function(t){var e=t.cvs,r=t.quality;"canvas"===a?f(e):setTimeout((function(){var t=e.toDataURL("image/"+c,r||u);f(t)}),0)}))}))},t.prototype.crop=function(t){return void 0===t&&(t={}),this._run((function(e){return c(e.cvs,t)}))},t.prototype.compress=function(t){return void 0===t&&(t={}),this._run((function(e){var r=e.cvs,i=e.ctx,o=t.quality,c=t.width,u=t.height,s=r.width/r.height;if(!n.g.num(c)&&!n.g.num(u))return{cvs:r,ctx:i,quality:o};n.g.num(c)||(c=u*s),n.g.num(u)||(u=c/s);var h=a.create(c,u),f=h[0],d=h[1];return d.drawImage(r,0,0,c,u),{cvs:f,ctx:d,quality:o}}))},t.prototype.filter=function(t){for(var e=[],r=1;r .window {
213 | display: inline-block;
214 | position: absolute;
215 | padding: 20px 50px;
216 | left: 50%;
217 | top: 50%;
218 | transform: translate(-50%, -50%);
219 | -webkit-transform: translate(-50%, -50%);
220 | background: white;
221 | max-width: 400px;
222 | text-align: center;
223 | width: 70%;
224 | border-radius: 5px; }
225 |
226 | .window > .Button {
227 | width: 40%;
228 | min-width: 40px; }
229 |
230 | .params {
231 | text-align: left;
232 | margin: 20px 0;
233 | font-size: 20px;
234 | line-height: 34px; }
235 | .params li {
236 | position: relative;
237 | white-space: nowrap; }
238 | .params .input {
239 | position: absolute;
240 | border: 2px solid #eee;
241 | border-radius: 5px;
242 | right: 60px;
243 | width: 100px;
244 | height: 70%;
245 | box-sizing: border-box;
246 | padding: 12px;
247 | text-align: center;
248 | font-size: 16px; }
249 | .params .input.focus {
250 | border: 2px solid #FF9999; }
251 | .params .select {
252 | position: absolute;
253 | right: 60px;
254 | border-radius: 5px;
255 | padding: 5px 20px;
256 | box-sizing: border-box;
257 | background: white;
258 | border: 2px solid #eee;
259 | font-size: 16px; }
260 |
261 | .right__crop {
262 | text-align: left; }
263 | .right__crop__title {
264 | font-size: 26px;
265 | color: #8566aa;
266 | margin-bottom: 20px; }
267 | .right__crop__img {
268 | vertical-align: middle;
269 | display: inline-block;
270 | width: 200px;
271 | height: 200px;
272 | margin-right: 30px;
273 | border: 2px solid #8566aa;
274 | border-radius: 5px;
275 | background-size: contain;
276 | background-position: center;
277 | background-repeat: no-repeat;
278 | background-image: url("http://mtapplet.meitudata.com/596c72073971d86b5128.jpg"); }
279 |
280 | .right__filter {
281 | text-align: left;
282 | width: 80%; }
283 | .right__filter__title {
284 | font-size: 26px;
285 | color: #8566aa;
286 | margin-bottom: 20px;
287 | margin-top: 40px; }
288 | .right__filter__list {
289 | white-space: nowrap;
290 | overflow-x: scroll; }
291 | .right__filter__btn {
292 | display: inline-block;
293 | font-size: 20px;
294 | line-height: 40px;
295 | color: #8566aa;
296 | text-align: center;
297 | padding: 0 20px;
298 | border-radius: 5px;
299 | border: 2px solid #8566aa;
300 | margin-top: 10px;
301 | cursor: pointer; }
302 | .right__filter__btn:hover {
303 | color: white;
304 | background-color: #8566aa; }
305 | .right__filter__img {
306 | text-align: center;
307 | display: inline-block;
308 | width: 250px;
309 | height: 360px;
310 | border: 2px solid #8566aa;
311 | border-radius: 5px;
312 | background-size: 90% auto;
313 | background-position: center bottom;
314 | background-repeat: no-repeat;
315 | background-image: url("http://mtapplet.meitudata.com/596c72073971d86b5128.jpg");
316 | margin: 0 20px 0 0; }
317 |
318 |
--------------------------------------------------------------------------------
/example/dist/images/1.7a9a8328.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xd-tayde/mcanvas/ce4108309c070aa2183d32fb918851c089e0f93e/example/dist/images/1.7a9a8328.jpg
--------------------------------------------------------------------------------
/example/dist/images/3.f15f13f2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xd-tayde/mcanvas/ce4108309c070aa2183d32fb918851c089e0f93e/example/dist/images/3.f15f13f2.jpg
--------------------------------------------------------------------------------
/example/dist/images/ear.c5b725cb.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xd-tayde/mcanvas/ce4108309c070aa2183d32fb918851c089e0f93e/example/dist/images/ear.c5b725cb.png
--------------------------------------------------------------------------------
/example/dist/images/watermark.c925393e.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xd-tayde/mcanvas/ce4108309c070aa2183d32fb918851c089e0f93e/example/dist/images/watermark.c925393e.jpg
--------------------------------------------------------------------------------
/example/dist/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | MCanvas
8 |
35 |
36 |
37 | MCanvas
38 | mcanvas is a image handler plugin that can easily merge, crop, compress,
filter the image and export a image of base64 finally. DOCS
39 |
40 |
MERGE IMAGE:
41 |
42 |

43 |
44 |
45 | Add Image
46 | Watermark
47 | Add Text
48 | Add Rect
49 | Add Circle
50 | Reset
51 |
52 |
53 |
54 |
55 |
CROP IMAGE:
56 |
57 |
Crop Image
58 |
59 |
60 |
FILTER IMAGE:
61 |
62 |
65 |
68 |
71 |
74 |
77 |
78 |
79 |
80 |
83 |
84 |
85 |
Params:
86 |
87 |
Cancel
88 |
OK
89 |
90 |
91 |
92 |
93 |
94 |
95 |
--------------------------------------------------------------------------------
/example/dist/zepto.min.js:
--------------------------------------------------------------------------------
1 | /* Zepto v1.2.0 - zepto event ajax form ie - zeptojs.com/license */
2 | !function(t,e){"function"==typeof define&&define.amd?define(function(){return e(t)}):e(t)}(this,function(t){var e=function(){function $(t){return null==t?String(t):S[C.call(t)]||"object"}function F(t){return"function"==$(t)}function k(t){return null!=t&&t==t.window}function M(t){return null!=t&&t.nodeType==t.DOCUMENT_NODE}function R(t){return"object"==$(t)}function Z(t){return R(t)&&!k(t)&&Object.getPrototypeOf(t)==Object.prototype}function z(t){var e=!!t&&"length"in t&&t.length,n=r.type(t);return"function"!=n&&!k(t)&&("array"==n||0===e||"number"==typeof e&&e>0&&e-1 in t)}function q(t){return a.call(t,function(t){return null!=t})}function H(t){return t.length>0?r.fn.concat.apply([],t):t}function I(t){return t.replace(/::/g,"/").replace(/([A-Z]+)([A-Z][a-z])/g,"$1_$2").replace(/([a-z\d])([A-Z])/g,"$1_$2").replace(/_/g,"-").toLowerCase()}function V(t){return t in l?l[t]:l[t]=new RegExp("(^|\\s)"+t+"(\\s|$)")}function _(t,e){return"number"!=typeof e||h[I(t)]?e:e+"px"}function B(t){var e,n;return c[t]||(e=f.createElement(t),f.body.appendChild(e),n=getComputedStyle(e,"").getPropertyValue("display"),e.parentNode.removeChild(e),"none"==n&&(n="block"),c[t]=n),c[t]}function U(t){return"children"in t?u.call(t.children):r.map(t.childNodes,function(t){return 1==t.nodeType?t:void 0})}function X(t,e){var n,r=t?t.length:0;for(n=0;r>n;n++)this[n]=t[n];this.length=r,this.selector=e||""}function J(t,r,i){for(n in r)i&&(Z(r[n])||L(r[n]))?(Z(r[n])&&!Z(t[n])&&(t[n]={}),L(r[n])&&!L(t[n])&&(t[n]=[]),J(t[n],r[n],i)):r[n]!==e&&(t[n]=r[n])}function W(t,e){return null==e?r(t):r(t).filter(e)}function Y(t,e,n,r){return F(e)?e.call(t,n,r):e}function G(t,e,n){null==n?t.removeAttribute(e):t.setAttribute(e,n)}function K(t,n){var r=t.className||"",i=r&&r.baseVal!==e;return n===e?i?r.baseVal:r:void(i?r.baseVal=n:t.className=n)}function Q(t){try{return t?"true"==t||("false"==t?!1:"null"==t?null:+t+""==t?+t:/^[\[\{]/.test(t)?r.parseJSON(t):t):t}catch(e){return t}}function tt(t,e){e(t);for(var n=0,r=t.childNodes.length;r>n;n++)tt(t.childNodes[n],e)}var e,n,r,i,O,P,o=[],s=o.concat,a=o.filter,u=o.slice,f=t.document,c={},l={},h={"column-count":1,columns:1,"font-weight":1,"line-height":1,opacity:1,"z-index":1,zoom:1},p=/^\s*<(\w+|!)[^>]*>/,d=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,m=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,g=/^(?:body|html)$/i,v=/([A-Z])/g,y=["val","css","html","text","data","width","height","offset"],x=["after","prepend","before","append"],b=f.createElement("table"),E=f.createElement("tr"),j={tr:f.createElement("tbody"),tbody:b,thead:b,tfoot:b,td:E,th:E,"*":f.createElement("div")},w=/complete|loaded|interactive/,T=/^[\w-]*$/,S={},C=S.toString,N={},A=f.createElement("div"),D={tabindex:"tabIndex",readonly:"readOnly","for":"htmlFor","class":"className",maxlength:"maxLength",cellspacing:"cellSpacing",cellpadding:"cellPadding",rowspan:"rowSpan",colspan:"colSpan",usemap:"useMap",frameborder:"frameBorder",contenteditable:"contentEditable"},L=Array.isArray||function(t){return t instanceof Array};return N.matches=function(t,e){if(!e||!t||1!==t.nodeType)return!1;var n=t.matches||t.webkitMatchesSelector||t.mozMatchesSelector||t.oMatchesSelector||t.matchesSelector;if(n)return n.call(t,e);var r,i=t.parentNode,o=!i;return o&&(i=A).appendChild(t),r=~N.qsa(i,e).indexOf(t),o&&A.removeChild(t),r},O=function(t){return t.replace(/-+(.)?/g,function(t,e){return e?e.toUpperCase():""})},P=function(t){return a.call(t,function(e,n){return t.indexOf(e)==n})},N.fragment=function(t,n,i){var o,s,a;return d.test(t)&&(o=r(f.createElement(RegExp.$1))),o||(t.replace&&(t=t.replace(m,"<$1>$2>")),n===e&&(n=p.test(t)&&RegExp.$1),n in j||(n="*"),a=j[n],a.innerHTML=""+t,o=r.each(u.call(a.childNodes),function(){a.removeChild(this)})),Z(i)&&(s=r(o),r.each(i,function(t,e){y.indexOf(t)>-1?s[t](e):s.attr(t,e)})),o},N.Z=function(t,e){return new X(t,e)},N.isZ=function(t){return t instanceof N.Z},N.init=function(t,n){var i;if(!t)return N.Z();if("string"==typeof t)if(t=t.trim(),"<"==t[0]&&p.test(t))i=N.fragment(t,RegExp.$1,n),t=null;else{if(n!==e)return r(n).find(t);i=N.qsa(f,t)}else{if(F(t))return r(f).ready(t);if(N.isZ(t))return t;if(L(t))i=q(t);else if(R(t))i=[t],t=null;else if(p.test(t))i=N.fragment(t.trim(),RegExp.$1,n),t=null;else{if(n!==e)return r(n).find(t);i=N.qsa(f,t)}}return N.Z(i,t)},r=function(t,e){return N.init(t,e)},r.extend=function(t){var e,n=u.call(arguments,1);return"boolean"==typeof t&&(e=t,t=n.shift()),n.forEach(function(n){J(t,n,e)}),t},N.qsa=function(t,e){var n,r="#"==e[0],i=!r&&"."==e[0],o=r||i?e.slice(1):e,s=T.test(o);return t.getElementById&&s&&r?(n=t.getElementById(o))?[n]:[]:1!==t.nodeType&&9!==t.nodeType&&11!==t.nodeType?[]:u.call(s&&!r&&t.getElementsByClassName?i?t.getElementsByClassName(o):t.getElementsByTagName(e):t.querySelectorAll(e))},r.contains=f.documentElement.contains?function(t,e){return t!==e&&t.contains(e)}:function(t,e){for(;e&&(e=e.parentNode);)if(e===t)return!0;return!1},r.type=$,r.isFunction=F,r.isWindow=k,r.isArray=L,r.isPlainObject=Z,r.isEmptyObject=function(t){var e;for(e in t)return!1;return!0},r.isNumeric=function(t){var e=Number(t),n=typeof t;return null!=t&&"boolean"!=n&&("string"!=n||t.length)&&!isNaN(e)&&isFinite(e)||!1},r.inArray=function(t,e,n){return o.indexOf.call(e,t,n)},r.camelCase=O,r.trim=function(t){return null==t?"":String.prototype.trim.call(t)},r.uuid=0,r.support={},r.expr={},r.noop=function(){},r.map=function(t,e){var n,i,o,r=[];if(z(t))for(i=0;i=0?t:t+this.length]},toArray:function(){return this.get()},size:function(){return this.length},remove:function(){return this.each(function(){null!=this.parentNode&&this.parentNode.removeChild(this)})},each:function(t){return o.every.call(this,function(e,n){return t.call(e,n,e)!==!1}),this},filter:function(t){return F(t)?this.not(this.not(t)):r(a.call(this,function(e){return N.matches(e,t)}))},add:function(t,e){return r(P(this.concat(r(t,e))))},is:function(t){return this.length>0&&N.matches(this[0],t)},not:function(t){var n=[];if(F(t)&&t.call!==e)this.each(function(e){t.call(this,e)||n.push(this)});else{var i="string"==typeof t?this.filter(t):z(t)&&F(t.item)?u.call(t):r(t);this.forEach(function(t){i.indexOf(t)<0&&n.push(t)})}return r(n)},has:function(t){return this.filter(function(){return R(t)?r.contains(this,t):r(this).find(t).size()})},eq:function(t){return-1===t?this.slice(t):this.slice(t,+t+1)},first:function(){var t=this[0];return t&&!R(t)?t:r(t)},last:function(){var t=this[this.length-1];return t&&!R(t)?t:r(t)},find:function(t){var e,n=this;return e=t?"object"==typeof t?r(t).filter(function(){var t=this;return o.some.call(n,function(e){return r.contains(e,t)})}):1==this.length?r(N.qsa(this[0],t)):this.map(function(){return N.qsa(this,t)}):r()},closest:function(t,e){var n=[],i="object"==typeof t&&r(t);return this.each(function(r,o){for(;o&&!(i?i.indexOf(o)>=0:N.matches(o,t));)o=o!==e&&!M(o)&&o.parentNode;o&&n.indexOf(o)<0&&n.push(o)}),r(n)},parents:function(t){for(var e=[],n=this;n.length>0;)n=r.map(n,function(t){return(t=t.parentNode)&&!M(t)&&e.indexOf(t)<0?(e.push(t),t):void 0});return W(e,t)},parent:function(t){return W(P(this.pluck("parentNode")),t)},children:function(t){return W(this.map(function(){return U(this)}),t)},contents:function(){return this.map(function(){return this.contentDocument||u.call(this.childNodes)})},siblings:function(t){return W(this.map(function(t,e){return a.call(U(e.parentNode),function(t){return t!==e})}),t)},empty:function(){return this.each(function(){this.innerHTML=""})},pluck:function(t){return r.map(this,function(e){return e[t]})},show:function(){return this.each(function(){"none"==this.style.display&&(this.style.display=""),"none"==getComputedStyle(this,"").getPropertyValue("display")&&(this.style.display=B(this.nodeName))})},replaceWith:function(t){return this.before(t).remove()},wrap:function(t){var e=F(t);if(this[0]&&!e)var n=r(t).get(0),i=n.parentNode||this.length>1;return this.each(function(o){r(this).wrapAll(e?t.call(this,o):i?n.cloneNode(!0):n)})},wrapAll:function(t){if(this[0]){r(this[0]).before(t=r(t));for(var e;(e=t.children()).length;)t=e.first();r(t).append(this)}return this},wrapInner:function(t){var e=F(t);return this.each(function(n){var i=r(this),o=i.contents(),s=e?t.call(this,n):t;o.length?o.wrapAll(s):i.append(s)})},unwrap:function(){return this.parent().each(function(){r(this).replaceWith(r(this).children())}),this},clone:function(){return this.map(function(){return this.cloneNode(!0)})},hide:function(){return this.css("display","none")},toggle:function(t){return this.each(function(){var n=r(this);(t===e?"none"==n.css("display"):t)?n.show():n.hide()})},prev:function(t){return r(this.pluck("previousElementSibling")).filter(t||"*")},next:function(t){return r(this.pluck("nextElementSibling")).filter(t||"*")},html:function(t){return 0 in arguments?this.each(function(e){var n=this.innerHTML;r(this).empty().append(Y(this,t,e,n))}):0 in this?this[0].innerHTML:null},text:function(t){return 0 in arguments?this.each(function(e){var n=Y(this,t,e,this.textContent);this.textContent=null==n?"":""+n}):0 in this?this.pluck("textContent").join(""):null},attr:function(t,r){var i;return"string"!=typeof t||1 in arguments?this.each(function(e){if(1===this.nodeType)if(R(t))for(n in t)G(this,n,t[n]);else G(this,t,Y(this,r,e,this.getAttribute(t)))}):0 in this&&1==this[0].nodeType&&null!=(i=this[0].getAttribute(t))?i:e},removeAttr:function(t){return this.each(function(){1===this.nodeType&&t.split(" ").forEach(function(t){G(this,t)},this)})},prop:function(t,e){return t=D[t]||t,1 in arguments?this.each(function(n){this[t]=Y(this,e,n,this[t])}):this[0]&&this[0][t]},removeProp:function(t){return t=D[t]||t,this.each(function(){delete this[t]})},data:function(t,n){var r="data-"+t.replace(v,"-$1").toLowerCase(),i=1 in arguments?this.attr(r,n):this.attr(r);return null!==i?Q(i):e},val:function(t){return 0 in arguments?(null==t&&(t=""),this.each(function(e){this.value=Y(this,t,e,this.value)})):this[0]&&(this[0].multiple?r(this[0]).find("option").filter(function(){return this.selected}).pluck("value"):this[0].value)},offset:function(e){if(e)return this.each(function(t){var n=r(this),i=Y(this,e,t,n.offset()),o=n.offsetParent().offset(),s={top:i.top-o.top,left:i.left-o.left};"static"==n.css("position")&&(s.position="relative"),n.css(s)});if(!this.length)return null;if(f.documentElement!==this[0]&&!r.contains(f.documentElement,this[0]))return{top:0,left:0};var n=this[0].getBoundingClientRect();return{left:n.left+t.pageXOffset,top:n.top+t.pageYOffset,width:Math.round(n.width),height:Math.round(n.height)}},css:function(t,e){if(arguments.length<2){var i=this[0];if("string"==typeof t){if(!i)return;return i.style[O(t)]||getComputedStyle(i,"").getPropertyValue(t)}if(L(t)){if(!i)return;var o={},s=getComputedStyle(i,"");return r.each(t,function(t,e){o[e]=i.style[O(e)]||s.getPropertyValue(e)}),o}}var a="";if("string"==$(t))e||0===e?a=I(t)+":"+_(t,e):this.each(function(){this.style.removeProperty(I(t))});else for(n in t)t[n]||0===t[n]?a+=I(n)+":"+_(n,t[n])+";":this.each(function(){this.style.removeProperty(I(n))});return this.each(function(){this.style.cssText+=";"+a})},index:function(t){return t?this.indexOf(r(t)[0]):this.parent().children().indexOf(this[0])},hasClass:function(t){return t?o.some.call(this,function(t){return this.test(K(t))},V(t)):!1},addClass:function(t){return t?this.each(function(e){if("className"in this){i=[];var n=K(this),o=Y(this,t,e,n);o.split(/\s+/g).forEach(function(t){r(this).hasClass(t)||i.push(t)},this),i.length&&K(this,n+(n?" ":"")+i.join(" "))}}):this},removeClass:function(t){return this.each(function(n){if("className"in this){if(t===e)return K(this,"");i=K(this),Y(this,t,n,i).split(/\s+/g).forEach(function(t){i=i.replace(V(t)," ")}),K(this,i.trim())}})},toggleClass:function(t,n){return t?this.each(function(i){var o=r(this),s=Y(this,t,i,K(this));s.split(/\s+/g).forEach(function(t){(n===e?!o.hasClass(t):n)?o.addClass(t):o.removeClass(t)})}):this},scrollTop:function(t){if(this.length){var n="scrollTop"in this[0];return t===e?n?this[0].scrollTop:this[0].pageYOffset:this.each(n?function(){this.scrollTop=t}:function(){this.scrollTo(this.scrollX,t)})}},scrollLeft:function(t){if(this.length){var n="scrollLeft"in this[0];return t===e?n?this[0].scrollLeft:this[0].pageXOffset:this.each(n?function(){this.scrollLeft=t}:function(){this.scrollTo(t,this.scrollY)})}},position:function(){if(this.length){var t=this[0],e=this.offsetParent(),n=this.offset(),i=g.test(e[0].nodeName)?{top:0,left:0}:e.offset();return n.top-=parseFloat(r(t).css("margin-top"))||0,n.left-=parseFloat(r(t).css("margin-left"))||0,i.top+=parseFloat(r(e[0]).css("border-top-width"))||0,i.left+=parseFloat(r(e[0]).css("border-left-width"))||0,{top:n.top-i.top,left:n.left-i.left}}},offsetParent:function(){return this.map(function(){for(var t=this.offsetParent||f.body;t&&!g.test(t.nodeName)&&"static"==r(t).css("position");)t=t.offsetParent;return t})}},r.fn.detach=r.fn.remove,["width","height"].forEach(function(t){var n=t.replace(/./,function(t){return t[0].toUpperCase()});r.fn[t]=function(i){var o,s=this[0];return i===e?k(s)?s["inner"+n]:M(s)?s.documentElement["scroll"+n]:(o=this.offset())&&o[t]:this.each(function(e){s=r(this),s.css(t,Y(this,i,e,s[t]()))})}}),x.forEach(function(n,i){var o=i%2;r.fn[n]=function(){var n,a,s=r.map(arguments,function(t){var i=[];return n=$(t),"array"==n?(t.forEach(function(t){return t.nodeType!==e?i.push(t):r.zepto.isZ(t)?i=i.concat(t.get()):void(i=i.concat(N.fragment(t)))}),i):"object"==n||null==t?t:N.fragment(t)}),u=this.length>1;return s.length<1?this:this.each(function(e,n){a=o?n:n.parentNode,n=0==i?n.nextSibling:1==i?n.firstChild:2==i?n:null;var c=r.contains(f.documentElement,a);s.forEach(function(e){if(u)e=e.cloneNode(!0);else if(!a)return r(e).remove();a.insertBefore(e,n),c&&tt(e,function(e){if(!(null==e.nodeName||"SCRIPT"!==e.nodeName.toUpperCase()||e.type&&"text/javascript"!==e.type||e.src)){var n=e.ownerDocument?e.ownerDocument.defaultView:t;n.eval.call(n,e.innerHTML)}})})})},r.fn[o?n+"To":"insert"+(i?"Before":"After")]=function(t){return r(t)[n](this),this}}),N.Z.prototype=X.prototype=r.fn,N.uniq=P,N.deserializeValue=Q,r.zepto=N,r}();return t.Zepto=e,void 0===t.$&&(t.$=e),function(e){function h(t){return t._zid||(t._zid=n++)}function p(t,e,n,r){if(e=d(e),e.ns)var i=m(e.ns);return(a[h(t)]||[]).filter(function(t){return t&&(!e.e||t.e==e.e)&&(!e.ns||i.test(t.ns))&&(!n||h(t.fn)===h(n))&&(!r||t.sel==r)})}function d(t){var e=(""+t).split(".");return{e:e[0],ns:e.slice(1).sort().join(" ")}}function m(t){return new RegExp("(?:^| )"+t.replace(" "," .* ?")+"(?: |$)")}function g(t,e){return t.del&&!f&&t.e in c||!!e}function v(t){return l[t]||f&&c[t]||t}function y(t,n,i,o,s,u,f){var c=h(t),p=a[c]||(a[c]=[]);n.split(/\s/).forEach(function(n){if("ready"==n)return e(document).ready(i);var a=d(n);a.fn=i,a.sel=s,a.e in l&&(i=function(t){var n=t.relatedTarget;return!n||n!==this&&!e.contains(this,n)?a.fn.apply(this,arguments):void 0}),a.del=u;var c=u||i;a.proxy=function(e){if(e=T(e),!e.isImmediatePropagationStopped()){e.data=o;var n=c.apply(t,e._args==r?[e]:[e].concat(e._args));return n===!1&&(e.preventDefault(),e.stopPropagation()),n}},a.i=p.length,p.push(a),"addEventListener"in t&&t.addEventListener(v(a.e),a.proxy,g(a,f))})}function x(t,e,n,r,i){var o=h(t);(e||"").split(/\s/).forEach(function(e){p(t,e,n,r).forEach(function(e){delete a[o][e.i],"removeEventListener"in t&&t.removeEventListener(v(e.e),e.proxy,g(e,i))})})}function T(t,n){return(n||!t.isDefaultPrevented)&&(n||(n=t),e.each(w,function(e,r){var i=n[e];t[e]=function(){return this[r]=b,i&&i.apply(n,arguments)},t[r]=E}),t.timeStamp||(t.timeStamp=Date.now()),(n.defaultPrevented!==r?n.defaultPrevented:"returnValue"in n?n.returnValue===!1:n.getPreventDefault&&n.getPreventDefault())&&(t.isDefaultPrevented=b)),t}function S(t){var e,n={originalEvent:t};for(e in t)j.test(e)||t[e]===r||(n[e]=t[e]);return T(n,t)}var r,n=1,i=Array.prototype.slice,o=e.isFunction,s=function(t){return"string"==typeof t},a={},u={},f="onfocusin"in t,c={focus:"focusin",blur:"focusout"},l={mouseenter:"mouseover",mouseleave:"mouseout"};u.click=u.mousedown=u.mouseup=u.mousemove="MouseEvents",e.event={add:y,remove:x},e.proxy=function(t,n){var r=2 in arguments&&i.call(arguments,2);if(o(t)){var a=function(){return t.apply(n,r?r.concat(i.call(arguments)):arguments)};return a._zid=h(t),a}if(s(n))return r?(r.unshift(t[n],t),e.proxy.apply(null,r)):e.proxy(t[n],t);throw new TypeError("expected function")},e.fn.bind=function(t,e,n){return this.on(t,e,n)},e.fn.unbind=function(t,e){return this.off(t,e)},e.fn.one=function(t,e,n,r){return this.on(t,e,n,r,1)};var b=function(){return!0},E=function(){return!1},j=/^([A-Z]|returnValue$|layer[XY]$|webkitMovement[XY]$)/,w={preventDefault:"isDefaultPrevented",stopImmediatePropagation:"isImmediatePropagationStopped",stopPropagation:"isPropagationStopped"};e.fn.delegate=function(t,e,n){return this.on(e,t,n)},e.fn.undelegate=function(t,e,n){return this.off(e,t,n)},e.fn.live=function(t,n){return e(document.body).delegate(this.selector,t,n),this},e.fn.die=function(t,n){return e(document.body).undelegate(this.selector,t,n),this},e.fn.on=function(t,n,a,u,f){var c,l,h=this;return t&&!s(t)?(e.each(t,function(t,e){h.on(t,n,a,e,f)}),h):(s(n)||o(u)||u===!1||(u=a,a=n,n=r),(u===r||a===!1)&&(u=a,a=r),u===!1&&(u=E),h.each(function(r,o){f&&(c=function(t){return x(o,t.type,u),u.apply(this,arguments)}),n&&(l=function(t){var r,s=e(t.target).closest(n,o).get(0);return s&&s!==o?(r=e.extend(S(t),{currentTarget:s,liveFired:o}),(c||u).apply(s,[r].concat(i.call(arguments,1)))):void 0}),y(o,t,u,a,n,l||c)}))},e.fn.off=function(t,n,i){var a=this;return t&&!s(t)?(e.each(t,function(t,e){a.off(t,n,e)}),a):(s(n)||o(i)||i===!1||(i=n,n=r),i===!1&&(i=E),a.each(function(){x(this,t,i,n)}))},e.fn.trigger=function(t,n){return t=s(t)||e.isPlainObject(t)?e.Event(t):T(t),t._args=n,this.each(function(){t.type in c&&"function"==typeof this[t.type]?this[t.type]():"dispatchEvent"in this?this.dispatchEvent(t):e(this).triggerHandler(t,n)})},e.fn.triggerHandler=function(t,n){var r,i;return this.each(function(o,a){r=S(s(t)?e.Event(t):t),r._args=n,r.target=a,e.each(p(a,t.type||t),function(t,e){return i=e.proxy(r),r.isImmediatePropagationStopped()?!1:void 0})}),i},"focusin focusout focus blur load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select keydown keypress keyup error".split(" ").forEach(function(t){e.fn[t]=function(e){return 0 in arguments?this.bind(t,e):this.trigger(t)}}),e.Event=function(t,e){s(t)||(e=t,t=e.type);var n=document.createEvent(u[t]||"Events"),r=!0;if(e)for(var i in e)"bubbles"==i?r=!!e[i]:n[i]=e[i];return n.initEvent(t,r,!0),T(n)}}(e),function(e){function p(t,n,r){var i=e.Event(n);return e(t).trigger(i,r),!i.isDefaultPrevented()}function d(t,e,n,i){return t.global?p(e||r,n,i):void 0}function m(t){t.global&&0===e.active++&&d(t,null,"ajaxStart")}function g(t){t.global&&!--e.active&&d(t,null,"ajaxStop")}function v(t,e){var n=e.context;return e.beforeSend.call(n,t,e)===!1||d(e,n,"ajaxBeforeSend",[t,e])===!1?!1:void d(e,n,"ajaxSend",[t,e])}function y(t,e,n,r){var i=n.context,o="success";n.success.call(i,t,o,e),r&&r.resolveWith(i,[t,o,e]),d(n,i,"ajaxSuccess",[e,n,t]),b(o,e,n)}function x(t,e,n,r,i){var o=r.context;r.error.call(o,n,e,t),i&&i.rejectWith(o,[n,e,t]),d(r,o,"ajaxError",[n,r,t||e]),b(e,n,r)}function b(t,e,n){var r=n.context;n.complete.call(r,e,t),d(n,r,"ajaxComplete",[e,n]),g(n)}function E(t,e,n){if(n.dataFilter==j)return t;var r=n.context;return n.dataFilter.call(r,t,e)}function j(){}function w(t){return t&&(t=t.split(";",2)[0]),t&&(t==c?"html":t==f?"json":a.test(t)?"script":u.test(t)&&"xml")||"text"}function T(t,e){return""==e?t:(t+"&"+e).replace(/[&?]{1,2}/,"?")}function S(t){t.processData&&t.data&&"string"!=e.type(t.data)&&(t.data=e.param(t.data,t.traditional)),!t.data||t.type&&"GET"!=t.type.toUpperCase()&&"jsonp"!=t.dataType||(t.url=T(t.url,t.data),t.data=void 0)}function C(t,n,r,i){return e.isFunction(n)&&(i=r,r=n,n=void 0),e.isFunction(r)||(i=r,r=void 0),{url:t,data:n,success:r,dataType:i}}function O(t,n,r,i){var o,s=e.isArray(n),a=e.isPlainObject(n);e.each(n,function(n,u){o=e.type(u),i&&(n=r?i:i+"["+(a||"object"==o||"array"==o?n:"")+"]"),!i&&s?t.add(u.name,u.value):"array"==o||!r&&"object"==o?O(t,u,r,n):t.add(n,u)})}var i,o,n=+new Date,r=t.document,s=/
35 |
36 |
37 | MCanvas
38 | mcanvas is a image handler plugin that can easily merge, crop, compress,
filter the image and export a image of base64 finally. DOCS
39 |
40 |
MERGE IMAGE:
41 |
42 |

43 |
44 |
45 | Add Image
46 | Watermark
47 | Add Text
48 | Add Rect
49 | Add Circle
50 | Reset
51 |
52 |
53 |
54 |
55 |
CROP IMAGE:
56 |
57 |
Crop Image
58 |
59 |
60 |
FILTER IMAGE:
61 |
62 |
65 |
68 |
71 |
74 |
77 |
78 |
79 |
80 |
83 |
84 |
85 |
Params:
86 |
87 |
Cancel
88 |
OK
89 |
90 |
91 |
92 |
93 |
94 |