Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Reverted to using old parameter-merging procedure for stability reasons

  • Loading branch information...
commit e360e4d9754e67cf55425897a54be67454664ef2 1 parent a557211
@caleb531 authored
Showing with 146 additions and 135 deletions.
  1. +145 −134 jcanvas.js
  2. +1 −1  jcanvas.min.js
View
279 jcanvas.js
@@ -14,7 +14,7 @@ var defaults, prefs,
PI = Math.PI,
sin = Math.sin,
cos = Math.cos,
- eventFix = $.event.fix,
+ oldEventFix = $.event.fix,
eventCache = {},
cssProps,
colorProps;
@@ -23,10 +23,10 @@ var defaults, prefs,
function Prefs() {}
// jCanvas function
-function jCanvas(params) {
- if (params) {
+function jCanvas(args) {
+ if (args) {
// Merge arguments with preferences
- merge(prefs, params);
+ merge(prefs, args);
} else {
// Reset to defaults if nothing is passed
prefs = Prefs.prototype = merge({}, defaults);
@@ -94,19 +94,7 @@ defaults = {
// Copy defaults over to preferences
jCanvas();
-// Merge preferences with arguments (much faster than $.extend)
-function mergePrefs(params) {
- var p;
- params = params || {};
- for (p in prefs) {
- if (prefs.hasOwnProperty(p) && params[p] === undefined) {
- params[p] = prefs[p];
- }
- }
- return params;
-}
-
-// Set global canvas properties
+// Set global properties
function setGlobals(ctx, params) {
// Fill/stroke styles
ctx.fillStyle = params.fillStyle;
@@ -155,7 +143,9 @@ createEvent('mousemove');
// Detect "mouseover" and "mouseout" events with one "hover" event
jCanvas.events.mouseover = jCanvas.events.mouseout = function($elem) {
- $elem.unbind('mousemove.jCanvasHover').bind('mousemove.jCanvasHover', function(event) {
+ $elem
+ .unbind('mousemove.jCanvasHover')
+ .bind('mousemove.jCanvasHover', function(event) {
eventCache.x[1] = eventCache.x[0];
eventCache.y[1] = eventCache.y[0];
eventCache.x[0] = event.offsetX;
@@ -174,34 +164,34 @@ function updateEventCache(params) {
}
// Check if event fires when a drawing is drawn
-function checkEvents(elem, ctx, layer) {
- var callback = layer[eventCache.type],
+function checkEvents(elem, ctx, params) {
+ var callback = params[eventCache.type],
over = ctx.isPointInPath(eventCache.x[0], eventCache.y[0]),
out = ctx.isPointInPath(eventCache.x[1], eventCache.y[1]);
// Detect mouseover events
- if (eventCache.type === 'hover' && over && !layer.hovered) {
- layer.hovered = TRUE;
- updateEventCache(layer);
- if (layer.mouseover) {
- layer.mouseover.call(elem, layer);
- setGlobals(ctx, layer);
+ if (eventCache.type === 'hover' && over && !params.fired) {
+ params.fired = TRUE;
+ updateEventCache(params);
+ if (params.mouseover) {
+ params.mouseover.call(elem, params);
+ setGlobals(ctx, params);
}
// Detect mouseout events
- } else if (eventCache.type === 'hover' && !over && out && layer.hovered) {
- layer.hovered = FALSE;
- updateEventCache(layer);
- if (layer.mouseout) {
- layer.mouseout.call(elem, layer);
- setGlobals(ctx, layer);
+ } else if (eventCache.type === 'hover' && !over && out && params.fired) {
+ params.fired = FALSE;
+ updateEventCache(params);
+ if (params.mouseout) {
+ params.mouseout.call(elem, params);
+ setGlobals(ctx, params);
}
// Detect other mouse events
} else if (eventCache.type !== 'hover' && callback && over) {
- updateEventCache(layer);
- callback.call(elem, layer);
- setGlobals(ctx, layer);
+ updateEventCache(params);
+ callback.call(elem, params);
+ setGlobals(ctx, params);
}
}
@@ -250,7 +240,7 @@ function positionShape(ctx, params, width, height) {
}
}
-// Extend jCanvas with custom methods
+// Extend jCanvas
function extend(plugin) {
// Merge properties with defaults
@@ -260,9 +250,9 @@ function extend(plugin) {
// Create plugin
if (plugin.name) {
- $.fn[plugin.name] = function(params) {
- var $elems = this, elem, e, ctx;
- params = params = mergePrefs(params);
+ $.fn[plugin.name] = function(args) {
+ var $elems = this, elem, e, ctx,
+ params = merge(new Prefs(), args);
for (e=0; e<$elems.length; e+=1) {
elem = $elems[e];
@@ -278,15 +268,17 @@ function extend(plugin) {
return $.fn[plugin.name];
}
-// Get canvas context
+// Load canvas
$.fn.loadCanvas = function() {
return loadCanvas(this[0]);
};
-// Get canvas image as data URL
+// Load canvas
$.fn.getCanvasImage = function(type) {
var elem = this[0];
- if (!elem || !elem.toDataURL) {return NULL;}
+ if (!elem || !elem.toDataURL) {
+ return NULL;
+ }
if (type === UNDEFINED) {
type = 'image/png';
@@ -313,14 +305,14 @@ $.fn.draw = function(callback) {
return $elems;
};
-// Create a canvas gradient object
-$.fn.gradient = function(params) {
+// Create gradient
+$.fn.gradient = function(args) {
var $elems = this, ctx,
+ params = merge(new Prefs(), args),
gradient,
stops = [], nstops,
start, end,
i, a, n, p;
- params = mergePrefs(params);
ctx = loadCanvas($elems[0]);
if (ctx) {
@@ -401,10 +393,10 @@ $.fn.gradient = function(params) {
};
// Create pattern
-$.fn.pattern = function(params) {
- var $elems = this, ctx,
+$.fn.pattern = function(args) {
+ var $elems = this,
+ ctx, params = merge(new Prefs(), args),
img, pattern;
- params = mergePrefs(params);
// Create pattern when image can be loaded
function create() {
@@ -456,9 +448,9 @@ $.fn.pattern = function(params) {
};
// Clear canvas
-$.fn.clearCanvas = function(params) {
- var $elems = this, e, ctx;
- params = mergePrefs(params);
+$.fn.clearCanvas = function(args) {
+ var $elems = this, e, ctx,
+ params = merge(new Prefs(), args);
for (e=0; e<$elems.length; e+=1) {
ctx = loadCanvas($elems[e]);
@@ -507,9 +499,9 @@ $.fn.restoreCanvas = function() {
};
// Scale canvas
-$.fn.scaleCanvas = function(params) {
- var $elems = this, e, ctx;
- params = mergePrefs(params);
+$.fn.scaleCanvas = function(args) {
+ var $elems = this, e, ctx,
+ params = merge(new Prefs(), args);
for (e=0; e<$elems.length; e+=1) {
ctx = loadCanvas($elems[e]);
@@ -524,9 +516,9 @@ $.fn.scaleCanvas = function(params) {
};
// Translate canvas
-$.fn.translateCanvas = function(params) {
- var $elems = this, e, ctx;
- params = mergePrefs(params);
+$.fn.translateCanvas = function(args) {
+ var $elems = this, e, ctx,
+ params = merge(new Prefs(), args);
for (e=0; e<$elems.length; e+=1) {
ctx = loadCanvas($elems[e]);
@@ -539,9 +531,9 @@ $.fn.translateCanvas = function(params) {
};
// Rotate canvas
-$.fn.rotateCanvas = function(params) {
- var $elems = this, e, ctx;
- params = mergePrefs(params);
+$.fn.rotateCanvas = function(args) {
+ var $elems = this, e, ctx,
+ params = merge(new Prefs(), args);
for (e=0; e<$elems.length; e+=1) {
ctx = loadCanvas($elems[e]);
@@ -553,10 +545,10 @@ $.fn.rotateCanvas = function(params) {
};
// Draw rectangle
-$.fn.drawRect = function(params) {
+$.fn.drawRect = function(args) {
var $elems = this, e, ctx,
+ params = merge(new Prefs(), args),
x1, y1, x2, y2, r;
- params = mergePrefs(params);
for (e=0; e<$elems.length; e+=1) {
ctx = loadCanvas($elems[e]);
@@ -595,7 +587,9 @@ $.fn.drawRect = function(params) {
}
ctx.restore();
// Check for jCanvas events
- if (params.event) {checkEvents($elems[e], ctx, params);}
+ if (params.event) {
+ checkEvents($elems[e], ctx, args);
+ }
closePath(ctx, params);
}
@@ -604,9 +598,9 @@ $.fn.drawRect = function(params) {
};
// Draw arc
-$.fn.drawArc = function(params) {
- var $elems = this, e, ctx;
- params = mergePrefs(params);
+$.fn.drawArc = function(args) {
+ var $elems = this, e, ctx,
+ params = merge(new Prefs(), args);
// Change default end angle to radians if needed
if (!params.inDegrees && params.end === 360) {
@@ -626,7 +620,9 @@ $.fn.drawArc = function(params) {
// Close path if chosen
ctx.restore();
// Check for jCanvas events
- if (params.event) {checkEvents($elems[e], ctx, params);}
+ if (params.event) {
+ checkEvents($elems[e], ctx, args);
+ }
closePath(ctx, params);
}
@@ -635,9 +631,9 @@ $.fn.drawArc = function(params) {
};
// Draw ellipse
-$.fn.drawEllipse = function(params) {
- params = mergePrefs(params);
+$.fn.drawEllipse = function(args) {
var $elems = this, e, ctx,
+ params = merge(new Prefs(), args),
controlW = params.width * 4/3;
for (e=0; e<$elems.length; e+=1) {
@@ -656,19 +652,21 @@ $.fn.drawEllipse = function(params) {
ctx.bezierCurveTo(params.x+controlW/2, params.y+params.height/2, params.x+controlW/2, params.y-params.height/2, params.x, params.y-params.height/2);
ctx.restore();
// Check for jCanvas events
- if (params.event) {checkEvents($elems[e], ctx, params);}
+ if (params.event) {
+ checkEvents($elems[e], ctx, args);
+ }
closePath(ctx, params);
-
+
}
}
return $elems;
};
// Draw line
-$.fn.drawLine = function(params) {
+$.fn.drawLine = function(args) {
var $elems = this, e, ctx,
+ params = merge(new Prefs(), args),
l=2, lx=0, ly=0;
- params = mergePrefs(params);
for (e=0; e<$elems.length; e+=1) {
ctx = loadCanvas($elems[e]);
@@ -690,7 +688,9 @@ $.fn.drawLine = function(params) {
}
}
// Check for jCanvas events
- if (params.event) {checkEvents($elems[e], ctx, params);}
+ if (params.event) {
+ checkEvents($elems[e], ctx, args);
+ }
// Close path if chosen
closePath(ctx, params);
@@ -700,10 +700,10 @@ $.fn.drawLine = function(params) {
};
// Draw quadratic curve
-$.fn.drawQuad = function(params) {
+$.fn.drawQuad = function(args) {
var $elems = this, e, ctx,
+ params = merge(new Prefs(), args),
l=2, lx=0, ly=0, lcx=0, lcy=0;
- params = mergePrefs(params);
for (e=0; e<$elems.length; e+=1) {
ctx = loadCanvas($elems[e]);
@@ -727,7 +727,9 @@ $.fn.drawQuad = function(params) {
}
}
// Check for jCanvas events
- if (params.event) {checkEvents($elems[e], ctx, params);}
+ if (params.event) {
+ checkEvents($elems[e], ctx, args);
+ }
// Close path if chosen
closePath(ctx, params);
@@ -737,13 +739,13 @@ $.fn.drawQuad = function(params) {
};
// Draw Bezier curve
-$.fn.drawBezier = function(params) {
+$.fn.drawBezier = function(args) {
var $elems = this, e, ctx,
+ params = merge(new Prefs(), args),
l = 2, lc = 1,
lx=0, ly=0,
lcx1=0, lcy1=0,
lcx2=0, lcy2=0;
- params = mergePrefs(params);
for (e=0; e<$elems.length; e+=1) {
ctx = loadCanvas($elems[e]);
@@ -770,7 +772,9 @@ $.fn.drawBezier = function(params) {
}
}
// Check for jCanvas events
- if (params.event) {checkEvents($elems[e], ctx, params);}
+ if (params.event) {
+ checkEvents($elems[e], ctx, args);
+ }
// Close path if chosen
closePath(ctx, params);
@@ -780,9 +784,9 @@ $.fn.drawBezier = function(params) {
};
// Draw text
-$.fn.drawText = function(params) {
- var $elems = this, $elem, e, ctx;
- params = mergePrefs(params);
+$.fn.drawText = function(args) {
+ var $elems = this, $elem, e, ctx,
+ params = merge(new Prefs(), args);
for (e=0; e<$elems.length; e+=1) {
$elem = $($elems[e]);
@@ -795,7 +799,7 @@ $.fn.drawText = function(params) {
ctx.textBaseline = params.baseline;
ctx.textAlign = params.align;
ctx.font = params.font;
-
+
ctx.strokeText(params.text, params.x, params.y);
ctx.fillText(params.text, params.x, params.y);
@@ -805,12 +809,15 @@ $.fn.drawText = function(params) {
};
// Draw image
-$.fn.drawImage = function(params) {
+$.fn.drawImage = function(args) {
var $elems = this, ctx, elem, e,
+ params = merge(new Prefs(), args),
img, scaleFac;
- params = mergePrefs(params);
- // Use defined element, if not, a source URL
+ // Define arguments if not defined (because the jCanvas() function was used instead)
+ args = args || {};
+
+ // Use defined DOM element, if not, a source URL
if (params.source.src) {
img = params.source;
} else if (params.source) {
@@ -879,14 +886,14 @@ $.fn.drawImage = function(params) {
// If only width is present
if (params.width !== NULL && params.height === NULL) {
- params.height = params.height = params.width / scaleFac;
+ args.height = params.height = params.width / scaleFac;
// If only height is present
} else if (params.width === NULL && params.height !== NULL) {
- params.width = params.width = params.height * scaleFac;
+ args.width = params.width = params.height * scaleFac;
// If width and height are both absent
} else if (params.width === NULL && params.height === NULL) {
- params.width = params.width = img.width;
- params.height = params.height = img.height;
+ args.width = params.width = img.width;
+ args.height = params.height = img.height;
}
// Position image
positionShape(ctx, params, params.width, params.height);
@@ -914,7 +921,7 @@ $.fn.drawImage = function(params) {
params.height
);
ctx.restore();
- checkEvents($elems[e], ctx, params);
+ checkEvents($elems[e], ctx, args);
ctx.closePath();
} else {
ctx.restore();
@@ -958,10 +965,10 @@ $.fn.drawImage = function(params) {
return $elems;
};
-// Draw equiangular (regular) polygon
-$.fn.drawPolygon = function(params) {
- params = mergePrefs(params);
+// Draw a regular (equal-angled) polygon
+$.fn.drawPolygon = function(args) {
var $elems = this, e, ctx,
+ params = merge(new Prefs(), args),
inner = PI / params.sides,
theta = (PI/2) + inner,
dtheta = (PI*2) / params.sides,
@@ -998,7 +1005,9 @@ $.fn.drawPolygon = function(params) {
}
ctx.restore();
// Check for jCanvas events
- if (params.event) {checkEvents($elems[e], ctx, params);}
+ if (params.event) {
+ checkEvents($elems[e], ctx, args);
+ }
closePath(ctx, params);
}
@@ -1008,12 +1017,12 @@ $.fn.drawPolygon = function(params) {
};
// Get pixels on the canvas
-$.fn.setPixels = function(params) {
+$.fn.setPixels = function(args) {
var $elems = this,
ctx, elem, e, i,
+ params = merge(new Prefs(), args),
imgData, data, len, px = {};
- params = mergePrefs(params);
-
+
for (e=0; e<$elems.length; e+=1) {
elem = $elems[e];
ctx = loadCanvas($elems[e]);
@@ -1188,12 +1197,15 @@ function supportColorProps(props) {
// Get jCanvas layers
$.fn.getLayers = function() {
var elem = this[0], layers;
- if (!elem || !elem.getContext) {return NULL;}
- layers = $.data(elem, 'jCanvas-layers');
- // Create layers array if none exists
- if (!layers) {
- layers = [];
- $.data(elem, 'jCanvas-layers', layers);
+ if (!elem || !elem.getContext) {
+ layers = NULL;
+ } else {
+ layers = $.data(elem, 'jCanvas-layers');
+ // Create layers array if none exists
+ if (!layers) {
+ layers = [];
+ $.data(elem, 'jCanvas-layers', layers);
+ }
}
return layers;
};
@@ -1218,11 +1230,10 @@ $.fn.getLayer = function(index) {
};
// Add a new jCanvas layer
-$.fn.addLayer = function(params) {
+$.fn.addLayer = function(args) {
var $elems = this, $elem,
+ params = merge(args, new Prefs(), merge({}, args)),
layers, event, e;
-
- params = mergePrefs(params);
params.layer = TRUE;
for (e=0; e<$elems.length; e+=1) {
@@ -1325,36 +1336,36 @@ $.fn.drawLayers = function() {
// Animate jCanvas layer
$.fn.animateLayer = function() {
var $elems = this, $elem, e,
- params = ([]).slice.call(arguments, 0),
+ args = ([]).slice.call(arguments, 0),
layer;
// Deal with all cases of argument placement
// If index is omitted
- if (typeof params[0] === 'object' && !params[0].layer) {
- params.unshift(0);
+ if (typeof args[0] === 'object' && !args[0].layer) {
+ args.unshift(0);
}
// If object is the last argument
- if (params[2] === UNDEFINED) {
- params.splice(2, 0, NULL);
- params.splice(3, 0, NULL);
- params.splice(4, 0, function() {});
+ if (args[2] === UNDEFINED) {
+ args.splice(2, 0, NULL);
+ args.splice(3, 0, NULL);
+ args.splice(4, 0, function() {});
// If callback comes after object
- } else if (typeof params[2] === 'function') {
- params.splice(2, 0, NULL);
- params.splice(3, 0, NULL);
+ } else if (typeof args[2] === 'function') {
+ args.splice(2, 0, NULL);
+ args.splice(3, 0, NULL);
}
// If duration is the last argument
- if (params[3] === UNDEFINED) {
- params[3] = NULL;
- params.splice(4, 0, function() {});
+ if (args[3] === UNDEFINED) {
+ args[3] = NULL;
+ args.splice(4, 0, function() {});
// If callback comes after duration
- } else if (typeof params[3] === 'function') {
- params.splice(3, 0, NULL);
+ } else if (typeof args[3] === 'function') {
+ args.splice(3, 0, NULL);
}
// If callback is ommitted
- if (params[4] === UNDEFINED) {
- params[4] = function() {};
+ if (args[4] === UNDEFINED) {
+ args[4] = function() {};
}
// Animation callback functions
@@ -1362,7 +1373,7 @@ $.fn.animateLayer = function() {
return function() {
showProps(cssProps, layer);
$elem.drawLayers();
- params[4].call($elem[0]);
+ args[4].call($elem[0]);
};
}
function step($elem, layer) {
@@ -1376,21 +1387,21 @@ $.fn.animateLayer = function() {
$elem = $($elems[e]);
if (loadCanvas($elems[e])) {
// If a layer object was passed, use it as a reference
- if (params[0].layer) {
- layer = params[0];
+ if (args[0].layer) {
+ layer = args[0];
} else {
- layer = $elem.getLayer(params[0]);
+ layer = $elem.getLayer(args[0]);
}
// Ignore layers that are functions
if (layer && layer.method !== 'draw') {
// Allow jQuery to animate jCanvas CSS-named properties (width, opacity, etc.)
hideProps(cssProps, layer);
- hideProps(cssProps, params[1]);
+ hideProps(cssProps, args[1]);
// Animate layer
- $(layer).animate(params[1], {
- duration: params[2],
- easing: ($.easing[params[3]] ? params[3] : NULL),
+ $(layer).animate(args[1], {
+ duration: args[2],
+ easing: ($.easing[args[3]] ? args[3] : NULL),
// When animation completes
complete: complete($elem, layer),
// Redraw canvas for every animation frame
@@ -1406,7 +1417,7 @@ $.fn.animateLayer = function() {
// Normalize offsetX and offsetY for all browsers
$.event.fix = function(event) {
var offset;
- event = eventFix.call($.event, event);
+ event = oldEventFix.call($.event, event);
// If offsetX and offsetY are not supported
if (event.pageX !== UNDEFINED && event.offsetX === UNDEFINED) {
offset = $(event.target).offset();
View
2  jcanvas.min.js
@@ -3,4 +3,4 @@ jCanvas v5.3b
Copyright 2012, Caleb Evans
Licensed under the MIT license
*/
-(function(v,E,c,s,G,r,n,t,K,u,w){var x,M,D=v.extend,I=s.round,d=s.PI,o=s.sin,b=s.cos,k=v.event.fix,q={},A,B;function C(){}function J(N){if(N){D(M,N)}else{M=C.prototype=D({},x)}return this}J.version="5.3b";J.events={};v.fn.jCanvas=J;x={align:"center",angle:0,baseline:"middle",ccw:K,closed:K,compositing:"source-over",cornerRadius:0,cropFromCenter:t,each:u,end:360,fillStyle:"transparent",font:"12pt sans-serif",fromCenter:t,height:u,inDegrees:t,load:u,mask:K,opacity:1,projection:0,r1:u,r2:u,radius:0,repeat:"repeat",rounded:K,scaleX:1,scaleY:1,shadowBlur:3,shadowColor:"transparent",shadowX:0,shadowY:0,sHeight:0,sides:3,source:"",start:0,strokeCap:"butt",strokeJoin:"miter",strokeStyle:"transparent",strokeWidth:1,sWidth:0,sx:u,sy:u,text:"",visible:t,width:u,x:0,x1:0,x2:0,y:0,y1:0,y2:0};J();function y(O){var N;O=O||{};for(N in M){if(M.hasOwnProperty(N)&&O[N]===undefined){O[N]=M[N]}}return O}function a(N,O){N.fillStyle=O.fillStyle;N.strokeStyle=O.strokeStyle;N.lineWidth=O.strokeWidth;if(O.rounded){N.lineCap="round";N.lineJoin="round"}else{N.lineCap=O.strokeCap;N.lineJoin=O.strokeJoin}N.shadowOffsetX=O.shadowX;N.shadowOffsetY=O.shadowY;N.shadowBlur=O.shadowBlur;N.shadowColor=O.shadowColor;N.globalAlpha=O.opacity;N.globalCompositeOperation=O.compositing}q.x=[];q.y=[];function z(N){J.events[N]=function(O){O.unbind(N+".jCanvas").bind(N+".jCanvas",function(P){q.x[0]=P.offsetX;q.y[0]=P.offsetY;q.type=P.type;O.drawLayers()})}}z("click");z("dblclick");z("mousedown");z("mouseup");z("mousemove");J.events.mouseover=J.events.mouseout=function(N){N.unbind("mousemove.jCanvasHover").bind("mousemove.jCanvasHover",function(O){q.x[1]=q.x[0];q.y[1]=q.y[0];q.x[0]=O.offsetX;q.y[0]=O.offsetY;q.type="hover";N.drawLayers()})};function e(N){N.mouseX=q.x[0];N.mouseY=q.y[0];q.x[0]=w;q.y[0]=w}function H(Q,N,P){var S=P[q.type],R=N.isPointInPath(q.x[0],q.y[0]),O=N.isPointInPath(q.x[1],q.y[1]);if(q.type==="hover"&&R&&!P.hovered){P.hovered=t;e(P);if(P.mouseover){P.mouseover.call(Q,P);a(N,P)}}else{if(q.type==="hover"&&!R&&O&&P.hovered){P.hovered=K;e(P);if(P.mouseout){P.mouseout.call(Q,P);a(N,P)}}else{if(q.type!=="hover"&&S&&R){e(P);S.call(Q,P);a(N,P)}}}}function i(N){return(N.getContext?N.getContext("2d"):u)}function p(N,O){if(O.mask){N.save();N.clip()}if(O.closed){N.closePath();N.fill();N.stroke()}else{N.fill();N.stroke();N.closePath()}}function g(O,Q,P,N){Q.toRad=(Q.inDegrees?d/180:1);O.save();if(!Q.fromCenter){Q.x+=P/2;Q.y+=N/2}if(Q.angle){O.translate(Q.x,Q.y);O.rotate(Q.angle*Q.toRad);O.translate(-Q.x,-Q.y)}}function m(N){N=N||{};x=D(x,N.props);J();if(N.name){v.fn[N.name]=function(R){var S=this,P,Q,O;R=R=y(R);for(Q=0;Q<S.length;Q+=1){P=S[Q];O=i(P);if(O){a(O,R);N.fn.call(P,O,R)}}return S}}return v.fn[N.name]}v.fn.loadCanvas=function(){return i(this[0])};v.fn.getCanvasImage=function(N){var O=this[0];if(!O||!O.toDataURL){return u}if(N===w){N="image/png"}else{N=N.replace(/^([a-z]+)$/gi,"image/$1").replace(/jpg/gi,"jpeg")}return O.toDataURL(N)};v.fn.draw=function(Q){var P=this,N,O;for(O=0;O<P.length;O+=1){N=i(P[O]);if(N){Q.call(P[O],N)}}return P};v.fn.gradient=function(R){var N=this,Y,W,X=[],U,P,S,T,V,Q,O;R=y(R);Y=i(N[0]);if(Y){if(R.c2===w){W=R.c1}else{if(R.r1!==u||R.r2!==u){W=Y.createRadialGradient(R.x1,R.y1,R.r1,R.x2,R.y2,R.r2)}else{W=Y.createLinearGradient(R.x1,R.y1,R.x2,R.y2)}for(T=1;R["c"+T]!==w;T+=1){if(R["s"+T]!==w){X.push(R["s"+T])}else{X.push(u)}}U=X.length;if(X[0]===u){X[0]=0}if(X[U-1]===u){X[U-1]=1}for(T=0;T<U;T+=1){if(X[T]!==u&&X[T]!==1){V=T+1;Q=1;O=0;P=X[T];for(V=(T+1);V<U;V+=1){if(X[V]!==u){S=X[V];break}else{Q+=1}}if(P>S){X[V]=X[T]}}else{if(X[T]===u){O+=1;X[T]=P+(O*((S-P)/Q))}}W.addColorStop(X[T],R["c"+(T+1)])}}}else{W=u}return W};v.fn.pattern=function(S){var U=this,N,O,Q;S=y(S);function P(){var V=K;if(O.complete){Q=N.createPattern(O,S.repeat);V=t}return V}function T(){if(S.load){S.load.call(U[0],Q)}}function R(){P();T()}N=i(U[0]);if(N){O=new G();if(S.source.src){O=S.source}else{O.src=S.source}if(!O.complete&&S.load){O.onload=R}else{if(!P()){O.onload=R}else{T()}}}else{Q=u}return Q};v.fn.clearCanvas=function(P){var Q=this,O,N;P=y(P);for(O=0;O<Q.length;O+=1){N=i(Q[O]);if(N){g(N,P,P.width,P.height);if(!P.width&&!P.height){N.clearRect(0,0,Q[O].width,Q[O].height)}else{N.clearRect(P.x-P.width/2,P.y-P.height/2,P.width,P.height)}}}return Q};v.fn.saveCanvas=function(){var P=this,N,O;for(O=0;O<P.length;O+=1){N=i(P[O]);if(N){N.save()}}return P};v.fn.restoreCanvas=function(){var P=this,N,O;for(O=0;O<P.length;O+=1){N=i(P[O]);if(N){N.restore()}}return P};v.fn.scaleCanvas=function(P){var Q=this,O,N;P=y(P);for(O=0;O<Q.length;O+=1){N=i(Q[O]);if(N){N.save();N.translate(P.x,P.y);N.scale(P.scaleX,P.scaleY);N.translate(-P.x,-P.y)}}return Q};v.fn.translateCanvas=function(P){var Q=this,O,N;P=y(P);for(O=0;O<Q.length;O+=1){N=i(Q[O]);if(N){N.save();N.translate(P.x,P.y)}}return Q};v.fn.rotateCanvas=function(P){var Q=this,O,N;P=y(P);for(O=0;O<Q.length;O+=1){N=i(Q[O]);if(N){g(N,P,0,0)}}return Q};v.fn.drawRect=function(R){var O=this,S,V,Q,U,P,T,N;R=y(R);for(S=0;S<O.length;S+=1){V=i(O[S]);if(V){a(V,R);g(V,R,R.width,R.height);V.beginPath();if(R.cornerRadius){R.closed=t;Q=R.x-R.width/2;U=R.y-R.height/2;P=R.x+R.width/2;T=R.y+R.height/2;N=R.cornerRadius;if((P-Q)-(2*N)<0){N=(P-Q)/2}if((T-U)-(2*N)<0){N=(T-U)/2}V.moveTo(Q+N,U);V.lineTo(P-N,U);V.arc(P-N,U+N,N,3*d/2,d*2,K);V.lineTo(P,T-N);V.arc(P-N,T-N,N,0,d/2,K);V.lineTo(Q+N,T);V.arc(Q+N,T-N,N,d/2,d,K);V.lineTo(Q,U+N);V.arc(Q+N,U+N,N,d,3*d/2,K)}else{V.rect(R.x-R.width/2,R.y-R.height/2,R.width,R.height)}V.restore();if(R.event){H(O[S],V,R)}p(V,R)}}return O};v.fn.drawArc=function(P){var Q=this,O,N;P=y(P);if(!P.inDegrees&&P.end===360){P.end=d*2}for(O=0;O<Q.length;O+=1){N=i(Q[O]);if(N){a(N,P);g(N,P,P.radius*2,P.radius*2);N.beginPath();N.arc(P.x,P.y,P.radius,(P.start*P.toRad)-(d/2),(P.end*P.toRad)-(d/2),P.ccw);N.restore();if(P.event){H(Q[O],N,P)}p(N,P)}}return Q};v.fn.drawEllipse=function(Q){Q=y(Q);var R=this,P,N,O=Q.width*4/3;for(P=0;P<R.length;P+=1){N=i(R[P]);if(N){a(N,Q);g(N,Q,Q.width,Q.height);N.beginPath();N.moveTo(Q.x,Q.y-Q.height/2);N.bezierCurveTo(Q.x-O/2,Q.y-Q.height/2,Q.x-O/2,Q.y+Q.height/2,Q.x,Q.y+Q.height/2);N.bezierCurveTo(Q.x+O/2,Q.y+Q.height/2,Q.x+O/2,Q.y-Q.height/2,Q.x,Q.y-Q.height/2);N.restore();if(Q.event){H(R[P],N,Q)}p(N,Q)}}return R};v.fn.drawLine=function(S){var T=this,R,O,N=2,Q=0,P=0;S=y(S);for(R=0;R<T.length;R+=1){O=i(T[R]);if(O){a(O,S);O.beginPath();O.moveTo(S.x1,S.y1);while(t){Q=S["x"+N];P=S["y"+N];if(Q!==w&&P!==w){O.lineTo(Q,P);N+=1}else{break}}if(S.event){H(T[R],O,S)}p(O,S)}}return T};v.fn.drawQuad=function(R){var N=this,S,V,Q=2,P=0,O=0,U=0,T=0;R=y(R);for(S=0;S<N.length;S+=1){V=i(N[S]);if(V){a(V,R);V.beginPath();V.moveTo(R.x1,R.y1);while(t){P=R["x"+Q];O=R["y"+Q];U=R["cx"+(Q-1)];T=R["cy"+(Q-1)];if(P!==w&&O!==w&&U!==w&&T!==w){V.quadraticCurveTo(U,T,P,O);Q+=1}else{break}}if(R.event){H(N[S],V,R)}p(V,R)}}return N};v.fn.drawBezier=function(U){var N=this,X,Y,T=2,Q=1,S=0,R=0,W=0,P=0,V=0,O=0;U=y(U);for(X=0;X<N.length;X+=1){Y=i(N[X]);if(Y){a(Y,U);Y.beginPath();Y.moveTo(U.x1,U.y1);while(t){S=U["x"+T];R=U["y"+T];W=U["cx"+Q];P=U["cy"+Q];V=U["cx"+(Q+1)];O=U["cy"+(Q+1)];if(S!==w&&R!==w&&W!==w&&P!==w&&V!==w&&O!==w){Y.bezierCurveTo(W,P,V,O,S,R);T+=1;Q+=2}else{break}}if(U.event){H(N[X],Y,U)}p(Y,U)}}return N};v.fn.drawText=function(Q){var R=this,O,P,N;Q=y(Q);for(P=0;P<R.length;P+=1){O=v(R[P]);N=i(O[0]);if(N){a(N,Q);N.textBaseline=Q.baseline;N.textAlign=Q.align;N.font=Q.font;N.strokeText(Q.text,Q.x,Q.y);N.fillText(Q.text,Q.x,Q.y)}}return R};v.fn.drawImage=function(R){var N=this,W,P,T,S,O;R=y(R);if(R.source.src){S=R.source}else{if(R.source){S=new G();S.src=R.source}}function U(X){if(S.complete===w||S.complete===t){O=S.width/S.height;R.sWidth=R.sWidth||S.width;R.sHeight=R.sHeight||S.height;if(R.sWidth>S.width){R.sWidth=S.width}if(R.sHeight>S.height){R.sHeight=S.height}if(R.width===u&&R.sWidth!==S.width){R.width=R.sWidth}if(R.height===u&&R.sHeight!==S.height){R.height=R.sHeight}if(R.sx===u){if(R.cropFromCenter){R.sx=S.width/2}else{R.sx=0}}if(R.sy===u){if(R.cropFromCenter){R.sy=S.height/2}else{R.sy=0}}if(!R.cropFromCenter){R.sx+=R.sWidth/2;R.sy+=R.sHeight/2}if((R.sx+R.sWidth/2)>S.width){R.sx=S.width-R.sWidth/2}if((R.sx-R.sWidth/2)<0){R.sx=R.sWidth/2}if((R.sy-R.sHeight/2)<0){R.sy=R.sHeight/2}if((R.sy+R.sHeight/2)>S.height){R.sy=S.height-R.sHeight/2}if(R.width!==u&&R.height===u){R.height=R.height=R.width/O}else{if(R.width===u&&R.height!==u){R.width=R.width=R.height*O}else{if(R.width===u&&R.height===u){R.width=R.width=S.width;R.height=R.height=S.height}}}g(X,R,R.width,R.height);X.drawImage(S,R.sx-R.sWidth/2,R.sy-R.sHeight/2,R.sWidth,R.sHeight,R.x-R.width/2,R.y-R.height/2,R.width,R.height);if(R.event){X.fillStyle="#000";X.beginPath();X.rect(R.x-R.width/2,R.y-R.height/2,R.width,R.height);X.restore();H(N[T],X,R);X.closePath()}else{X.restore()}return t}}function V(){if(R.load){R.load.call(P)}}function Q(){U(W);V()}for(T=0;T<N.length;T+=1){P=N[T];W=i(N[T]);if(W){a(W,R);if(!S.complete&&R.load){S.onload=Q}else{if(!U(W)){S.onload=Q}else{V()}}}}return N};v.fn.drawPolygon=function(R){R=y(R);var N=this,T,Y,Z=d/R.sides,Q=(d/2)+Z,X=(d*2)/R.sides,W=b(X/2)*R.radius,P,V,O,U,S;R.closed=t;if(R.sides>2){for(T=0;T<N.length;T+=1){Y=i(N[T]);if(Y){a(Y,R);g(Y,R,R.radius,R.radius);Y.beginPath();for(S=0;S<R.sides;S+=1){P=R.x+I(R.radius*b(Q));V=R.y+I(R.radius*o(Q));if(S===0){Y.moveTo(P,V)}else{Y.lineTo(P,V)}if(R.projection){O=R.x+I((W+W*R.projection)*b(Q+Z));U=R.y+I((W+W*R.projection)*o(Q+Z));Y.lineTo(O,U)}Q+=X}Y.restore();if(R.event){H(N[T],Y,R)}p(Y,R)}}}return N};v.fn.setPixels=function(Q){var N=this,W,P,U,S,O,R,T,V={};Q=y(Q);for(U=0;U<N.length;U+=1){P=N[U];W=i(N[U]);if(W){if(!Q.x&&!Q.y&&!Q.width&&!Q.height){Q.width=P.width;Q.height=P.height;Q.x=Q.width/2;Q.y=Q.height/2}g(W,Q,Q.width,Q.height);O=W.getImageData(Q.x-Q.width/2,Q.y-Q.height/2,Q.width,Q.height);R=O.data;T=R.length;V=[];if(Q.each!==u){for(S=0;S<T;S+=4){V.index=S/4;V.r=R[S];V.g=R[S+1];V.b=R[S+2];V.a=R[S+3];Q.each.call(P,V);R[S]=V.r;R[S+1]=V.g;R[S+2]=V.b;R[S+3]=V.a}}W.putImageData(O,Q.x-Q.width/2,Q.y-Q.height/2);W.restore()}}return N};function f(O,P){var N;for(N=0;N<O.length;N+=1){P[O[N]]=P["_"+O[N]]}}function h(O,P){var N;for(N=0;N<O.length;N+=1){P["_"+O[N]]=P[O[N]]}}A=["width","height","opacity"];B=["backgroundColor","color","borderColor","borderTopColor","borderRightColor","borderBottomColor","borderLeftColor","fillStyle","strokeStyle","shadowColor"];function j(O){var R,Q,P=[],N=1;if(typeof O==="object"){P=O}else{if(O.match(/^[a-z]+$/gi)){if(O==="transparent"){O="rgba(255,255,255,0)"}Q=c.documentElement;R=Q.style.color;Q.style.color=O;O=v.css(Q,"color");Q.style.color=R}if(O.match(/^\#/gi)){if(O.length===4){O=O.replace(/([0-9a-f])/gi,"$1$1")}P=O.match(/[0-9a-f]{2}/gi);P[0]=n(P[0],16);P[1]=n(P[1],16);P[2]=n(P[2],16)}else{if(O.match(/^rgb/gi)){P=O.match(/[0-9\.]+/gi);if(O.match(/\%/gi)){N=2.55}P[0]=P[0]*N;P[1]=P[1]*N;P[2]=P[2]*N}}if(O.match("rgba")){P[3]=r(P[3])}else{P[3]=1}}return P}function L(O,N){O.now[N]=O.start[N]+(O.end[N]-O.start[N])*O.pos;if(N<3){O.now[N]=I(O.now[N])}}function F(N){if(typeof N.start!=="object"){N.start=j(N.start);N.end=j(N.end)}N.now=[];L(N,0);L(N,1);L(N,2);L(N,3);N.now="rgba("+N.now.join(",")+")";if(N.elem.style){N.elem.style[N.prop]=N.now}else{N.elem[N.prop]=N.now}}function l(N){var O;for(O=0;O<N.length;O+=1){if(!v.fx.step[N[O]]){v.fx.step[N[O]]=F}}}v.fn.getLayers=function(){var N=this[0],O;if(!N||!N.getContext){return u}O=v.data(N,"jCanvas-layers");if(!O){O=[];v.data(N,"jCanvas-layers",O)}return O};v.fn.getLayer=function(N){var Q=this.getLayers(),P,O;if(!Q){P=u}else{if(typeof N==="string"){for(O=0;O<Q.length;O+=1){if(Q[O].name===N){N=O;break}}}}N=N||0;P=Q[N];return P};v.fn.addLayer=function(R){var S=this,N,Q,O,P;R=y(R);R.layer=t;for(P=0;P<S.length;P+=1){N=v(S[P]);if(i(S[P])){Q=N.getLayers();if(typeof R==="function"){R.method="draw"}else{if(R.method!=="drawImage"){R.width=R.width||0;R.height=R.height||0}for(O in J.events){if(J.events.hasOwnProperty(O)&&R[O]){J.events[O].call(E,N);R.event=t}}}Q.push(R)}}S.drawLayers();return S};v.fn.removeLayers=function(){var P=this,O,N;for(N=0;N<P.length;N+=1){O=v(P[N]).getLayers()||[];O.length=0}return this};v.fn.removeLayer=function(N){var S=this,R,P=typeof N,Q,O;for(R=0;R<S.length;R+=1){Q=v(S[R]).getLayers()||[];if(P==="string"){for(O=0;O<Q.length;O+=1){if(Q[O].name===N){Q.splice(O,1);break}}}else{if(P==="number"){Q.splice(N,1)}}}return this};v.fn.drawLayers=function(){var T=this,O,N,S,R,Q,P;for(Q=0;Q<T.length;Q+=1){O=v(T[Q]);N=i(O[0]);if(N){R=O.getLayers();N.clearRect(0,0,O[0].width,O[0].height);for(P=0;P<R.length;P+=1){S=R[P];if(S.visible){if(S.method==="draw"){S.call(O[0],N)}else{if(v.fn[S.method]){v.fn[S.method].call(O,S)}}}}}}return T};v.fn.animateLayer=function(){var T=this,O,R,S=([]).slice.call(arguments,0),P;if(typeof S[0]==="object"&&!S[0].layer){S.unshift(0)}if(S[2]===w){S.splice(2,0,u);S.splice(3,0,u);S.splice(4,0,function(){})}else{if(typeof S[2]==="function"){S.splice(2,0,u);S.splice(3,0,u)}}if(S[3]===w){S[3]=u;S.splice(4,0,function(){})}else{if(typeof S[3]==="function"){S.splice(3,0,u)}}if(S[4]===w){S[4]=function(){}}function N(U,V){return function(){f(A,V);U.drawLayers();S[4].call(U[0])}}function Q(U,V){return function(){f(A,V);U.drawLayers()}}for(R=0;R<T.length;R+=1){O=v(T[R]);if(i(T[R])){if(S[0].layer){P=S[0]}else{P=O.getLayer(S[0])}if(P&&P.method!=="draw"){h(A,P);h(A,S[1]);v(P).animate(S[1],{duration:S[2],easing:(v.easing[S[3]]?S[3]:u),complete:N(O,P),step:Q(O,P)})}}}return T};v.event.fix=function(N){var O;N=k.call(v.event,N);if(N.pageX!==w&&N.offsetX===w){O=v(N.target).offset();if(O){N.offsetX=N.pageX-O.left;N.offsetY=N.pageY-O.top}}return N};l(B);v.support.canvas=(c.createElement("canvas").getContext!==w);J.defaults=x;J.prefs=M;J.extend=m;v.jCanvas=J}(jQuery,window,document,Math,Image,parseFloat,parseInt,true,false,null));
+(function(v,D,c,s,F,r,n,t,J,u,w){var x,L,C=v.extend,H=s.round,d=s.PI,o=s.sin,b=s.cos,j=v.event.fix,q={},z,A;function B(){}function I(M){if(M){C(L,M)}else{L=B.prototype=C({},x)}return this}I.version="5.3b";I.events={};v.fn.jCanvas=I;x={align:"center",angle:0,baseline:"middle",ccw:J,closed:J,compositing:"source-over",cornerRadius:0,cropFromCenter:t,each:u,end:360,fillStyle:"transparent",font:"12pt sans-serif",fromCenter:t,height:u,inDegrees:t,load:u,mask:J,opacity:1,projection:0,r1:u,r2:u,radius:0,repeat:"repeat",rounded:J,scaleX:1,scaleY:1,shadowBlur:3,shadowColor:"transparent",shadowX:0,shadowY:0,sHeight:0,sides:3,source:"",start:0,strokeCap:"butt",strokeJoin:"miter",strokeStyle:"transparent",strokeWidth:1,sWidth:0,sx:u,sy:u,text:"",visible:t,width:u,x:0,x1:0,x2:0,y:0,y1:0,y2:0};I();function a(M,N){M.fillStyle=N.fillStyle;M.strokeStyle=N.strokeStyle;M.lineWidth=N.strokeWidth;if(N.rounded){M.lineCap="round";M.lineJoin="round"}else{M.lineCap=N.strokeCap;M.lineJoin=N.strokeJoin}M.shadowOffsetX=N.shadowX;M.shadowOffsetY=N.shadowY;M.shadowBlur=N.shadowBlur;M.shadowColor=N.shadowColor;M.globalAlpha=N.opacity;M.globalCompositeOperation=N.compositing}q.x=[];q.y=[];function y(M){I.events[M]=function(N){N.unbind(M+".jCanvas").bind(M+".jCanvas",function(O){q.x[0]=O.offsetX;q.y[0]=O.offsetY;q.type=O.type;N.drawLayers()})}}y("click");y("dblclick");y("mousedown");y("mouseup");y("mousemove");I.events.mouseover=I.events.mouseout=function(M){M.unbind("mousemove.jCanvasHover").bind("mousemove.jCanvasHover",function(N){q.x[1]=q.x[0];q.y[1]=q.y[0];q.x[0]=N.offsetX;q.y[0]=N.offsetY;q.type="hover";M.drawLayers()})};function e(M){M.mouseX=q.x[0];M.mouseY=q.y[0];q.x[0]=w;q.y[0]=w}function G(O,M,Q){var R=Q[q.type],P=M.isPointInPath(q.x[0],q.y[0]),N=M.isPointInPath(q.x[1],q.y[1]);if(q.type==="hover"&&P&&!Q.fired){Q.fired=t;e(Q);if(Q.mouseover){Q.mouseover.call(O,Q);a(M,Q)}}else{if(q.type==="hover"&&!P&&N&&Q.fired){Q.fired=J;e(Q);if(Q.mouseout){Q.mouseout.call(O,Q);a(M,Q)}}else{if(q.type!=="hover"&&R&&P){e(Q);R.call(O,Q);a(M,Q)}}}}function i(M){return(M.getContext?M.getContext("2d"):u)}function p(M,N){if(N.mask){M.save();M.clip()}if(N.closed){M.closePath();M.fill();M.stroke()}else{M.fill();M.stroke();M.closePath()}}function g(N,P,O,M){P.toRad=(P.inDegrees?d/180:1);N.save();if(!P.fromCenter){P.x+=O/2;P.y+=M/2}if(P.angle){N.translate(P.x,P.y);N.rotate(P.angle*P.toRad);N.translate(-P.x,-P.y)}}function m(M){M=M||{};x=C(x,M.props);I();if(M.name){v.fn[M.name]=function(O){var S=this,P,Q,N,R=C(new B(),O);for(Q=0;Q<S.length;Q+=1){P=S[Q];N=i(P);if(N){a(N,R);M.fn.call(P,N,R)}}return S}}return v.fn[M.name]}v.fn.loadCanvas=function(){return i(this[0])};v.fn.getCanvasImage=function(M){var N=this[0];if(!N||!N.toDataURL){return u}if(M===w){M="image/png"}else{M=M.replace(/^([a-z]+)$/gi,"image/$1").replace(/jpg/gi,"jpeg")}return N.toDataURL(M)};v.fn.draw=function(P){var O=this,M,N;for(N=0;N<O.length;N+=1){M=i(O[N]);if(M){P.call(O[N],M)}}return O};v.fn.gradient=function(U){var M=this,Y,R=C(new B(),U),W,X=[],T,O,Q,S,V,P,N;Y=i(M[0]);if(Y){if(R.c2===w){W=R.c1}else{if(R.r1!==u||R.r2!==u){W=Y.createRadialGradient(R.x1,R.y1,R.r1,R.x2,R.y2,R.r2)}else{W=Y.createLinearGradient(R.x1,R.y1,R.x2,R.y2)}for(S=1;R["c"+S]!==w;S+=1){if(R["s"+S]!==w){X.push(R["s"+S])}else{X.push(u)}}T=X.length;if(X[0]===u){X[0]=0}if(X[T-1]===u){X[T-1]=1}for(S=0;S<T;S+=1){if(X[S]!==u&&X[S]!==1){V=S+1;P=1;N=0;O=X[S];for(V=(S+1);V<T;V+=1){if(X[V]!==u){Q=X[V];break}else{P+=1}}if(O>Q){X[V]=X[S]}}else{if(X[S]===u){N+=1;X[S]=O+(N*((Q-O)/P))}}W.addColorStop(X[S],R["c"+(S+1)])}}}else{W=u}return W};v.fn.pattern=function(S){var M=this,U,O=C(new B(),S),P,R;function Q(){var V=J;if(P.complete){R=U.createPattern(P,O.repeat);V=t}return V}function T(){if(O.load){O.load.call(M[0],R)}}function N(){Q();T()}U=i(M[0]);if(U){P=new F();if(O.source.src){P=O.source}else{P.src=O.source}if(!P.complete&&O.load){P.onload=N}else{if(!Q()){P.onload=N}else{T()}}}else{R=u}return R};v.fn.clearCanvas=function(N){var Q=this,O,M,P=C(new B(),N);for(O=0;O<Q.length;O+=1){M=i(Q[O]);if(M){g(M,P,P.width,P.height);if(!P.width&&!P.height){M.clearRect(0,0,Q[O].width,Q[O].height)}else{M.clearRect(P.x-P.width/2,P.y-P.height/2,P.width,P.height)}}}return Q};v.fn.saveCanvas=function(){var O=this,M,N;for(N=0;N<O.length;N+=1){M=i(O[N]);if(M){M.save()}}return O};v.fn.restoreCanvas=function(){var O=this,M,N;for(N=0;N<O.length;N+=1){M=i(O[N]);if(M){M.restore()}}return O};v.fn.scaleCanvas=function(N){var Q=this,O,M,P=C(new B(),N);for(O=0;O<Q.length;O+=1){M=i(Q[O]);if(M){M.save();M.translate(P.x,P.y);M.scale(P.scaleX,P.scaleY);M.translate(-P.x,-P.y)}}return Q};v.fn.translateCanvas=function(N){var Q=this,O,M,P=C(new B(),N);for(O=0;O<Q.length;O+=1){M=i(Q[O]);if(M){M.save();M.translate(P.x,P.y)}}return Q};v.fn.rotateCanvas=function(N){var Q=this,O,M,P=C(new B(),N);for(O=0;O<Q.length;O+=1){M=i(Q[O]);if(M){g(M,P,0,0)}}return Q};v.fn.drawRect=function(S){var N=this,R,V,Q=C(new B(),S),P,U,O,T,M;for(R=0;R<N.length;R+=1){V=i(N[R]);if(V){a(V,Q);g(V,Q,Q.width,Q.height);V.beginPath();if(Q.cornerRadius){Q.closed=t;P=Q.x-Q.width/2;U=Q.y-Q.height/2;O=Q.x+Q.width/2;T=Q.y+Q.height/2;M=Q.cornerRadius;if((O-P)-(2*M)<0){M=(O-P)/2}if((T-U)-(2*M)<0){M=(T-U)/2}V.moveTo(P+M,U);V.lineTo(O-M,U);V.arc(O-M,U+M,M,3*d/2,d*2,J);V.lineTo(O,T-M);V.arc(O-M,T-M,M,0,d/2,J);V.lineTo(P+M,T);V.arc(P+M,T-M,M,d/2,d,J);V.lineTo(P,U+M);V.arc(P+M,U+M,M,d,3*d/2,J)}else{V.rect(Q.x-Q.width/2,Q.y-Q.height/2,Q.width,Q.height)}V.restore();if(Q.event){G(N[R],V,S)}p(V,Q)}}return N};v.fn.drawArc=function(N){var Q=this,O,M,P=C(new B(),N);if(!P.inDegrees&&P.end===360){P.end=d*2}for(O=0;O<Q.length;O+=1){M=i(Q[O]);if(M){a(M,P);g(M,P,P.radius*2,P.radius*2);M.beginPath();M.arc(P.x,P.y,P.radius,(P.start*P.toRad)-(d/2),(P.end*P.toRad)-(d/2),P.ccw);M.restore();if(P.event){G(Q[O],M,N)}p(M,P)}}return Q};v.fn.drawEllipse=function(N){var R=this,P,M,Q=C(new B(),N),O=Q.width*4/3;for(P=0;P<R.length;P+=1){M=i(R[P]);if(M){a(M,Q);g(M,Q,Q.width,Q.height);M.beginPath();M.moveTo(Q.x,Q.y-Q.height/2);M.bezierCurveTo(Q.x-O/2,Q.y-Q.height/2,Q.x-O/2,Q.y+Q.height/2,Q.x,Q.y+Q.height/2);M.bezierCurveTo(Q.x+O/2,Q.y+Q.height/2,Q.x+O/2,Q.y-Q.height/2,Q.x,Q.y-Q.height/2);M.restore();if(Q.event){G(R[P],M,N)}p(M,Q)}}return R};v.fn.drawLine=function(O){var T=this,R,N,S=C(new B(),O),M=2,Q=0,P=0;for(R=0;R<T.length;R+=1){N=i(T[R]);if(N){a(N,S);N.beginPath();N.moveTo(S.x1,S.y1);while(t){Q=S["x"+M];P=S["y"+M];if(Q!==w&&P!==w){N.lineTo(Q,P);M+=1}else{break}}if(S.event){G(T[R],N,O)}p(N,S)}}return T};v.fn.drawQuad=function(S){var M=this,R,V,Q=C(new B(),S),P=2,O=0,N=0,U=0,T=0;for(R=0;R<M.length;R+=1){V=i(M[R]);if(V){a(V,Q);V.beginPath();V.moveTo(Q.x1,Q.y1);while(t){O=Q["x"+P];N=Q["y"+P];U=Q["cx"+(P-1)];T=Q["cy"+(P-1)];if(O!==w&&N!==w&&U!==w&&T!==w){V.quadraticCurveTo(U,T,O,N);P+=1}else{break}}if(Q.event){G(M[R],V,S)}p(V,Q)}}return M};v.fn.drawBezier=function(X){var M=this,W,Y,T=C(new B(),X),S=2,P=1,R=0,Q=0,V=0,O=0,U=0,N=0;for(W=0;W<M.length;W+=1){Y=i(M[W]);if(Y){a(Y,T);Y.beginPath();Y.moveTo(T.x1,T.y1);while(t){R=T["x"+S];Q=T["y"+S];V=T["cx"+P];O=T["cy"+P];U=T["cx"+(P+1)];N=T["cy"+(P+1)];if(R!==w&&Q!==w&&V!==w&&O!==w&&U!==w&&N!==w){Y.bezierCurveTo(V,O,U,N,R,Q);S+=1;P+=2}else{break}}if(T.event){G(M[W],Y,X)}p(Y,T)}}return M};v.fn.drawText=function(O){var R=this,N,P,M,Q=C(new B(),O);for(P=0;P<R.length;P+=1){N=v(R[P]);M=i(N[0]);if(M){a(M,Q);M.textBaseline=Q.baseline;M.textAlign=Q.align;M.font=Q.font;M.strokeText(Q.text,Q.x,Q.y);M.fillText(Q.text,Q.x,Q.y)}}return R};v.fn.drawImage=function(T){var M=this,W,O,S,Q=C(new B(),T),R,N;T=T||{};if(Q.source.src){R=Q.source}else{if(Q.source){R=new F();R.src=Q.source}}function U(X){if(R.complete===w||R.complete===t){N=R.width/R.height;Q.sWidth=Q.sWidth||R.width;Q.sHeight=Q.sHeight||R.height;if(Q.sWidth>R.width){Q.sWidth=R.width}if(Q.sHeight>R.height){Q.sHeight=R.height}if(Q.width===u&&Q.sWidth!==R.width){Q.width=Q.sWidth}if(Q.height===u&&Q.sHeight!==R.height){Q.height=Q.sHeight}if(Q.sx===u){if(Q.cropFromCenter){Q.sx=R.width/2}else{Q.sx=0}}if(Q.sy===u){if(Q.cropFromCenter){Q.sy=R.height/2}else{Q.sy=0}}if(!Q.cropFromCenter){Q.sx+=Q.sWidth/2;Q.sy+=Q.sHeight/2}if((Q.sx+Q.sWidth/2)>R.width){Q.sx=R.width-Q.sWidth/2}if((Q.sx-Q.sWidth/2)<0){Q.sx=Q.sWidth/2}if((Q.sy-Q.sHeight/2)<0){Q.sy=Q.sHeight/2}if((Q.sy+Q.sHeight/2)>R.height){Q.sy=R.height-Q.sHeight/2}if(Q.width!==u&&Q.height===u){T.height=Q.height=Q.width/N}else{if(Q.width===u&&Q.height!==u){T.width=Q.width=Q.height*N}else{if(Q.width===u&&Q.height===u){T.width=Q.width=R.width;T.height=Q.height=R.height}}}g(X,Q,Q.width,Q.height);X.drawImage(R,Q.sx-Q.sWidth/2,Q.sy-Q.sHeight/2,Q.sWidth,Q.sHeight,Q.x-Q.width/2,Q.y-Q.height/2,Q.width,Q.height);if(Q.event){X.fillStyle="#000";X.beginPath();X.rect(Q.x-Q.width/2,Q.y-Q.height/2,Q.width,Q.height);X.restore();G(M[S],X,T);X.closePath()}else{X.restore()}return t}}function V(){if(Q.load){Q.load.call(O)}}function P(){U(W);V()}for(S=0;S<M.length;S+=1){O=M[S];W=i(M[S]);if(W){a(W,Q);if(!R.complete&&Q.load){R.onload=P}else{if(!U(W)){R.onload=P}else{V()}}}}return M};v.fn.drawPolygon=function(T){var M=this,S,Y,Q=C(new B(),T),Z=d/Q.sides,P=(d/2)+Z,X=(d*2)/Q.sides,W=b(X/2)*Q.radius,O,V,N,U,R;Q.closed=t;if(Q.sides>2){for(S=0;S<M.length;S+=1){Y=i(M[S]);if(Y){a(Y,Q);g(Y,Q,Q.radius,Q.radius);Y.beginPath();for(R=0;R<Q.sides;R+=1){O=Q.x+H(Q.radius*b(P));V=Q.y+H(Q.radius*o(P));if(R===0){Y.moveTo(O,V)}else{Y.lineTo(O,V)}if(Q.projection){N=Q.x+H((W+W*Q.projection)*b(P+Z));U=Q.y+H((W+W*Q.projection)*o(P+Z));Y.lineTo(N,U)}P+=X}Y.restore();if(Q.event){G(M[S],Y,T)}p(Y,Q)}}}return M};v.fn.setPixels=function(U){var M=this,W,O,T,R,P=C(new B(),U),N,Q,S,V={};for(T=0;T<M.length;T+=1){O=M[T];W=i(M[T]);if(W){if(!P.x&&!P.y&&!P.width&&!P.height){P.width=O.width;P.height=O.height;P.x=P.width/2;P.y=P.height/2}g(W,P,P.width,P.height);N=W.getImageData(P.x-P.width/2,P.y-P.height/2,P.width,P.height);Q=N.data;S=Q.length;V=[];if(P.each!==u){for(R=0;R<S;R+=4){V.index=R/4;V.r=Q[R];V.g=Q[R+1];V.b=Q[R+2];V.a=Q[R+3];P.each.call(O,V);Q[R]=V.r;Q[R+1]=V.g;Q[R+2]=V.b;Q[R+3]=V.a}}W.putImageData(N,P.x-P.width/2,P.y-P.height/2);W.restore()}}return M};function f(N,O){var M;for(M=0;M<N.length;M+=1){O[N[M]]=O["_"+N[M]]}}function h(N,O){var M;for(M=0;M<N.length;M+=1){O["_"+N[M]]=O[N[M]]}}z=["width","height","opacity"];A=["backgroundColor","color","borderColor","borderTopColor","borderRightColor","borderBottomColor","borderLeftColor","fillStyle","strokeStyle","shadowColor"];function k(N){var Q,P,O=[],M=1;if(typeof N==="object"){O=N}else{if(N.match(/^[a-z]+$/gi)){if(N==="transparent"){N="rgba(255,255,255,0)"}P=c.documentElement;Q=P.style.color;P.style.color=N;N=v.css(P,"color");P.style.color=Q}if(N.match(/^\#/gi)){if(N.length===4){N=N.replace(/([0-9a-f])/gi,"$1$1")}O=N.match(/[0-9a-f]{2}/gi);O[0]=n(O[0],16);O[1]=n(O[1],16);O[2]=n(O[2],16)}else{if(N.match(/^rgb/gi)){O=N.match(/[0-9\.]+/gi);if(N.match(/\%/gi)){M=2.55}O[0]=O[0]*M;O[1]=O[1]*M;O[2]=O[2]*M}}if(N.match("rgba")){O[3]=r(O[3])}else{O[3]=1}}return O}function K(N,M){N.now[M]=N.start[M]+(N.end[M]-N.start[M])*N.pos;if(M<3){N.now[M]=H(N.now[M])}}function E(M){if(typeof M.start!=="object"){M.start=k(M.start);M.end=k(M.end)}M.now=[];K(M,0);K(M,1);K(M,2);K(M,3);M.now="rgba("+M.now.join(",")+")";if(M.elem.style){M.elem.style[M.prop]=M.now}else{M.elem[M.prop]=M.now}}function l(M){var N;for(N=0;N<M.length;N+=1){if(!v.fx.step[M[N]]){v.fx.step[M[N]]=E}}}v.fn.getLayers=function(){var M=this[0],N;if(!M||!M.getContext){N=u}else{N=v.data(M,"jCanvas-layers");if(!N){N=[];v.data(M,"jCanvas-layers",N)}}return N};v.fn.getLayer=function(M){var P=this.getLayers(),O,N;if(!P){O=u}else{if(typeof M==="string"){for(N=0;N<P.length;N+=1){if(P[N].name===M){M=N;break}}}}M=M||0;O=P[M];return O};v.fn.addLayer=function(N){var S=this,M,R=C(N,new B(),C({},N)),Q,O,P;R.layer=t;for(P=0;P<S.length;P+=1){M=v(S[P]);if(i(S[P])){Q=M.getLayers();if(typeof R==="function"){R.method="draw"}else{if(R.method!=="drawImage"){R.width=R.width||0;R.height=R.height||0}for(O in I.events){if(I.events.hasOwnProperty(O)&&R[O]){I.events[O].call(D,M);R.event=t}}}Q.push(R)}}S.drawLayers();return S};v.fn.removeLayers=function(){var O=this,N,M;for(M=0;M<O.length;M+=1){N=v(O[M]).getLayers()||[];N.length=0}return this};v.fn.removeLayer=function(M){var R=this,Q,O=typeof M,P,N;for(Q=0;Q<R.length;Q+=1){P=v(R[Q]).getLayers()||[];if(O==="string"){for(N=0;N<P.length;N+=1){if(P[N].name===M){P.splice(N,1);break}}}else{if(O==="number"){P.splice(M,1)}}}return this};v.fn.drawLayers=function(){var S=this,N,M,R,Q,P,O;for(P=0;P<S.length;P+=1){N=v(S[P]);M=i(N[0]);if(M){Q=N.getLayers();M.clearRect(0,0,N[0].width,N[0].height);for(O=0;O<Q.length;O+=1){R=Q[O];if(R.visible){if(R.method==="draw"){R.call(N[0],M)}else{if(v.fn[R.method]){v.fn[R.method].call(N,R)}}}}}}return S};v.fn.animateLayer=function(){var S=this,N,R,O=([]).slice.call(arguments,0),P;if(typeof O[0]==="object"&&!O[0].layer){O.unshift(0)}if(O[2]===w){O.splice(2,0,u);O.splice(3,0,u);O.splice(4,0,function(){})}else{if(typeof O[2]==="function"){O.splice(2,0,u);O.splice(3,0,u)}}if(O[3]===w){O[3]=u;O.splice(4,0,function(){})}else{if(typeof O[3]==="function"){O.splice(3,0,u)}}if(O[4]===w){O[4]=function(){}}function M(T,U){return function(){f(z,U);T.drawLayers();O[4].call(T[0])}}function Q(T,U){return function(){f(z,U);T.drawLayers()}}for(R=0;R<S.length;R+=1){N=v(S[R]);if(i(S[R])){if(O[0].layer){P=O[0]}else{P=N.getLayer(O[0])}if(P&&P.method!=="draw"){h(z,P);h(z,O[1]);v(P).animate(O[1],{duration:O[2],easing:(v.easing[O[3]]?O[3]:u),complete:M(N,P),step:Q(N,P)})}}}return S};v.event.fix=function(M){var N;M=j.call(v.event,M);if(M.pageX!==w&&M.offsetX===w){N=v(M.target).offset();if(N){M.offsetX=M.pageX-N.left;M.offsetY=M.pageY-N.top}}return M};l(A);v.support.canvas=(c.createElement("canvas").getContext!==w);I.defaults=x;I.prefs=L;I.extend=m;v.jCanvas=I}(jQuery,window,document,Math,Image,parseFloat,parseInt,true,false,null));
Please sign in to comment.
Something went wrong with that request. Please try again.