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