/* jQuery Canvas Plugin for WYSIWYG Web Builder v8.x
 * Copyright Pablo Software solutions 2011
 * http://www.wysiwygwebbuilder.com/ 
 */
(function(e){function g(b,a){b.shadowColor=a.shadowColor;b.shadowOffsetX=a.shadowOffsetX;b.shadowOffsetY=a.shadowOffsetY;b.shadowBlur=a.shadowBlur;b.fillStyle=a.fillStyle;b.fill();b.shadowColor="transparent";b.save();b.clip();b.strokeStyle=a.strokeStyle;b.lineWidth=a.lineWidth*2;b.stroke();b.restore()}function h(b,a,c){var b=e(b),d=b.get(0).getContext("2d");if(a.fillStyle=="pattern"){var i=new Image;i.onload=function(){a.fillStyle=d.createPattern(i,"repeat");c(d,a)};i.src=a.image}else{if(a.fillStyle==
"gradient"){if(a.gradientType=="linear")var b=[0,0,b.width(),b.height()],f=[[0,1,0,3],[2,3,0,1],[0,1,2,1],[0,3,2,1],[0,3,0,1],[0,1,2,3],[2,1,0,1],[2,1,0,3]],b=d.createLinearGradient(b[f[a.gradientMode][0]],b[f[a.gradientMode][1]],b[f[a.gradientMode][2]],b[f[a.gradientMode][3]]);else var f=b.width()/2,g=b.height()/2,f=Math.sqrt(f*f+g*g),b=d.createRadialGradient(b.width()/2,b.height()/2,f,b.width()/2,b.height()/2,0);for(f=0;f<a.gradientColorStops.length;f+=2)b.addColorStop(a.gradientColorStops[f],a.gradientColorStops[f+
1]);a.fillStyle=b}c(d,a)}}function j(b,a){var c=4*((Math.SQRT2-1)/3),d=a.width/2,e=a.height/2,f=d*c;c*=e;b.save();b.translate(a.x,a.y);b.beginPath();b.moveTo(d,0);b.bezierCurveTo(d+f,0,a.width,e-c,a.width,e);b.bezierCurveTo(a.width,e+c,d+f,a.height,d,a.height);b.bezierCurveTo(d-f,a.height,0,e+c,0,e);b.bezierCurveTo(0,e-c,d-f,0,d,0);b.closePath();b.restore();g(b,a)}function k(b,a){b.beginPath();b.moveTo(a.x+a.radius,a.y);b.lineTo(a.x+a.width-a.radius,a.y);a.radius!=0&&b.quadraticCurveTo(a.x+a.width,
a.y,a.x+a.width,a.y+a.radius);b.lineTo(a.x+a.width,a.y+a.height-a.radius);a.radius!=0&&b.quadraticCurveTo(a.x+a.width,a.y+a.height,a.x+a.width-a.radius,a.y+a.height);b.lineTo(a.x+a.radius,a.y+a.height);a.radius!=0&&b.quadraticCurveTo(a.x,a.y+a.height,a.x,a.y+a.height-a.radius);b.lineTo(a.x,a.y+a.radius);a.radius!=0&&b.quadraticCurveTo(a.x,a.y,a.x+a.radius,a.y);b.closePath();g(b,a)}function l(b,a){b.beginPath();var c=false;b.moveTo(a.points[0],a.points[1]);for(var d=2;d<a.points.length-1;d+=2)a.points[d]==
-1&&a.points[d+1]==-1?c=true:c?(b.closePath(),b.moveTo(a.points[d],a.points[d+1]),c=false):b.lineTo(a.points[d],a.points[d+1]);a.closePath&&b.closePath();g(b,a)}function m(b,a){b.beginPath();b.moveTo(a.points[0],a.points[1]);for(var c=2;c<a.points.length-1;c+=6)b.bezierCurveTo(a.points[c],a.points[c+1],a.points[c+2],a.points[c+3],a.points[c+4],a.points[c+5]);a.closePath&&b.closePath();g(b,a)}e.fn.DrawEllipse=function(b){return this.each(function(){e.DrawEllipse(this,b)})};e.fn.DrawRectangle=function(b){return this.each(function(){e.DrawRectangle(this,
b)})};e.fn.DrawPolygon=function(b){return this.each(function(){e.DrawPolygon(this,b)})};e.fn.DrawCurve=function(b){return this.each(function(){e.DrawCurve(this,b)})};e.fn.DrawLine=function(b){return this.each(function(){e.DrawLine(this,b)})};e.DrawEllipse=function(b,a){var c={x:0,y:0,width:10,height:10,fillStyle:"transparent",strokeStyle:"#000000",lineWidth:1,image:"",gradientColorStops:null,gradientMode:0,gradientType:"linear"};a&&(c=e.extend(c,a));h(b,c,j)};e.DrawRectangle=function(b,a){var c={x:0,
y:0,width:10,height:10,radius:0,fillStyle:"transparent",strokeStyle:"#000000",lineWidth:1,image:"",gradientColorStops:null,gradientMode:0,gradientType:"linear",shadowOffsetX:0,shadowOffsetY:0,shadowBlur:3,shadowColor:"transparent"};a&&(c=e.extend(c,a));h(b,c,k)};e.DrawPolygon=function(b,a){var c={points:null,closePath:true,fillStyle:"transparent",strokeStyle:"#000000",lineWidth:1,image:"",gradientColorStops:null,gradientMode:0,gradientType:"linear"};a&&(c=e.extend(c,a));h(b,c,l)};e.DrawCurve=function(b,
a){var c={points:null,closePath:true,fillStyle:"transparent",strokeStyle:"#000000",lineWidth:1,image:"",gradientColorStops:null,gradientMode:0,gradientType:"linear"};a&&(c=e.extend(c,a));h(b,c,m)};e.DrawLine=function(b,a){var c={points:null,strokeStyle:"#000000",lineWidth:1};a&&(c=e.extend(c,a));var d=e(b).get(0).getContext("2d");d.beginPath();d.moveTo(c.points[0],c.points[1]);d.lineTo(c.points[2],c.points[3]);d.closePath();d.strokeStyle=c.strokeStyle;d.lineWidth=c.lineWidth*2;d.stroke()}})(jQuery);
