diff --git a/dist/all.js b/dist/all.js index 6c95973e..8d4171bf 100644 --- a/dist/all.js +++ b/dist/all.js @@ -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 "#"; + return "#"; }, /** @@ -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)); }; /** diff --git a/dist/all.min.js b/dist/all.min.js index b330c2db..64b1d62a 100644 --- a/dist/all.min.js +++ b/dist/all.min.js @@ -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>>0;m=Number(m)||0;m=Math[m<0?"ceil":"floor"](m);if(m<0)m+=l;for(;m>>0;l>>0;n>>0;l>>0;l>>0;c>>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=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=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.ya.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;l0)h.status="Intersection";return h};e.intersectPolygonPolygon= -function(a,b){for(var g=new e("No Intersection"),h=a.length,m=0;m0)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)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;o1){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;k1?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"};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;i1?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"#"},set:function(a,b){if((a==="scaleX"||a==="scaleY")&&b>>0;h=Number(h)||0;h=Math[h<0?"ceil":"floor"](h);if(h<0)h+=a;for(;h>>0;a>>0;e>>0;a>>0;a>>0;n>>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=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=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.yg.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;a0)c.status="Intersection";return c};d.intersectPolygonPolygon= +function(g,k){for(var m=new d("No Intersection"),c=g.length,h=0;h0)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)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;o1){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;l1?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"};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;i1?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"#"},set:function(a,e){if((a==="scaleX"||a==="scaleY")&&ea.x&&m.xa.y&&l.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"},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"}, -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"},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;bf.x&&h-bf.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"#"},_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.heighte.width||e.height>a)){normalizedWidth=Math.floor(e.width*a/e.height);normalizedHeight=a}else if(f&&f'},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.scaleYa.x&&r.xa.y&&s.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"},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"},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"},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;hm.x&&e-hm.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"#"},_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.heightd.width||d.height>g)){normalizedWidth=Math.floor(d.width*g/d.height);normalizedHeight=g}else if(q&&q'},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")})(); diff --git a/src/circle.class.js b/src/circle.class.js index e79bf824..cacedc49 100644 --- a/src/circle.class.js +++ b/src/circle.class.js @@ -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)); }; /** diff --git a/src/element.class.js b/src/element.class.js index 63e0785f..c6c3b1a7 100644 --- a/src/element.class.js +++ b/src/element.class.js @@ -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 diff --git a/src/ellipse.class.js b/src/ellipse.class.js index c10fda18..3dfe703c 100644 --- a/src/ellipse.class.js +++ b/src/ellipse.class.js @@ -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)); }; /** diff --git a/src/group.class.js b/src/group.class.js index 1d398781..8c26d7c3 100644 --- a/src/group.class.js +++ b/src/group.class.js @@ -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; diff --git a/src/line.class.js b/src/line.class.js index c056afc6..36deaab7 100644 --- a/src/line.class.js +++ b/src/line.class.js @@ -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)); }; /** diff --git a/src/object.class.js b/src/object.class.js index 297a6386..007482fc 100644 --- a/src/object.class.js +++ b/src/object.class.js @@ -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 "#"; + return "#"; }, /** @@ -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, diff --git a/src/parser.js b/src/parser.js index ffee44d0..6a4bfaad 100644 --- a/src/parser.js +++ b/src/parser.js @@ -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, diff --git a/src/path.class.js b/src/path.class.js index ef892250..d6e83893 100644 --- a/src/path.class.js +++ b/src/path.class.js @@ -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)); } })(); \ No newline at end of file diff --git a/src/path_group.class.js b/src/path_group.class.js index 086d354b..0bd65e4b 100644 --- a/src/path_group.class.js +++ b/src/path_group.class.js @@ -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 }); }, diff --git a/src/polygon.class.js b/src/polygon.class.js index fa08fe67..20ec6cc8 100644 --- a/src/polygon.class.js +++ b/src/polygon.class.js @@ -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)); }; /** diff --git a/src/text.class.js b/src/text.class.js index 9eb4fbc6..b67b5800 100644 --- a/src/text.class.js +++ b/src/text.class.js @@ -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)); }; /**