Create local aliases of some of the "long" methods.

This commit is contained in:
kangax 2010-07-26 19:20:19 -04:00
parent 04ec1688e9
commit ad679a6f87
13 changed files with 407 additions and 345 deletions

213
dist/all.js vendored
View file

@ -1221,7 +1221,10 @@ fabric.util.animate = animate;
})(this);
(function(){
var fabric = this.fabric || (this.fabric = { });
var fabric = this.fabric || (this.fabric = { }),
extend = fabric.util.object.extend,
capitalize = fabric.util.string.capitalize,
clone = fabric.util.object.clone;
var attributesMap = {
'cx': 'left',
@ -1277,8 +1280,8 @@ fabric.util.animate = animate;
return memo;
}, { });
ownAttributes = fabric.util.object.extend(fabric.parseStyleAttribute(element), ownAttributes);
return fabric.util.object.extend(parentAttributes, ownAttributes);
ownAttributes = extend(fabric.parseStyleAttribute(element), ownAttributes);
return extend(parentAttributes, ownAttributes);
};
/**
@ -1467,7 +1470,7 @@ fabric.util.animate = animate;
*/
function parseElements(elements, options) {
var _elements = elements.map(function(el) {
var klass = fabric[fabric.util.string.capitalize(el.tagName)];
var klass = fabric[capitalize(el.tagName)];
if (klass && klass.fromElement) {
try {
return klass.fromElement(el, options);
@ -1549,7 +1552,7 @@ fabric.util.animate = animate;
height: height
};
var elements = fabric.parseElements(elements, fabric.util.object.clone(options));
var elements = fabric.parseElements(elements, clone(options));
if (!elements || (elements && !elements.length)) return;
if (callback) {
@ -1558,7 +1561,7 @@ fabric.util.animate = animate;
};
})();
fabric.util.object.extend(fabric, {
extend(fabric, {
parseAttributes: parseAttributes,
parseElements: parseElements,
parseStyleAttribute: parseStyleAttribute,
@ -2062,24 +2065,30 @@ fabric.util.animate = animate;
(function () {
var global = this,
window = global.window,
document = window.document,
capitalize = fabric.util.string.capitalize,
camelize = fabric.util.string.camelize;
if (fabric.Element) {
console.warn('fabric.Element is already defined.');
return;
}
var CANVAS_INIT_ERROR = new Error('Could not initialize `canvas` element'),
var global = this,
window = global.window,
document = window.document,
extend = fabric.util.object.extend,
capitalize = fabric.util.string.capitalize,
camelize = fabric.util.string.camelize,
fireEvent = fabric.util.fireEvent,
getPointer = fabric.util.getPointer,
getElementOffset = fabric.util.getElementOffset,
removeFromArray = fabric.util.removeFromArray,
addListener = fabric.util.addlistener,
removeListener = fabric.util.removelistener,
CANVAS_INIT_ERROR = new Error('Could not initialize `canvas` element'),
FX_DURATION = 500,
STROKE_OFFSET = 0.5,
FX_TRANSITION = 'decel',
getPointer = fabric.util.getPointer,
cursorMap = {
'tr': 'ne-resize',
'br': 'se-resize',
@ -2239,7 +2248,7 @@ fabric.util.animate = animate;
this.calcOffset();
};
fabric.util.object.extend(fabric.Element.prototype, {
extend(fabric.Element.prototype, {
selectionColor: 'rgba(100,100,255,0.3)', // blue
selectionBorderColor: 'rgba(255,255,255,0.3)',
@ -2264,7 +2273,7 @@ fabric.util.animate = animate;
* @chainable
*/
calcOffset: function () {
this._offset = fabric.util.getElementOffset(this.getElement());
this._offset = getElementOffset(this.getElement());
return this;
},
@ -2356,7 +2365,7 @@ fabric.util.animate = animate;
* See configuration documentation for more details.
*/
_initConfig: function (oConfig) {
fabric.util.object.extend(this._oConfig, oConfig || { });
extend(this._oConfig, oConfig || { });
this._oConfig.width = parseInt(this._oElement.width, 10) || 0;
this._oConfig.height = parseInt(this._oElement.height, 10) || 0;
@ -2375,15 +2384,15 @@ fabric.util.animate = animate;
var _this = this;
this._onMouseDown = function (e){ _this.__onMouseDown(e); };
this._onMouseUp = function (e){ _this.__onMouseUp(e); };
this._onMouseMove = function (e){ _this.__onMouseMove(e); };
this._onMouseDown = function (e) { _this.__onMouseDown(e); };
this._onMouseUp = function (e) { _this.__onMouseUp(e); };
this._onMouseMove = function (e) { _this.__onMouseMove(e); };
this._onResize = function (e) { _this.calcOffset() };
fabric.util.addListener(this._oElement, 'mousedown', this._onMouseDown);
fabric.util.addListener(document, 'mousemove', this._onMouseMove);
fabric.util.addListener(document, 'mouseup', this._onMouseUp);
fabric.util.addListener(window, 'resize', this._onResize);
addListener(this._oElement, 'mousedown', this._onMouseDown);
addListener(document, 'mousemove', this._onMouseMove);
addListener(document, 'mouseup', this._onMouseUp);
addListener(window, 'resize', this._onResize);
},
/**
@ -2527,7 +2536,7 @@ fabric.util.animate = animate;
target = transform.target;
if (target.__scaling) {
fabric.util.fireEvent('object:scaled', { target: target });
fireEvent('object:scaled', { target: target });
target.__scaling = false;
}
@ -2537,7 +2546,7 @@ fabric.util.animate = animate;
if (target.hasStateChanged()) {
target.isMoving = false;
fabric.util.fireEvent('object:modified', { target: target });
fireEvent('object:modified', { target: target });
}
}
@ -2550,7 +2559,7 @@ fabric.util.animate = animate;
if (activeGroup) {
if (activeGroup.hasStateChanged() &&
activeGroup.containsPoint(this.getPointer(e))) {
fabric.util.fireEvent('group:modified', { target: activeGroup });
fireEvent('group:modified', { target: activeGroup });
}
activeGroup.setObjectsCoords();
activeGroup.set('isMoving', false);
@ -2651,15 +2660,15 @@ fabric.util.animate = animate;
deactivateAllWithDispatch: function () {
var activeGroup = this.getActiveGroup();
if (activeGroup) {
fabric.util.fireEvent('before:group:destroyed', {
fireEvent('before:group:destroyed', {
target: activeGroup
});
}
this.deactivateAll();
if (activeGroup) {
fabric.util.fireEvent('after:group:destroyed');
fireEvent('after:group:destroyed');
}
fabric.util.fireEvent('selection:cleared');
fireEvent('selection:cleared');
return this;
},
@ -2720,7 +2729,7 @@ fabric.util.animate = animate;
else {
activeGroup.add(target);
}
fabric.util.fireEvent('group:selected', { target: activeGroup });
fireEvent('group:selected', { target: activeGroup });
activeGroup.setActive(true);
}
else {
@ -2968,7 +2977,7 @@ fabric.util.animate = animate;
}
if (group.length === 1) {
this.setActiveObject(group[0]);
fabric.util.fireEvent('object:selected', {
fireEvent('object:selected', {
target: group[0]
});
}
@ -2976,7 +2985,7 @@ fabric.util.animate = animate;
var group = new fabric.Group(group);
this.setActiveGroup(group);
group.saveCoords();
fabric.util.fireEvent('group:selected', { target: group });
fireEvent('group:selected', { target: group });
}
this.renderAll();
},
@ -3587,7 +3596,7 @@ fabric.util.animate = animate;
_this.loadImageFromURL(path, function (image) {
image.setSourcePath(path);
fabric.util.object.extend(image, obj);
extend(image, obj);
image.setAngle(obj.angle);
onObjectLoaded(image, index);
@ -3622,7 +3631,7 @@ fabric.util.animate = animate;
object.setSourcePath(path);
if (!(object instanceof fabric.PathGroup)) {
fabric.util.object.extend(object, obj);
extend(object, obj);
if (typeof obj.angle !== 'undefined') {
object.setAngle(obj.angle);
}
@ -3750,7 +3759,7 @@ fabric.util.animate = animate;
* @return {Object} removed object
*/
remove: function (object) {
fabric.util.removeFromArray(this._aObjects, object);
removeFromArray(this._aObjects, object);
this.renderAll();
return object;
},
@ -3785,7 +3794,7 @@ fabric.util.animate = animate;
* @chainable
*/
sendToBack: function (object) {
fabric.util.removeFromArray(this._aObjects, object);
removeFromArray(this._aObjects, object);
this._aObjects.unshift(object);
return this.renderAll();
},
@ -3798,7 +3807,7 @@ fabric.util.animate = animate;
* @chainable
*/
bringToFront: function (object) {
fabric.util.removeFromArray(this._aObjects, object);
removeFromArray(this._aObjects, object);
this._aObjects.push(object);
return this.renderAll();
},
@ -3822,7 +3831,7 @@ fabric.util.animate = animate;
break;
}
}
fabric.util.removeFromArray(this._aObjects, object);
removeFromArray(this._aObjects, object);
this._aObjects.splice(nextIntersectingIdx, 0, object);
}
return this.renderAll();
@ -3849,7 +3858,7 @@ fabric.util.animate = animate;
break;
}
}
fabric.util.removeFromArray(objects, object);
removeFromArray(objects, object);
objects.splice(nextIntersectingIdx, 0, object);
}
this.renderAll();
@ -3871,7 +3880,7 @@ fabric.util.animate = animate;
this.renderAll();
fabric.util.fireEvent('object:selected', { target: object });
fireEvent('object:selected', { target: object });
return this;
},
@ -3978,10 +3987,10 @@ fabric.util.animate = animate;
*/
dispose: function () {
this.clear();
fabric.util.removeListener(this.getElement(), 'mousedown', this._onMouseDown);
fabric.util.removeListener(document, 'mouseup', this._onMouseUp);
fabric.util.removeListener(document, 'mousemove', this._onMouseMove);
fabric.util.removeListener(window, 'resize', this._onResize);
removeListener(this.getElement(), 'mousedown', this._onMouseDown);
removeListener(document, 'mouseup', this._onMouseUp);
removeListener(document, 'mousemove', this._onMouseMove);
removeListener(window, 'resize', this._onResize);
return this;
},
@ -4047,7 +4056,7 @@ fabric.util.animate = animate;
'{ objects: ' + this.getObjects().length + ' }>';
};
fabric.util.object.extend(fabric.Element, {
extend(fabric.Element, {
/**
* @property EMPTY_JSON
@ -4125,7 +4134,12 @@ fabric.util.animate = animate;
* @name Canvas
* @namespace
*/
fabric = global.fabric || (global.fabric = { });
fabric = global.fabric || (global.fabric = { }),
extend = fabric.util.object.extend,
clone = fabric.util.object.clone,
toFixed = fabric.util.toFixed,
capitalize = fabric.util.string.capitalize,
getPointer = fabric.util.getPointer;
if (fabric.Object) {
return;
@ -4219,7 +4233,7 @@ fabric.util.animate = animate;
},
setOptions: function(options) {
this.options = fabric.util.object.extend(this._getOptions(), options);
this.options = extend(this._getOptions(), options);
},
/**
@ -4227,7 +4241,7 @@ fabric.util.animate = animate;
* @method _getOptions
*/
_getOptions: function() {
return fabric.util.object.extend(fabric.util.object.clone(this._getSuperOptions()), this.options);
return extend(clone(this._getSuperOptions()), this.options);
},
/**
@ -4289,7 +4303,6 @@ fabric.util.animate = animate;
* @return {Object}
*/
toObject: function() {
var toFixed = fabric.util.toFixed;
var object = {
type: this.type,
left: toFixed(this.left, this.NUM_FRACTION_DIGITS),
@ -4359,7 +4372,7 @@ fabric.util.animate = animate;
* @return {String}
*/
toString: function() {
return "#<fabric." + fabric.util.string.capitalize(this.type) + ">";
return "#<fabric." + capitalize(this.type) + ">";
},
/**
@ -4895,7 +4908,7 @@ fabric.util.animate = animate;
* @return {String|Boolean} corner code (tl, tr, bl, br, etc.), or false if nothing is found
*/
_findTargetCorner: function(e, offset) {
var pointer = fabric.util.getPointer(e),
var pointer = getPointer(e),
ex = pointer.x - offset.left,
ey = pointer.y - offset.top,
xpoints,
@ -5340,7 +5353,9 @@ fabric.util.animate = animate;
(function(){
var fabric = this.fabric || (this.fabric = { });
var fabric = this.fabric || (this.fabric = { }),
extend = fabric.util.object.extend;
if (fabric.Line) {
return;
}
@ -5404,7 +5419,7 @@ fabric.util.animate = animate;
* @return {Object}
*/
toObject: function() {
return fabric.util.object.extend(this.callSuper('toObject'), {
return extend(this.callSuper('toObject'), {
x1: this.get('x1'),
y1: this.get('y1'),
x2: this.get('x2'),
@ -5430,7 +5445,7 @@ fabric.util.animate = animate;
parsedAttributes.x2 || 0,
parsedAttributes.y2 || 0
];
return new fabric.Line(points, fabric.util.object.extend(parsedAttributes, options));
return new fabric.Line(points, extend(parsedAttributes, options));
};
/**
@ -5449,7 +5464,8 @@ fabric.util.animate = animate;
var global = this,
fabric = global.fabric || (global.fabric = { }),
piBy2 = Math.PI * 2;
piBy2 = Math.PI * 2,
extend = fabric.util.object.extend;
if (fabric.Circle) {
console.warn('fabric.Circle is already defined.');
@ -5485,7 +5501,7 @@ fabric.util.animate = animate;
* @return {Object} object representation of an instance
*/
toObject: function() {
return fabric.util.object.extend(this.callSuper('toObject'), {
return extend(this.callSuper('toObject'), {
radius: this.get('radius')
});
},
@ -5534,7 +5550,7 @@ fabric.util.animate = animate;
if (!isValidRadius(parsedAttributes)) {
throw Error('value of `r` attribute is required and can not be negative');
}
return new fabric.Circle(fabric.util.object.extend(parsedAttributes, options));
return new fabric.Circle(extend(parsedAttributes, options));
};
/**
@ -5625,7 +5641,8 @@ fabric.util.animate = animate;
(function(){
var fabric = this.fabric || (this.fabric = { });
var fabric = this.fabric || (this.fabric = { }),
extend = fabric.util.object.extend;
if (fabric.Ellipse) {
console.warn('fabric.Ellipse is already defined.');
@ -5660,7 +5677,7 @@ fabric.util.animate = animate;
* @return {Object} object representation of an instance
*/
toObject: function() {
return fabric.util.object.extend(this.callSuper('toObject'), {
return extend(this.callSuper('toObject'), {
rx: this.get('rx'),
ry: this.get('ry')
})
@ -5715,7 +5732,7 @@ fabric.util.animate = animate;
*/
fabric.Ellipse.fromElement = function(element, options) {
var parsedAttributes = fabric.parseAttributes(element, fabric.Ellipse.ATTRIBUTE_NAMES);
return new fabric.Ellipse(fabric.util.object.extend(parsedAttributes, options));
return new fabric.Ellipse(extend(parsedAttributes, options));
};
/**
@ -5983,7 +6000,10 @@ fabric.util.animate = animate;
(function(){
var fabric = this.fabric || (this.fabric = { });
var fabric = this.fabric || (this.fabric = { }),
extend = fabric.util.object.extend,
min = fabric.util.array.min,
max = fabric.util.array.max;
if (fabric.Polygon) {
console.warn('fabric.Polygon is already defined');
@ -6018,10 +6038,10 @@ fabric.util.animate = animate;
_calcDimensions: function() {
var points = this.points,
minX = fabric.util.array.min(points, 'x'),
minY = fabric.util.array.min(points, 'y'),
maxX = fabric.util.array.max(points, 'x'),
maxY = fabric.util.array.max(points, 'y');
minX = min(points, 'x'),
minY = min(points, 'y'),
maxX = max(points, 'x'),
maxY = max(points, 'y');
this.width = maxX - minX;
this.height = maxY - minY;
@ -6048,7 +6068,7 @@ fabric.util.animate = animate;
* @return {Object} object representation of an instance
*/
toObject: function() {
return fabric.util.object.extend(this.callSuper('toObject'), {
return extend(this.callSuper('toObject'), {
points: this.points.concat()
});
},
@ -6100,7 +6120,7 @@ fabric.util.animate = animate;
var points = fabric.parsePointsAttribute(element.getAttribute('points')),
parsedAttributes = fabric.parseAttributes(element, fabric.Polygon.ATTRIBUTE_NAMES);
return new fabric.Polygon(points, fabric.util.object.extend(parsedAttributes, options));
return new fabric.Polygon(points, extend(parsedAttributes, options));
};
/**
@ -6117,7 +6137,10 @@ fabric.util.animate = animate;
(function(){
var fabric = this.fabric || (this.fabric = { });
var fabric = this.fabric || (this.fabric = { }),
min = fabric.util.array.min,
max = fabric.util.array.max,
extend = fabric.util.object.extend;
if (fabric.Path) {
console.warn('fabric.Path is already defined');
@ -6176,7 +6199,7 @@ fabric.util.animate = animate;
this.path = this._parsePath();
if (!isWidthSet || !isHeightSet) {
fabric.util.object.extend(this, this._parseDimensions());
extend(this, this._parseDimensions());
if (isWidthSet) {
this.width = this.options.width;
}
@ -6420,7 +6443,7 @@ fabric.util.animate = animate;
* @return {Object}
*/
toObject: function() {
var o = fabric.util.object.extend(this.callSuper('toObject'), {
var o = extend(this.callSuper('toObject'), {
path: this.path
});
if (this.sourcePath) {
@ -6521,15 +6544,15 @@ fabric.util.animate = animate;
}, this);
var minX = fabric.util.array.min(aX),
minY = fabric.util.array.min(aY),
var minX = min(aX),
minY = min(aY),
deltaX = deltaY = 0;
var o = {
top: minY - deltaY,
left: minX - deltaX,
bottom: fabric.util.array.max(aY) - deltaY,
right: fabric.util.array.max(aX) - deltaX
bottom: max(aY) - deltaY,
right: max(aX) - deltaX
};
o.width = o.right - o.left;
@ -6562,13 +6585,15 @@ fabric.util.animate = animate;
var parsedAttributes = fabric.parseAttributes(element, ATTRIBUTE_NAMES),
path = parsedAttributes.d;
delete parsedAttributes.d;
return new fabric.Path(path, fabric.util.object.extend(parsedAttributes, options));
return new fabric.Path(path, extend(parsedAttributes, options));
}
})();
(function(){
var fabric = this.fabric || (this.fabric = { });
var fabric = this.fabric || (this.fabric = { }),
extend = fabric.util.object.extend,
invoke = fabric.util.array.invoke;
if (fabric.PathGroup) {
console.warn('fabric.PathGroup is already defined');
@ -6669,8 +6694,8 @@ fabric.util.animate = animate;
*/
toObject: function() {
var _super = fabric.Object.prototype.toObject;
return fabric.util.object.extend(_super.call(this), {
paths: fabric.util.array.invoke(this.getObjects(), 'clone'),
return extend(_super.call(this), {
paths: invoke(this.getObjects(), 'clone'),
sourcePath: this.sourcePath
});
},
@ -6770,7 +6795,11 @@ fabric.util.animate = animate;
(function(){
var fabric = this.fabric || (this.fabric = { });
var fabric = this.fabric || (this.fabric = { }),
extend = fabric.util.object.extend,
min = fabric.util.array.min,
max = fabric.util.array.max;
if (fabric.Group) {
return;
}
@ -6797,7 +6826,7 @@ fabric.util.animate = animate;
this._updateObjectsCoords();
if (options) {
fabric.util.object.extend(this, options);
extend(this, options);
}
this._setOpacityIfSame();
@ -6930,7 +6959,7 @@ fabric.util.animate = animate;
* @return {Object} object representation of an instance
*/
toObject: function() {
return fabric.util.object.extend(this.callSuper('toObject'), {
return extend(this.callSuper('toObject'), {
objects: fabric.util.array.invoke(this.objects, 'clone')
});
},
@ -7142,10 +7171,10 @@ fabric.util.animate = animate;
}
};
minX = fabric.util.array.min(aX);
maxX = fabric.util.array.max(aX);
minY = fabric.util.array.min(aY);
maxY = fabric.util.array.max(aY);
minX = min(aX);
maxX = max(aX);
minY = min(aY);
maxY = max(aY);
width = maxX - minX;
height = maxY - minY;
@ -7198,7 +7227,9 @@ fabric.util.animate = animate;
(function(){
var fabric = this.fabric || (this.fabric = { });
var fabric = this.fabric || (this.fabric = { }),
extend = fabric.util.object.extend,
clone = fabric.util.object.clone;
if (fabric.Text) {
console.warn('fabric.Text is already defined');
@ -7227,7 +7258,7 @@ fabric.util.animate = animate;
this.initStateProperties();
this.text = text;
this.setOptions(options);
fabric.util.object.extend(this, this.options);
extend(this, this.options);
this.theta = this.angle * (Math.PI/180);
this.width = this.getWidth();
this.setCoords();
@ -7301,7 +7332,7 @@ fabric.util.animate = animate;
* @return {Object} object representation of an instance
*/
toObject: function() {
return fabric.util.object.extend(this.callSuper('toObject'), {
return extend(this.callSuper('toObject'), {
text: this.text,
fontsize: this.fontsize,
fontweight: this.fontweight,
@ -7368,7 +7399,7 @@ fabric.util.animate = animate;
* @return {fabric.Text} an instance
*/
fabric.Text.fromObject = function(object) {
return new fabric.Text(object.text, fabric.util.object.clone(object));
return new fabric.Text(object.text, clone(object));
};
/**

325
dist/all.min.js vendored
View file

@ -1,165 +1,164 @@
if(typeof console=="undefined")var console={log:function(){},warn:function(){}};if(!this.JSON)this.JSON={};
(function(){function e(c){return c<10?"0"+c:c}function f(c){g.lastIndex=0;return g.test(c)?'"'+c.replace(g,function(d){var k=l[d];return typeof k==="string"?k:"\\u"+("0000"+d.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+c+'"'}function a(c,d){var k,o,s,r,t=h,p,q=d[c];if(q&&typeof q==="object"&&typeof q.toJSON==="function")q=q.toJSON(c);if(typeof n==="function")q=n.call(d,c,q);switch(typeof q){case "string":return f(q);case "number":return isFinite(q)?String(q):"null";case "boolean":case "null":return String(q);
case "object":if(!q)return"null";h+=m;p=[];if(Object.prototype.toString.apply(q)==="[object Array]"){r=q.length;for(k=0;k<r;k+=1)p[k]=a(k,q)||"null";s=p.length===0?"[]":h?"[\n"+h+p.join(",\n"+h)+"\n"+t+"]":"["+p.join(",")+"]";h=t;return s}if(n&&typeof n==="object"){r=n.length;for(k=0;k<r;k+=1){o=n[k];if(typeof o==="string")if(s=a(o,q))p.push(f(o)+(h?": ":":")+s)}}else for(o in q)if(Object.hasOwnProperty.call(q,o))if(s=a(o,q))p.push(f(o)+(h?": ":":")+s);s=p.length===0?"{}":h?"{\n"+h+p.join(",\n"+h)+
"\n"+t+"}":"{"+p.join(",")+"}";h=t;return s}}if(typeof Date.prototype.toJSON!=="function"){Date.prototype.toJSON=function(){return isFinite(this.valueOf())?this.getUTCFullYear()+"-"+e(this.getUTCMonth()+1)+"-"+e(this.getUTCDate())+"T"+e(this.getUTCHours())+":"+e(this.getUTCMinutes())+":"+e(this.getUTCSeconds())+"Z":null};String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(){return this.valueOf()}}var b=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
g=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,h,m,l={"\u0008":"\\b","\t":"\\t","\n":"\\n","\u000c":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},n;if(typeof JSON.stringify!=="function")JSON.stringify=function(c,d,k){var o;m=h="";if(typeof k==="number")for(o=0;o<k;o+=1)m+=" ";else if(typeof k==="string")m=k;if((n=d)&&typeof d!=="function"&&(typeof d!=="object"||typeof d.length!=="number"))throw Error("JSON.stringify");return a("",
{"":c})};if(typeof JSON.parse!=="function")JSON.parse=function(c,d){function k(s,r){var t,p,q=s[r];if(q&&typeof q==="object")for(t in q)if(Object.hasOwnProperty.call(q,t)){p=k(q,t);if(p!==undefined)q[t]=p;else delete q[t]}return d.call(s,r,q)}var o;c=String(c);b.lastIndex=0;if(b.test(c))c=c.replace(b,function(s){return"\\u"+("0000"+s.charCodeAt(0).toString(16)).slice(-4)});if(/^[\],:{}\s]*$/.test(c.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,
"]").replace(/(?:^|:|,)(?:\s*\[)+/g,""))){o=eval("("+c+")");return typeof d==="function"?k({"":o},""):o}throw new SyntaxError("JSON.parse");}})();
(function(){function e(h,m){for(var l in m)h[l]=m[l];return h}function f(h,m){var l=document.createElement(h);for(var n in m)if(n==="class")l.className=m[n];else if(n==="for")l.htmlFor=m[n];else l.setAttribute(n,m[n]);return l}function a(){return false}var b=this.fabric||(this.fabric={}),g=Array.prototype.slice;b.util={};if(!Array.prototype.indexOf)Array.prototype.indexOf=function(h,m){var l=this.length>>>0;m=Number(m)||0;m=Math[m<0?"ceil":"floor"](m);if(m<0)m+=l;for(;m<l;m++)if(m in this&&this[m]===
h)return m;return-1};if(!Array.prototype.forEach)Array.prototype.forEach=function(h,m){for(var l=0,n=this.length>>>0;l<n;l++)l in this&&h.call(m,this[l],l,this)};if(!Array.prototype.map)Array.prototype.map=function(h,m){for(var l=[],n=0,c=this.length>>>0;n<c;n++)if(n in this)l[n]=h.call(m,this[n],n,this);return l};if(!Array.prototype.every)Array.prototype.every=function(h,m){for(var l=0,n=this.length>>>0;l<n;l++)if(l in this&&!h.call(m,this[l],l,this))return false;return true};if(!Array.prototype.some)Array.prototype.some=
function(h,m){for(var l=0,n=this.length>>>0;l<n;l++)if(l in this&&h.call(m,this[l],l,this))return true;return false};if(!Array.prototype.filter)Array.prototype.filter=function(h,m){for(var l=[],n,c=0,d=this.length>>>0;c<d;c++)if(c in this){n=this[c];h.call(m,n,c,this)&&l.push(n)}return res};if(!Array.prototype.reduce)Array.prototype.reduce=function(h){var m=this.length>>>0,l=0,n;if(arguments.length>1)n=arguments[1];else{do{if(l in this){n=this[l++];break}if(++l>=m)throw new TypeError;}while(1)}for(;l<
m;l++)if(l in this)n=h.call(null,n,this[l],l,this);return n};b.util.array={invoke:function(h,m){for(var l=g.call(arguments,2),n=[],c=0,d=h.length;c<d;c++)n[c]=l.length?h[c][m].apply(h[c],l):h[c][m].call(h[c]);return n},min:function(h,m){var l=h.length-1,n=m?h[l][m]:h[l];if(m)for(;l--;){if(h[l][m]<n)n=h[l][m]}else for(;l--;)if(h[l]<n)n=h[l];return n},max:function(h,m){var l=h.length-1,n=m?h[l][m]:h[l];if(m)for(;l--;){if(h[l][m]>=n)n=h[l][m]}else for(;l--;)if(h[l]>=n)n=h[l];return n}};b.util.object=
{extend:e,clone:function(h){return e({},h)}};if(!String.prototype.trim)String.prototype.trim=function(){return this.replace(/^\s+/,"").replace(/\s+$/,"")};b.util.string={camelize:function(h){return h.replace(/-+(.)?/g,function(m,l){return l?l.toUpperCase():""})},capitalize:function(h){return h.charAt(0).toUpperCase()+h.slice(1).toLowerCase()}};if(!Function.prototype.bind)Function.prototype.bind=function(h){var m=this,l=Array.prototype.slice.call(arguments,1);return function(){return m.apply(h,l.concat(Array.prototype.slice.call(arguments)))}};
(function(){function h(){}var m;m=function(){for(var l in{toString:1})if(l==="toString")return false;return true}()?function(l,n){if(n.toString!==Object.prototype.toString)l.prototype.toString=n.toString;if(n.valueOf!==Object.prototype.valueOf)l.prototype.valueOf=n.valueOf;for(var c in n)l.prototype[c]=n[c]}:function(l,n){for(var c in n)l.prototype[c]=n[c]};b.util.createClass=function(){function l(){this.initialize.apply(this,arguments)}var n=null,c=g.call(arguments,0);if(typeof c[0]==="function")n=
c.shift();l.superclass=n;l.subclasses=[];if(n){h.prototype=n.prototype;l.prototype=new h;n.subclasses.push(l)}n=0;for(var d=c.length;n<d;n++)m(l,c[n]);if(!l.prototype.initialize)l.prototype.initialize=emptyFunction;return l.prototype.constructor=l}})();(function(){function h(p){var q=Array.prototype.slice.call(arguments,1),v,u,x=q.length;for(u=0;u<x;u++){v=typeof p[q[u]];if(!/^(?:function|object|unknown)$/.test(v))return false}return true}function m(p,q){return function(v){q.call(c(p),v||window.event)}}
function l(p,q){return function(v){if(r[p]&&r[p][q])for(var u=r[p][q],x=0,w=u.length;x<w;x++)u[x].call(this,v||window.event)}}var n=function(){if(typeof document.documentElement.uniqueID!=="undefined")return function(q){return q.uniqueID};var p=0;return function(q){return q.__uniqueID||(q.__uniqueID="uniqueID__"+p++)}}(),c,d;(function(){var p={};c=function(q){return p[q]};d=function(q,v){p[q]=v}})();var k=h(document.documentElement,"addEventListener","removeEventListener")&&h(window,"addEventListener",
"removeEventListener"),o=h(document.documentElement,"attachEvent","detachEvent")&&h(window,"attachEvent","detachEvent"),s={},r={};if(k){addListener=function(p,q,v){p.addEventListener(q,v,false)};removeListener=function(p,q,v){p.removeEventListener(q,v,false)}}else if(o){addListener=function(p,q,v){var u=n(p);d(u,p);s[u]||(s[u]={});s[u][q]||(s[u][q]=[]);v={handler:v,wrappedHandler:m(u,v)};s[u][q].push(v);p.attachEvent("on"+q,v.wrappedHandler)};removeListener=function(p,q,v){var u=n(p),x;if(s[u]&&s[u][q])for(var w=
0,y=s[u][q].length;w<y;w++)if((x=s[u][q][w])&&x.handler===v){p.detachEvent("on"+q,x.wrappedHandler);s[u][q][w]=null}}}else{addListener=function(p,q,v){var u=n(p);r[u]||(r[u]={});if(!r[u][q]){r[u][q]=[];var x=p["on"+q];x&&r[u][q].push(x);p["on"+q]=l(u,q)}r[u][q].push(v)};removeListener=function(p,q,v){p=n(p);if(r[p]&&r[p][q]){q=r[p][q];p=0;for(var u=q.length;p<u;p++)q[p]===v&&q.splice(p,1)}}}b.util.addListener=addListener;b.util.removeListener=removeListener;var t={};b.util.observeEvent=function(p,
q){t[p]||(t[p]=[]);t[p].push(q)};b.util.fireEvent=function(p,q){if(t[p])for(var v=0,u=t[p].length;v<u;v++)try{t[p][v]({memo:q})}catch(x){setTimeout(function(){throw x;},0)}};b.util.getPointer=function(p){var q=document.documentElement,v=document.body||{scrollLeft:0},u=document.documentElement,x=document.body||{scrollTop:0};return{x:p.pageX||p.clientX+(q.scrollLeft||v.scrollLeft)-(q.clientLeft||0),y:p.pageY||p.clientY+(u.scrollTop||x.scrollTop)-(u.clientTop||0)}}})(this);(function(){var h=document.createElement("div"),
m=typeof h.style.filter==="string",l=/alpha\s*\(\s*opacity\s*=\s*([^\)]+)\)/,n=function(c){return c};if(typeof h.style.opacity==="string")n=function(c,d){c.style.opacity=d;return c};else if(m)n=function(c,d){var k=c.style;if(c.currentStyle&&!c.currentStyle.hasLayout)k.zoom=1;if(l.test(k.filter)){d=d>=0.9999?"":"alpha(opacity="+d*100+")";k.filter=k.filter.replace(l,d)}else k.filter+=" alpha(opacity="+d*100+")";return c};b.util.setStyle=function(c,d){var k=c.style;if(typeof d==="string"){c.style.cssText+=
";"+d;return d.indexOf("opacity")>-1?n(c,d.match(/opacity:\s*(\d?\.?\d*)/)[1]):c}for(var o in d)if(o==="opacity")n(c,d[o]);else k[o==="float"||o==="cssFloat"?typeof k.styleFloat==="undefined"?"cssFloat":"styleFloat":o]=d[o];return c}})();(function(){var h=document.documentElement.style,m="userSelect"in h?"userSelect":"MozUserSelect"in h?"MozUserSelect":"WebkitUserSelect"in h?"WebkitUserSelect":"KhtmlUserSelect"in h?"KhtmlUserSelect":"";b.util.makeElementUnselectable=function(l){if(typeof l.onselectstart!==
"undefined")l.onselectstart=a;if(m)l.style[m]="none";else if(typeof l.unselectable=="string")l.unselectable="on";return l}})();(function(){function h(l,n){m.load(l);n()}b.util.getScript=function(l,n){var c=document.getElementsByTagName("head")[0],d=document.createElement("script"),k=true;d.type="text/javascript";d.setAttribute("runat","server");d.onload=d.onreadystatechange=function(o){if(k)if(!(typeof this.readyState=="string"&&this.readyState!=="loaded"&&this.readyState!=="complete")){k=false;n(o||
window.event);d=d.onload=d.onreadystatechange=null}};d.src=l;c.appendChild(d)};var m=this.Jaxer;if(m&&m.load)b.util.getScript=h})();b.util.getById=function(h){return typeof h==="string"?document.getElementById(h):h};b.util.toArray=function(h){for(var m=[],l=h.length;l--;)m[l]=h[l];return m};b.util.makeElement=f;b.util.addClass=function(h,m){if((" "+h.className+" ").indexOf(" "+m+" ")===-1)h.className+=(h.className?" ":"")+m};b.util.wrapElement=function(h,m,l){if(typeof m==="string")m=f(m,l);h.parentNode&&
h.parentNode.replaceChild(m,h);m.appendChild(h);return m};b.util.getElementOffset=function(h){var m=0,l=0;do{m+=h.offsetTop||0;l+=h.offsetLeft||0;h=h.offsetParent}while(h);return{left:l,top:m}};b.util.animate=function(h){h||(h={});var m=+new Date,l=h.duration||500,n=m+l,c,d,k=h.onChange||function(){},o=h.easing||function(q){return-Math.cos(q*Math.PI)/2+0.5},s="startValue"in h?h.startValue:0,r="endValue"in h?h.endValue:100,t=s>r;h.onStart&&h.onStart();var p=setInterval(function(){c=+new Date;d=c>n?
1:(c-m)/l;k(t?s-(s-r)*o(d):s+(r-s)*o(d));if(c>n){clearInterval(p);h.onComplete&&h.onComplete()}},10)};(function(){function h(){}var m=function(){for(var l=[function(){return new ActiveXObject("Microsoft.XMLHTTP")},function(){return new ActiveXObject("Msxml2.XMLHTTP")},function(){return new ActiveXObject("Msxml2.XMLHTTP.3.0")},function(){return new XMLHttpRequest}],n=l.length;n--;)try{if(l[n]())return l[n]}catch(c){}}();b.util.request=function(l,n){n||(n={});var c=n.method?n.method.toUpperCase():"GET",
d=n.onComplete||function(){},k=m(),o;k.onreadystatechange=function(){if(k.readyState===4){d(k);k.onreadystatechange=h}};if(c==="GET"){o=null;if(typeof n.parameters=="string")l=l+(/\?/.test(l)?"&":"?")+n.parameters}k.open(c,l,true);if(c==="POST"||c==="PUT")k.setRequestHeader("Content-Type","application/x-www-form-urlencoded");k.send(o);return k}})();(function(){var h=Math.PI/180;b.util.removeFromArray=function(m,l){var n=m.indexOf(l);n!==-1&&m.splice(n,1);return m};b.util.degreesToRadians=function(m){return m*
h};b.util.toFixed=function(m,l){return parseFloat(Number(m).toFixed(l))};b.util.getRandomInt=function(m,l){return Math.floor(Math.random()*(l-m+1))+m}})()})(this);
(function(){var e=this.fabric||(this.fabric={}),f={cx:"left",x:"left",cy:"top",y:"top",r:"radius","fill-opacity":"opacity","fill-rule":"fillRule","stroke-width":"strokeWidth",transform:"transformMatrix"};e.parseTransformAttribute=function(){function a(n,c){var d=c[0];n[0]=Math.cos(d);n[1]=Math.sin(d);n[2]=-Math.sin(d);n[3]=Math.cos(d)}function b(n,c){var d=c.length===2?c[1]:c[0];n[0]=c[0];n[3]=d}function g(n,c){n[4]=c[0];if(c.length===2)n[5]=c[1]}var h=[1,0,0,1,0,0],m=RegExp("^\\s*(?:(?:(?:(?:(matrix)\\s*\\(\\s*((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))\\s*\\))|(?:(translate)\\s*\\(\\s*((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?)))?\\s*\\))|(?:(scale)\\s*\\(\\s*((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?)))?\\s*\\))|(?:(rotate)\\s*\\(\\s*((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?)))?\\s*\\))|(?:(skewX)\\s*\\(\\s*((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))\\s*\\))|(?:(skewY)\\s*\\(\\s*((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))\\s*\\)))(?:(?:\\s+,?\\s*|,\\s*)(?:(?:(matrix)\\s*\\(\\s*((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))\\s*\\))|(?:(translate)\\s*\\(\\s*((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?)))?\\s*\\))|(?:(scale)\\s*\\(\\s*((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?)))?\\s*\\))|(?:(rotate)\\s*\\(\\s*((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?)))?\\s*\\))|(?:(skewX)\\s*\\(\\s*((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))\\s*\\))|(?:(skewY)\\s*\\(\\s*((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))\\s*\\))))*)?)\\s*$"),
l=RegExp("(?:(?:(matrix)\\s*\\(\\s*((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))\\s*\\))|(?:(translate)\\s*\\(\\s*((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?)))?\\s*\\))|(?:(scale)\\s*\\(\\s*((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?)))?\\s*\\))|(?:(rotate)\\s*\\(\\s*((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?)))?\\s*\\))|(?:(skewX)\\s*\\(\\s*((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))\\s*\\))|(?:(skewY)\\s*\\(\\s*((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))\\s*\\)))");
return function(n){var c=h.concat();if(!n||n&&!m.test(n))return c;n.replace(l,function(d){var k=RegExp("(?:(?:(matrix)\\s*\\(\\s*((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))\\s*\\))|(?:(translate)\\s*\\(\\s*((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?)))?\\s*\\))|(?:(scale)\\s*\\(\\s*((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?)))?\\s*\\))|(?:(rotate)\\s*\\(\\s*((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?)))?\\s*\\))|(?:(skewX)\\s*\\(\\s*((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))\\s*\\))|(?:(skewY)\\s*\\(\\s*((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))\\s*\\)))").exec(d).filter(function(o){return o!==
""&&o!=null});d=k[1];k=k.slice(2).map(parseFloat);switch(d){case "translate":g(c,k);break;case "rotate":a(c,k);break;case "scale":b(c,k);break;case "skewX":c[2]=k[0];break;case "skewY":c[1]=k[0];break;case "matrix":c=k;break}});return c}}();e.parseSVGDocument=function(){var a=/^(path|circle|polygon|polyline|ellipse|rect|line)$/,b=RegExp("^\\s*((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?)+)\\s*,?\\s*((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?)+)\\s*,?\\s*((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?)+)\\s*,?\\s*((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?)+)\\s*$");
return function(g,h){if(g){var m=e.util.toArray(g.getElementsByTagName("*")).filter(function(o){var s;if(s=a.test(o.tagName)){a:{for(o=o;o&&(o=o.parentNode);)if(o.nodeName==="pattern"){o=true;break a}o=false}s=!o}return s});if(!(!m||m&&!m.length)){var l=g.getAttribute("viewBox"),n=g.getAttribute("width"),c=g.getAttribute("height"),d=null,k=null;if(l&&(l=l.match(b))){parseInt(l[1],10);parseInt(l[2],10);d=parseInt(l[3],10);k=parseInt(l[4],10)}d=n?parseFloat(n):d;k=c?parseFloat(c):k;l={width:d,height:k};
m=e.parseElements(m,e.util.object.clone(l));!m||m&&!m.length||h&&h(m,l)}}}}();e.util.object.extend(e,{parseAttributes:function(a,b){if(a){var g,h,m={};if(a.parentNode&&/^g$/i.test(a.parentNode.nodeName))m=e.parseAttributes(a.parentNode,b);var l=b.reduce(function(n,c){g=a.getAttribute(c);h=parseFloat(g);if(g){if((c==="fill"||c==="stroke")&&g==="none")g="";if(c==="fill-rule")g=g==="evenodd"?"destination-over":g;if(c==="transform")g=e.parseTransformAttribute(g);if(c in f)c=f[c];n[c]=isNaN(h)?g:h}return n},
{});l=e.util.object.extend(e.parseStyleAttribute(a),l);return e.util.object.extend(m,l)}},parseElements:function(a,b){var g=a.map(function(h){var m=e[e.util.string.capitalize(h.tagName)];if(m&&m.fromElement)try{return m.fromElement(h,b)}catch(l){console.log(l.message||l)}});return g=g.filter(function(h){return h!=null})},parseStyleAttribute:function(a){var b={};if(a=a.getAttribute("style"))if(typeof a=="string"){a=a.split(";");a.pop();b=a.reduce(function(h,m){var l=m.split(":"),n=l[0].trim();l=l[1].trim();
h[n]=l;return h},{})}else for(var g in a)if(typeof a[g]!=="undefined")b[g]=a[g];return b},parsePointsAttribute:function(a){if(!a)return null;a=a.trim().split(/\s+/);a=a.reduce(function(b,g){g=g.split(",");b.push({x:parseFloat(g[0]),y:parseFloat(g[1])});return b},[]);if(a.length%2!==0)return null;return a}})})();
(function(){function e(a,b){arguments.length>0&&this.init(a,b)}var f=this.fabric||(this.fabric={});if(f.Point)console.warn("fabric.Point is already defined");else{e.prototype={constructor:e,init:function(a,b){this.x=a;this.y=b},add:function(a){return new e(this.x+a.x,this.y+a.y)},addEquals:function(a){this.x+=a.x;this.y+=a.y;return this},scalarAdd:function(a){return new e(this.x+a,this.y+a)},scalarAddEquals:function(a){this.x+=a;this.y+=a;return this},subtract:function(a){return new e(this.x-a.x,
this.y-a.y)},subtractEquals:function(a){this.x-=a.x;this.y-=a.y;return this},scalarSubtract:function(a){return new e(this.x-a,this.y-a)},scalarSubtractEquals:function(a){this.x-=a;this.y-=a;return this},multiply:function(a){return new e(this.x*a,this.y*a)},multiplyEquals:function(a){this.x*=a;this.y*=a;return this},divide:function(a){return new e(this.x/a,this.y/a)},divideEquals:function(a){this.x/=a;this.y/=a;return this},eq:function(a){return this.x==a.x&&this.y==a.y},lt:function(a){return this.x<
a.x&&this.y<a.y},lte:function(a){return this.x<=a.x&&this.y<=a.y},gt:function(a){return this.x>a.x&&this.y>a.y},gte:function(a){return this.x>=a.x&&this.y>=a.y},lerp:function(a,b){return new e(this.x+(a.x-this.x)*b,this.y+(a.y-this.y)*b)},distanceFrom:function(a){var b=this.x-a.x;a=this.y-a.y;return Math.sqrt(b*b+a*a)},min:function(a){return new e(Math.min(this.x,a.x),Math.min(this.y,a.y))},max:function(a){return new e(Math.max(this.x,a.x),Math.max(this.y,a.y))},toString:function(){return this.x+
","+this.y},setXY:function(a,b){this.x=a;this.y=b},setFromPoint:function(a){this.x=a.x;this.y=a.y},swap:function(a){var b=this.x,g=this.y;this.x=a.x;this.y=a.y;a.x=b;a.y=g}};f.Point=e}})();
(function(){function e(a){arguments.length>0&&this.init(a)}var f=this.fabric||(this.fabric={});if(f.Intersection)console.warn("fabric.Intersection is already defined");else{e.prototype.init=function(a){this.status=a;this.points=[]};e.prototype.appendPoint=function(a){this.points.push(a)};e.prototype.appendPoints=function(a){this.points=this.points.concat(a)};e.intersectLineLine=function(a,b,g,h){var m,l=(h.x-g.x)*(a.y-g.y)-(h.y-g.y)*(a.x-g.x);m=(b.x-a.x)*(a.y-g.y)-(b.y-a.y)*(a.x-g.x);g=(h.y-g.y)*
(b.x-a.x)-(h.x-g.x)*(b.y-a.y);if(g!=0){l=l/g;m=m/g;if(0<=l&&l<=1&&0<=m&&m<=1){m=new e("Intersection");m.points.push(new f.Point(a.x+l*(b.x-a.x),a.y+l*(b.y-a.y)))}else m=new e("No Intersection")}else m=l==0||m==0?new e("Coincident"):new e("Parallel");return m};e.intersectLinePolygon=function(a,b,g){for(var h=new e("No Intersection"),m=g.length,l=0;l<m;l++){var n=e.intersectLineLine(a,b,g[l],g[(l+1)%m]);h.appendPoints(n.points)}if(h.points.length>0)h.status="Intersection";return h};e.intersectPolygonPolygon=
function(a,b){for(var g=new e("No Intersection"),h=a.length,m=0;m<h;m++){var l=e.intersectLinePolygon(a[m],a[(m+1)%h],b);g.appendPoints(l.points)}if(g.points.length>0)g.status="Intersection";return g};e.intersectPolygonRectangle=function(a,b,g){var h=b.min(g),m=b.max(g);g=new f.Point(m.x,h.y);var l=new f.Point(h.x,m.y);b=e.intersectLinePolygon(h,g,a);g=e.intersectLinePolygon(g,m,a);m=e.intersectLinePolygon(m,l,a);a=e.intersectLinePolygon(l,h,a);h=new e("No Intersection");h.appendPoints(b.points);
h.appendPoints(g.points);h.appendPoints(m.points);h.appendPoints(a.points);if(h.points.length>0)h.status="Intersection";return h};f.Intersection=e}})();
(function(){function e(a){a?this._tryParsingColor(a):this.setSource([0,0,0,1])}var f=this.fabric||(this.fabric={});if(f.Color)console.warn("fabric.Color is already defined.");else{f.Color=e;e.prototype._tryParsingColor=function(a){var b=e.sourceFromHex(a);b||(b=e.sourceFromRgb(a));b&&this.setSource(b)};e.prototype.getSource=function(){return this._source};e.prototype.setSource=function(a){this._source=a};e.prototype.toRgb=function(){var a=this.getSource();return"rgb("+a[0]+","+a[1]+","+a[2]+")"};
e.prototype.toRgba=function(){var a=this.getSource();return"rgba("+a[0]+","+a[1]+","+a[2]+","+a[3]+")"};e.prototype.toHex=function(){var a=this.getSource(),b=a[0].toString(16);b=b.length==1?"0"+b:b;var g=a[1].toString(16);g=g.length==1?"0"+g:g;a=a[2].toString(16);a=a.length==1?"0"+a:a;return b.toUpperCase()+g.toUpperCase()+a.toUpperCase()};e.prototype.getAlpha=function(){return this.getSource()[3]};e.prototype.setAlpha=function(a){var b=this.getSource();b[3]=a;this.setSource(b);return this};e.prototype.toGrayscale=
function(){var a=this.getSource(),b=parseInt((a[0]*0.3+a[1]*0.59+a[2]*0.11).toFixed(0),10);this.setSource([b,b,b,a[3]]);return this};e.prototype.toBlackWhite=function(a){var b=this.getSource(),g=(b[0]*0.3+b[1]*0.59+b[2]*0.11).toFixed(0);b=b[3];a=a||127;g=Number(g)<Number(a)?0:255;this.setSource([g,g,g,b]);return this};e.prototype.overlayWith=function(a){a=new e(a);var b=[],g=this.getAlpha(),h=this.getSource();a=a.getSource();for(var m=0;m<3;m++)b.push(Math.round(h[m]*0.5+a[m]*0.5));b[4]=g;this.setSource(b);
return this};e.reRGBa=/^rgba?\((\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})(?:\s*,\s*(\d+(?:\.\d+)?))?\)$/;e.reHex=/^#?([0-9a-f]{6}|[0-9a-f]{3})$/i;e.fromRgb=function(a){return e.fromSource(e.sourceFromRgb(a))};e.sourceFromRgb=function(a){if(a=a.match(e.reRGBa))return[parseInt(a[1],10),parseInt(a[2],10),parseInt(a[3],10),a[4]?parseFloat(a[4]):1]};e.fromRgba=e.fromRgb;e.fromHex=function(a){return e.fromSource(e.sourceFromHex(a))};e.sourceFromHex=function(a){if(a.match(e.reHex)){var b=a.slice(a.indexOf("#")+
1),g=b.length===3;a=g?b.charAt(0)+b.charAt(0):b.substring(0,2);var h=g?b.charAt(1)+b.charAt(1):b.substring(2,4);b=g?b.charAt(2)+b.charAt(2):b.substring(4,6);return[parseInt(a,16),parseInt(h,16),parseInt(b,16),1]}};e.fromSource=function(a){var b=new e;b.setSource(a);return b}}})();
(function(){var e=this.window,f=e.document,a=fabric.util.string.capitalize,b=fabric.util.string.camelize,g=this.Canvas||(this.Canvas={});if(fabric.Element)console.warn("fabric.Element is already defined.");else{var h=Error("Could not initialize `canvas` element"),m=fabric.util.getPointer,l={tr:"ne-resize",br:"se-resize",bl:"sw-resize",tl:"nw-resize",ml:"w-resize",mt:"n-resize",mr:"e-resize",mb:"s-resize"};(function(){var c=f.createElement("canvas"),d,k,o;c.width=c.height=300;if(c.getContext)if(k=
c.getContext("2d")){d=new Date;for(o=200;o--;)k.clearRect(0,0,300,300);k=new Date-d;d=new Date;for(o=200;o--;)c.width=c.height;if(new Date-d<k)return"width"}})();var n=function(){var c=f.createElement("canvas");if(c&&c.getContext)if(c=c.getContext("2d")){try{c.fillStyle="transparent";return true}catch(d){}return false}}();fabric.Element=function(c,d){this._groupSelector=null;this._aObjects=[];this._activeGroup=this._currentTransform=this._oElement=this._oContext=null;this._oConfig={width:300,height:150};
d=d||{};this._initElement(c);this._initConfig(d);d.overlayImage&&this.setOverlayImage(d.overlayImage);if(d.afterRender)this.afterRender=d.afterRender;this._createCanvasBackground();this._createCanvasContainer();this._initEvents();this.calcOffset()};fabric.util.object.extend(fabric.Element.prototype,{selectionColor:"rgba(100,100,255,0.3)",selectionBorderColor:"rgba(255,255,255,0.3)",selectionLineWidth:1,backgroundColor:"rgba(255,255,255,1)",includeDefaultValues:true,shouldCacheImages:false,CANVAS_WIDTH:600,
CANVAS_HEIGHT:600,onBeforeScaleRotate:function(){},calcOffset:function(){this._offset=fabric.util.getElementOffset(this.getElement());return this},setOverlayImage:function(c,d){if(c){var k=this,o=new Image;o.onload=function(){k.overlayImage=o;d&&d();o=o.onload=null};o.src=c}return this},_initElement:function(c){this._oElement=fabric.util.getById(c)||f.createElement("canvas");typeof this._oElement.getContext==="undefined"&&G_vmlCanvasManager.initElement(this._oElement);if(typeof this._oElement.getContext===
"undefined")throw h;if(!(this._oContextTop=this._oElement.getContext("2d")))throw h;c=this._oElement.width||0;var d=this._oElement.height||0;this._initWrapperElement(c,d);this._setElementStyle(c,d)},_initWrapperElement:function(c,d){var k=fabric.util.wrapElement(this.getElement(),"div",{"class":"canvas_container"});fabric.util.setStyle(k,{width:c+"px",height:d+"px"});fabric.util.makeElementUnselectable(k);this.wrapper=k},_setElementStyle:function(c,d){fabric.util.setStyle(this.getElement(),{position:"absolute",
width:c+"px",height:d+"px",left:0,top:0})},_initConfig:function(c){fabric.util.object.extend(this._oConfig,c||{});this._oConfig.width=parseInt(this._oElement.width,10)||0;this._oConfig.height=parseInt(this._oElement.height,10)||0;this._oElement.style.width=this._oConfig.width+"px";this._oElement.style.height=this._oConfig.height+"px"},_initEvents:function(){var c=this;this._onMouseDown=function(d){c.__onMouseDown(d)};this._onMouseUp=function(d){c.__onMouseUp(d)};this._onMouseMove=function(d){c.__onMouseMove(d)};
this._onResize=function(){c.calcOffset()};fabric.util.addListener(this._oElement,"mousedown",this._onMouseDown);fabric.util.addListener(f,"mousemove",this._onMouseMove);fabric.util.addListener(f,"mouseup",this._onMouseUp);fabric.util.addListener(e,"resize",this._onResize)},_createCanvasElement:function(c){var d=f.createElement("canvas");if(d){d.className=c;c=this._oElement.parentNode.insertBefore(d,this._oElement);c.width=this.getWidth();c.height=this.getHeight();c.style.width=this.getWidth()+"px";
c.style.height=this.getHeight()+"px";c.style.position="absolute";c.style.left=0;c.style.top=0;typeof d.getContext==="undefined"&&G_vmlCanvasManager.initElement(d);if(typeof d.getContext==="undefined")throw h;fabric.util.makeElementUnselectable(c);return c}},_createCanvasContainer:function(){var c=this._createCanvasElement("canvas-container");this._oContextContainerEl=c;this._oContextContainer=c.getContext("2d")},_createCanvasBackground:function(){var c=this._createCanvasElement("canvas-container");
this._oContextBackgroundEl=c;this._oContextBackground=c.getContext("2d")},getWidth:function(){return this._oConfig.width},getHeight:function(){return this._oConfig.height},setWidth:function(c){return this._setDimension("width",c)},setHeight:function(c){return this._setDimension("height",c)},setDimensions:function(c){for(var d in c)this._setDimension(d,c[d]);return this},_setDimension:function(c,d){this._oContextContainerEl[c]=d;this._oContextContainerEl.style[c]=d+"px";this._oContextBackgroundEl[c]=
d;this._oContextBackgroundEl.style[c]=d+"px";this._oElement[c]=d;this._oElement.style[c]=d+"px";this._oElement.parentNode.style[c]=d+"px";this._oConfig[c]=d;this.calcOffset();this.renderAll();return this},__onMouseUp:function(c){if(this._currentTransform){var d=this._currentTransform.target;if(d.__scaling){fabric.util.fireEvent("object:scaled",{target:d});d.__scaling=false}for(var k=0,o=this._aObjects.length;k<o;++k)this._aObjects[k].setCoords();if(d.hasStateChanged()){d.isMoving=false;fabric.util.fireEvent("object:modified",
{target:d})}}this._currentTransform=null;this._groupSelector&&this._findSelectedObjects(c);if(k=this.getActiveGroup()){k.hasStateChanged()&&k.containsPoint(this.getPointer(c))&&fabric.util.fireEvent("group:modified",{target:k});k.setObjectsCoords();k.set("isMoving",false);this._setCursor("default")}this._groupSelector=null;this.renderAll();this._setCursorFromEvent(c,d);this._setCursor("");var s=this;setTimeout(function(){s._setCursorFromEvent(c,d)},50)},shouldClearSelection:function(c){var d=this.findTarget(c),
k=this.getActiveGroup();return!d||d&&k&&!k.contains(d)&&k!==d&&!c.shiftKey},__onMouseDown:function(c){if(!this._currentTransform){var d=this.findTarget(c),k=this.getPointer(c),o=this.getActiveGroup();if(this.shouldClearSelection(c)){this._groupSelector={ex:k.x,ey:k.y,top:0,left:0};this.deactivateAllWithDispatch()}else{d.saveState();d._findTargetCorner(c,this._offset)&&this.onBeforeScaleRotate(d);this._setupCurrentTransform(c,d);if(c.shiftKey&&(o||this.getActiveObject()))this._handleGroupLogic(c,d);
else{d!==this.getActiveGroup()&&this.deactivateAll();this.setActiveObject(d)}}this.renderAll()}},getElement:function(){return this._oElement},deactivateAllWithDispatch:function(){var c=this.getActiveGroup();c&&fabric.util.fireEvent("before:group:destroyed",{target:c});this.deactivateAll();c&&fabric.util.fireEvent("after:group:destroyed");fabric.util.fireEvent("selection:cleared");return this},_setupCurrentTransform:function(c,d){var k="drag",o,s=m(c);if(o=d._findTargetCorner(c,this._offset))k=/ml|mr/.test(o)?
"scaleX":/mt|mb/.test(o)?"scaleY":"rotate";this._currentTransform={target:d,action:k,scaleX:d.scaleX,scaleY:d.scaleY,offsetX:s.x-d.left,offsetY:s.y-d.top,ex:s.x,ey:s.y,left:d.left,top:d.top,theta:d.theta,width:d.width*d.scaleX};this._currentTransform.original={left:d.left,top:d.top}},_handleGroupLogic:function(c,d){if(d.isType("group")){d=this.findTarget(c,true);if(!d||d.isType("group"))return}var k=this.getActiveGroup();if(k){if(k.contains(d)){k.remove(d);d.setActive(false);k.size()===1&&this.removeActiveGroup()}else k.add(d);
fabric.util.fireEvent("group:selected",{target:k});k.setActive(true)}else{if(this._activeObject)if(d!==this._activeObject){this.setActiveGroup(new fabric.Group([this._activeObject,d]));k=this.getActiveGroup()}d.setActive(true)}k&&k.saveCoords()},__onMouseMove:function(c){if(this._groupSelector!==null){var d=m(c);this._groupSelector.left=d.x-this._offset.left-this._groupSelector.ex;this._groupSelector.top=d.y-this._offset.top-this._groupSelector.ey;this.renderTop()}else if(this._currentTransform){d=
m(c);var k=d.x;d=d.y;this._currentTransform.target.isMoving=true;if(this._currentTransform.action==="rotate"){c.shiftKey||this._rotateObject(k,d);this._scaleObject(k,d)}else if(this._currentTransform.action==="scaleX")this._scaleObject(k,d,"x");else this._currentTransform.action==="scaleY"?this._scaleObject(k,d,"y"):this._translateObject(k,d);this.renderAll()}else{k=this._oElement.style;if(d=this.findTarget(c)){this._setCursorFromEvent(c,d);d.isActive()&&d.setCornersVisibility&&d.setCornersVisibility(true)}else{for(c=
this._aObjects.length;c--;)this._aObjects[c].active||this._aObjects[c].setActive(false);k.cursor="default"}}},_translateObject:function(c,d){var k=this._currentTransform.target;k.set("left",c-this._currentTransform.offsetX);k.set("top",d-this._currentTransform.offsetY)},_scaleObject:function(c,d,k){var o=Math.sqrt(Math.pow(this._currentTransform.ey-this._currentTransform.top-this._offset.top,2)+Math.pow(this._currentTransform.ex-this._currentTransform.left-this._offset.left,2));c=Math.sqrt(Math.pow(d-
this._currentTransform.top-this._offset.top,2)+Math.pow(c-this._currentTransform.left-this._offset.left,2));d=this._currentTransform.target;d.__scaling=true;if(k)if(k==="x")d.set("scaleX",this._currentTransform.scaleX*c/o);else k==="y"&&d.set("scaleY",this._currentTransform.scaleY*c/o);else{d.set("scaleX",this._currentTransform.scaleX*c/o);d.set("scaleY",this._currentTransform.scaleY*c/o)}},_rotateObject:function(c,d){var k=Math.atan2(this._currentTransform.ey-this._currentTransform.top-this._offset.top,
this._currentTransform.ex-this._currentTransform.left-this._offset.left);this._currentTransform.target.set("theta",Math.atan2(d-this._currentTransform.top-this._offset.top,c-this._currentTransform.left-this._offset.left)-k+this._currentTransform.theta)},_setCursor:function(c){this._oElement.style.cursor=c},_setCursorFromEvent:function(c,d){var k=this._oElement.style;if(d){var o=this.getActiveGroup();if(o=!!d._findTargetCorner&&(!o||!o.contains(d))&&d._findTargetCorner(c,this._offset))if(o in l)k.cursor=
l[o];else{k.cursor="default";return false}else k.cursor="move"}else{k.cursor="default";return false}return true},_draw:function(c,d){d&&d.render(c)},_drawSelection:function(){var c=this._groupSelector.left,d=this._groupSelector.top,k=Math.abs(c),o=Math.abs(d);this._oContextTop.fillStyle=this.selectionColor;this._oContextTop.fillRect(this._groupSelector.ex-(c>0?0:-c),this._groupSelector.ey-(d>0?0:-d),k,o);this._oContextTop.lineWidth=this.selectionLineWidth;this._oContextTop.strokeStyle=this.selectionBorderColor;
this._oContextTop.strokeRect(this._groupSelector.ex+0.5-(c>0?0:k),this._groupSelector.ey+0.5-(d>0?0:o),k,o)},_findSelectedObjects:function(){var c=[],d=this._groupSelector.ex,k=this._groupSelector.ey,o=d+this._groupSelector.left,s=k+this._groupSelector.top,r=new fabric.Point(Math.min(d,o),Math.min(k,s));k=new fabric.Point(Math.max(d,o),Math.max(k,s));o=0;for(s=this._aObjects.length;o<s;++o){d=this._aObjects[o];if(d.intersectsWithRect(r,k)||d.isContainedWithinRect(r,k)){d.setActive(true);c.push(d)}}if(c.length===
1){this.setActiveObject(c[0]);fabric.util.fireEvent("object:selected",{target:c[0]})}else if(c.length>1){c=new fabric.Group(c);this.setActiveGroup(c);c.saveCoords();fabric.util.fireEvent("group:selected",{target:c})}this.renderAll()},add:function(){this._aObjects.push.apply(this._aObjects,arguments);this.renderAll();return this},insertAt:function(c,d){this._aObjects.splice(d,0,c);this.renderAll();return this},getObjects:function(){return this._aObjects},getContext:function(){return this._oContextTop},
clearContext:function(c){c.clearRect(0,0,this._oConfig.width,this._oConfig.height);return this},clear:function(){this._aObjects.length=0;this.clearContext(this._oContextTop);this.clearContext(this._oContextContainer);this.renderAll();return this},renderAll:function(c){var d=this._oConfig.width,k=this._oConfig.height,o=c?this._oContextTop:this._oContextContainer;this.clearContext(this._oContextTop);o!==this._oContextTop&&this.clearContext(o);if(c){if(!n&&this.backgroundColor==="transparent")var s=
true;if(!s)o.fillStyle=this.backgroundColor;o.fillRect(0,0,d,k)}c=this._aObjects.length;d=this.getActiveGroup();if(c)for(k=0;k<c;++k)if(!d||d&&!d.contains(this._aObjects[k]))this._draw(o,this._aObjects[k]);d&&this._draw(this._oContextTop,d);this.overlayImage&&this._oContextTop.drawImage(this.overlayImage,0,0);this.afterRender&&this.afterRender();return this},renderTop:function(){this.clearContext(this._oContextTop);this.overlayImage&&this._oContextTop.drawImage(this.overlayImage,0,0);this._groupSelector&&
this._drawSelection();var c=this.getActiveGroup();c&&c.render(this._oContextTop);this.afterRender&&this.afterRender();return this},containsPoint:function(c,d){var k=this.getPointer(c),o=this._normalizePointer(d,k);k=o.x;o=o.y;var s=d._getImageLines(d.oCoords);if((k=d._findCrossPoints(k,o,s))&&k%2===1||d._findTargetCorner(c,this._offset))return true;return false},_normalizePointer:function(c,d){var k=this.getActiveGroup(),o=d.x,s=d.y;if(k&&c.type!=="group"&&k.contains(c)){o-=k.left;s-=k.top}return{x:o,
y:s}},findTarget:function(c,d){var k;this.getPointer(c);var o=this.getActiveGroup();if(o&&!d&&this.containsPoint(c,o))return k=o;for(o=this._aObjects.length;o--;)if(this.containsPoint(c,this._aObjects[o])){this.relatedTarget=k=this._aObjects[o];break}return k},toDataURL:function(c){var d;c||(c="png");if(c==="jpeg"||c==="png"){this.renderAll(true);d=this.getElement().toDataURL("image/"+c)}return d},toDataURLWithMultiplier:function(c,d){var k=this.getWidth(),o=this.getHeight(),s=k*d,r=o*d,t=this.getActiveObject();
this.setWidth(s).setHeight(r);this._oContextTop.scale(d,d);t&&this.deactivateAll().renderAll();s=this.toDataURL(c);this._oContextTop.scale(1/d,1/d);this.setWidth(k).setHeight(o);t&&this.setActiveObject(t);this.renderAll();return s},getPointer:function(c){c=m(c);return{x:c.x-this._offset.left,y:c.y-this._offset.top}},getCenter:function(){return{top:this.getHeight()/2,left:this.getWidth()/2}},centerObjectH:function(c){c.set("left",this.getCenter().left);this.renderAll();return this},fxCenterObjectH:function(c){var d=
this,k=new APE.anim.Animation,o=c.get("left"),s=d.getCenter().left-o;k.run=function(r){c.set("left",o+s*r);d.renderAll()};k.onend=function(){c.setCoords()};k.duration=500;k.transition=APE.anim.Transitions.decel;k.start();return this},centerObjectV:function(c){c.set("top",this.getCenter().top);this.renderAll();return this},fxCenterObjectV:function(c){var d=this,k=new APE.anim.Animation,o=c.get("top"),s=d.getCenter().top-o;k.run=function(r){c.set("top",o+s*r).setCoords();d.renderAll()};k.onend=function(){c.setCoords()};
k.duration=500;k.transition=APE.anim.Transitions.decel;k.start()},straightenObject:function(c){c.straighten();this.renderAll();return this},fxStraightenObject:function(c){c.fxStraighten({onChange:this.renderAll.bind(this)});return this},toJSON:function(){return JSON.stringify(this.toObject())},toDatalessJSON:function(){return JSON.stringify(this.toDatalessObject())},toObject:function(){return this._toObjectMethod("toObject")},toDatalessObject:function(){return this._toObjectMethod("toDatalessObject")},
_toObjectMethod:function(c){return{objects:this._aObjects.map(function(d){if(!this.includeDefaultValues){var k=d.includeDefaultValues;d.includeDefaultValues=false}var o=d[c]();if(!this.includeDefaultValues)d.includeDefaultValues=k;return o},this),background:this.backgroundColor}},isEmpty:function(){return this._aObjects.length===0},loadFromJSON:function(c,d){if(c){var k=JSON.parse(c);if(!(!k||k&&!k.objects)){this.clear();var o=this;this._enlivenObjects(k.objects,function(){o.backgroundColor=k.background;
d&&d()});return this}}},_enlivenObjects:function(c,d){var k=0,o=c.filter(function(r){return r.type==="image"}).length,s=this;c.forEach(function(r){if(r.type)switch(r.type){case "image":case "font":fabric[a(r.type)].fromObject(r,function(p){s.add(p);++k===o&&d&&d()});break;default:var t=fabric[b(a(r.type))];t&&t.fromObject&&s.add(t.fromObject(r));break}});o===0&&d&&d()},loadFromDatalessJSON:function(c,d){if(c){var k=typeof c==="string"?c.evalJSON():c;if(!(!k||k&&!k.objects)){this.clear();this._enlivenDatalessObjects(k.objects,
d)}}},_enlivenDatalessObjects:function(c,d){function k(p,q){o.insertAt(p,q);p.setCoords();++s===r&&d&&d()}var o=this,s=0,r=c.length;try{c.forEach(function(p,q){var v=p.paths?"paths":"path",u=p[v];delete p[v];if(typeof u!=="string")switch(p.type){case "image":case "text":g[p.type.capitalize()].fromObject(p,function(w){k(w,q)});break;default:(v=g[p.type.capitalize().camelize()])&&v.fromObject&&k(v.fromObject(p),q);break}else if(p.type==="image")o.loadImageFromURL(u,function(w){w.setSourcePath(u);fabric.util.object.extend(w,
p);w.setAngle(p.angle);k(w,q)});else if(p.type==="text"){p.path=u;var x=fabric.Text.fromObject(p);e.__context=o;fabric.util.getScript(u,function(){Prototype.Browser.Opera?setTimeout(function(){k(x,q)},500):k(x,q)})}else o.loadSVGFromURL(u,function(w){w=w.length>1?new fabric.PathGroup(w,p):w[0];w.setSourcePath(u);if(!(w instanceof fabric.PathGroup)){fabric.util.object.extend(w,p);typeof p.angle!=="undefined"&&w.setAngle(p.angle)}k(w,q)})},this)}catch(t){console.log(t.message)}},loadImageFromURL:function(){var c=
{};return function(d,k){function o(){var t=f.getElementById(c[d]);t.width&&t.height?k(new fabric.Image(t)):setTimeout(o,50)}var s=this;if(c[d])o();else{var r=new Image;r.onload=function(){r.onload=null;s._resizeImageToFit(r);var t=new fabric.Image(r);k(t)};r.className="canvas-img-clone";r.src=d;if(this.shouldCacheImages)c[d]=Element.identify(r);f.body.appendChild(r)}}}(),loadSVGFromURL:function(c,d){function k(r){if(r=r.responseXML)(r=r.documentElement)&&fabric.parseSVGDocument(r,function(t,p){s.cache.set(c,
{objects:t.invoke("toObject"),options:p});d(t,p)})}function o(){console.log("ERROR!")}var s=this;c=c.replace(/^\n\s*/,"").replace(/\?.*$/,"").trim();this.cache.has(c,function(r){if(r)s.cache.get(c,function(t){t=s._enlivenCachedObject(t);d(t.objects,t.options)});else new Ajax.Request(c,{method:"get",onComplete:k,onFailure:o})})},_enlivenCachedObject:function(c){var d=c.objects;c=c.options;d=d.map(function(k){return g[k.type.capitalize()].fromObject(k)});return{objects:d,options:c}},remove:function(c){fabric.util.removeFromArray(this._aObjects,
c);this.renderAll();return c},fxRemove:function(c,d){var k=this;c.fxRemove({onChange:this.renderAll.bind(this),onComplete:function(){k.remove(c);typeof d==="function"&&d()}});return this},sendToBack:function(c){fabric.util.removeFromArray(this._aObjects,c);this._aObjects.unshift(c);return this.renderAll()},bringToFront:function(c){fabric.util.removeFromArray(this._aObjects,c);this._aObjects.push(c);return this.renderAll()},sendBackwards:function(c){var d=this._aObjects.indexOf(c),k=d;if(d!==0){for(d=
d-1;d>=0;--d)if(c.intersectsWithObject(this._aObjects[d])){k=d;break}fabric.util.removeFromArray(this._aObjects,c);this._aObjects.splice(k,0,c)}return this.renderAll()},bringForward:function(c){var d=this.getObjects(),k=d.indexOf(c),o=k;if(k!==d.length-1){k=k+1;for(var s=this._aObjects.length;k<s;++k)if(c.intersectsWithObject(d[k])){o=k;break}fabric.util.removeFromArray(d,c);d.splice(o,0,c)}this.renderAll()},setActiveObject:function(c){this._activeObject&&this._activeObject.setActive(false);this._activeObject=
c;c.setActive(true);this.renderAll();fabric.util.fireEvent("object:selected",{target:c});return this},getActiveObject:function(){return this._activeObject},removeActiveObject:function(){this._activeObject&&this._activeObject.setActive(false);this._activeObject=null;return this},setActiveGroup:function(c){this._activeGroup=c;return this},getActiveGroup:function(){return this._activeGroup},removeActiveGroup:function(){var c=this.getActiveGroup();c&&c.destroy();return this.setActiveGroup(null)},item:function(c){return this.getObjects()[c]},
deactivateAll:function(){for(var c=this.getObjects(),d=0,k=c.length;d<k;d++)c[d].setActive(false);this.removeActiveGroup();this.removeActiveObject();return this},complexity:function(){return this.getObjects().reduce(function(c,d){c+=d.complexity?d.complexity():0;return c},0)},dispose:function(){this.clear();fabric.util.removeListener(this.getElement(),"mousedown",this._onMouseDown);fabric.util.removeListener(f,"mouseup",this._onMouseUp);fabric.util.removeListener(f,"mousemove",this._onMouseMove);
fabric.util.removeListener(e,"resize",this._onResize);return this},clone:function(c){var d=f.createElement("canvas");d.width=this.getWidth();d.height=this.getHeight();var k=this.__clone||(this.__clone=new fabric.Element(d));return k.loadFromJSON(this.toJSON(),function(){c&&c(k)})},_toDataURL:function(c,d){this.clone(function(k){d(k.toDataURL(c))})},_toDataURLWithMultiplier:function(c,d,k){this.clone(function(o){k(o.toDataURLWithMultiplier(c,d))})},_resizeImageToFit:function(c){var d=c.width||c.offsetWidth,
k=c.height||c.offsetHeight,o=this.getWidth()/d,s=this.getHeight()/k;if(d&&k){c.width=d*o;c.height=k*s}},cache:{has:function(c,d){d(false)},get:function(){},set:function(){}}});fabric.Element.prototype.toString=function(){return"#<fabric.Element ("+this.complexity()+"): { objects: "+this.getObjects().length+" }>"};fabric.util.object.extend(fabric.Element,{EMPTY_JSON:'{"objects": [], "background": "white"}',toGrayscale:function(c){var d=c.getContext("2d");c=d.getImageData(0,0,c.width,c.height);var k=
c.data,o=c.width,s=c.height,r,t;for(i=0;i<o;i++)for(j=0;j<s;j++){r=i*4*s+j*4;t=(k[r]+k[r+1]+k[r+2])/3;k[r]=t;k[r+1]=t;k[r+2]=t}d.putImageData(c,0,0)},supports:function(c){var d=f.createElement("canvas");if(!d||!d.getContext)return null;var k=d.getContext("2d");if(!k)return null;switch(c){case "getImageData":return typeof k.getImageData!=="undefined";case "toDataURL":return typeof d.toDataURL!=="undefined";default:return null}}})}})();
(function(){var e=this.fabric||(this.fabric={});if(!e.Object){var f=Array.prototype.slice;e.Object=e.util.createClass({type:"object",includeDefaultValues:true,NUM_FRACTION_DIGITS:2,FX_DURATION:500,FX_TRANSITION:"decel",MIN_SCALE_LIMIT:0.1,stateProperties:"top left width height scaleX scaleY flipX flipY theta angle opacity cornersize fill overlayFill stroke strokeWidth fillRule borderScaleFactor transformMatrix".split(" "),options:{top:0,left:0,width:100,height:100,scaleX:1,scaleY:1,flipX:false,flipY:false,
theta:0,opacity:1,angle:0,cornersize:10,padding:0,borderColor:"rgba(102,153,255,0.75)",cornerColor:"rgba(102,153,255,0.5)",fill:"rgb(0,0,0)",overlayFill:null,stroke:null,strokeWidth:1,fillRule:"source-over",borderOpacityWhenMoving:0.4,borderScaleFactor:1,transformMatrix:null},callSuper:function(a){var b=this.constructor.superclass.prototype[a];return arguments.length>1?b.apply(this,f.call(arguments,1)):b.call(this)},initialize:function(a){this.setOptions(a);this._importProperties();this.originalState=
{};this.setCoords();this.saveState()},setOptions:function(a){this.options=e.util.object.extend(this._getOptions(),a)},_getOptions:function(){return e.util.object.extend(e.util.object.clone(this._getSuperOptions()),this.options)},_getSuperOptions:function(){var a=this.constructor;if(a)if(a=a.superclass)if((a=a.prototype)&&typeof a._getOptions=="function")return a._getOptions();return{}},_importProperties:function(){this.stateProperties.forEach(function(a){a==="angle"?this.setAngle(this.options[a]):
this[a]=this.options[a]},this)},transform:function(a){a.globalAlpha=this.opacity;a.translate(this.left,this.top);a.rotate(this.theta);a.scale(this.scaleX*(this.flipX?-1:1),this.scaleY*(this.flipY?-1:1))},toJSON:function(){return JSON.stringify(this.toObject())},toObject:function(){var a=e.util.toFixed;a={type:this.type,left:a(this.left,this.NUM_FRACTION_DIGITS),top:a(this.top,this.NUM_FRACTION_DIGITS),width:a(this.width,this.NUM_FRACTION_DIGITS),height:a(this.height,this.NUM_FRACTION_DIGITS),fill:this.fill,
overlayFill:this.overlayFill,stroke:this.stroke,strokeWidth:this.strokeWidth,scaleX:a(this.scaleX,this.NUM_FRACTION_DIGITS),scaleY:a(this.scaleY,this.NUM_FRACTION_DIGITS),angle:a(this.getAngle(),this.NUM_FRACTION_DIGITS),flipX:this.flipX,flipY:this.flipY,opacity:a(this.opacity,this.NUM_FRACTION_DIGITS)};this.includeDefaultValues||(a=this._removeDefaultValues(a));return a},toDatalessObject:function(){return this.toObject()},_removeDefaultValues:function(a){var b=e.Object.prototype.options;this.stateProperties.forEach(function(g){a[g]===
b[g]&&delete a[g]});return a},isActive:function(){return!!this.active},setActive:function(a){this.active=!!a;return this},toString:function(){return"#<fabric."+e.util.string.capitalize(this.type)+">"},set:function(a,b){if((a==="scaleX"||a==="scaleY")&&b<this.MIN_SCALE_LIMIT)b=this.MIN_SCALE_LIMIT;if(a==="angle")this.setAngle(b);else this[a]=b;return this},toggle:function(a){var b=this.get(a);typeof b==="boolean"&&this.set(a,!b);return this},setSourcePath:function(a){this.sourcePath=a;return this},
get:function(a){return a==="angle"?this.getAngle():this[a]},render:function(a,b){if(!(this.width===0||this.height===0)){a.save();var g=this.transformMatrix;g&&a.setTransform(g[0],g[1],g[2],g[3],g[4],g[5]);b||this.transform(a);if(this.stroke){a.lineWidth=this.strokeWidth;a.strokeStyle=this.stroke}if(this.overlayFill)a.fillStyle=this.overlayFill;else if(this.fill)a.fillStyle=this.fill;this._render(a);if(this.active&&!b){this.drawBorders(a);this.drawCorners(a)}a.restore()}},getWidth:function(){return this.width*
(function(){function d(n){return n<10?"0"+n:n}function q(n){m.lastIndex=0;return m.test(n)?'"'+n.replace(m,function(p){var r=a[p];return typeof r==="string"?r:"\\u"+("0000"+p.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+n+'"'}function g(n,p){var r,s,t,b,f=c,l,o=p[n];if(o&&typeof o==="object"&&typeof o.toJSON==="function")o=o.toJSON(n);if(typeof e==="function")o=e.call(p,n,o);switch(typeof o){case "string":return q(o);case "number":return isFinite(o)?String(o):"null";case "boolean":case "null":return String(o);
case "object":if(!o)return"null";c+=h;l=[];if(Object.prototype.toString.apply(o)==="[object Array]"){b=o.length;for(r=0;r<b;r+=1)l[r]=g(r,o)||"null";t=l.length===0?"[]":c?"[\n"+c+l.join(",\n"+c)+"\n"+f+"]":"["+l.join(",")+"]";c=f;return t}if(e&&typeof e==="object"){b=e.length;for(r=0;r<b;r+=1){s=e[r];if(typeof s==="string")if(t=g(s,o))l.push(q(s)+(c?": ":":")+t)}}else for(s in o)if(Object.hasOwnProperty.call(o,s))if(t=g(s,o))l.push(q(s)+(c?": ":":")+t);t=l.length===0?"{}":c?"{\n"+c+l.join(",\n"+c)+
"\n"+f+"}":"{"+l.join(",")+"}";c=f;return t}}if(typeof Date.prototype.toJSON!=="function"){Date.prototype.toJSON=function(){return isFinite(this.valueOf())?this.getUTCFullYear()+"-"+d(this.getUTCMonth()+1)+"-"+d(this.getUTCDate())+"T"+d(this.getUTCHours())+":"+d(this.getUTCMinutes())+":"+d(this.getUTCSeconds())+"Z":null};String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(){return this.valueOf()}}var k=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
m=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,c,h,a={"\u0008":"\\b","\t":"\\t","\n":"\\n","\u000c":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},e;if(typeof JSON.stringify!=="function")JSON.stringify=function(n,p,r){var s;h=c="";if(typeof r==="number")for(s=0;s<r;s+=1)h+=" ";else if(typeof r==="string")h=r;if((e=p)&&typeof p!=="function"&&(typeof p!=="object"||typeof p.length!=="number"))throw Error("JSON.stringify");return g("",
{"":n})};if(typeof JSON.parse!=="function")JSON.parse=function(n,p){function r(t,b){var f,l,o=t[b];if(o&&typeof o==="object")for(f in o)if(Object.hasOwnProperty.call(o,f)){l=r(o,f);if(l!==undefined)o[f]=l;else delete o[f]}return p.call(t,b,o)}var s;n=String(n);k.lastIndex=0;if(k.test(n))n=n.replace(k,function(t){return"\\u"+("0000"+t.charCodeAt(0).toString(16)).slice(-4)});if(/^[\],:{}\s]*$/.test(n.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,
"]").replace(/(?:^|:|,)(?:\s*\[)+/g,""))){s=eval("("+n+")");return typeof p==="function"?r({"":s},""):s}throw new SyntaxError("JSON.parse");}})();
(function(){function d(c,h){for(var a in h)c[a]=h[a];return c}function q(c,h){var a=document.createElement(c);for(var e in h)if(e==="class")a.className=h[e];else if(e==="for")a.htmlFor=h[e];else a.setAttribute(e,h[e]);return a}function g(){return false}var k=this.fabric||(this.fabric={}),m=Array.prototype.slice;k.util={};if(!Array.prototype.indexOf)Array.prototype.indexOf=function(c,h){var a=this.length>>>0;h=Number(h)||0;h=Math[h<0?"ceil":"floor"](h);if(h<0)h+=a;for(;h<a;h++)if(h in this&&this[h]===
c)return h;return-1};if(!Array.prototype.forEach)Array.prototype.forEach=function(c,h){for(var a=0,e=this.length>>>0;a<e;a++)a in this&&c.call(h,this[a],a,this)};if(!Array.prototype.map)Array.prototype.map=function(c,h){for(var a=[],e=0,n=this.length>>>0;e<n;e++)if(e in this)a[e]=c.call(h,this[e],e,this);return a};if(!Array.prototype.every)Array.prototype.every=function(c,h){for(var a=0,e=this.length>>>0;a<e;a++)if(a in this&&!c.call(h,this[a],a,this))return false;return true};if(!Array.prototype.some)Array.prototype.some=
function(c,h){for(var a=0,e=this.length>>>0;a<e;a++)if(a in this&&c.call(h,this[a],a,this))return true;return false};if(!Array.prototype.filter)Array.prototype.filter=function(c,h){for(var a=[],e,n=0,p=this.length>>>0;n<p;n++)if(n in this){e=this[n];c.call(h,e,n,this)&&a.push(e)}return res};if(!Array.prototype.reduce)Array.prototype.reduce=function(c){var h=this.length>>>0,a=0,e;if(arguments.length>1)e=arguments[1];else{do{if(a in this){e=this[a++];break}if(++a>=h)throw new TypeError;}while(1)}for(;a<
h;a++)if(a in this)e=c.call(null,e,this[a],a,this);return e};k.util.array={invoke:function(c,h){for(var a=m.call(arguments,2),e=[],n=0,p=c.length;n<p;n++)e[n]=a.length?c[n][h].apply(c[n],a):c[n][h].call(c[n]);return e},min:function(c,h){var a=c.length-1,e=h?c[a][h]:c[a];if(h)for(;a--;){if(c[a][h]<e)e=c[a][h]}else for(;a--;)if(c[a]<e)e=c[a];return e},max:function(c,h){var a=c.length-1,e=h?c[a][h]:c[a];if(h)for(;a--;){if(c[a][h]>=e)e=c[a][h]}else for(;a--;)if(c[a]>=e)e=c[a];return e}};k.util.object=
{extend:d,clone:function(c){return d({},c)}};if(!String.prototype.trim)String.prototype.trim=function(){return this.replace(/^\s+/,"").replace(/\s+$/,"")};k.util.string={camelize:function(c){return c.replace(/-+(.)?/g,function(h,a){return a?a.toUpperCase():""})},capitalize:function(c){return c.charAt(0).toUpperCase()+c.slice(1).toLowerCase()}};if(!Function.prototype.bind)Function.prototype.bind=function(c){var h=this,a=Array.prototype.slice.call(arguments,1);return function(){return h.apply(c,a.concat(Array.prototype.slice.call(arguments)))}};
(function(){function c(){}var h;h=function(){for(var a in{toString:1})if(a==="toString")return false;return true}()?function(a,e){if(e.toString!==Object.prototype.toString)a.prototype.toString=e.toString;if(e.valueOf!==Object.prototype.valueOf)a.prototype.valueOf=e.valueOf;for(var n in e)a.prototype[n]=e[n]}:function(a,e){for(var n in e)a.prototype[n]=e[n]};k.util.createClass=function(){function a(){this.initialize.apply(this,arguments)}var e=null,n=m.call(arguments,0);if(typeof n[0]==="function")e=
n.shift();a.superclass=e;a.subclasses=[];if(e){c.prototype=e.prototype;a.prototype=new c;e.subclasses.push(a)}e=0;for(var p=n.length;e<p;e++)h(a,n[e]);if(!a.prototype.initialize)a.prototype.initialize=emptyFunction;return a.prototype.constructor=a}})();(function(){function c(l){var o=Array.prototype.slice.call(arguments,1),v,u,w=o.length;for(u=0;u<w;u++){v=typeof l[o[u]];if(!/^(?:function|object|unknown)$/.test(v))return false}return true}function h(l,o){return function(v){o.call(n(l),v||window.event)}}
function a(l,o){return function(v){if(b[l]&&b[l][o])for(var u=b[l][o],w=0,x=u.length;w<x;w++)u[w].call(this,v||window.event)}}var e=function(){if(typeof document.documentElement.uniqueID!=="undefined")return function(o){return o.uniqueID};var l=0;return function(o){return o.__uniqueID||(o.__uniqueID="uniqueID__"+l++)}}(),n,p;(function(){var l={};n=function(o){return l[o]};p=function(o,v){l[o]=v}})();var r=c(document.documentElement,"addEventListener","removeEventListener")&&c(window,"addEventListener",
"removeEventListener"),s=c(document.documentElement,"attachEvent","detachEvent")&&c(window,"attachEvent","detachEvent"),t={},b={};if(r){addListener=function(l,o,v){l.addEventListener(o,v,false)};removeListener=function(l,o,v){l.removeEventListener(o,v,false)}}else if(s){addListener=function(l,o,v){var u=e(l);p(u,l);t[u]||(t[u]={});t[u][o]||(t[u][o]=[]);v={handler:v,wrappedHandler:h(u,v)};t[u][o].push(v);l.attachEvent("on"+o,v.wrappedHandler)};removeListener=function(l,o,v){var u=e(l),w;if(t[u]&&t[u][o])for(var x=
0,z=t[u][o].length;x<z;x++)if((w=t[u][o][x])&&w.handler===v){l.detachEvent("on"+o,w.wrappedHandler);t[u][o][x]=null}}}else{addListener=function(l,o,v){var u=e(l);b[u]||(b[u]={});if(!b[u][o]){b[u][o]=[];var w=l["on"+o];w&&b[u][o].push(w);l["on"+o]=a(u,o)}b[u][o].push(v)};removeListener=function(l,o,v){l=e(l);if(b[l]&&b[l][o]){o=b[l][o];l=0;for(var u=o.length;l<u;l++)o[l]===v&&o.splice(l,1)}}}k.util.addListener=addListener;k.util.removeListener=removeListener;var f={};k.util.observeEvent=function(l,
o){f[l]||(f[l]=[]);f[l].push(o)};k.util.fireEvent=function(l,o){if(f[l])for(var v=0,u=f[l].length;v<u;v++)try{f[l][v]({memo:o})}catch(w){setTimeout(function(){throw w;},0)}};k.util.getPointer=function(l){var o=document.documentElement,v=document.body||{scrollLeft:0},u=document.documentElement,w=document.body||{scrollTop:0};return{x:l.pageX||l.clientX+(o.scrollLeft||v.scrollLeft)-(o.clientLeft||0),y:l.pageY||l.clientY+(u.scrollTop||w.scrollTop)-(u.clientTop||0)}}})(this);(function(){var c=document.createElement("div"),
h=typeof c.style.filter==="string",a=/alpha\s*\(\s*opacity\s*=\s*([^\)]+)\)/,e=function(n){return n};if(typeof c.style.opacity==="string")e=function(n,p){n.style.opacity=p;return n};else if(h)e=function(n,p){var r=n.style;if(n.currentStyle&&!n.currentStyle.hasLayout)r.zoom=1;if(a.test(r.filter)){p=p>=0.9999?"":"alpha(opacity="+p*100+")";r.filter=r.filter.replace(a,p)}else r.filter+=" alpha(opacity="+p*100+")";return n};k.util.setStyle=function(n,p){var r=n.style;if(typeof p==="string"){n.style.cssText+=
";"+p;return p.indexOf("opacity")>-1?e(n,p.match(/opacity:\s*(\d?\.?\d*)/)[1]):n}for(var s in p)if(s==="opacity")e(n,p[s]);else r[s==="float"||s==="cssFloat"?typeof r.styleFloat==="undefined"?"cssFloat":"styleFloat":s]=p[s];return n}})();(function(){var c=document.documentElement.style,h="userSelect"in c?"userSelect":"MozUserSelect"in c?"MozUserSelect":"WebkitUserSelect"in c?"WebkitUserSelect":"KhtmlUserSelect"in c?"KhtmlUserSelect":"";k.util.makeElementUnselectable=function(a){if(typeof a.onselectstart!==
"undefined")a.onselectstart=g;if(h)a.style[h]="none";else if(typeof a.unselectable=="string")a.unselectable="on";return a}})();(function(){function c(a,e){h.load(a);e()}k.util.getScript=function(a,e){var n=document.getElementsByTagName("head")[0],p=document.createElement("script"),r=true;p.type="text/javascript";p.setAttribute("runat","server");p.onload=p.onreadystatechange=function(s){if(r)if(!(typeof this.readyState=="string"&&this.readyState!=="loaded"&&this.readyState!=="complete")){r=false;e(s||
window.event);p=p.onload=p.onreadystatechange=null}};p.src=a;n.appendChild(p)};var h=this.Jaxer;if(h&&h.load)k.util.getScript=c})();k.util.getById=function(c){return typeof c==="string"?document.getElementById(c):c};k.util.toArray=function(c){for(var h=[],a=c.length;a--;)h[a]=c[a];return h};k.util.makeElement=q;k.util.addClass=function(c,h){if((" "+c.className+" ").indexOf(" "+h+" ")===-1)c.className+=(c.className?" ":"")+h};k.util.wrapElement=function(c,h,a){if(typeof h==="string")h=q(h,a);c.parentNode&&
c.parentNode.replaceChild(h,c);h.appendChild(c);return h};k.util.getElementOffset=function(c){var h=0,a=0;do{h+=c.offsetTop||0;a+=c.offsetLeft||0;c=c.offsetParent}while(c);return{left:a,top:h}};k.util.animate=function(c){c||(c={});var h=+new Date,a=c.duration||500,e=h+a,n,p,r=c.onChange||function(){},s=c.easing||function(o){return-Math.cos(o*Math.PI)/2+0.5},t="startValue"in c?c.startValue:0,b="endValue"in c?c.endValue:100,f=t>b;c.onStart&&c.onStart();var l=setInterval(function(){n=+new Date;p=n>e?
1:(n-h)/a;r(f?t-(t-b)*s(p):t+(b-t)*s(p));if(n>e){clearInterval(l);c.onComplete&&c.onComplete()}},10)};(function(){function c(){}var h=function(){for(var a=[function(){return new ActiveXObject("Microsoft.XMLHTTP")},function(){return new ActiveXObject("Msxml2.XMLHTTP")},function(){return new ActiveXObject("Msxml2.XMLHTTP.3.0")},function(){return new XMLHttpRequest}],e=a.length;e--;)try{if(a[e]())return a[e]}catch(n){}}();k.util.request=function(a,e){e||(e={});var n=e.method?e.method.toUpperCase():"GET",
p=e.onComplete||function(){},r=h(),s;r.onreadystatechange=function(){if(r.readyState===4){p(r);r.onreadystatechange=c}};if(n==="GET"){s=null;if(typeof e.parameters=="string")a=a+(/\?/.test(a)?"&":"?")+e.parameters}r.open(n,a,true);if(n==="POST"||n==="PUT")r.setRequestHeader("Content-Type","application/x-www-form-urlencoded");r.send(s);return r}})();(function(){var c=Math.PI/180;k.util.removeFromArray=function(h,a){var e=h.indexOf(a);e!==-1&&h.splice(e,1);return h};k.util.degreesToRadians=function(h){return h*
c};k.util.toFixed=function(h,a){return parseFloat(Number(h).toFixed(a))};k.util.getRandomInt=function(h,a){return Math.floor(Math.random()*(a-h+1))+h}})()})(this);
(function(){var d=this.fabric||(this.fabric={}),q=d.util.object.extend,g=d.util.string.capitalize,k=d.util.object.clone,m={cx:"left",x:"left",cy:"top",y:"top",r:"radius","fill-opacity":"opacity","fill-rule":"fillRule","stroke-width":"strokeWidth",transform:"transformMatrix"};d.parseTransformAttribute=function(){function c(r,s){var t=s[0];r[0]=Math.cos(t);r[1]=Math.sin(t);r[2]=-Math.sin(t);r[3]=Math.cos(t)}function h(r,s){var t=s.length===2?s[1]:s[0];r[0]=s[0];r[3]=t}function a(r,s){r[4]=s[0];if(s.length===
2)r[5]=s[1]}var e=[1,0,0,1,0,0],n=RegExp("^\\s*(?:(?:(?:(?:(matrix)\\s*\\(\\s*((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))\\s*\\))|(?:(translate)\\s*\\(\\s*((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?)))?\\s*\\))|(?:(scale)\\s*\\(\\s*((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?)))?\\s*\\))|(?:(rotate)\\s*\\(\\s*((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?)))?\\s*\\))|(?:(skewX)\\s*\\(\\s*((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))\\s*\\))|(?:(skewY)\\s*\\(\\s*((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))\\s*\\)))(?:(?:\\s+,?\\s*|,\\s*)(?:(?:(matrix)\\s*\\(\\s*((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))\\s*\\))|(?:(translate)\\s*\\(\\s*((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?)))?\\s*\\))|(?:(scale)\\s*\\(\\s*((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?)))?\\s*\\))|(?:(rotate)\\s*\\(\\s*((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?)))?\\s*\\))|(?:(skewX)\\s*\\(\\s*((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))\\s*\\))|(?:(skewY)\\s*\\(\\s*((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))\\s*\\))))*)?)\\s*$"),
p=RegExp("(?:(?:(matrix)\\s*\\(\\s*((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))\\s*\\))|(?:(translate)\\s*\\(\\s*((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?)))?\\s*\\))|(?:(scale)\\s*\\(\\s*((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?)))?\\s*\\))|(?:(rotate)\\s*\\(\\s*((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?)))?\\s*\\))|(?:(skewX)\\s*\\(\\s*((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))\\s*\\))|(?:(skewY)\\s*\\(\\s*((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))\\s*\\)))");
return function(r){var s=e.concat();if(!r||r&&!n.test(r))return s;r.replace(p,function(t){var b=RegExp("(?:(?:(matrix)\\s*\\(\\s*((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))\\s*\\))|(?:(translate)\\s*\\(\\s*((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?)))?\\s*\\))|(?:(scale)\\s*\\(\\s*((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?)))?\\s*\\))|(?:(rotate)\\s*\\(\\s*((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))(?:\\s+,?\\s*|,\\s*)((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?)))?\\s*\\))|(?:(skewX)\\s*\\(\\s*((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))\\s*\\))|(?:(skewY)\\s*\\(\\s*((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))\\s*\\)))").exec(t).filter(function(f){return f!==
""&&f!=null});t=b[1];b=b.slice(2).map(parseFloat);switch(t){case "translate":a(s,b);break;case "rotate":c(s,b);break;case "scale":h(s,b);break;case "skewX":s[2]=b[0];break;case "skewY":s[1]=b[0];break;case "matrix":s=b;break}});return s}}();d.parseSVGDocument=function(){var c=/^(path|circle|polygon|polyline|ellipse|rect|line)$/,h=RegExp("^\\s*((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?)+)\\s*,?\\s*((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?)+)\\s*,?\\s*((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?)+)\\s*,?\\s*((?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?)+)\\s*$");
return function(a,e){if(a){var n=d.util.toArray(a.getElementsByTagName("*")).filter(function(f){var l;if(l=c.test(f.tagName)){a:{for(f=f;f&&(f=f.parentNode);)if(f.nodeName==="pattern"){f=true;break a}f=false}l=!f}return l});if(!(!n||n&&!n.length)){var p=a.getAttribute("viewBox"),r=a.getAttribute("width"),s=a.getAttribute("height"),t=null,b=null;if(p&&(p=p.match(h))){parseInt(p[1],10);parseInt(p[2],10);t=parseInt(p[3],10);b=parseInt(p[4],10)}t=r?parseFloat(r):t;b=s?parseFloat(s):b;p={width:t,height:b};
n=d.parseElements(n,k(p));!n||n&&!n.length||e&&e(n,p)}}}}();q(d,{parseAttributes:function(c,h){if(c){var a,e,n={};if(c.parentNode&&/^g$/i.test(c.parentNode.nodeName))n=d.parseAttributes(c.parentNode,h);var p=h.reduce(function(r,s){a=c.getAttribute(s);e=parseFloat(a);if(a){if((s==="fill"||s==="stroke")&&a==="none")a="";if(s==="fill-rule")a=a==="evenodd"?"destination-over":a;if(s==="transform")a=d.parseTransformAttribute(a);if(s in m)s=m[s];r[s]=isNaN(e)?a:e}return r},{});p=q(d.parseStyleAttribute(c),
p);return q(n,p)}},parseElements:function(c,h){var a=c.map(function(e){var n=d[g(e.tagName)];if(n&&n.fromElement)try{return n.fromElement(e,h)}catch(p){console.log(p.message||p)}});return a=a.filter(function(e){return e!=null})},parseStyleAttribute:function(c){var h={};if(c=c.getAttribute("style"))if(typeof c=="string"){c=c.split(";");c.pop();h=c.reduce(function(e,n){var p=n.split(":"),r=p[0].trim();p=p[1].trim();e[r]=p;return e},{})}else for(var a in c)if(typeof c[a]!=="undefined")h[a]=c[a];return h},
parsePointsAttribute:function(c){if(!c)return null;c=c.trim().split(/\s+/);c=c.reduce(function(h,a){a=a.split(",");h.push({x:parseFloat(a[0]),y:parseFloat(a[1])});return h},[]);if(c.length%2!==0)return null;return c}})})();
(function(){function d(g,k){arguments.length>0&&this.init(g,k)}var q=this.fabric||(this.fabric={});if(q.Point)console.warn("fabric.Point is already defined");else{d.prototype={constructor:d,init:function(g,k){this.x=g;this.y=k},add:function(g){return new d(this.x+g.x,this.y+g.y)},addEquals:function(g){this.x+=g.x;this.y+=g.y;return this},scalarAdd:function(g){return new d(this.x+g,this.y+g)},scalarAddEquals:function(g){this.x+=g;this.y+=g;return this},subtract:function(g){return new d(this.x-g.x,
this.y-g.y)},subtractEquals:function(g){this.x-=g.x;this.y-=g.y;return this},scalarSubtract:function(g){return new d(this.x-g,this.y-g)},scalarSubtractEquals:function(g){this.x-=g;this.y-=g;return this},multiply:function(g){return new d(this.x*g,this.y*g)},multiplyEquals:function(g){this.x*=g;this.y*=g;return this},divide:function(g){return new d(this.x/g,this.y/g)},divideEquals:function(g){this.x/=g;this.y/=g;return this},eq:function(g){return this.x==g.x&&this.y==g.y},lt:function(g){return this.x<
g.x&&this.y<g.y},lte:function(g){return this.x<=g.x&&this.y<=g.y},gt:function(g){return this.x>g.x&&this.y>g.y},gte:function(g){return this.x>=g.x&&this.y>=g.y},lerp:function(g,k){return new d(this.x+(g.x-this.x)*k,this.y+(g.y-this.y)*k)},distanceFrom:function(g){var k=this.x-g.x;g=this.y-g.y;return Math.sqrt(k*k+g*g)},min:function(g){return new d(Math.min(this.x,g.x),Math.min(this.y,g.y))},max:function(g){return new d(Math.max(this.x,g.x),Math.max(this.y,g.y))},toString:function(){return this.x+
","+this.y},setXY:function(g,k){this.x=g;this.y=k},setFromPoint:function(g){this.x=g.x;this.y=g.y},swap:function(g){var k=this.x,m=this.y;this.x=g.x;this.y=g.y;g.x=k;g.y=m}};q.Point=d}})();
(function(){function d(g){arguments.length>0&&this.init(g)}var q=this.fabric||(this.fabric={});if(q.Intersection)console.warn("fabric.Intersection is already defined");else{d.prototype.init=function(g){this.status=g;this.points=[]};d.prototype.appendPoint=function(g){this.points.push(g)};d.prototype.appendPoints=function(g){this.points=this.points.concat(g)};d.intersectLineLine=function(g,k,m,c){var h,a=(c.x-m.x)*(g.y-m.y)-(c.y-m.y)*(g.x-m.x);h=(k.x-g.x)*(g.y-m.y)-(k.y-g.y)*(g.x-m.x);m=(c.y-m.y)*
(k.x-g.x)-(c.x-m.x)*(k.y-g.y);if(m!=0){a=a/m;h=h/m;if(0<=a&&a<=1&&0<=h&&h<=1){h=new d("Intersection");h.points.push(new q.Point(g.x+a*(k.x-g.x),g.y+a*(k.y-g.y)))}else h=new d("No Intersection")}else h=a==0||h==0?new d("Coincident"):new d("Parallel");return h};d.intersectLinePolygon=function(g,k,m){for(var c=new d("No Intersection"),h=m.length,a=0;a<h;a++){var e=d.intersectLineLine(g,k,m[a],m[(a+1)%h]);c.appendPoints(e.points)}if(c.points.length>0)c.status="Intersection";return c};d.intersectPolygonPolygon=
function(g,k){for(var m=new d("No Intersection"),c=g.length,h=0;h<c;h++){var a=d.intersectLinePolygon(g[h],g[(h+1)%c],k);m.appendPoints(a.points)}if(m.points.length>0)m.status="Intersection";return m};d.intersectPolygonRectangle=function(g,k,m){var c=k.min(m),h=k.max(m);m=new q.Point(h.x,c.y);var a=new q.Point(c.x,h.y);k=d.intersectLinePolygon(c,m,g);m=d.intersectLinePolygon(m,h,g);h=d.intersectLinePolygon(h,a,g);g=d.intersectLinePolygon(a,c,g);c=new d("No Intersection");c.appendPoints(k.points);
c.appendPoints(m.points);c.appendPoints(h.points);c.appendPoints(g.points);if(c.points.length>0)c.status="Intersection";return c};q.Intersection=d}})();
(function(){function d(g){g?this._tryParsingColor(g):this.setSource([0,0,0,1])}var q=this.fabric||(this.fabric={});if(q.Color)console.warn("fabric.Color is already defined.");else{q.Color=d;d.prototype._tryParsingColor=function(g){var k=d.sourceFromHex(g);k||(k=d.sourceFromRgb(g));k&&this.setSource(k)};d.prototype.getSource=function(){return this._source};d.prototype.setSource=function(g){this._source=g};d.prototype.toRgb=function(){var g=this.getSource();return"rgb("+g[0]+","+g[1]+","+g[2]+")"};
d.prototype.toRgba=function(){var g=this.getSource();return"rgba("+g[0]+","+g[1]+","+g[2]+","+g[3]+")"};d.prototype.toHex=function(){var g=this.getSource(),k=g[0].toString(16);k=k.length==1?"0"+k:k;var m=g[1].toString(16);m=m.length==1?"0"+m:m;g=g[2].toString(16);g=g.length==1?"0"+g:g;return k.toUpperCase()+m.toUpperCase()+g.toUpperCase()};d.prototype.getAlpha=function(){return this.getSource()[3]};d.prototype.setAlpha=function(g){var k=this.getSource();k[3]=g;this.setSource(k);return this};d.prototype.toGrayscale=
function(){var g=this.getSource(),k=parseInt((g[0]*0.3+g[1]*0.59+g[2]*0.11).toFixed(0),10);this.setSource([k,k,k,g[3]]);return this};d.prototype.toBlackWhite=function(g){var k=this.getSource(),m=(k[0]*0.3+k[1]*0.59+k[2]*0.11).toFixed(0);k=k[3];g=g||127;m=Number(m)<Number(g)?0:255;this.setSource([m,m,m,k]);return this};d.prototype.overlayWith=function(g){g=new d(g);var k=[],m=this.getAlpha(),c=this.getSource();g=g.getSource();for(var h=0;h<3;h++)k.push(Math.round(c[h]*0.5+g[h]*0.5));k[4]=m;this.setSource(k);
return this};d.reRGBa=/^rgba?\((\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})(?:\s*,\s*(\d+(?:\.\d+)?))?\)$/;d.reHex=/^#?([0-9a-f]{6}|[0-9a-f]{3})$/i;d.fromRgb=function(g){return d.fromSource(d.sourceFromRgb(g))};d.sourceFromRgb=function(g){if(g=g.match(d.reRGBa))return[parseInt(g[1],10),parseInt(g[2],10),parseInt(g[3],10),g[4]?parseFloat(g[4]):1]};d.fromRgba=d.fromRgb;d.fromHex=function(g){return d.fromSource(d.sourceFromHex(g))};d.sourceFromHex=function(g){if(g.match(d.reHex)){var k=g.slice(g.indexOf("#")+
1),m=k.length===3;g=m?k.charAt(0)+k.charAt(0):k.substring(0,2);var c=m?k.charAt(1)+k.charAt(1):k.substring(2,4);k=m?k.charAt(2)+k.charAt(2):k.substring(4,6);return[parseInt(g,16),parseInt(c,16),parseInt(k,16),1]}};d.fromSource=function(g){var k=new d;k.setSource(g);return k}}})();
(function(){if(fabric.Element)console.warn("fabric.Element is already defined.");else{var d=this.window,q=d.document,g=fabric.util.object.extend,k=fabric.util.string.capitalize,m=fabric.util.string.camelize,c=fabric.util.fireEvent,h=fabric.util.getPointer,a=fabric.util.getElementOffset,e=fabric.util.removeFromArray,n=fabric.util.addlistener,p=fabric.util.removelistener,r=Error("Could not initialize `canvas` element"),s={tr:"ne-resize",br:"se-resize",bl:"sw-resize",tl:"nw-resize",ml:"w-resize",mt:"n-resize",
mr:"e-resize",mb:"s-resize"};(function(){var b=q.createElement("canvas"),f,l,o;b.width=b.height=300;if(b.getContext)if(l=b.getContext("2d")){f=new Date;for(o=200;o--;)l.clearRect(0,0,300,300);l=new Date-f;f=new Date;for(o=200;o--;)b.width=b.height;if(new Date-f<l)return"width"}})();var t=function(){var b=q.createElement("canvas");if(b&&b.getContext)if(b=b.getContext("2d")){try{b.fillStyle="transparent";return true}catch(f){}return false}}();fabric.Element=function(b,f){this._groupSelector=null;this._aObjects=
[];this._activeGroup=this._currentTransform=this._oElement=this._oContext=null;this._oConfig={width:300,height:150};f=f||{};this._initElement(b);this._initConfig(f);f.overlayImage&&this.setOverlayImage(f.overlayImage);if(f.afterRender)this.afterRender=f.afterRender;this._createCanvasBackground();this._createCanvasContainer();this._initEvents();this.calcOffset()};g(fabric.Element.prototype,{selectionColor:"rgba(100,100,255,0.3)",selectionBorderColor:"rgba(255,255,255,0.3)",selectionLineWidth:1,backgroundColor:"rgba(255,255,255,1)",
includeDefaultValues:true,shouldCacheImages:false,CANVAS_WIDTH:600,CANVAS_HEIGHT:600,onBeforeScaleRotate:function(){},calcOffset:function(){this._offset=a(this.getElement());return this},setOverlayImage:function(b,f){if(b){var l=this,o=new Image;o.onload=function(){l.overlayImage=o;f&&f();o=o.onload=null};o.src=b}return this},_initElement:function(b){this._oElement=fabric.util.getById(b)||q.createElement("canvas");typeof this._oElement.getContext==="undefined"&&G_vmlCanvasManager.initElement(this._oElement);
if(typeof this._oElement.getContext==="undefined")throw r;if(!(this._oContextTop=this._oElement.getContext("2d")))throw r;b=this._oElement.width||0;var f=this._oElement.height||0;this._initWrapperElement(b,f);this._setElementStyle(b,f)},_initWrapperElement:function(b,f){var l=fabric.util.wrapElement(this.getElement(),"div",{"class":"canvas_container"});fabric.util.setStyle(l,{width:b+"px",height:f+"px"});fabric.util.makeElementUnselectable(l);this.wrapper=l},_setElementStyle:function(b,f){fabric.util.setStyle(this.getElement(),
{position:"absolute",width:b+"px",height:f+"px",left:0,top:0})},_initConfig:function(b){g(this._oConfig,b||{});this._oConfig.width=parseInt(this._oElement.width,10)||0;this._oConfig.height=parseInt(this._oElement.height,10)||0;this._oElement.style.width=this._oConfig.width+"px";this._oElement.style.height=this._oConfig.height+"px"},_initEvents:function(){var b=this;this._onMouseDown=function(f){b.__onMouseDown(f)};this._onMouseUp=function(f){b.__onMouseUp(f)};this._onMouseMove=function(f){b.__onMouseMove(f)};
this._onResize=function(){b.calcOffset()};n(this._oElement,"mousedown",this._onMouseDown);n(q,"mousemove",this._onMouseMove);n(q,"mouseup",this._onMouseUp);n(d,"resize",this._onResize)},_createCanvasElement:function(b){var f=q.createElement("canvas");if(f){f.className=b;b=this._oElement.parentNode.insertBefore(f,this._oElement);b.width=this.getWidth();b.height=this.getHeight();b.style.width=this.getWidth()+"px";b.style.height=this.getHeight()+"px";b.style.position="absolute";b.style.left=0;b.style.top=
0;typeof f.getContext==="undefined"&&G_vmlCanvasManager.initElement(f);if(typeof f.getContext==="undefined")throw r;fabric.util.makeElementUnselectable(b);return b}},_createCanvasContainer:function(){var b=this._createCanvasElement("canvas-container");this._oContextContainerEl=b;this._oContextContainer=b.getContext("2d")},_createCanvasBackground:function(){var b=this._createCanvasElement("canvas-container");this._oContextBackgroundEl=b;this._oContextBackground=b.getContext("2d")},getWidth:function(){return this._oConfig.width},
getHeight:function(){return this._oConfig.height},setWidth:function(b){return this._setDimension("width",b)},setHeight:function(b){return this._setDimension("height",b)},setDimensions:function(b){for(var f in b)this._setDimension(f,b[f]);return this},_setDimension:function(b,f){this._oContextContainerEl[b]=f;this._oContextContainerEl.style[b]=f+"px";this._oContextBackgroundEl[b]=f;this._oContextBackgroundEl.style[b]=f+"px";this._oElement[b]=f;this._oElement.style[b]=f+"px";this._oElement.parentNode.style[b]=
f+"px";this._oConfig[b]=f;this.calcOffset();this.renderAll();return this},__onMouseUp:function(b){if(this._currentTransform){var f=this._currentTransform.target;if(f.__scaling){c("object:scaled",{target:f});f.__scaling=false}for(var l=0,o=this._aObjects.length;l<o;++l)this._aObjects[l].setCoords();if(f.hasStateChanged()){f.isMoving=false;c("object:modified",{target:f})}}this._currentTransform=null;this._groupSelector&&this._findSelectedObjects(b);if(l=this.getActiveGroup()){l.hasStateChanged()&&l.containsPoint(this.getPointer(b))&&
c("group:modified",{target:l});l.setObjectsCoords();l.set("isMoving",false);this._setCursor("default")}this._groupSelector=null;this.renderAll();this._setCursorFromEvent(b,f);this._setCursor("");var v=this;setTimeout(function(){v._setCursorFromEvent(b,f)},50)},shouldClearSelection:function(b){var f=this.findTarget(b),l=this.getActiveGroup();return!f||f&&l&&!l.contains(f)&&l!==f&&!b.shiftKey},__onMouseDown:function(b){if(!this._currentTransform){var f=this.findTarget(b),l=this.getPointer(b),o=this.getActiveGroup();
if(this.shouldClearSelection(b)){this._groupSelector={ex:l.x,ey:l.y,top:0,left:0};this.deactivateAllWithDispatch()}else{f.saveState();f._findTargetCorner(b,this._offset)&&this.onBeforeScaleRotate(f);this._setupCurrentTransform(b,f);if(b.shiftKey&&(o||this.getActiveObject()))this._handleGroupLogic(b,f);else{f!==this.getActiveGroup()&&this.deactivateAll();this.setActiveObject(f)}}this.renderAll()}},getElement:function(){return this._oElement},deactivateAllWithDispatch:function(){var b=this.getActiveGroup();
b&&c("before:group:destroyed",{target:b});this.deactivateAll();b&&c("after:group:destroyed");c("selection:cleared");return this},_setupCurrentTransform:function(b,f){var l="drag",o,v=h(b);if(o=f._findTargetCorner(b,this._offset))l=/ml|mr/.test(o)?"scaleX":/mt|mb/.test(o)?"scaleY":"rotate";this._currentTransform={target:f,action:l,scaleX:f.scaleX,scaleY:f.scaleY,offsetX:v.x-f.left,offsetY:v.y-f.top,ex:v.x,ey:v.y,left:f.left,top:f.top,theta:f.theta,width:f.width*f.scaleX};this._currentTransform.original=
{left:f.left,top:f.top}},_handleGroupLogic:function(b,f){if(f.isType("group")){f=this.findTarget(b,true);if(!f||f.isType("group"))return}var l=this.getActiveGroup();if(l){if(l.contains(f)){l.remove(f);f.setActive(false);l.size()===1&&this.removeActiveGroup()}else l.add(f);c("group:selected",{target:l});l.setActive(true)}else{if(this._activeObject)if(f!==this._activeObject){this.setActiveGroup(new fabric.Group([this._activeObject,f]));l=this.getActiveGroup()}f.setActive(true)}l&&l.saveCoords()},__onMouseMove:function(b){if(this._groupSelector!==
null){var f=h(b);this._groupSelector.left=f.x-this._offset.left-this._groupSelector.ex;this._groupSelector.top=f.y-this._offset.top-this._groupSelector.ey;this.renderTop()}else if(this._currentTransform){f=h(b);var l=f.x;f=f.y;this._currentTransform.target.isMoving=true;if(this._currentTransform.action==="rotate"){b.shiftKey||this._rotateObject(l,f);this._scaleObject(l,f)}else if(this._currentTransform.action==="scaleX")this._scaleObject(l,f,"x");else this._currentTransform.action==="scaleY"?this._scaleObject(l,
f,"y"):this._translateObject(l,f);this.renderAll()}else{l=this._oElement.style;if(f=this.findTarget(b)){this._setCursorFromEvent(b,f);f.isActive()&&f.setCornersVisibility&&f.setCornersVisibility(true)}else{for(b=this._aObjects.length;b--;)this._aObjects[b].active||this._aObjects[b].setActive(false);l.cursor="default"}}},_translateObject:function(b,f){var l=this._currentTransform.target;l.set("left",b-this._currentTransform.offsetX);l.set("top",f-this._currentTransform.offsetY)},_scaleObject:function(b,
f,l){var o=Math.sqrt(Math.pow(this._currentTransform.ey-this._currentTransform.top-this._offset.top,2)+Math.pow(this._currentTransform.ex-this._currentTransform.left-this._offset.left,2));b=Math.sqrt(Math.pow(f-this._currentTransform.top-this._offset.top,2)+Math.pow(b-this._currentTransform.left-this._offset.left,2));f=this._currentTransform.target;f.__scaling=true;if(l)if(l==="x")f.set("scaleX",this._currentTransform.scaleX*b/o);else l==="y"&&f.set("scaleY",this._currentTransform.scaleY*b/o);else{f.set("scaleX",
this._currentTransform.scaleX*b/o);f.set("scaleY",this._currentTransform.scaleY*b/o)}},_rotateObject:function(b,f){var l=Math.atan2(this._currentTransform.ey-this._currentTransform.top-this._offset.top,this._currentTransform.ex-this._currentTransform.left-this._offset.left);this._currentTransform.target.set("theta",Math.atan2(f-this._currentTransform.top-this._offset.top,b-this._currentTransform.left-this._offset.left)-l+this._currentTransform.theta)},_setCursor:function(b){this._oElement.style.cursor=
b},_setCursorFromEvent:function(b,f){var l=this._oElement.style;if(f){var o=this.getActiveGroup();if(o=!!f._findTargetCorner&&(!o||!o.contains(f))&&f._findTargetCorner(b,this._offset))if(o in s)l.cursor=s[o];else{l.cursor="default";return false}else l.cursor="move"}else{l.cursor="default";return false}return true},_draw:function(b,f){f&&f.render(b)},_drawSelection:function(){var b=this._groupSelector.left,f=this._groupSelector.top,l=Math.abs(b),o=Math.abs(f);this._oContextTop.fillStyle=this.selectionColor;
this._oContextTop.fillRect(this._groupSelector.ex-(b>0?0:-b),this._groupSelector.ey-(f>0?0:-f),l,o);this._oContextTop.lineWidth=this.selectionLineWidth;this._oContextTop.strokeStyle=this.selectionBorderColor;this._oContextTop.strokeRect(this._groupSelector.ex+0.5-(b>0?0:l),this._groupSelector.ey+0.5-(f>0?0:o),l,o)},_findSelectedObjects:function(){var b=[],f=this._groupSelector.ex,l=this._groupSelector.ey,o=f+this._groupSelector.left,v=l+this._groupSelector.top,u=new fabric.Point(Math.min(f,o),Math.min(l,
v));l=new fabric.Point(Math.max(f,o),Math.max(l,v));o=0;for(v=this._aObjects.length;o<v;++o){f=this._aObjects[o];if(f.intersectsWithRect(u,l)||f.isContainedWithinRect(u,l)){f.setActive(true);b.push(f)}}if(b.length===1){this.setActiveObject(b[0]);c("object:selected",{target:b[0]})}else if(b.length>1){b=new fabric.Group(b);this.setActiveGroup(b);b.saveCoords();c("group:selected",{target:b})}this.renderAll()},add:function(){this._aObjects.push.apply(this._aObjects,arguments);this.renderAll();return this},
insertAt:function(b,f){this._aObjects.splice(f,0,b);this.renderAll();return this},getObjects:function(){return this._aObjects},getContext:function(){return this._oContextTop},clearContext:function(b){b.clearRect(0,0,this._oConfig.width,this._oConfig.height);return this},clear:function(){this._aObjects.length=0;this.clearContext(this._oContextTop);this.clearContext(this._oContextContainer);this.renderAll();return this},renderAll:function(b){var f=this._oConfig.width,l=this._oConfig.height,o=b?this._oContextTop:
this._oContextContainer;this.clearContext(this._oContextTop);o!==this._oContextTop&&this.clearContext(o);if(b){if(!t&&this.backgroundColor==="transparent")var v=true;if(!v)o.fillStyle=this.backgroundColor;o.fillRect(0,0,f,l)}b=this._aObjects.length;f=this.getActiveGroup();if(b)for(l=0;l<b;++l)if(!f||f&&!f.contains(this._aObjects[l]))this._draw(o,this._aObjects[l]);f&&this._draw(this._oContextTop,f);this.overlayImage&&this._oContextTop.drawImage(this.overlayImage,0,0);this.afterRender&&this.afterRender();
return this},renderTop:function(){this.clearContext(this._oContextTop);this.overlayImage&&this._oContextTop.drawImage(this.overlayImage,0,0);this._groupSelector&&this._drawSelection();var b=this.getActiveGroup();b&&b.render(this._oContextTop);this.afterRender&&this.afterRender();return this},containsPoint:function(b,f){var l=this.getPointer(b),o=this._normalizePointer(f,l);l=o.x;o=o.y;var v=f._getImageLines(f.oCoords);if((l=f._findCrossPoints(l,o,v))&&l%2===1||f._findTargetCorner(b,this._offset))return true;
return false},_normalizePointer:function(b,f){var l=this.getActiveGroup(),o=f.x,v=f.y;if(l&&b.type!=="group"&&l.contains(b)){o-=l.left;v-=l.top}return{x:o,y:v}},findTarget:function(b,f){var l;this.getPointer(b);var o=this.getActiveGroup();if(o&&!f&&this.containsPoint(b,o))return l=o;for(o=this._aObjects.length;o--;)if(this.containsPoint(b,this._aObjects[o])){this.relatedTarget=l=this._aObjects[o];break}return l},toDataURL:function(b){var f;b||(b="png");if(b==="jpeg"||b==="png"){this.renderAll(true);
f=this.getElement().toDataURL("image/"+b)}return f},toDataURLWithMultiplier:function(b,f){var l=this.getWidth(),o=this.getHeight(),v=l*f,u=o*f,w=this.getActiveObject();this.setWidth(v).setHeight(u);this._oContextTop.scale(f,f);w&&this.deactivateAll().renderAll();v=this.toDataURL(b);this._oContextTop.scale(1/f,1/f);this.setWidth(l).setHeight(o);w&&this.setActiveObject(w);this.renderAll();return v},getPointer:function(b){b=h(b);return{x:b.x-this._offset.left,y:b.y-this._offset.top}},getCenter:function(){return{top:this.getHeight()/
2,left:this.getWidth()/2}},centerObjectH:function(b){b.set("left",this.getCenter().left);this.renderAll();return this},fxCenterObjectH:function(b){var f=this,l=new APE.anim.Animation,o=b.get("left"),v=f.getCenter().left-o;l.run=function(u){b.set("left",o+v*u);f.renderAll()};l.onend=function(){b.setCoords()};l.duration=500;l.transition=APE.anim.Transitions.decel;l.start();return this},centerObjectV:function(b){b.set("top",this.getCenter().top);this.renderAll();return this},fxCenterObjectV:function(b){var f=
this,l=new APE.anim.Animation,o=b.get("top"),v=f.getCenter().top-o;l.run=function(u){b.set("top",o+v*u).setCoords();f.renderAll()};l.onend=function(){b.setCoords()};l.duration=500;l.transition=APE.anim.Transitions.decel;l.start()},straightenObject:function(b){b.straighten();this.renderAll();return this},fxStraightenObject:function(b){b.fxStraighten({onChange:this.renderAll.bind(this)});return this},toJSON:function(){return JSON.stringify(this.toObject())},toDatalessJSON:function(){return JSON.stringify(this.toDatalessObject())},
toObject:function(){return this._toObjectMethod("toObject")},toDatalessObject:function(){return this._toObjectMethod("toDatalessObject")},_toObjectMethod:function(b){return{objects:this._aObjects.map(function(f){if(!this.includeDefaultValues){var l=f.includeDefaultValues;f.includeDefaultValues=false}var o=f[b]();if(!this.includeDefaultValues)f.includeDefaultValues=l;return o},this),background:this.backgroundColor}},isEmpty:function(){return this._aObjects.length===0},loadFromJSON:function(b,f){if(b){var l=
JSON.parse(b);if(!(!l||l&&!l.objects)){this.clear();var o=this;this._enlivenObjects(l.objects,function(){o.backgroundColor=l.background;f&&f()});return this}}},_enlivenObjects:function(b,f){var l=0,o=b.filter(function(u){return u.type==="image"}).length,v=this;b.forEach(function(u){if(u.type)switch(u.type){case "image":case "font":fabric[k(u.type)].fromObject(u,function(x){v.add(x);++l===o&&f&&f()});break;default:var w=fabric[m(k(u.type))];w&&w.fromObject&&v.add(w.fromObject(u));break}});o===0&&f&&
f()},loadFromDatalessJSON:function(b,f){if(b){var l=typeof b==="string"?b.evalJSON():b;if(!(!l||l&&!l.objects)){this.clear();this._enlivenDatalessObjects(l.objects,f)}}},_enlivenDatalessObjects:function(b,f){function l(x,z){o.insertAt(x,z);x.setCoords();++v===u&&f&&f()}var o=this,v=0,u=b.length;try{b.forEach(function(x,z){var B=x.paths?"paths":"path",A=x[B];delete x[B];if(typeof A!=="string")switch(x.type){case "image":case "text":Canvas[k(x.type)].fromObject(x,function(y){l(y,z)});break;default:(B=
Canvas[m(k(x.type))])&&B.fromObject&&l(B.fromObject(x),z);break}else if(x.type==="image")o.loadImageFromURL(A,function(y){y.setSourcePath(A);g(y,x);y.setAngle(x.angle);l(y,z)});else if(x.type==="text"){x.path=A;var C=fabric.Text.fromObject(x);d.__context=o;fabric.util.getScript(A,function(){Prototype.Browser.Opera?setTimeout(function(){l(C,z)},500):l(C,z)})}else o.loadSVGFromURL(A,function(y){y=y.length>1?new fabric.PathGroup(y,x):y[0];y.setSourcePath(A);if(!(y instanceof fabric.PathGroup)){g(y,x);
typeof x.angle!=="undefined"&&y.setAngle(x.angle)}l(y,z)})},this)}catch(w){console.log(w.message)}},loadImageFromURL:function(){var b={};return function(f,l){function o(){var w=q.getElementById(b[f]);w.width&&w.height?l(new fabric.Image(w)):setTimeout(o,50)}var v=this;if(b[f])o();else{var u=new Image;u.onload=function(){u.onload=null;v._resizeImageToFit(u);var w=new fabric.Image(u);l(w)};u.className="canvas-img-clone";u.src=f;if(this.shouldCacheImages)b[f]=Element.identify(u);q.body.appendChild(u)}}}(),
loadSVGFromURL:function(b,f){function l(u){if(u=u.responseXML)(u=u.documentElement)&&fabric.parseSVGDocument(u,function(w,x){v.cache.set(b,{objects:w.invoke("toObject"),options:x});f(w,x)})}function o(){console.log("ERROR!")}var v=this;b=b.replace(/^\n\s*/,"").replace(/\?.*$/,"").trim();this.cache.has(b,function(u){if(u)v.cache.get(b,function(w){w=v._enlivenCachedObject(w);f(w.objects,w.options)});else new Ajax.Request(b,{method:"get",onComplete:l,onFailure:o})})},_enlivenCachedObject:function(b){var f=
b.objects;b=b.options;f=f.map(function(l){return fabric[k(l.type)].fromObject(l)});return{objects:f,options:b}},remove:function(b){e(this._aObjects,b);this.renderAll();return b},fxRemove:function(b,f){var l=this;b.fxRemove({onChange:this.renderAll.bind(this),onComplete:function(){l.remove(b);typeof f==="function"&&f()}});return this},sendToBack:function(b){e(this._aObjects,b);this._aObjects.unshift(b);return this.renderAll()},bringToFront:function(b){e(this._aObjects,b);this._aObjects.push(b);return this.renderAll()},
sendBackwards:function(b){var f=this._aObjects.indexOf(b),l=f;if(f!==0){for(f=f-1;f>=0;--f)if(b.intersectsWithObject(this._aObjects[f])){l=f;break}e(this._aObjects,b);this._aObjects.splice(l,0,b)}return this.renderAll()},bringForward:function(b){var f=this.getObjects(),l=f.indexOf(b),o=l;if(l!==f.length-1){l=l+1;for(var v=this._aObjects.length;l<v;++l)if(b.intersectsWithObject(f[l])){o=l;break}e(f,b);f.splice(o,0,b)}this.renderAll()},setActiveObject:function(b){this._activeObject&&this._activeObject.setActive(false);
this._activeObject=b;b.setActive(true);this.renderAll();c("object:selected",{target:b});return this},getActiveObject:function(){return this._activeObject},removeActiveObject:function(){this._activeObject&&this._activeObject.setActive(false);this._activeObject=null;return this},setActiveGroup:function(b){this._activeGroup=b;return this},getActiveGroup:function(){return this._activeGroup},removeActiveGroup:function(){var b=this.getActiveGroup();b&&b.destroy();return this.setActiveGroup(null)},item:function(b){return this.getObjects()[b]},
deactivateAll:function(){for(var b=this.getObjects(),f=0,l=b.length;f<l;f++)b[f].setActive(false);this.removeActiveGroup();this.removeActiveObject();return this},complexity:function(){return this.getObjects().reduce(function(b,f){b+=f.complexity?f.complexity():0;return b},0)},dispose:function(){this.clear();p(this.getElement(),"mousedown",this._onMouseDown);p(q,"mouseup",this._onMouseUp);p(q,"mousemove",this._onMouseMove);p(d,"resize",this._onResize);return this},clone:function(b){var f=q.createElement("canvas");
f.width=this.getWidth();f.height=this.getHeight();var l=this.__clone||(this.__clone=new fabric.Element(f));return l.loadFromJSON(this.toJSON(),function(){b&&b(l)})},_toDataURL:function(b,f){this.clone(function(l){f(l.toDataURL(b))})},_toDataURLWithMultiplier:function(b,f,l){this.clone(function(o){l(o.toDataURLWithMultiplier(b,f))})},_resizeImageToFit:function(b){var f=b.width||b.offsetWidth,l=b.height||b.offsetHeight,o=this.getWidth()/f,v=this.getHeight()/l;if(f&&l){b.width=f*o;b.height=l*v}},cache:{has:function(b,
f){f(false)},get:function(){},set:function(){}}});fabric.Element.prototype.toString=function(){return"#<fabric.Element ("+this.complexity()+"): { objects: "+this.getObjects().length+" }>"};g(fabric.Element,{EMPTY_JSON:'{"objects": [], "background": "white"}',toGrayscale:function(b){var f=b.getContext("2d");b=f.getImageData(0,0,b.width,b.height);var l=b.data,o=b.width,v=b.height,u,w;for(i=0;i<o;i++)for(j=0;j<v;j++){u=i*4*v+j*4;w=(l[u]+l[u+1]+l[u+2])/3;l[u]=w;l[u+1]=w;l[u+2]=w}f.putImageData(b,0,0)},
supports:function(b){var f=q.createElement("canvas");if(!f||!f.getContext)return null;var l=f.getContext("2d");if(!l)return null;switch(b){case "getImageData":return typeof l.getImageData!=="undefined";case "toDataURL":return typeof f.toDataURL!=="undefined";default:return null}}})}})();
(function(){var d=this.fabric||(this.fabric={}),q=d.util.object.extend,g=d.util.object.clone,k=d.util.toFixed,m=d.util.string.capitalize,c=d.util.getPointer;if(!d.Object){var h=Array.prototype.slice;d.Object=d.util.createClass({type:"object",includeDefaultValues:true,NUM_FRACTION_DIGITS:2,FX_DURATION:500,FX_TRANSITION:"decel",MIN_SCALE_LIMIT:0.1,stateProperties:"top left width height scaleX scaleY flipX flipY theta angle opacity cornersize fill overlayFill stroke strokeWidth fillRule borderScaleFactor transformMatrix".split(" "),
options:{top:0,left:0,width:100,height:100,scaleX:1,scaleY:1,flipX:false,flipY:false,theta:0,opacity:1,angle:0,cornersize:10,padding:0,borderColor:"rgba(102,153,255,0.75)",cornerColor:"rgba(102,153,255,0.5)",fill:"rgb(0,0,0)",overlayFill:null,stroke:null,strokeWidth:1,fillRule:"source-over",borderOpacityWhenMoving:0.4,borderScaleFactor:1,transformMatrix:null},callSuper:function(a){var e=this.constructor.superclass.prototype[a];return arguments.length>1?e.apply(this,h.call(arguments,1)):e.call(this)},
initialize:function(a){this.setOptions(a);this._importProperties();this.originalState={};this.setCoords();this.saveState()},setOptions:function(a){this.options=q(this._getOptions(),a)},_getOptions:function(){return q(g(this._getSuperOptions()),this.options)},_getSuperOptions:function(){var a=this.constructor;if(a)if(a=a.superclass)if((a=a.prototype)&&typeof a._getOptions=="function")return a._getOptions();return{}},_importProperties:function(){this.stateProperties.forEach(function(a){a==="angle"?
this.setAngle(this.options[a]):this[a]=this.options[a]},this)},transform:function(a){a.globalAlpha=this.opacity;a.translate(this.left,this.top);a.rotate(this.theta);a.scale(this.scaleX*(this.flipX?-1:1),this.scaleY*(this.flipY?-1:1))},toJSON:function(){return JSON.stringify(this.toObject())},toObject:function(){var a={type:this.type,left:k(this.left,this.NUM_FRACTION_DIGITS),top:k(this.top,this.NUM_FRACTION_DIGITS),width:k(this.width,this.NUM_FRACTION_DIGITS),height:k(this.height,this.NUM_FRACTION_DIGITS),
fill:this.fill,overlayFill:this.overlayFill,stroke:this.stroke,strokeWidth:this.strokeWidth,scaleX:k(this.scaleX,this.NUM_FRACTION_DIGITS),scaleY:k(this.scaleY,this.NUM_FRACTION_DIGITS),angle:k(this.getAngle(),this.NUM_FRACTION_DIGITS),flipX:this.flipX,flipY:this.flipY,opacity:k(this.opacity,this.NUM_FRACTION_DIGITS)};this.includeDefaultValues||(a=this._removeDefaultValues(a));return a},toDatalessObject:function(){return this.toObject()},_removeDefaultValues:function(a){var e=d.Object.prototype.options;
this.stateProperties.forEach(function(n){a[n]===e[n]&&delete a[n]});return a},isActive:function(){return!!this.active},setActive:function(a){this.active=!!a;return this},toString:function(){return"#<fabric."+m(this.type)+">"},set:function(a,e){if((a==="scaleX"||a==="scaleY")&&e<this.MIN_SCALE_LIMIT)e=this.MIN_SCALE_LIMIT;if(a==="angle")this.setAngle(e);else this[a]=e;return this},toggle:function(a){var e=this.get(a);typeof e==="boolean"&&this.set(a,!e);return this},setSourcePath:function(a){this.sourcePath=
a;return this},get:function(a){return a==="angle"?this.getAngle():this[a]},render:function(a,e){if(!(this.width===0||this.height===0)){a.save();var n=this.transformMatrix;n&&a.setTransform(n[0],n[1],n[2],n[3],n[4],n[5]);e||this.transform(a);if(this.stroke){a.lineWidth=this.strokeWidth;a.strokeStyle=this.stroke}if(this.overlayFill)a.fillStyle=this.overlayFill;else if(this.fill)a.fillStyle=this.fill;this._render(a);if(this.active&&!e){this.drawBorders(a);this.drawCorners(a)}a.restore()}},getWidth:function(){return this.width*
this.scaleX},getHeight:function(){return this.height*this.scaleY},scale:function(a){this.scaleY=this.scaleX=a;return this},scaleToWidth:function(a){return this.scale(a/this.width)},scaleToHeight:function(a){return this.scale(a/this.height)},setOpacity:function(a){this.set("opacity",a);return this},getAngle:function(){return this.theta*180/Math.PI},setAngle:function(a){this.theta=a/180*Math.PI;this.angle=a;return this},setCoords:function(){this.currentWidth=this.width*this.scaleX;this.currentHeight=
this.height*this.scaleY;this._hypotenuse=Math.sqrt(Math.pow(this.currentWidth/2,2)+Math.pow(this.currentHeight/2,2));this._angle=Math.atan(this.currentHeight/this.currentWidth);var a=Math.cos(this._angle+this.theta)*this._hypotenuse,b=Math.sin(this._angle+this.theta)*this._hypotenuse,g=this.theta,h=Math.sin(g);g=Math.cos(g);a={x:this.left-a,y:this.top-b};b={x:a.x+this.currentWidth*g,y:a.y+this.currentWidth*h};var m={x:a.x-this.currentHeight*h,y:a.y+this.currentHeight*g};this.oCoords={tl:a,tr:b,br:{x:b.x-
this.currentHeight*h,y:b.y+this.currentHeight*g},bl:m,ml:{x:a.x-this.currentHeight/2*h,y:a.y+this.currentHeight/2*g},mt:{x:a.x+this.currentWidth/2*g,y:a.y+this.currentWidth/2*h},mr:{x:b.x-this.currentHeight/2*h,y:b.y+this.currentHeight/2*g},mb:{x:m.x+this.currentWidth/2*g,y:m.y+this.currentWidth/2*h}};this._setCornerCoords();return this},drawBorders:function(a){var b=this.options,g=b.padding,h=g*2;a.save();a.globalAlpha=this.isMoving?b.borderOpacityWhenMoving:1;a.strokeStyle=b.borderColor;b=1/(this.scaleX<
this.MIN_SCALE_LIMIT?this.MIN_SCALE_LIMIT:this.scaleX);var m=1/(this.scaleY<this.MIN_SCALE_LIMIT?this.MIN_SCALE_LIMIT:this.scaleY);a.lineWidth=1/this.borderScaleFactor;a.scale(b,m);b=this.getWidth();m=this.getHeight();a.strokeRect(Math.floor(-(b/2)-g)+0.5,Math.floor(-(m/2)-g)+0.5,Math.floor(b+h),Math.floor(m+h));a.restore();return this},drawCorners:function(a){var b=this.options.cornersize,g=b/2,h=this.options.padding,m=-(this.width/2),l=-(this.height/2),n=b/this.scaleX,c=b/this.scaleY,d=(h+g)/this.scaleY,
k=(h+g)/this.scaleX,o=(h+g-b)/this.scaleX;h=(h+g-b)/this.scaleY;a.save();a.globalAlpha=this.isMoving?this.options.borderOpacityWhenMoving:1;a.fillStyle=this.options.cornerColor;b=m-k;g=l-d;a.fillRect(b,g,n,c);b=m+this.width-k;g=l-d;a.fillRect(b,g,n,c);b=m-k;g=l+this.height+h;a.fillRect(b,g,n,c);b=m+this.width+o;g=l+this.height+h;a.fillRect(b,g,n,c);b=m+this.width/2-k;g=l-d;a.fillRect(b,g,n,c);b=m+this.width/2-k;g=l+this.height+h;a.fillRect(b,g,n,c);b=m+this.width+o;g=l+this.height/2-d;a.fillRect(b,
g,n,c);b=m-k;g=l+this.height/2-d;a.fillRect(b,g,n,c);a.restore();return this},clone:function(a){if(this.constructor.fromObject)return this.constructor.fromObject(this.toObject(),a);return new e.Object(this.toObject())},cloneAsImage:function(a){if(e.Image){var b=new Image;b.onload=function(){a&&a(new e.Image(b),g);b=b.onload=null};var g={angle:this.get("angle"),flipX:this.get("flipX"),flipY:this.get("flipY")};this.set("angle",0).set("flipX",false).set("flipY",false);b.src=this.toDataURL()}return this},
toDataURL:function(){var a=document.createElement("canvas");a.width=this.getWidth();a.height=this.getHeight();e.util.wrapElement(a,"div");var b=new e.Element(a);b.backgroundColor="transparent";b.renderAll();var g=this.clone();g.left=a.width/2;g.top=a.height/2;g.setActive(false);b.add(g);a=b.toDataURL("png");b.dispose();return a},hasStateChanged:function(){return this.stateProperties.some(function(a){return this[a]!==this.originalState[a]},this)},saveState:function(){this.stateProperties.forEach(function(a){this.originalState[a]=
this.get(a)},this);return this},intersectsWithRect:function(a,b){var g=this.oCoords,h=new e.Point(g.tl.x,g.tl.y),m=new e.Point(g.tr.x,g.tr.y),l=new e.Point(g.bl.x,g.bl.y);g=new e.Point(g.br.x,g.br.y);return e.Intersection.intersectPolygonRectangle([h,m,g,l],a,b).status==="Intersection"},intersectsWithObject:function(a){function b(h){return{tl:new e.Point(h.tl.x,h.tl.y),tr:new e.Point(h.tr.x,h.tr.y),bl:new e.Point(h.bl.x,h.bl.y),br:new e.Point(h.br.x,h.br.y)}}var g=b(this.oCoords);a=b(a.oCoords);return e.Intersection.intersectPolygonPolygon([g.tl,
g.tr,g.br,g.bl],[a.tl,a.tr,a.br,a.bl]).status==="Intersection"},isContainedWithinRect:function(a,b){var g=this.oCoords,h=new e.Point(g.tl.x,g.tl.y),m=new e.Point(g.tr.x,g.tr.y),l=new e.Point(g.bl.x,g.bl.y);new e.Point(g.br.x,g.br.y);return h.x>a.x&&m.x<b.x&&h.y>a.y&&l.y<b.y},isType:function(a){return this.type===a},_findTargetCorner:function(a,b){var g=e.util.getPointer(a),h=g.x-b.left;g=g.y-b.top;var m;for(var l in this.oCoords){m=this._getImageLines(this.oCoords[l].corner,l);m=this._findCrossPoints(h,
g,m);if(m%2==1&&m!=0)return this.__corner=l}return false},_findCrossPoints:function(a,b,g){var h,m,l,n=0;for(var c in g){l=g[c];if(!(l.o.y<b&&l.d.y<b))if(!(l.o.y>=b&&l.d.y>=b)){if(l.o.x==l.d.x&&l.o.x>=a)h=l.o.x;else{h=(l.d.y-l.o.y)/(l.d.x-l.o.x);m=b-0*a;l=l.o.y-h*l.o.x;h=-(m-l)/(0-h)}if(h>=a)n+=1;if(n==2)break}}return n},_getImageLines:function(a){return{topline:{o:a.tl,d:a.tr},rightline:{o:a.tr,d:a.br},bottomline:{o:a.br,d:a.bl},leftline:{o:a.bl,d:a.tl}}},_setCornerCoords:function(){var a=this.oCoords,
b=this.theta,g=this.cornersize*Math.cos(b),h=this.cornersize*Math.sin(b);b=this.cornersize/2;var m=b-h;a.tl.x-=m;a.tl.y-=b;a.tl.corner={tl:{x:a.tl.x,y:a.tl.y},tr:{x:a.tl.x+g,y:a.tl.y+h},bl:{x:a.tl.x-h,y:a.tl.y+g}};a.tl.corner.br={x:a.tl.corner.tr.x-h,y:a.tl.corner.tr.y+g};a.tl.x+=m;a.tl.y+=b;a.tr.x+=b;a.tr.y-=b;a.tr.corner={tl:{x:a.tr.x-g,y:a.tr.y-h},tr:{x:a.tr.x,y:a.tr.y},br:{x:a.tr.x-h,y:a.tr.y+g}};a.tr.corner.bl={x:a.tr.corner.tl.x-h,y:a.tr.corner.tl.y+g};a.tr.x-=b;a.tr.y+=b;a.bl.x-=b;a.bl.y+=
b;a.bl.corner={tl:{x:a.bl.x+h,y:a.bl.y-g},bl:{x:a.bl.x,y:a.bl.y},br:{x:a.bl.x+g,y:a.bl.y+h}};a.bl.corner.tr={x:a.bl.corner.br.x+h,y:a.bl.corner.br.y-g};a.bl.x+=b;a.bl.y-=b;a.br.x+=b;a.br.y+=b;a.br.corner={tr:{x:a.br.x+h,y:a.br.y-g},bl:{x:a.br.x-g,y:a.br.y-h},br:{x:a.br.x,y:a.br.y}};a.br.corner.tl={x:a.br.corner.bl.x+h,y:a.br.corner.bl.y-g};a.br.x-=b;a.br.y-=b;a.ml.x-=b;a.ml.y-=b;a.ml.corner={tl:{x:a.ml.x,y:a.ml.y},tr:{x:a.ml.x+g,y:a.ml.y+h},bl:{x:a.ml.x-h,y:a.ml.y+g}};a.ml.corner.br={x:a.ml.corner.tr.x-
h,y:a.ml.corner.tr.y+g};a.ml.x+=b;a.ml.y+=b;a.mt.x-=b;a.mt.y-=b;a.mt.corner={tl:{x:a.mt.x,y:a.mt.y},tr:{x:a.mt.x+g,y:a.mt.y+h},bl:{x:a.mt.x-h,y:a.mt.y+g}};a.mt.corner.br={x:a.mt.corner.tr.x-h,y:a.mt.corner.tr.y+g};a.mt.x+=b;a.mt.y+=b;a.mr.x-=b;a.mr.y-=b;a.mr.corner={tl:{x:a.mr.x,y:a.mr.y},tr:{x:a.mr.x+g,y:a.mr.y+h},bl:{x:a.mr.x-h,y:a.mr.y+g}};a.mr.corner.br={x:a.mr.corner.tr.x-h,y:a.mr.corner.tr.y+g};a.mr.x+=b;a.mr.y+=b;a.mb.x-=b;a.mb.y-=b;a.mb.corner={tl:{x:a.mb.x,y:a.mb.y},tr:{x:a.mb.x+g,y:a.mb.y+
h},bl:{x:a.mb.x-h,y:a.mb.y+g}};a.mb.corner.br={x:a.mb.corner.tr.x-h,y:a.mb.corner.tr.y+g};a.mb.x+=b;a.mb.y+=b;a=a.mb.corner;a.tl.x-=b;a.tl.y-=b;a.tr.x-=b;a.tr.y-=b;a.br.x-=b;a.br.y-=b;a.bl.x-=b;a.bl.y-=b},toGrayscale:function(){var a=this.get("fill");a&&this.set("overlayFill",(new e.Color(a)).toGrayscale().toRgb());return this},complexity:function(){return 0},getCenter:function(){return{x:this.get("left")+this.width/2,y:this.get("top")+this.height/2}},straighten:function(){this.setAngle(this._getAngleValueForStraighten());
return this},fxStraighten:function(a){a=a||{};var b=function(){},g=a.onComplete||b,h=a.onChange||b,m=this;e.util.animate({startValue:this.get("angle"),endValue:this._getAngleValueForStraighten(),duration:this.FX_DURATION,onChange:function(l){m.setAngle(l);h()},onComplete:function(){m.setCoords();g()},onStart:function(){m.setActive(false)}});return this},fxRemove:function(a){a||(a={});var b=function(){},g=a.onComplete||b,h=a.onChange||b,m=this;e.util.animate({startValue:this.get("opacity"),endValue:0,
duration:this.FX_DURATION,onChange:function(l){m.set("opacity",l);h()},onComplete:g,onStart:function(){m.setActive(false)}});return this},_getAngleValueForStraighten:function(){var a=this.get("angle");if(a>-225&&a<=-135)return-180;else if(a>-135&&a<=-45)return-90;else if(a>-45&&a<=45)return 0;else if(a>45&&a<=135)return 90;else if(a>135&&a<=225)return 180;else if(a>225&&a<=315)return 270;else if(a>315)return 360;return 0}});e.Object.prototype.rotate=e.Object.prototype.setAngle}})();
(function(){var e=this.fabric||(this.fabric={});if(!e.Line){e.Line=e.util.createClass(e.Object,{type:"line",initialize:function(f,a){f||(f=[0,0,0,0]);this.callSuper("initialize",a);this.set("x1",f[0]);this.set("y1",f[1]);this.set("x2",f[2]);this.set("y2",f[3]);this.set("width",this.x2-this.x1);this.set("height",this.y2-this.y1);this.set("left",this.x1+this.width/2);this.set("top",this.y1+this.height/2)},_render:function(f){f.beginPath();f.moveTo(-this.width/2,-this.height/2);f.lineTo(this.width/2,
this.height/2);var a=f.strokeStyle;f.strokeStyle=f.fillStyle;f.stroke();f.strokeStyle=a},complexity:function(){return 1},toObject:function(){return e.util.object.extend(this.callSuper("toObject"),{x1:this.get("x1"),y1:this.get("y1"),x2:this.get("x2"),y2:this.get("y2")})}});e.Element.ATTRIBUTE_NAMES="x1 y1 x2 y2 stroke stroke-width transform".split(" ");e.Line.fromElement=function(f,a){var b=e.parseAttributes(f,e.Element.ATTRIBUTE_NAMES);return new e.Line([b.x1||0,b.y1||0,b.x2||0,b.y2||0],e.util.object.extend(b,
a))};e.Line.fromObject=function(f){return new e.Line([f.x1,f.y1,f.x2,f.y2],f)}}})();
(function(){var e=this.fabric||(this.fabric={}),f=Math.PI*2;if(e.Circle)console.warn("fabric.Circle is already defined.");else{e.Circle=e.util.createClass(e.Object,{type:"circle",initialize:function(a){a=a||{};this.set("radius",a.radius||0);this.callSuper("initialize",a);a=this.get("radius")*2*this.get("scaleX");this.set("width",a).set("height",a)},toObject:function(){return e.util.object.extend(this.callSuper("toObject"),{radius:this.get("radius")})},_render:function(a){a.beginPath();a.arc(0,0,this.radius,
0,f,false);this.fill&&a.fill();this.stroke&&a.stroke()},complexity:function(){return 1}});e.Circle.ATTRIBUTE_NAMES="cx cy r fill fill-opacity stroke stroke-width transform".split(" ");e.Circle.fromElement=function(a,b){var g=e.parseAttributes(a,e.Circle.ATTRIBUTE_NAMES);if(!("radius"in g&&g.radius>0))throw Error("value of `r` attribute is required and can not be negative");return new e.Circle(e.util.object.extend(g,b))};e.Circle.fromObject=function(a){return new e.Circle(a)}}})();
(function(){var e=this.fabric||(this.fabric={});if(!e.Triangle){e.Triangle=e.util.createClass(e.Object,{type:"triangle",initialize:function(f){f=f||{};this.callSuper("initialize",f);this.set("width",f.width||100).set("height",f.height||100)},_render:function(f){f.beginPath();f.moveTo(-this.width/2,this.height/2);f.lineTo(0,-this.height/2);f.lineTo(this.width/2,this.height/2);this.fill&&f.fill();this.stroke&&f.stroke()},complexity:function(){return 1}});e.Triangle.fromObject=function(f){return new e.Triangle(f)}}})();
(function(){var e=this.fabric||(this.fabric={});if(e.Ellipse)console.warn("fabric.Ellipse is already defined.");else{e.Ellipse=e.util.createClass(e.Object,{type:"ellipse",initialize:function(f){f=f||{};this.callSuper("initialize",f);this.set("rx",f.rx||0);this.set("ry",f.ry||0);this.set("width",this.get("rx")*2);this.set("height",this.get("ry")*2)},toObject:function(){return e.util.object.extend(this.callSuper("toObject"),{rx:this.get("rx"),ry:this.get("ry")})},render:function(f,a){if(!(this.rx===
0||this.ry===0))return this.callSuper("render",f,a)},_render:function(f){f.beginPath();f.save();f.transform(1,0,0,this.ry/this.rx,0,0);f.arc(0,0,this.rx,0,Math.PI*2,false);f.restore();this.stroke&&f.stroke();this.fill&&f.fill()},complexity:function(){return 1}});e.Ellipse.ATTRIBUTE_NAMES="cx cy rx ry fill fill-opacity stroke stroke-width transform".split(" ");e.Ellipse.fromElement=function(f,a){var b=e.parseAttributes(f,e.Ellipse.ATTRIBUTE_NAMES);return new e.Ellipse(e.util.object.extend(b,a))};e.Ellipse.fromObject=
function(f){return new e.Ellipse(f)}}})();
(function(){var e=this.fabric||(this.fabric={});if(!e.Rect){e.Rect=e.util.createClass(e.Object,{type:"rect",options:{rx:0,ry:0},initialize:function(f){this.callSuper("initialize",f);this._initRxRy()},_initRxRy:function(){if(this.options.rx&&!this.options.ry)this.options.ry=this.options.rx;else if(this.options.ry&&!this.options.rx)this.options.rx=this.options.ry},_render:function(f){var a=this.options.rx||0,b=this.options.ry||0,g=-this.width/2,h=-this.height/2,m=this.width,l=this.height;f.beginPath();
f.moveTo(g+a,h);f.lineTo(g+m-a,h);f.bezierCurveTo(g+m,h,g+m,h+b,g+m,h+b);f.lineTo(g+m,h+l-b);f.bezierCurveTo(g+m,h+l,g+m-a,h+l,g+m-a,h+l);f.lineTo(g+a,h+l);f.bezierCurveTo(g,h+l,g,h+l-b,g,h+l-b);f.lineTo(g,h+b);f.bezierCurveTo(g,h,g+a,h,g+a,h);f.closePath();this.fill&&f.fill();this.stroke&&f.stroke()},_normalizeLeftTopProperties:function(f){f.left&&this.set("left",f.left+this.getWidth()/2);f.top&&this.set("top",f.top+this.getHeight()/2);return this},complexity:function(){return 1}});e.Rect.ATTRIBUTE_NAMES=
"x y width height rx ry fill fill-opacity stroke stroke-width transform".split(" ");e.Rect.fromElement=function(f,a){if(!f)return null;var b=e.parseAttributes(f,e.Rect.ATTRIBUTE_NAMES);b=b;b.left=b.left||0;b.top=b.top||0;b=b;var g=new e.Rect(e.util.object.extend(a||{},b));g._normalizeLeftTopProperties(b);return g};e.Rect.fromObject=function(f){return new e.Rect(f)}}})();
(function(){var e=this.fabric||(this.fabric={});if(e.Polyline)console.warn("fabric.Polyline is already defined");else{e.Polyline=e.util.createClass(e.Object,{type:"polyline",initialize:function(a,b){b=b||{};this.set("points",a);this.callSuper("initialize",b);this._calcDimensions()},_calcDimensions:function(){return e.Polygon.prototype._calcDimensions.call(this)},_toOrigin:function(){return e.Polygon.prototype._toOrigin.call(this)},toObject:function(){return e.Polygon.prototype.toObject.call(this)},
_render:function(a){var b;a.beginPath();for(var g=0,h=this.points.length;g<h;g++){b=this.points[g];a.lineTo(b.x,b.y)}this.fill&&a.fill();this.stroke&&a.stroke()},complexity:function(){return this.get("points").length}});var f="fill fill-opacity stroke stroke-width transform".split(" ");e.Polyline.fromElement=function(a,b){if(!a)return null;var g=e.parsePointsAttribute(a.getAttribute("points")),h=e.parseAttributes(a,f);return new e.Polyline(g,e.util.object.extend(h,b))};e.Polyline.fromObject=function(a){return new e.Polyline(a.points,
a)}}})();
(function(){var e=this.fabric||(this.fabric={});if(e.Polygon)console.warn("fabric.Polygon is already defined");else{e.Polygon=e.util.createClass(e.Object,{type:"polygon",initialize:function(f,a){a=a||{};this.points=f;this.callSuper("initialize",a);this._calcDimensions()},_calcDimensions:function(){var f=this.points,a=e.util.array.min(f,"x"),b=e.util.array.min(f,"y"),g=e.util.array.max(f,"x");f=e.util.array.max(f,"y");this.width=g-a;this.height=f-b;this.minX=a;this.minY=b},_toOrigin:function(){this.points=this.points.map(function(f){return{x:f.x-
this.minX,y:f.y-this.minY}},this)},toObject:function(){return e.util.object.extend(this.callSuper("toObject"),{points:this.points.concat()})},_render:function(f){var a;f.beginPath();for(var b=0,g=this.points.length;b<g;b++){a=this.points[b];f.lineTo(a.x,a.y)}this.fill&&f.fill();if(this.stroke){f.closePath();f.stroke()}},complexity:function(){return this.points.length}});e.Polygon.ATTRIBUTE_NAMES="fill fill-opacity stroke stroke-width transform".split(" ");e.Polygon.fromElement=function(f,a){if(!f)return null;
var b=e.parsePointsAttribute(f.getAttribute("points")),g=e.parseAttributes(f,e.Polygon.ATTRIBUTE_NAMES);return new e.Polygon(b,e.util.object.extend(g,a))};e.Polygon.fromObject=function(f){return new e.Polygon(f.points,f)}}})();
(function(){var e=this.fabric||(this.fabric={});if(e.Path)console.warn("fabric.Path is already defined");else if(e.Object){e.Path=e.util.createClass(e.Object,{type:"path",initialize:function(a,b){b=b||{};this.setOptions(b);this._importProperties();this.originalState={};if(!a)throw Error("`path` argument is required");var g=Object.prototype.toString.call(a)==="[object Array]";if(this.path=g?a:a.match&&a.match(/[a-zA-Z][^a-zA-Z]*/g)){g||this._initializeFromArray(b);this.setCoords();b.sourcePath&&this.setSourcePath(b.sourcePath)}},
_initializeFromArray:function(a){var b="width"in a;a="height"in a;this.path=this._parsePath();if(!b||!a){e.util.object.extend(this,this._parseDimensions());if(b)this.width=this.options.width;if(a)this.height=this.options.height}},_render:function(a){for(var b,g=0,h=0,m=0,l=0,n,c,d=-(this.width/2),k=-(this.height/2),o=0,s=this.path.length;o<s;++o){b=this.path[o];switch(b[0]){case "l":g+=b[1];h+=b[2];a.lineTo(g+d,h+k);break;case "L":g=b[1];h=b[2];a.lineTo(g+d,h+k);break;case "h":g+=b[1];a.lineTo(g+
d,h+k);break;case "H":g=b[1];a.lineTo(g+d,h+k);break;case "v":h+=b[1];a.lineTo(g+d,h+k);break;case "V":h=b[1];a.lineTo(g+d,h+k);break;case "m":g+=b[1];h+=b[2];a.moveTo(g+d,h+k);break;case "M":g=b[1];h=b[2];a.moveTo(g+d,h+k);break;case "c":n=g+b[5];c=h+b[6];m=g+b[3];l=h+b[4];a.bezierCurveTo(g+b[1]+d,h+b[2]+k,m+d,l+k,n+d,c+k);g=n;h=c;break;case "C":g=b[5];h=b[6];m=b[3];l=b[4];a.bezierCurveTo(b[1]+d,b[2]+k,m+d,l+k,g+d,h+k);break;case "s":n=g+b[3];c=h+b[4];m=2*g-m;l=2*h-l;a.bezierCurveTo(m+d,l+k,g+b[1]+
d,h+b[2]+k,n+d,c+k);g=n;h=c;break;case "S":n=b[3];c=b[4];m=2*g-m;l=2*h-l;a.bezierCurveTo(m+d,l+k,b[1]+d,b[2]+k,n+d,c+k);g=n;h=c;break;case "q":g+=b[3];h+=b[4];a.quadraticCurveTo(b[1]+d,b[2]+k,g+d,h+k);break;case "Q":g=b[3];h=b[4];m=b[1];l=b[2];a.quadraticCurveTo(m+d,l+k,g+d,h+k);break;case "T":n=g;c=h;g=b[1];h=b[2];m=-m+2*n;l=-l+2*c;a.quadraticCurveTo(m+d,l+k,g+d,h+k);break;case "a":break;case "A":break;case "z":case "Z":a.closePath();break}}},render:function(a,b){a.save();var g=this.transformMatrix;
g&&a.transform(g[0],g[1],g[2],g[3],g[4],g[5]);b||this.transform(a);if(this.overlayFill)a.fillStyle=this.overlayFill;else if(this.fill)a.fillStyle=this.fill;if(this.stroke)a.strokeStyle=this.stroke;a.beginPath();this.stub?this.stub._render(a):this._render(a);this.fill&&a.fill();if(this.options.stroke){a.strokeStyle=this.options.stroke;a.lineWidth=this.options.strokeWidth;a.stroke()}if(!b&&this.active){this.drawBorders(a);this.hideCorners||this.drawCorners(a)}a.restore()},toString:function(){return"#<fabric.Path ("+
this.complexity()+"): "+JSON.stringify({top:this.top,left:this.left})+">"},toObject:function(){var a=e.util.object.extend(this.callSuper("toObject"),{path:this.path});if(this.sourcePath)a.sourcePath=this.sourcePath;if(this.transformMatrix)a.transformMatrix=this.transformMatrix;return a},toDatalessObject:function(){var a=this.toObject();if(this.sourcePath)a.path=this.sourcePath;delete a.sourcePath;return a},complexity:function(){return this.path.length},set:function(a,b){this.stub&&this.stub.set(a,
b);return this.callSuper("set",a,b)},_parsePath:function(){for(var a=[],b,g,h=0,m=this.path.length;h<m;h++){b=this.path[h];g=b.slice(1).trim().replace(/(\d)-/g,"$1###-").split(/\s|,|###/);a.push([b.charAt(0)].concat(g.map(parseFloat)))}return a},_parseDimensions:function(){function a(r){if(r[0]==="H")return r[1];return r[r.length-2]}function b(r){if(r[0]==="V")return r[1];return r[r.length-1]}var g=[],h=[],m,l,n=false,c,d;this.path.forEach(function(r,t){if(r[0]!=="H")m=t===0?a(r):a(this.path[t-1]);
if(r[0]!=="V")l=t===0?b(r):b(this.path[t-1]);if(r[0]===r[0].toLowerCase())n=true;c=n?m+a(r):r[0]==="V"?m:a(r);d=n?l+b(r):r[0]==="H"?l:b(r);var p=parseInt(c,10);isNaN(p)||g.push(p);p=parseInt(d,10);isNaN(p)||h.push(p)},this);var k=e.util.array.min(g),o=e.util.array.min(h),s=deltaY=0;k={top:o-deltaY,left:k-s,bottom:e.util.array.max(h)-deltaY,right:e.util.array.max(g)-s};k.width=k.right-k.left;k.height=k.bottom-k.top;return k}});e.Path.fromObject=function(a){return new e.Path(a.path,a)};var f=e.Path.ATTRIBUTE_NAMES=
"d fill fill-opacity fill-rule stroke stroke-width transform".split(" ");e.Path.fromElement=function(a,b){var g=e.parseAttributes(a,f),h=g.d;delete g.d;return new e.Path(h,e.util.object.extend(g,b))}}else console.warn("fabric.Path requires fabric.Object")})();
(function(){var e=this.fabric||(this.fabric={});if(e.PathGroup)console.warn("fabric.PathGroup is already defined");else{e.PathGroup=e.util.createClass(e.Path,{type:"path-group",forceFillOverwrite:false,initialize:function(f,a){a=a||{};this.originalState={};this.paths=f;this.setOptions(a);this.initProperties();this.setCoords();a.sourcePath&&this.setSourcePath(a.sourcePath)},initProperties:function(){this.stateProperties.forEach(function(f){if(f==="fill")this.set(f,this.options[f]);else if(f==="angle")this.setAngle(this.options[f]);
else this[f]=this.options[f]},this)},render:function(f){if(this.stub){f.save();this.transform(f);this.stub.render(f,false);if(this.active){this.drawBorders(f);this.drawCorners(f)}}else{f.save();var a=this.transformMatrix;a&&f.transform(a[0],a[1],a[2],a[3],a[4],a[5]);this.transform(f);a=0;for(var b=this.paths.length;a<b;++a)this.paths[a].render(f,true);if(this.active){this.drawBorders(f);this.hideCorners||this.drawCorners(f)}}f.restore()},set:function(f,a){if((f==="fill"||f==="overlayFill")&&this.isSameColor()){this[f]=
a;for(var b=this.paths.length;b--;)this.paths[b].set(f,a)}else e.Object.prototype.set.call(this,f,a);return this},toObject:function(){return e.util.object.extend(e.Object.prototype.toObject.call(this),{paths:e.util.array.invoke(this.getObjects(),"clone"),sourcePath:this.sourcePath})},toDatalessObject:function(){var f=this.toObject();if(this.sourcePath)f.paths=this.sourcePath;return f},toString:function(){return"#<fabric.PathGroup ("+this.complexity()+"): { top: "+this.top+", left: "+this.left+" }>"},
isSameColor:function(){var f=this.getObjects()[0].get("fill");return this.getObjects().every(function(a){return a.get("fill")===f})},complexity:function(){return this.paths.reduce(function(f,a){return f+(a&&a.complexity?a.complexity():0)},0)},toGrayscale:function(){for(var f=this.paths.length;f--;)this.paths[f].toGrayscale();return this},getObjects:function(){return this.paths}});e.PathGroup.fromObject=function(f){for(var a=f.paths,b=0,g=a.length;b<g;b++)if(!(a[b]instanceof e.Object)){var h=a[b].type.camelize().capitalize();
a[b]=Canvas[h].fromObject(a[b])}return new e.PathGroup(a,f)}}})();
(function(){var e=this.fabric||(this.fabric={});if(!e.Group){e.Group=e.util.createClass(e.Object,{type:"group",initialize:function(f,a){this.objects=f||[];this.originalState={};this.callSuper("initialize");this._calcBounds();this._updateObjectsCoords();a&&e.util.object.extend(this,a);this._setOpacityIfSame();this.setCoords(true);this.saveCoords();this.activateAllObjects()},_updateObjectsCoords:function(){var f=this.left,a=this.top;this.forEachObject(function(b){var g=b.get("left"),h=b.get("top");
b.set("originalLeft",g);b.set("originalTop",h);b.set("left",g-f);b.set("top",h-a);b.setCoords();b.hideCorners=true},this)},toString:function(){return"#<fabric.Group: ("+this.complexity()+")>"},getObjects:function(){return this.objects},add:function(f){this._restoreObjectsState();this.objects.push(f);f.setActive(true);this._calcBounds();this._updateObjectsCoords();return this},remove:function(f){this._restoreObjectsState();e.util.removeFromArray(this.objects,f);f.setActive(false);this._calcBounds();
this._updateObjectsCoords();return this},size:function(){return this.getObjects().length},set:function(f,a){if(typeof a=="function")this.set(f,a(this[f]));else if(f==="fill"||f==="opacity"){var b=this.objects.length;for(this[f]=a;b--;)this.objects[b].set(f,a)}else this[f]=a;return this},contains:function(f){return this.objects.indexOf(f)>-1},toObject:function(){return e.util.object.extend(this.callSuper("toObject"),{objects:e.util.array.invoke(this.objects,"clone")})},render:function(f){f.save();
this.transform(f);for(var a=Math.max(this.scaleX,this.scaleY),b=0,g=this.objects.length;b<g;b++){var h=this.objects[b].borderScaleFactor;this.objects[b].borderScaleFactor=a;this.objects[b].render(f);this.objects[b].borderScaleFactor=h}this.hideBorders||this.drawBorders(f);this.hideCorners||this.drawCorners(f);f.restore();this.setCoords()},item:function(f){return this.getObjects()[f]},complexity:function(){return this.getObjects().reduce(function(f,a){f+=typeof a.complexity=="function"?a.complexity():
0;return f},0)},_restoreObjectsState:function(){this.objects.forEach(this._restoreObjectState,this);return this},_restoreObjectState:function(f){var a=this.get("left"),b=this.get("top"),g=this.getAngle()*(Math.PI/180);f.get("originalLeft");f.get("originalTop");var h=Math.cos(g)*f.get("top")+Math.sin(g)*f.get("left");g=-Math.sin(g)*f.get("top")+Math.cos(g)*f.get("left");f.setAngle(f.getAngle()+this.getAngle());f.set("left",a+g*this.get("scaleX"));f.set("top",b+h*this.get("scaleY"));f.set("scaleX",
f.get("scaleX")*this.get("scaleX"));f.set("scaleY",f.get("scaleY")*this.get("scaleY"));f.setCoords();f.hideCorners=false;f.setActive(false);f.setCoords();return this},destroy:function(){return this._restoreObjectsState()},saveCoords:function(){this._originalLeft=this.get("left");this._originalTop=this.get("top");return this},hasMoved:function(){return this._originalLeft!==this.get("left")||this._originalTop!==this.get("top")},setObjectsCoords:function(){this.forEachObject(function(f){f.setCoords()});
return this},activateAllObjects:function(){return this.setActive(true)},setActive:function(f){this.forEachObject(function(a){a.setActive(f)});return this},forEachObject:function(f,a){for(var b=this.getObjects(),g=b.length;g--;)f.call(a,b[g],g,b);return this},_setOpacityIfSame:function(){var f=this.getObjects(),a=f[0]?f[0].get("opacity"):1;if(f.every(function(b){return b.get("opacity")===a}))this.opacity=a},_calcBounds:function(){var f=[],a=[],b,g;g=0;for(var h=this.objects.length;g<h;++g){b=this.objects[g];
b.setCoords();for(var m in b.oCoords){f.push(b.oCoords[m].x);a.push(b.oCoords[m].y)}}b=e.util.array.min(f);g=e.util.array.max(f);f=e.util.array.min(a);a=e.util.array.max(a);g=g-b;a=a-f;this.width=g;this.height=a;this.left=b+g/2;this.top=f+a/2},containsPoint:function(f){var a=this.get("width")/2,b=this.get("height")/2,g=this.get("left"),h=this.get("top");return g-a<f.x&&g+a>f.x&&h-b<f.y&&h+b>f.y},toGrayscale:function(){for(var f=this.objects.length;f--;)this.objects[f].toGrayscale()}});e.Group.fromObject=
function(f){return new e.Group(f.objects,f)}}})();
(function(){var e=this.fabric||(this.fabric={});if(e.Text)console.warn("fabric.Text is already defined");else if(e.Object){e.Text=e.util.createClass(e.Object,{options:{top:10,left:10,fontsize:20,fontweight:100,fontfamily:"Modernist_One_400",path:null},type:"text",initialize:function(f,a){this.originalState={};this.initStateProperties();this.text=f;this.setOptions(a);e.util.object.extend(this,this.options);this.theta=this.angle*(Math.PI/180);this.width=this.getWidth();this.setCoords()},initStateProperties:function(){var f;
if((f=this.constructor)&&(f=f.superclass)&&(f=f.prototype)&&(f=f.stateProperties)&&f.clone){this.stateProperties=f.clone();this.stateProperties.push("fontfamily","fontweight","path")}},toString:function(){return"#<fabric.Text ("+this.complexity()+"): "+JSON.stringify({text:this.text,fontfamily:this.fontfamily})+">"},_render:function(f){var a=Cufon.textOptions||(Cufon.textOptions={});a.left=this.left;a.top=this.top;a.context=f;a.color=this.fill;var b=this._initDummyElement();this.transform(f);Cufon.replaceElement(b,
{separate:"none",fontFamily:this.fontfamily});this.width=a.width;this.height=a.height},_initDummyElement:function(){var f=document.createElement("div");f.innerHTML=this.text;f.style.fontSize="40px";f.style.fontWeight="400";f.style.fontStyle="normal";f.style.letterSpacing="normal";f.style.color="#000000";f.style.fontWeight="600";f.style.fontFamily="Verdana";return f},render:function(f){f.save();this._render(f);if(this.active){this.drawBorders(f);this.drawCorners(f)}f.restore()},toObject:function(){return e.util.object.extend(this.callSuper("toObject"),
{text:this.text,fontsize:this.fontsize,fontweight:this.fontweight,fontfamily:this.fontfamily,path:this.path})},setColor:function(f){this.set("fill",f);return this},setFontsize:function(f){this.set("fontsize",f);this.setCoords();return this},getText:function(){return this.text},setText:function(f){this.set("text",f);this.setCoords();return this},set:function(f,a){this[f]=a;if(f==="fontfamily")this.path=this.path.replace(/(.*?)([^\/]*)(\.font\.js)/,"$1"+a+"$3");return this}});e.Text.fromObject=function(f){return new e.Text(f.text,
e.util.object.clone(f))};e.Text.fromElement=function(){}}else console.warn("fabric.Text requires fabric.Object")})();
(function(){if(!this.fabric)this.fabric={};if(this.fabric.Image)console.warn("fabric.Image is already defined.");else if(fabric.Object){fabric.Image=fabric.util.createClass(fabric.Object,{maxwidth:null,maxheight:null,active:false,bordervisibility:false,cornervisibility:false,type:"image",__isGrayscaled:false,initialize:function(e,f){this.callSuper("initialize",f);this._initElement(e);this._initConfig(f||{})},getElement:function(){return this._element},setElement:function(e){this._element=e;return this},
getNormalizedSize:function(e,f,a){if(a&&f&&e.width>e.height&&e.width/e.height<f/a){normalizedWidth=Math.floor(e.width*a/e.height);normalizedHeight=a}else if(a&&(e.height==e.width||e.height>e.width||e.height>a)){normalizedWidth=Math.floor(e.width*a/e.height);normalizedHeight=a}else if(f&&f<e.width){normalizedHeight=Math.floor(e.height*f/e.width);normalizedWidth=f}else{normalizedWidth=e.width;normalizedHeight=e.height}return{width:normalizedWidth,height:normalizedHeight}},getOriginalSize:function(){var e=
this.getElement();return{width:e.width,height:e.height}},setBorderVisibility:function(e){this._resetWidthHeight();this._adjustWidthHeightToBorders(e);this.setCoords()},setCornersVisibility:function(e){this.cornervisibility=!!e},render:function(e,f){e.save();f||this.transform(e);this._render(e);if(this.active&&!f){this.drawBorders(e);this.hideCorners||this.drawCorners(e)}e.restore()},toObject:function(){return fabric.util.object.extend(this.callSuper("toObject"),{src:this.getSrc()})},getSrc:function(){return this.getElement().src},
toString:function(){return'#<fabric.Image: { src: "'+this.getSrc()+'" }>'},clone:function(e){this.constructor.fromObject(this.toObject(),e)},toGrayscale:function(e){if(!this.__isGrayscaled){var f=this.getElement(),a=document.createElement("canvas"),b=document.createElement("img"),g=this;a.width=f.width;a.height=f.height;a.getContext("2d").drawImage(f,0,0);fabric.Element.toGrayscale(a);b.onload=function(){g.setElement(b);e&&e();b.onload=a=f=imageData=null};b.width=f.width;b.height=f.height;b.src=a.toDataURL("image/png");
this.__isGrayscaled=true;return this}},_render:function(e){var f=this.getOriginalSize();e.drawImage(this.getElement(),-f.width/2,-f.height/2,f.width,f.height)},_adjustWidthHeightToBorders:function(e){if(e){this.currentBorder=this.borderwidth;this.width+=2*this.currentBorder;this.height+=2*this.currentBorder}else this.currentBorder=0},_resetWidthHeight:function(){var e=this.getElement();this.set("width",e.width);this.set("height",e.height)},_initElement:function(e){this.setElement(fabric.util.getById(e));
fabric.util.addClass(this.getElement(),fabric.Image.CSS_CANVAS)},_initConfig:function(e){this.setOptions(e);this._setBorder();this._setWidthHeight(e)},_setBorder:function(){this.currentBorder=this.bordervisibility?this.borderwidth:0},_setWidthHeight:function(){var e=2*this.currentBorder;this.width=(this.getElement().width||0)+e;this.height=(this.getElement().height||0)+e}});fabric.Image.CSS_CANVAS="canvas-img";fabric.Image.fromObject=function(e,f){var a=document.createElement("img"),b=e.src;if(e.width)a.width=
e.width;if(e.height)a.height=e.height;a.onload=function(){f&&f(new fabric.Image(a,e));a=a.onload=null};a.src=b};fabric.Image.fromURL=function(e,f,a){var b=document.createElement("img");b.onload=function(){f&&f(new fabric.Image(b,a));b=b.onload=null};b.src=e}}else console.warn("fabric.Object is required for fabric.Image initialization")})();
this.height*this.scaleY;this._hypotenuse=Math.sqrt(Math.pow(this.currentWidth/2,2)+Math.pow(this.currentHeight/2,2));this._angle=Math.atan(this.currentHeight/this.currentWidth);var a=Math.cos(this._angle+this.theta)*this._hypotenuse,e=Math.sin(this._angle+this.theta)*this._hypotenuse,n=this.theta,p=Math.sin(n);n=Math.cos(n);a={x:this.left-a,y:this.top-e};e={x:a.x+this.currentWidth*n,y:a.y+this.currentWidth*p};var r={x:a.x-this.currentHeight*p,y:a.y+this.currentHeight*n};this.oCoords={tl:a,tr:e,br:{x:e.x-
this.currentHeight*p,y:e.y+this.currentHeight*n},bl:r,ml:{x:a.x-this.currentHeight/2*p,y:a.y+this.currentHeight/2*n},mt:{x:a.x+this.currentWidth/2*n,y:a.y+this.currentWidth/2*p},mr:{x:e.x-this.currentHeight/2*p,y:e.y+this.currentHeight/2*n},mb:{x:r.x+this.currentWidth/2*n,y:r.y+this.currentWidth/2*p}};this._setCornerCoords();return this},drawBorders:function(a){var e=this.options,n=e.padding,p=n*2;a.save();a.globalAlpha=this.isMoving?e.borderOpacityWhenMoving:1;a.strokeStyle=e.borderColor;e=1/(this.scaleX<
this.MIN_SCALE_LIMIT?this.MIN_SCALE_LIMIT:this.scaleX);var r=1/(this.scaleY<this.MIN_SCALE_LIMIT?this.MIN_SCALE_LIMIT:this.scaleY);a.lineWidth=1/this.borderScaleFactor;a.scale(e,r);e=this.getWidth();r=this.getHeight();a.strokeRect(Math.floor(-(e/2)-n)+0.5,Math.floor(-(r/2)-n)+0.5,Math.floor(e+p),Math.floor(r+p));a.restore();return this},drawCorners:function(a){var e=this.options.cornersize,n=e/2,p=this.options.padding,r=-(this.width/2),s=-(this.height/2),t=e/this.scaleX,b=e/this.scaleY,f=(p+n)/this.scaleY,
l=(p+n)/this.scaleX,o=(p+n-e)/this.scaleX;p=(p+n-e)/this.scaleY;a.save();a.globalAlpha=this.isMoving?this.options.borderOpacityWhenMoving:1;a.fillStyle=this.options.cornerColor;e=r-l;n=s-f;a.fillRect(e,n,t,b);e=r+this.width-l;n=s-f;a.fillRect(e,n,t,b);e=r-l;n=s+this.height+p;a.fillRect(e,n,t,b);e=r+this.width+o;n=s+this.height+p;a.fillRect(e,n,t,b);e=r+this.width/2-l;n=s-f;a.fillRect(e,n,t,b);e=r+this.width/2-l;n=s+this.height+p;a.fillRect(e,n,t,b);e=r+this.width+o;n=s+this.height/2-f;a.fillRect(e,
n,t,b);e=r-l;n=s+this.height/2-f;a.fillRect(e,n,t,b);a.restore();return this},clone:function(a){if(this.constructor.fromObject)return this.constructor.fromObject(this.toObject(),a);return new d.Object(this.toObject())},cloneAsImage:function(a){if(d.Image){var e=new Image;e.onload=function(){a&&a(new d.Image(e),n);e=e.onload=null};var n={angle:this.get("angle"),flipX:this.get("flipX"),flipY:this.get("flipY")};this.set("angle",0).set("flipX",false).set("flipY",false);e.src=this.toDataURL()}return this},
toDataURL:function(){var a=document.createElement("canvas");a.width=this.getWidth();a.height=this.getHeight();d.util.wrapElement(a,"div");var e=new d.Element(a);e.backgroundColor="transparent";e.renderAll();var n=this.clone();n.left=a.width/2;n.top=a.height/2;n.setActive(false);e.add(n);a=e.toDataURL("png");e.dispose();return a},hasStateChanged:function(){return this.stateProperties.some(function(a){return this[a]!==this.originalState[a]},this)},saveState:function(){this.stateProperties.forEach(function(a){this.originalState[a]=
this.get(a)},this);return this},intersectsWithRect:function(a,e){var n=this.oCoords,p=new d.Point(n.tl.x,n.tl.y),r=new d.Point(n.tr.x,n.tr.y),s=new d.Point(n.bl.x,n.bl.y);n=new d.Point(n.br.x,n.br.y);return d.Intersection.intersectPolygonRectangle([p,r,n,s],a,e).status==="Intersection"},intersectsWithObject:function(a){function e(p){return{tl:new d.Point(p.tl.x,p.tl.y),tr:new d.Point(p.tr.x,p.tr.y),bl:new d.Point(p.bl.x,p.bl.y),br:new d.Point(p.br.x,p.br.y)}}var n=e(this.oCoords);a=e(a.oCoords);return d.Intersection.intersectPolygonPolygon([n.tl,
n.tr,n.br,n.bl],[a.tl,a.tr,a.br,a.bl]).status==="Intersection"},isContainedWithinRect:function(a,e){var n=this.oCoords,p=new d.Point(n.tl.x,n.tl.y),r=new d.Point(n.tr.x,n.tr.y),s=new d.Point(n.bl.x,n.bl.y);new d.Point(n.br.x,n.br.y);return p.x>a.x&&r.x<e.x&&p.y>a.y&&s.y<e.y},isType:function(a){return this.type===a},_findTargetCorner:function(a,e){var n=c(a),p=n.x-e.left;n=n.y-e.top;var r;for(var s in this.oCoords){r=this._getImageLines(this.oCoords[s].corner,s);r=this._findCrossPoints(p,n,r);if(r%
2==1&&r!=0)return this.__corner=s}return false},_findCrossPoints:function(a,e,n){var p,r,s,t=0;for(var b in n){s=n[b];if(!(s.o.y<e&&s.d.y<e))if(!(s.o.y>=e&&s.d.y>=e)){if(s.o.x==s.d.x&&s.o.x>=a)p=s.o.x;else{p=(s.d.y-s.o.y)/(s.d.x-s.o.x);r=e-0*a;s=s.o.y-p*s.o.x;p=-(r-s)/(0-p)}if(p>=a)t+=1;if(t==2)break}}return t},_getImageLines:function(a){return{topline:{o:a.tl,d:a.tr},rightline:{o:a.tr,d:a.br},bottomline:{o:a.br,d:a.bl},leftline:{o:a.bl,d:a.tl}}},_setCornerCoords:function(){var a=this.oCoords,e=this.theta,
n=this.cornersize*Math.cos(e),p=this.cornersize*Math.sin(e);e=this.cornersize/2;var r=e-p;a.tl.x-=r;a.tl.y-=e;a.tl.corner={tl:{x:a.tl.x,y:a.tl.y},tr:{x:a.tl.x+n,y:a.tl.y+p},bl:{x:a.tl.x-p,y:a.tl.y+n}};a.tl.corner.br={x:a.tl.corner.tr.x-p,y:a.tl.corner.tr.y+n};a.tl.x+=r;a.tl.y+=e;a.tr.x+=e;a.tr.y-=e;a.tr.corner={tl:{x:a.tr.x-n,y:a.tr.y-p},tr:{x:a.tr.x,y:a.tr.y},br:{x:a.tr.x-p,y:a.tr.y+n}};a.tr.corner.bl={x:a.tr.corner.tl.x-p,y:a.tr.corner.tl.y+n};a.tr.x-=e;a.tr.y+=e;a.bl.x-=e;a.bl.y+=e;a.bl.corner=
{tl:{x:a.bl.x+p,y:a.bl.y-n},bl:{x:a.bl.x,y:a.bl.y},br:{x:a.bl.x+n,y:a.bl.y+p}};a.bl.corner.tr={x:a.bl.corner.br.x+p,y:a.bl.corner.br.y-n};a.bl.x+=e;a.bl.y-=e;a.br.x+=e;a.br.y+=e;a.br.corner={tr:{x:a.br.x+p,y:a.br.y-n},bl:{x:a.br.x-n,y:a.br.y-p},br:{x:a.br.x,y:a.br.y}};a.br.corner.tl={x:a.br.corner.bl.x+p,y:a.br.corner.bl.y-n};a.br.x-=e;a.br.y-=e;a.ml.x-=e;a.ml.y-=e;a.ml.corner={tl:{x:a.ml.x,y:a.ml.y},tr:{x:a.ml.x+n,y:a.ml.y+p},bl:{x:a.ml.x-p,y:a.ml.y+n}};a.ml.corner.br={x:a.ml.corner.tr.x-p,y:a.ml.corner.tr.y+
n};a.ml.x+=e;a.ml.y+=e;a.mt.x-=e;a.mt.y-=e;a.mt.corner={tl:{x:a.mt.x,y:a.mt.y},tr:{x:a.mt.x+n,y:a.mt.y+p},bl:{x:a.mt.x-p,y:a.mt.y+n}};a.mt.corner.br={x:a.mt.corner.tr.x-p,y:a.mt.corner.tr.y+n};a.mt.x+=e;a.mt.y+=e;a.mr.x-=e;a.mr.y-=e;a.mr.corner={tl:{x:a.mr.x,y:a.mr.y},tr:{x:a.mr.x+n,y:a.mr.y+p},bl:{x:a.mr.x-p,y:a.mr.y+n}};a.mr.corner.br={x:a.mr.corner.tr.x-p,y:a.mr.corner.tr.y+n};a.mr.x+=e;a.mr.y+=e;a.mb.x-=e;a.mb.y-=e;a.mb.corner={tl:{x:a.mb.x,y:a.mb.y},tr:{x:a.mb.x+n,y:a.mb.y+p},bl:{x:a.mb.x-p,
y:a.mb.y+n}};a.mb.corner.br={x:a.mb.corner.tr.x-p,y:a.mb.corner.tr.y+n};a.mb.x+=e;a.mb.y+=e;a=a.mb.corner;a.tl.x-=e;a.tl.y-=e;a.tr.x-=e;a.tr.y-=e;a.br.x-=e;a.br.y-=e;a.bl.x-=e;a.bl.y-=e},toGrayscale:function(){var a=this.get("fill");a&&this.set("overlayFill",(new d.Color(a)).toGrayscale().toRgb());return this},complexity:function(){return 0},getCenter:function(){return{x:this.get("left")+this.width/2,y:this.get("top")+this.height/2}},straighten:function(){this.setAngle(this._getAngleValueForStraighten());
return this},fxStraighten:function(a){a=a||{};var e=function(){},n=a.onComplete||e,p=a.onChange||e,r=this;d.util.animate({startValue:this.get("angle"),endValue:this._getAngleValueForStraighten(),duration:this.FX_DURATION,onChange:function(s){r.setAngle(s);p()},onComplete:function(){r.setCoords();n()},onStart:function(){r.setActive(false)}});return this},fxRemove:function(a){a||(a={});var e=function(){},n=a.onComplete||e,p=a.onChange||e,r=this;d.util.animate({startValue:this.get("opacity"),endValue:0,
duration:this.FX_DURATION,onChange:function(s){r.set("opacity",s);p()},onComplete:n,onStart:function(){r.setActive(false)}});return this},_getAngleValueForStraighten:function(){var a=this.get("angle");if(a>-225&&a<=-135)return-180;else if(a>-135&&a<=-45)return-90;else if(a>-45&&a<=45)return 0;else if(a>45&&a<=135)return 90;else if(a>135&&a<=225)return 180;else if(a>225&&a<=315)return 270;else if(a>315)return 360;return 0}});d.Object.prototype.rotate=d.Object.prototype.setAngle}})();
(function(){var d=this.fabric||(this.fabric={}),q=d.util.object.extend;if(!d.Line){d.Line=d.util.createClass(d.Object,{type:"line",initialize:function(g,k){g||(g=[0,0,0,0]);this.callSuper("initialize",k);this.set("x1",g[0]);this.set("y1",g[1]);this.set("x2",g[2]);this.set("y2",g[3]);this.set("width",this.x2-this.x1);this.set("height",this.y2-this.y1);this.set("left",this.x1+this.width/2);this.set("top",this.y1+this.height/2)},_render:function(g){g.beginPath();g.moveTo(-this.width/2,-this.height/2);
g.lineTo(this.width/2,this.height/2);var k=g.strokeStyle;g.strokeStyle=g.fillStyle;g.stroke();g.strokeStyle=k},complexity:function(){return 1},toObject:function(){return q(this.callSuper("toObject"),{x1:this.get("x1"),y1:this.get("y1"),x2:this.get("x2"),y2:this.get("y2")})}});d.Element.ATTRIBUTE_NAMES="x1 y1 x2 y2 stroke stroke-width transform".split(" ");d.Line.fromElement=function(g,k){var m=d.parseAttributes(g,d.Element.ATTRIBUTE_NAMES);return new d.Line([m.x1||0,m.y1||0,m.x2||0,m.y2||0],q(m,k))};
d.Line.fromObject=function(g){return new d.Line([g.x1,g.y1,g.x2,g.y2],g)}}})();
(function(){var d=this.fabric||(this.fabric={}),q=Math.PI*2,g=d.util.object.extend;if(d.Circle)console.warn("fabric.Circle is already defined.");else{d.Circle=d.util.createClass(d.Object,{type:"circle",initialize:function(k){k=k||{};this.set("radius",k.radius||0);this.callSuper("initialize",k);k=this.get("radius")*2*this.get("scaleX");this.set("width",k).set("height",k)},toObject:function(){return g(this.callSuper("toObject"),{radius:this.get("radius")})},_render:function(k){k.beginPath();k.arc(0,
0,this.radius,0,q,false);this.fill&&k.fill();this.stroke&&k.stroke()},complexity:function(){return 1}});d.Circle.ATTRIBUTE_NAMES="cx cy r fill fill-opacity stroke stroke-width transform".split(" ");d.Circle.fromElement=function(k,m){var c=d.parseAttributes(k,d.Circle.ATTRIBUTE_NAMES);if(!("radius"in c&&c.radius>0))throw Error("value of `r` attribute is required and can not be negative");return new d.Circle(g(c,m))};d.Circle.fromObject=function(k){return new d.Circle(k)}}})();
(function(){var d=this.fabric||(this.fabric={});if(!d.Triangle){d.Triangle=d.util.createClass(d.Object,{type:"triangle",initialize:function(q){q=q||{};this.callSuper("initialize",q);this.set("width",q.width||100).set("height",q.height||100)},_render:function(q){q.beginPath();q.moveTo(-this.width/2,this.height/2);q.lineTo(0,-this.height/2);q.lineTo(this.width/2,this.height/2);this.fill&&q.fill();this.stroke&&q.stroke()},complexity:function(){return 1}});d.Triangle.fromObject=function(q){return new d.Triangle(q)}}})();
(function(){var d=this.fabric||(this.fabric={}),q=d.util.object.extend;if(d.Ellipse)console.warn("fabric.Ellipse is already defined.");else{d.Ellipse=d.util.createClass(d.Object,{type:"ellipse",initialize:function(g){g=g||{};this.callSuper("initialize",g);this.set("rx",g.rx||0);this.set("ry",g.ry||0);this.set("width",this.get("rx")*2);this.set("height",this.get("ry")*2)},toObject:function(){return q(this.callSuper("toObject"),{rx:this.get("rx"),ry:this.get("ry")})},render:function(g,k){if(!(this.rx===
0||this.ry===0))return this.callSuper("render",g,k)},_render:function(g){g.beginPath();g.save();g.transform(1,0,0,this.ry/this.rx,0,0);g.arc(0,0,this.rx,0,Math.PI*2,false);g.restore();this.stroke&&g.stroke();this.fill&&g.fill()},complexity:function(){return 1}});d.Ellipse.ATTRIBUTE_NAMES="cx cy rx ry fill fill-opacity stroke stroke-width transform".split(" ");d.Ellipse.fromElement=function(g,k){var m=d.parseAttributes(g,d.Ellipse.ATTRIBUTE_NAMES);return new d.Ellipse(q(m,k))};d.Ellipse.fromObject=
function(g){return new d.Ellipse(g)}}})();
(function(){var d=this.fabric||(this.fabric={});if(!d.Rect){d.Rect=d.util.createClass(d.Object,{type:"rect",options:{rx:0,ry:0},initialize:function(q){this.callSuper("initialize",q);this._initRxRy()},_initRxRy:function(){if(this.options.rx&&!this.options.ry)this.options.ry=this.options.rx;else if(this.options.ry&&!this.options.rx)this.options.rx=this.options.ry},_render:function(q){var g=this.options.rx||0,k=this.options.ry||0,m=-this.width/2,c=-this.height/2,h=this.width,a=this.height;q.beginPath();
q.moveTo(m+g,c);q.lineTo(m+h-g,c);q.bezierCurveTo(m+h,c,m+h,c+k,m+h,c+k);q.lineTo(m+h,c+a-k);q.bezierCurveTo(m+h,c+a,m+h-g,c+a,m+h-g,c+a);q.lineTo(m+g,c+a);q.bezierCurveTo(m,c+a,m,c+a-k,m,c+a-k);q.lineTo(m,c+k);q.bezierCurveTo(m,c,m+g,c,m+g,c);q.closePath();this.fill&&q.fill();this.stroke&&q.stroke()},_normalizeLeftTopProperties:function(q){q.left&&this.set("left",q.left+this.getWidth()/2);q.top&&this.set("top",q.top+this.getHeight()/2);return this},complexity:function(){return 1}});d.Rect.ATTRIBUTE_NAMES=
"x y width height rx ry fill fill-opacity stroke stroke-width transform".split(" ");d.Rect.fromElement=function(q,g){if(!q)return null;var k=d.parseAttributes(q,d.Rect.ATTRIBUTE_NAMES);k=k;k.left=k.left||0;k.top=k.top||0;k=k;var m=new d.Rect(d.util.object.extend(g||{},k));m._normalizeLeftTopProperties(k);return m};d.Rect.fromObject=function(q){return new d.Rect(q)}}})();
(function(){var d=this.fabric||(this.fabric={});if(d.Polyline)console.warn("fabric.Polyline is already defined");else{d.Polyline=d.util.createClass(d.Object,{type:"polyline",initialize:function(g,k){k=k||{};this.set("points",g);this.callSuper("initialize",k);this._calcDimensions()},_calcDimensions:function(){return d.Polygon.prototype._calcDimensions.call(this)},_toOrigin:function(){return d.Polygon.prototype._toOrigin.call(this)},toObject:function(){return d.Polygon.prototype.toObject.call(this)},
_render:function(g){var k;g.beginPath();for(var m=0,c=this.points.length;m<c;m++){k=this.points[m];g.lineTo(k.x,k.y)}this.fill&&g.fill();this.stroke&&g.stroke()},complexity:function(){return this.get("points").length}});var q="fill fill-opacity stroke stroke-width transform".split(" ");d.Polyline.fromElement=function(g,k){if(!g)return null;var m=d.parsePointsAttribute(g.getAttribute("points")),c=d.parseAttributes(g,q);return new d.Polyline(m,d.util.object.extend(c,k))};d.Polyline.fromObject=function(g){return new d.Polyline(g.points,
g)}}})();
(function(){var d=this.fabric||(this.fabric={}),q=d.util.object.extend,g=d.util.array.min,k=d.util.array.max;if(d.Polygon)console.warn("fabric.Polygon is already defined");else{d.Polygon=d.util.createClass(d.Object,{type:"polygon",initialize:function(m,c){c=c||{};this.points=m;this.callSuper("initialize",c);this._calcDimensions()},_calcDimensions:function(){var m=this.points,c=g(m,"x"),h=g(m,"y"),a=k(m,"x");m=k(m,"y");this.width=a-c;this.height=m-h;this.minX=c;this.minY=h},_toOrigin:function(){this.points=this.points.map(function(m){return{x:m.x-
this.minX,y:m.y-this.minY}},this)},toObject:function(){return q(this.callSuper("toObject"),{points:this.points.concat()})},_render:function(m){var c;m.beginPath();for(var h=0,a=this.points.length;h<a;h++){c=this.points[h];m.lineTo(c.x,c.y)}this.fill&&m.fill();if(this.stroke){m.closePath();m.stroke()}},complexity:function(){return this.points.length}});d.Polygon.ATTRIBUTE_NAMES="fill fill-opacity stroke stroke-width transform".split(" ");d.Polygon.fromElement=function(m,c){if(!m)return null;var h=
d.parsePointsAttribute(m.getAttribute("points")),a=d.parseAttributes(m,d.Polygon.ATTRIBUTE_NAMES);return new d.Polygon(h,q(a,c))};d.Polygon.fromObject=function(m){return new d.Polygon(m.points,m)}}})();
(function(){var d=this.fabric||(this.fabric={}),q=d.util.array.min,g=d.util.array.max,k=d.util.object.extend;if(d.Path)console.warn("fabric.Path is already defined");else if(d.Object){d.Path=d.util.createClass(d.Object,{type:"path",initialize:function(c,h){h=h||{};this.setOptions(h);this._importProperties();this.originalState={};if(!c)throw Error("`path` argument is required");var a=Object.prototype.toString.call(c)==="[object Array]";if(this.path=a?c:c.match&&c.match(/[a-zA-Z][^a-zA-Z]*/g)){a||this._initializeFromArray(h);
this.setCoords();h.sourcePath&&this.setSourcePath(h.sourcePath)}},_initializeFromArray:function(c){var h="width"in c;c="height"in c;this.path=this._parsePath();if(!h||!c){k(this,this._parseDimensions());if(h)this.width=this.options.width;if(c)this.height=this.options.height}},_render:function(c){for(var h,a=0,e=0,n=0,p=0,r,s,t=-(this.width/2),b=-(this.height/2),f=0,l=this.path.length;f<l;++f){h=this.path[f];switch(h[0]){case "l":a+=h[1];e+=h[2];c.lineTo(a+t,e+b);break;case "L":a=h[1];e=h[2];c.lineTo(a+
t,e+b);break;case "h":a+=h[1];c.lineTo(a+t,e+b);break;case "H":a=h[1];c.lineTo(a+t,e+b);break;case "v":e+=h[1];c.lineTo(a+t,e+b);break;case "V":e=h[1];c.lineTo(a+t,e+b);break;case "m":a+=h[1];e+=h[2];c.moveTo(a+t,e+b);break;case "M":a=h[1];e=h[2];c.moveTo(a+t,e+b);break;case "c":r=a+h[5];s=e+h[6];n=a+h[3];p=e+h[4];c.bezierCurveTo(a+h[1]+t,e+h[2]+b,n+t,p+b,r+t,s+b);a=r;e=s;break;case "C":a=h[5];e=h[6];n=h[3];p=h[4];c.bezierCurveTo(h[1]+t,h[2]+b,n+t,p+b,a+t,e+b);break;case "s":r=a+h[3];s=e+h[4];n=2*
a-n;p=2*e-p;c.bezierCurveTo(n+t,p+b,a+h[1]+t,e+h[2]+b,r+t,s+b);a=r;e=s;break;case "S":r=h[3];s=h[4];n=2*a-n;p=2*e-p;c.bezierCurveTo(n+t,p+b,h[1]+t,h[2]+b,r+t,s+b);a=r;e=s;break;case "q":a+=h[3];e+=h[4];c.quadraticCurveTo(h[1]+t,h[2]+b,a+t,e+b);break;case "Q":a=h[3];e=h[4];n=h[1];p=h[2];c.quadraticCurveTo(n+t,p+b,a+t,e+b);break;case "T":r=a;s=e;a=h[1];e=h[2];n=-n+2*r;p=-p+2*s;c.quadraticCurveTo(n+t,p+b,a+t,e+b);break;case "a":break;case "A":break;case "z":case "Z":c.closePath();break}}},render:function(c,
h){c.save();var a=this.transformMatrix;a&&c.transform(a[0],a[1],a[2],a[3],a[4],a[5]);h||this.transform(c);if(this.overlayFill)c.fillStyle=this.overlayFill;else if(this.fill)c.fillStyle=this.fill;if(this.stroke)c.strokeStyle=this.stroke;c.beginPath();this._render(c);this.fill&&c.fill();if(this.options.stroke){c.strokeStyle=this.options.stroke;c.lineWidth=this.options.strokeWidth;c.stroke()}if(!h&&this.active){this.drawBorders(c);this.hideCorners||this.drawCorners(c)}c.restore()},toString:function(){return"#<fabric.Path ("+
this.complexity()+"): "+JSON.stringify({top:this.top,left:this.left})+">"},toObject:function(){var c=k(this.callSuper("toObject"),{path:this.path});if(this.sourcePath)c.sourcePath=this.sourcePath;if(this.transformMatrix)c.transformMatrix=this.transformMatrix;return c},toDatalessObject:function(){var c=this.toObject();if(this.sourcePath)c.path=this.sourcePath;delete c.sourcePath;return c},complexity:function(){return this.path.length},set:function(c,h){return this.callSuper("set",c,h)},_parsePath:function(){for(var c=
[],h,a,e=0,n=this.path.length;e<n;e++){h=this.path[e];a=h.slice(1).trim().replace(/(\d)-/g,"$1###-").split(/\s|,|###/);c.push([h.charAt(0)].concat(a.map(parseFloat)))}return c},_parseDimensions:function(){function c(o){if(o[0]==="H")return o[1];return o[o.length-2]}function h(o){if(o[0]==="V")return o[1];return o[o.length-1]}var a=[],e=[],n,p,r=false,s,t;this.path.forEach(function(o,v){if(o[0]!=="H")n=v===0?c(o):c(this.path[v-1]);if(o[0]!=="V")p=v===0?h(o):h(this.path[v-1]);if(o[0]===o[0].toLowerCase())r=
true;s=r?n+c(o):o[0]==="V"?n:c(o);t=r?p+h(o):o[0]==="H"?p:h(o);var u=parseInt(s,10);isNaN(u)||a.push(u);u=parseInt(t,10);isNaN(u)||e.push(u)},this);var b=q(a),f=q(e),l=deltaY=0;b={top:f-deltaY,left:b-l,bottom:g(e)-deltaY,right:g(a)-l};b.width=b.right-b.left;b.height=b.bottom-b.top;return b}});d.Path.fromObject=function(c){return new d.Path(c.path,c)};var m=d.Path.ATTRIBUTE_NAMES="d fill fill-opacity fill-rule stroke stroke-width transform".split(" ");d.Path.fromElement=function(c,h){var a=d.parseAttributes(c,
m),e=a.d;delete a.d;return new d.Path(e,k(a,h))}}else console.warn("fabric.Path requires fabric.Object")})();
(function(){var d=this.fabric||(this.fabric={}),q=d.util.object.extend,g=d.util.array.invoke;if(d.PathGroup)console.warn("fabric.PathGroup is already defined");else{d.PathGroup=d.util.createClass(d.Path,{type:"path-group",forceFillOverwrite:false,initialize:function(k,m){m=m||{};this.originalState={};this.paths=k;this.setOptions(m);this.initProperties();this.setCoords();m.sourcePath&&this.setSourcePath(m.sourcePath)},initProperties:function(){this.stateProperties.forEach(function(k){if(k==="fill")this.set(k,
this.options[k]);else if(k==="angle")this.setAngle(this.options[k]);else this[k]=this.options[k]},this)},render:function(k){if(this.stub){k.save();this.transform(k);this.stub.render(k,false);if(this.active){this.drawBorders(k);this.drawCorners(k)}}else{k.save();var m=this.transformMatrix;m&&k.transform(m[0],m[1],m[2],m[3],m[4],m[5]);this.transform(k);m=0;for(var c=this.paths.length;m<c;++m)this.paths[m].render(k,true);if(this.active){this.drawBorders(k);this.hideCorners||this.drawCorners(k)}}k.restore()},
set:function(k,m){if((k==="fill"||k==="overlayFill")&&this.isSameColor()){this[k]=m;for(var c=this.paths.length;c--;)this.paths[c].set(k,m)}else d.Object.prototype.set.call(this,k,m);return this},toObject:function(){return q(d.Object.prototype.toObject.call(this),{paths:g(this.getObjects(),"clone"),sourcePath:this.sourcePath})},toDatalessObject:function(){var k=this.toObject();if(this.sourcePath)k.paths=this.sourcePath;return k},toString:function(){return"#<fabric.PathGroup ("+this.complexity()+"): { top: "+
this.top+", left: "+this.left+" }>"},isSameColor:function(){var k=this.getObjects()[0].get("fill");return this.getObjects().every(function(m){return m.get("fill")===k})},complexity:function(){return this.paths.reduce(function(k,m){return k+(m&&m.complexity?m.complexity():0)},0)},toGrayscale:function(){for(var k=this.paths.length;k--;)this.paths[k].toGrayscale();return this},getObjects:function(){return this.paths}});d.PathGroup.fromObject=function(k){for(var m=k.paths,c=0,h=m.length;c<h;c++)if(!(m[c]instanceof
d.Object)){var a=m[c].type.camelize().capitalize();m[c]=Canvas[a].fromObject(m[c])}return new d.PathGroup(m,k)}}})();
(function(){var d=this.fabric||(this.fabric={}),q=d.util.object.extend,g=d.util.array.min,k=d.util.array.max;if(!d.Group){d.Group=d.util.createClass(d.Object,{type:"group",initialize:function(m,c){this.objects=m||[];this.originalState={};this.callSuper("initialize");this._calcBounds();this._updateObjectsCoords();c&&q(this,c);this._setOpacityIfSame();this.setCoords(true);this.saveCoords();this.activateAllObjects()},_updateObjectsCoords:function(){var m=this.left,c=this.top;this.forEachObject(function(h){var a=
h.get("left"),e=h.get("top");h.set("originalLeft",a);h.set("originalTop",e);h.set("left",a-m);h.set("top",e-c);h.setCoords();h.hideCorners=true},this)},toString:function(){return"#<fabric.Group: ("+this.complexity()+")>"},getObjects:function(){return this.objects},add:function(m){this._restoreObjectsState();this.objects.push(m);m.setActive(true);this._calcBounds();this._updateObjectsCoords();return this},remove:function(m){this._restoreObjectsState();d.util.removeFromArray(this.objects,m);m.setActive(false);
this._calcBounds();this._updateObjectsCoords();return this},size:function(){return this.getObjects().length},set:function(m,c){if(typeof c=="function")this.set(m,c(this[m]));else if(m==="fill"||m==="opacity"){var h=this.objects.length;for(this[m]=c;h--;)this.objects[h].set(m,c)}else this[m]=c;return this},contains:function(m){return this.objects.indexOf(m)>-1},toObject:function(){return q(this.callSuper("toObject"),{objects:d.util.array.invoke(this.objects,"clone")})},render:function(m){m.save();
this.transform(m);for(var c=Math.max(this.scaleX,this.scaleY),h=0,a=this.objects.length;h<a;h++){var e=this.objects[h].borderScaleFactor;this.objects[h].borderScaleFactor=c;this.objects[h].render(m);this.objects[h].borderScaleFactor=e}this.hideBorders||this.drawBorders(m);this.hideCorners||this.drawCorners(m);m.restore();this.setCoords()},item:function(m){return this.getObjects()[m]},complexity:function(){return this.getObjects().reduce(function(m,c){m+=typeof c.complexity=="function"?c.complexity():
0;return m},0)},_restoreObjectsState:function(){this.objects.forEach(this._restoreObjectState,this);return this},_restoreObjectState:function(m){var c=this.get("left"),h=this.get("top"),a=this.getAngle()*(Math.PI/180);m.get("originalLeft");m.get("originalTop");var e=Math.cos(a)*m.get("top")+Math.sin(a)*m.get("left");a=-Math.sin(a)*m.get("top")+Math.cos(a)*m.get("left");m.setAngle(m.getAngle()+this.getAngle());m.set("left",c+a*this.get("scaleX"));m.set("top",h+e*this.get("scaleY"));m.set("scaleX",
m.get("scaleX")*this.get("scaleX"));m.set("scaleY",m.get("scaleY")*this.get("scaleY"));m.setCoords();m.hideCorners=false;m.setActive(false);m.setCoords();return this},destroy:function(){return this._restoreObjectsState()},saveCoords:function(){this._originalLeft=this.get("left");this._originalTop=this.get("top");return this},hasMoved:function(){return this._originalLeft!==this.get("left")||this._originalTop!==this.get("top")},setObjectsCoords:function(){this.forEachObject(function(m){m.setCoords()});
return this},activateAllObjects:function(){return this.setActive(true)},setActive:function(m){this.forEachObject(function(c){c.setActive(m)});return this},forEachObject:function(m,c){for(var h=this.getObjects(),a=h.length;a--;)m.call(c,h[a],a,h);return this},_setOpacityIfSame:function(){var m=this.getObjects(),c=m[0]?m[0].get("opacity"):1;if(m.every(function(h){return h.get("opacity")===c}))this.opacity=c},_calcBounds:function(){var m=[],c=[],h,a;a=0;for(var e=this.objects.length;a<e;++a){h=this.objects[a];
h.setCoords();for(var n in h.oCoords){m.push(h.oCoords[n].x);c.push(h.oCoords[n].y)}}h=g(m);a=k(m);m=g(c);c=k(c);a=a-h;c=c-m;this.width=a;this.height=c;this.left=h+a/2;this.top=m+c/2},containsPoint:function(m){var c=this.get("width")/2,h=this.get("height")/2,a=this.get("left"),e=this.get("top");return a-c<m.x&&a+c>m.x&&e-h<m.y&&e+h>m.y},toGrayscale:function(){for(var m=this.objects.length;m--;)this.objects[m].toGrayscale()}});d.Group.fromObject=function(m){return new d.Group(m.objects,m)}}})();
(function(){var d=this.fabric||(this.fabric={}),q=d.util.object.extend,g=d.util.object.clone;if(d.Text)console.warn("fabric.Text is already defined");else if(d.Object){d.Text=d.util.createClass(d.Object,{options:{top:10,left:10,fontsize:20,fontweight:100,fontfamily:"Modernist_One_400",path:null},type:"text",initialize:function(k,m){this.originalState={};this.initStateProperties();this.text=k;this.setOptions(m);q(this,this.options);this.theta=this.angle*(Math.PI/180);this.width=this.getWidth();this.setCoords()},
initStateProperties:function(){var k;if((k=this.constructor)&&(k=k.superclass)&&(k=k.prototype)&&(k=k.stateProperties)&&k.clone){this.stateProperties=k.clone();this.stateProperties.push("fontfamily","fontweight","path")}},toString:function(){return"#<fabric.Text ("+this.complexity()+"): "+JSON.stringify({text:this.text,fontfamily:this.fontfamily})+">"},_render:function(k){var m=Cufon.textOptions||(Cufon.textOptions={});m.left=this.left;m.top=this.top;m.context=k;m.color=this.fill;var c=this._initDummyElement();
this.transform(k);Cufon.replaceElement(c,{separate:"none",fontFamily:this.fontfamily});this.width=m.width;this.height=m.height},_initDummyElement:function(){var k=document.createElement("div");k.innerHTML=this.text;k.style.fontSize="40px";k.style.fontWeight="400";k.style.fontStyle="normal";k.style.letterSpacing="normal";k.style.color="#000000";k.style.fontWeight="600";k.style.fontFamily="Verdana";return k},render:function(k){k.save();this._render(k);if(this.active){this.drawBorders(k);this.drawCorners(k)}k.restore()},
toObject:function(){return q(this.callSuper("toObject"),{text:this.text,fontsize:this.fontsize,fontweight:this.fontweight,fontfamily:this.fontfamily,path:this.path})},setColor:function(k){this.set("fill",k);return this},setFontsize:function(k){this.set("fontsize",k);this.setCoords();return this},getText:function(){return this.text},setText:function(k){this.set("text",k);this.setCoords();return this},set:function(k,m){this[k]=m;if(k==="fontfamily")this.path=this.path.replace(/(.*?)([^\/]*)(\.font\.js)/,
"$1"+m+"$3");return this}});d.Text.fromObject=function(k){return new d.Text(k.text,g(k))};d.Text.fromElement=function(){}}else console.warn("fabric.Text requires fabric.Object")})();
(function(){if(!this.fabric)this.fabric={};if(this.fabric.Image)console.warn("fabric.Image is already defined.");else if(fabric.Object){fabric.Image=fabric.util.createClass(fabric.Object,{maxwidth:null,maxheight:null,active:false,bordervisibility:false,cornervisibility:false,type:"image",__isGrayscaled:false,initialize:function(d,q){this.callSuper("initialize",q);this._initElement(d);this._initConfig(q||{})},getElement:function(){return this._element},setElement:function(d){this._element=d;return this},
getNormalizedSize:function(d,q,g){if(g&&q&&d.width>d.height&&d.width/d.height<q/g){normalizedWidth=Math.floor(d.width*g/d.height);normalizedHeight=g}else if(g&&(d.height==d.width||d.height>d.width||d.height>g)){normalizedWidth=Math.floor(d.width*g/d.height);normalizedHeight=g}else if(q&&q<d.width){normalizedHeight=Math.floor(d.height*q/d.width);normalizedWidth=q}else{normalizedWidth=d.width;normalizedHeight=d.height}return{width:normalizedWidth,height:normalizedHeight}},getOriginalSize:function(){var d=
this.getElement();return{width:d.width,height:d.height}},setBorderVisibility:function(d){this._resetWidthHeight();this._adjustWidthHeightToBorders(d);this.setCoords()},setCornersVisibility:function(d){this.cornervisibility=!!d},render:function(d,q){d.save();q||this.transform(d);this._render(d);if(this.active&&!q){this.drawBorders(d);this.hideCorners||this.drawCorners(d)}d.restore()},toObject:function(){return fabric.util.object.extend(this.callSuper("toObject"),{src:this.getSrc()})},getSrc:function(){return this.getElement().src},
toString:function(){return'#<fabric.Image: { src: "'+this.getSrc()+'" }>'},clone:function(d){this.constructor.fromObject(this.toObject(),d)},toGrayscale:function(d){if(!this.__isGrayscaled){var q=this.getElement(),g=document.createElement("canvas"),k=document.createElement("img"),m=this;g.width=q.width;g.height=q.height;g.getContext("2d").drawImage(q,0,0);fabric.Element.toGrayscale(g);k.onload=function(){m.setElement(k);d&&d();k.onload=g=q=imageData=null};k.width=q.width;k.height=q.height;k.src=g.toDataURL("image/png");
this.__isGrayscaled=true;return this}},_render:function(d){var q=this.getOriginalSize();d.drawImage(this.getElement(),-q.width/2,-q.height/2,q.width,q.height)},_adjustWidthHeightToBorders:function(d){if(d){this.currentBorder=this.borderwidth;this.width+=2*this.currentBorder;this.height+=2*this.currentBorder}else this.currentBorder=0},_resetWidthHeight:function(){var d=this.getElement();this.set("width",d.width);this.set("height",d.height)},_initElement:function(d){this.setElement(fabric.util.getById(d));
fabric.util.addClass(this.getElement(),fabric.Image.CSS_CANVAS)},_initConfig:function(d){this.setOptions(d);this._setBorder();this._setWidthHeight(d)},_setBorder:function(){this.currentBorder=this.bordervisibility?this.borderwidth:0},_setWidthHeight:function(){var d=2*this.currentBorder;this.width=(this.getElement().width||0)+d;this.height=(this.getElement().height||0)+d}});fabric.Image.CSS_CANVAS="canvas-img";fabric.Image.fromObject=function(d,q){var g=document.createElement("img"),k=d.src;if(d.width)g.width=
d.width;if(d.height)g.height=d.height;g.onload=function(){q&&q(new fabric.Image(g,d));g=g.onload=null};g.src=k};fabric.Image.fromURL=function(d,q,g){var k=document.createElement("img");k.onload=function(){q&&q(new fabric.Image(k,g));k=k.onload=null};k.src=d}}else console.warn("fabric.Object is required for fabric.Image initialization")})();

View file

@ -4,7 +4,8 @@
var global = this,
fabric = global.fabric || (global.fabric = { }),
piBy2 = Math.PI * 2;
piBy2 = Math.PI * 2,
extend = fabric.util.object.extend;
if (fabric.Circle) {
console.warn('fabric.Circle is already defined.');
@ -40,7 +41,7 @@
* @return {Object} object representation of an instance
*/
toObject: function() {
return fabric.util.object.extend(this.callSuper('toObject'), {
return extend(this.callSuper('toObject'), {
radius: this.get('radius')
});
},
@ -89,7 +90,7 @@
if (!isValidRadius(parsedAttributes)) {
throw Error('value of `r` attribute is required and can not be negative');
}
return new fabric.Circle(fabric.util.object.extend(parsedAttributes, options));
return new fabric.Circle(extend(parsedAttributes, options));
};
/**

View file

@ -1,23 +1,30 @@
(function () {
var global = this,
window = global.window,
document = window.document,
capitalize = fabric.util.string.capitalize,
camelize = fabric.util.string.camelize;
if (fabric.Element) {
console.warn('fabric.Element is already defined.');
return;
}
var CANVAS_INIT_ERROR = new Error('Could not initialize `canvas` element'),
var global = this,
window = global.window,
document = window.document,
// aliases for faster resolution
extend = fabric.util.object.extend,
capitalize = fabric.util.string.capitalize,
camelize = fabric.util.string.camelize,
fireEvent = fabric.util.fireEvent,
getPointer = fabric.util.getPointer,
getElementOffset = fabric.util.getElementOffset,
removeFromArray = fabric.util.removeFromArray,
addListener = fabric.util.addlistener,
removeListener = fabric.util.removelistener,
CANVAS_INIT_ERROR = new Error('Could not initialize `canvas` element'),
FX_DURATION = 500,
STROKE_OFFSET = 0.5,
FX_TRANSITION = 'decel',
getPointer = fabric.util.getPointer,
cursorMap = {
'tr': 'ne-resize',
'br': 'se-resize',
@ -182,7 +189,7 @@
this.calcOffset();
};
fabric.util.object.extend(fabric.Element.prototype, {
extend(fabric.Element.prototype, {
selectionColor: 'rgba(100,100,255,0.3)', // blue
selectionBorderColor: 'rgba(255,255,255,0.3)',
@ -207,7 +214,7 @@
* @chainable
*/
calcOffset: function () {
this._offset = fabric.util.getElementOffset(this.getElement());
this._offset = getElementOffset(this.getElement());
return this;
},
@ -300,7 +307,7 @@
* See configuration documentation for more details.
*/
_initConfig: function (oConfig) {
fabric.util.object.extend(this._oConfig, oConfig || { });
extend(this._oConfig, oConfig || { });
this._oConfig.width = parseInt(this._oElement.width, 10) || 0;
this._oConfig.height = parseInt(this._oElement.height, 10) || 0;
@ -319,15 +326,15 @@
var _this = this;
this._onMouseDown = function (e){ _this.__onMouseDown(e); };
this._onMouseUp = function (e){ _this.__onMouseUp(e); };
this._onMouseMove = function (e){ _this.__onMouseMove(e); };
this._onMouseDown = function (e) { _this.__onMouseDown(e); };
this._onMouseUp = function (e) { _this.__onMouseUp(e); };
this._onMouseMove = function (e) { _this.__onMouseMove(e); };
this._onResize = function (e) { _this.calcOffset() };
fabric.util.addListener(this._oElement, 'mousedown', this._onMouseDown);
fabric.util.addListener(document, 'mousemove', this._onMouseMove);
fabric.util.addListener(document, 'mouseup', this._onMouseUp);
fabric.util.addListener(window, 'resize', this._onResize);
addListener(this._oElement, 'mousedown', this._onMouseDown);
addListener(document, 'mousemove', this._onMouseMove);
addListener(document, 'mouseup', this._onMouseUp);
addListener(window, 'resize', this._onResize);
},
/**
@ -476,7 +483,7 @@
target = transform.target;
if (target.__scaling) {
fabric.util.fireEvent('object:scaled', { target: target });
fireEvent('object:scaled', { target: target });
target.__scaling = false;
}
@ -488,7 +495,7 @@
// only fire :modified event if target coordinates were changed during mousedown-mouseup
if (target.hasStateChanged()) {
target.isMoving = false;
fabric.util.fireEvent('object:modified', { target: target });
fireEvent('object:modified', { target: target });
}
}
@ -502,7 +509,7 @@
if (activeGroup) {
if (activeGroup.hasStateChanged() &&
activeGroup.containsPoint(this.getPointer(e))) {
fabric.util.fireEvent('group:modified', { target: activeGroup });
fireEvent('group:modified', { target: activeGroup });
}
activeGroup.setObjectsCoords();
activeGroup.set('isMoving', false);
@ -609,15 +616,15 @@
deactivateAllWithDispatch: function () {
var activeGroup = this.getActiveGroup();
if (activeGroup) {
fabric.util.fireEvent('before:group:destroyed', {
fireEvent('before:group:destroyed', {
target: activeGroup
});
}
this.deactivateAll();
if (activeGroup) {
fabric.util.fireEvent('after:group:destroyed');
fireEvent('after:group:destroyed');
}
fabric.util.fireEvent('selection:cleared');
fireEvent('selection:cleared');
return this;
},
@ -681,7 +688,7 @@
else {
activeGroup.add(target);
}
fabric.util.fireEvent('group:selected', { target: activeGroup });
fireEvent('group:selected', { target: activeGroup });
activeGroup.setActive(true);
}
else {
@ -948,7 +955,7 @@
// do not create group for 1 element only
if (group.length === 1) {
this.setActiveObject(group[0]);
fabric.util.fireEvent('object:selected', {
fireEvent('object:selected', {
target: group[0]
});
}
@ -956,7 +963,7 @@
var group = new fabric.Group(group);
this.setActiveGroup(group);
group.saveCoords();
fabric.util.fireEvent('group:selected', { target: group });
fireEvent('group:selected', { target: group });
}
this.renderAll();
},
@ -1585,7 +1592,7 @@
_this.loadImageFromURL(path, function (image) {
image.setSourcePath(path);
fabric.util.object.extend(image, obj);
extend(image, obj);
image.setAngle(obj.angle);
onObjectLoaded(image, index);
@ -1623,7 +1630,7 @@
// copy parameters from serialied json to object (left, top, scaleX, scaleY, etc.)
// skip this step if an object is a PathGroup, since we already passed it options object before
if (!(object instanceof fabric.PathGroup)) {
fabric.util.object.extend(object, obj);
extend(object, obj);
if (typeof obj.angle !== 'undefined') {
object.setAngle(obj.angle);
}
@ -1755,7 +1762,7 @@
* @return {Object} removed object
*/
remove: function (object) {
fabric.util.removeFromArray(this._aObjects, object);
removeFromArray(this._aObjects, object);
this.renderAll();
return object;
},
@ -1790,7 +1797,7 @@
* @chainable
*/
sendToBack: function (object) {
fabric.util.removeFromArray(this._aObjects, object);
removeFromArray(this._aObjects, object);
this._aObjects.unshift(object);
return this.renderAll();
},
@ -1803,7 +1810,7 @@
* @chainable
*/
bringToFront: function (object) {
fabric.util.removeFromArray(this._aObjects, object);
removeFromArray(this._aObjects, object);
this._aObjects.push(object);
return this.renderAll();
},
@ -1829,7 +1836,7 @@
break;
}
}
fabric.util.removeFromArray(this._aObjects, object);
removeFromArray(this._aObjects, object);
this._aObjects.splice(nextIntersectingIdx, 0, object);
}
return this.renderAll();
@ -1858,7 +1865,7 @@
break;
}
}
fabric.util.removeFromArray(objects, object);
removeFromArray(objects, object);
objects.splice(nextIntersectingIdx, 0, object);
}
this.renderAll();
@ -1880,7 +1887,7 @@
this.renderAll();
fabric.util.fireEvent('object:selected', { target: object });
fireEvent('object:selected', { target: object });
return this;
},
@ -1987,10 +1994,10 @@
*/
dispose: function () {
this.clear();
fabric.util.removeListener(this.getElement(), 'mousedown', this._onMouseDown);
fabric.util.removeListener(document, 'mouseup', this._onMouseUp);
fabric.util.removeListener(document, 'mousemove', this._onMouseMove);
fabric.util.removeListener(window, 'resize', this._onResize);
removeListener(this.getElement(), 'mousedown', this._onMouseDown);
removeListener(document, 'mouseup', this._onMouseUp);
removeListener(document, 'mousemove', this._onMouseMove);
removeListener(window, 'resize', this._onResize);
return this;
},
@ -2059,7 +2066,7 @@
'{ objects: ' + this.getObjects().length + ' }>';
};
fabric.util.object.extend(fabric.Element, {
extend(fabric.Element, {
/**
* @property EMPTY_JSON

View file

@ -2,7 +2,8 @@
(function(){
var fabric = this.fabric || (this.fabric = { });
var fabric = this.fabric || (this.fabric = { }),
extend = fabric.util.object.extend;
if (fabric.Ellipse) {
console.warn('fabric.Ellipse is already defined.');
@ -37,7 +38,7 @@
* @return {Object} object representation of an instance
*/
toObject: function() {
return fabric.util.object.extend(this.callSuper('toObject'), {
return extend(this.callSuper('toObject'), {
rx: this.get('rx'),
ry: this.get('ry')
})
@ -93,7 +94,7 @@
*/
fabric.Ellipse.fromElement = function(element, options) {
var parsedAttributes = fabric.parseAttributes(element, fabric.Ellipse.ATTRIBUTE_NAMES);
return new fabric.Ellipse(fabric.util.object.extend(parsedAttributes, options));
return new fabric.Ellipse(extend(parsedAttributes, options));
};
/**

View file

@ -2,7 +2,11 @@
(function(){
var fabric = this.fabric || (this.fabric = { });
var fabric = this.fabric || (this.fabric = { }),
extend = fabric.util.object.extend,
min = fabric.util.array.min,
max = fabric.util.array.max;
if (fabric.Group) {
return;
}
@ -29,7 +33,7 @@
this._updateObjectsCoords();
if (options) {
fabric.util.object.extend(this, options);
extend(this, options);
}
this._setOpacityIfSame();
@ -165,7 +169,7 @@
* @return {Object} object representation of an instance
*/
toObject: function() {
return fabric.util.object.extend(this.callSuper('toObject'), {
return extend(this.callSuper('toObject'), {
objects: fabric.util.array.invoke(this.objects, 'clone')
});
},
@ -377,10 +381,10 @@
}
};
minX = fabric.util.array.min(aX);
maxX = fabric.util.array.max(aX);
minY = fabric.util.array.min(aY);
maxY = fabric.util.array.max(aY);
minX = min(aX);
maxX = max(aX);
minY = min(aY);
maxY = max(aY);
width = maxX - minX;
height = maxY - minY;

View file

@ -2,7 +2,9 @@
(function(){
var fabric = this.fabric || (this.fabric = { });
var fabric = this.fabric || (this.fabric = { }),
extend = fabric.util.object.extend;
if (fabric.Line) {
return;
}
@ -70,7 +72,7 @@
* @return {Object}
*/
toObject: function() {
return fabric.util.object.extend(this.callSuper('toObject'), {
return extend(this.callSuper('toObject'), {
x1: this.get('x1'),
y1: this.get('y1'),
x2: this.get('x2'),
@ -97,7 +99,7 @@
parsedAttributes.x2 || 0,
parsedAttributes.y2 || 0
];
return new fabric.Line(points, fabric.util.object.extend(parsedAttributes, options));
return new fabric.Line(points, extend(parsedAttributes, options));
};
/**

View file

@ -6,7 +6,12 @@
* @name Canvas
* @namespace
*/
fabric = global.fabric || (global.fabric = { });
fabric = global.fabric || (global.fabric = { }),
extend = fabric.util.object.extend,
clone = fabric.util.object.clone,
toFixed = fabric.util.toFixed,
capitalize = fabric.util.string.capitalize,
getPointer = fabric.util.getPointer;
if (fabric.Object) {
return;
@ -107,7 +112,7 @@
setOptions: function(options) {
// this.constructor.superclass.prototype.options -> this.options -> options
this.options = fabric.util.object.extend(this._getOptions(), options);
this.options = extend(this._getOptions(), options);
},
/**
@ -115,7 +120,7 @@
* @method _getOptions
*/
_getOptions: function() {
return fabric.util.object.extend(fabric.util.object.clone(this._getSuperOptions()), this.options);
return extend(clone(this._getSuperOptions()), this.options);
},
/**
@ -177,7 +182,6 @@
* @return {Object}
*/
toObject: function() {
var toFixed = fabric.util.toFixed;
var object = {
type: this.type,
left: toFixed(this.left, this.NUM_FRACTION_DIGITS),
@ -248,7 +252,7 @@
* @return {String}
*/
toString: function() {
return "#<fabric." + fabric.util.string.capitalize(this.type) + ">";
return "#<fabric." + capitalize(this.type) + ">";
},
/**
@ -799,7 +803,7 @@
* @return {String|Boolean} corner code (tl, tr, bl, br, etc.), or false if nothing is found
*/
_findTargetCorner: function(e, offset) {
var pointer = fabric.util.getPointer(e),
var pointer = getPointer(e),
ex = pointer.x - offset.left,
ey = pointer.y - offset.top,
xpoints,

View file

@ -1,6 +1,9 @@
(function(){
var fabric = this.fabric || (this.fabric = { });
var fabric = this.fabric || (this.fabric = { }),
extend = fabric.util.object.extend,
capitalize = fabric.util.string.capitalize,
clone = fabric.util.object.clone;
var attributesMap = {
'cx': 'left',
@ -61,8 +64,8 @@
// add values parsed from style
// TODO (kangax): check the presedence of values from the style attribute
ownAttributes = fabric.util.object.extend(fabric.parseStyleAttribute(element), ownAttributes);
return fabric.util.object.extend(parentAttributes, ownAttributes);
ownAttributes = extend(fabric.parseStyleAttribute(element), ownAttributes);
return extend(parentAttributes, ownAttributes);
};
/**
@ -261,7 +264,7 @@
function parseElements(elements, options) {
// transform svg elements to fabric.Path elements
var _elements = elements.map(function(el) {
var klass = fabric[fabric.util.string.capitalize(el.tagName)];
var klass = fabric[capitalize(el.tagName)];
if (klass && klass.fromElement) {
try {
return klass.fromElement(el, options);
@ -347,7 +350,7 @@
height: height
};
var elements = fabric.parseElements(elements, fabric.util.object.clone(options));
var elements = fabric.parseElements(elements, clone(options));
if (!elements || (elements && !elements.length)) return;
if (callback) {
@ -356,7 +359,7 @@
};
})();
fabric.util.object.extend(fabric, {
extend(fabric, {
parseAttributes: parseAttributes,
parseElements: parseElements,
parseStyleAttribute: parseStyleAttribute,

View file

@ -2,7 +2,10 @@
(function(){
var fabric = this.fabric || (this.fabric = { });
var fabric = this.fabric || (this.fabric = { }),
min = fabric.util.array.min,
max = fabric.util.array.max,
extend = fabric.util.object.extend;
if (fabric.Path) {
console.warn('fabric.Path is already defined');
@ -63,7 +66,7 @@
this.path = this._parsePath();
if (!isWidthSet || !isHeightSet) {
fabric.util.object.extend(this, this._parseDimensions());
extend(this, this._parseDimensions());
if (isWidthSet) {
this.width = this.options.width;
}
@ -314,7 +317,7 @@
* @return {Object}
*/
toObject: function() {
var o = fabric.util.object.extend(this.callSuper('toObject'), {
var o = extend(this.callSuper('toObject'), {
path: this.path
});
if (this.sourcePath) {
@ -421,15 +424,15 @@
}, this);
var minX = fabric.util.array.min(aX),
minY = fabric.util.array.min(aY),
var minX = min(aX),
minY = min(aY),
deltaX = deltaY = 0;
var o = {
top: minY - deltaY,
left: minX - deltaX,
bottom: fabric.util.array.max(aY) - deltaY,
right: fabric.util.array.max(aX) - deltaX
bottom: max(aY) - deltaY,
right: max(aX) - deltaX
};
o.width = o.right - o.left;
@ -462,6 +465,6 @@
var parsedAttributes = fabric.parseAttributes(element, ATTRIBUTE_NAMES),
path = parsedAttributes.d;
delete parsedAttributes.d;
return new fabric.Path(path, fabric.util.object.extend(parsedAttributes, options));
return new fabric.Path(path, extend(parsedAttributes, options));
}
})();

View file

@ -2,7 +2,9 @@
(function(){
var fabric = this.fabric || (this.fabric = { });
var fabric = this.fabric || (this.fabric = { }),
extend = fabric.util.object.extend,
invoke = fabric.util.array.invoke;
if (fabric.PathGroup) {
console.warn('fabric.PathGroup is already defined');
@ -105,8 +107,8 @@
*/
toObject: function() {
var _super = fabric.Object.prototype.toObject;
return fabric.util.object.extend(_super.call(this), {
paths: fabric.util.array.invoke(this.getObjects(), 'clone'),
return extend(_super.call(this), {
paths: invoke(this.getObjects(), 'clone'),
sourcePath: this.sourcePath
});
},

View file

@ -2,7 +2,10 @@
(function(){
var fabric = this.fabric || (this.fabric = { });
var fabric = this.fabric || (this.fabric = { }),
extend = fabric.util.object.extend,
min = fabric.util.array.min,
max = fabric.util.array.max;
if (fabric.Polygon) {
console.warn('fabric.Polygon is already defined');
@ -37,10 +40,10 @@
_calcDimensions: function() {
var points = this.points,
minX = fabric.util.array.min(points, 'x'),
minY = fabric.util.array.min(points, 'y'),
maxX = fabric.util.array.max(points, 'x'),
maxY = fabric.util.array.max(points, 'y');
minX = min(points, 'x'),
minY = min(points, 'y'),
maxX = max(points, 'x'),
maxY = max(points, 'y');
this.width = maxX - minX;
this.height = maxY - minY;
@ -67,7 +70,7 @@
* @return {Object} object representation of an instance
*/
toObject: function() {
return fabric.util.object.extend(this.callSuper('toObject'), {
return extend(this.callSuper('toObject'), {
points: this.points.concat()
});
},
@ -120,7 +123,7 @@
var points = fabric.parsePointsAttribute(element.getAttribute('points')),
parsedAttributes = fabric.parseAttributes(element, fabric.Polygon.ATTRIBUTE_NAMES);
return new fabric.Polygon(points, fabric.util.object.extend(parsedAttributes, options));
return new fabric.Polygon(points, extend(parsedAttributes, options));
};
/**

View file

@ -2,7 +2,9 @@
(function(){
var fabric = this.fabric || (this.fabric = { });
var fabric = this.fabric || (this.fabric = { }),
extend = fabric.util.object.extend,
clone = fabric.util.object.clone;
if (fabric.Text) {
console.warn('fabric.Text is already defined');
@ -31,7 +33,7 @@
this.initStateProperties();
this.text = text;
this.setOptions(options);
fabric.util.object.extend(this, this.options);
extend(this, this.options);
this.theta = this.angle * (Math.PI/180);
this.width = this.getWidth();
this.setCoords();
@ -110,7 +112,7 @@
* @return {Object} object representation of an instance
*/
toObject: function() {
return fabric.util.object.extend(this.callSuper('toObject'), {
return extend(this.callSuper('toObject'), {
text: this.text,
fontsize: this.fontsize,
fontweight: this.fontweight,
@ -177,7 +179,7 @@
* @return {fabric.Text} an instance
*/
fabric.Text.fromObject = function(object) {
return new fabric.Text(object.text, fabric.util.object.clone(object));
return new fabric.Text(object.text, clone(object));
};
/**