var fabric = fabric || {
version: "3.6.3"
};
if ("undefined" != typeof exports ? exports.fabric = fabric : "function" == typeof define && define.amd && define([], function () {
return fabric
}), "undefined" != typeof document && "undefined" != typeof window)
document instanceof("undefined" != typeof HTMLDocument ? HTMLDocument : Document) ? fabric.document = document : fabric.document = document.implementation.createHTMLDocument(""), fabric.window = window;
else {
var jsdom = require("jsdom"),
virtualWindow = new jsdom.JSDOM(decodeURIComponent("%3C!DOCTYPE%20html%3E%3Chtml%3E%3Chead%3E%3C%2Fhead%3E%3Cbody%3E%3C%2Fbody%3E%3C%2Fhtml%3E"), {
features: {
FetchExternalResources: ["img"]
},
resources: "usable"
}).window;
fabric.document = virtualWindow.document,
fabric.jsdomImplForWrapper = require("jsdom/lib/jsdom/living/generated/utils").implForWrapper,
fabric.nodeCanvas = require("jsdom/lib/jsdom/utils").Canvas,
fabric.window = virtualWindow,
DOMParser = fabric.window.DOMParser
}
function resizeCanvasIfNeeded(t) {
var e = t.targetCanvas,
i = e.width,
r = e.height,
n = t.destinationWidth,
s = t.destinationHeight;
i === n && r === s || (e.width = n, e.height = s)
}
function copyGLTo2DDrawImage(t, e) {
var i = t.canvas,
r = e.targetCanvas,
n = r.getContext("2d");
n.translate(0, r.height),
n.scale(1, -1);
var s = i.height - r.height;
n.drawImage(i, 0, s, r.width, r.height, 0, 0, r.width, r.height)
}
function copyGLTo2DPutImageData(t, e) {
var i = e.targetCanvas.getContext("2d"),
r = e.destinationWidth,
n = e.destinationHeight,
s = r * n * 4,
o = new Uint8Array(this.imageBuffer, 0, s),
a = new Uint8ClampedArray(this.imageBuffer, 0, s);
t.readPixels(0, 0, r, n, t.RGBA, t.UNSIGNED_BYTE, o);
var h = new ImageData(a, r, n);
i.putImageData(h, 0, 0)
}
fabric.isTouchSupported = "ontouchstart" in fabric.window || "ontouchstart" in fabric.document || fabric.window && fabric.window.navigator && 0 < fabric.window.navigator.maxTouchPoints, fabric.isLikelyNode = "undefined" != typeof Buffer && "undefined" == typeof window, fabric.SHARED_ATTRIBUTES = ["display", "transform", "fill", "fill-opacity", "fill-rule", "opacity", "stroke", "stroke-dasharray", "stroke-linecap", "stroke-dashoffset", "stroke-linejoin", "stroke-miterlimit", "stroke-opacity", "stroke-width", "id", "paint-order", "vector-effect", "instantiated_by_use", "clip-path"], fabric.DPI = 96, fabric.reNum = "(?:[-+]?(?:\\d+|\\d*\\.\\d+)(?:[eE][-+]?\\d+)?)", fabric.rePathCommand = /([-+]?((\d+\.\d+)|((\d+)|(\.\d+)))(?:[eE][-+]?\d+)?)/gi, fabric.reNonWord = /[ \n\.,;!\?\-]/, fabric.fontPaths = {}, fabric.iMatrix = [1, 0, 0, 1, 0, 0], fabric.svgNS = "http://www.w3.org/2000/svg", fabric.perfLimitSizeTotal = 2097152, fabric.maxCacheSideLimit = 4096, fabric.minCacheSideLimit = 256, fabric.charWidthsCache = {}, fabric.textureSize = 2048, fabric.disableStyleCopyPaste = !1, fabric.enableGLFiltering = !0, fabric.devicePixelRatio = fabric.window.devicePixelRatio || fabric.window.webkitDevicePixelRatio || fabric.window.mozDevicePixelRatio || 1, fabric.browserShadowBlurConstant = 1, fabric.arcToSegmentsCache = {}, fabric.boundsOfCurveCache = {}, fabric.cachesBoundsOfCurve = !0, fabric.forceGLPutImageData = !1, fabric.initFilterBackend = function () {
return fabric.enableGLFiltering && fabric.isWebglSupported && fabric.isWebglSupported(fabric.textureSize) ? (console.log("max texture size: " + fabric.maxTextureSize), new fabric.WebglFilterBackend({
tileSize: fabric.textureSize
})) : fabric.Canvas2dFilterBackend ? new fabric.Canvas2dFilterBackend : void 0
}, "undefined" != typeof document && "undefined" != typeof window && (window.fabric = fabric), function () {
function r(t, e) {
if (this.__eventListeners[t]) {
var i = this.__eventListeners[t];
e ? i[i.indexOf(e)] = !1 : fabric.util.array.fill(i, !1)
}
}
function t(t, e) {
if (this.__eventListeners || (this.__eventListeners = {}), 1 === arguments.length)
for (var i in t)
this.on(i, t[i]);
else
this.__eventListeners[t] || (this.__eventListeners[t] = []), this.__eventListeners[t].push(e);
return this
}
function e(t, e) {
if (!this.__eventListeners)
return this;
if (0 === arguments.length)
for (t in this.__eventListeners)
r.call(this, t);
else if (1 === arguments.length && "object" == typeof t)
for (var i in t)
r.call(this, i, t[i]);
else
r.call(this, t, e);
return this
}
function i(t, e) {
if (!this.__eventListeners)
return this;
var i = this.__eventListeners[t];
if (!i)
return this;
for (var r = 0, n = i.length; r < n; r++)
i[r] && i[r].call(this, e || {});
return this.__eventListeners[t] = i.filter(function (t) {
return !1 !== t
}),
this
}
fabric.Observable = {
observe: t,
stopObserving: e,
fire: i,
on: t,
off: e,
trigger: i
}
}
(), fabric.Collection = {
_objects: [],
add: function () {
if (this._objects.push.apply(this._objects, arguments), this._onObjectAdded)
for (var t = 0, e = arguments.length; t < e; t++)
this._onObjectAdded(arguments[t]);
return this.renderOnAddRemove && this.requestRenderAll(),
this
},
insertAt: function (t, e, i) {
var r = this._objects;
return i ? r[e] = t : r.splice(e, 0, t),
this._onObjectAdded && this._onObjectAdded(t),
this.renderOnAddRemove && this.requestRenderAll(),
this
},
remove: function () {
for (var t, e = this._objects, i = !1, r = 0, n = arguments.length; r < n; r++)
- 1 !== (t = e.indexOf(arguments[r])) && (i = !0, e.splice(t, 1), this._onObjectRemoved && this._onObjectRemoved(arguments[r]));
return this.renderOnAddRemove && i && this.requestRenderAll(),
this
},
forEachObject: function (t, e) {
for (var i = this.getObjects(), r = 0, n = i.length; r < n; r++)
t.call(e, i[r], r, i);
return this
},
getObjects: function (e) {
return void 0 === e ? this._objects.concat() : this._objects.filter(function (t) {
return t.type === e
})
},
item: function (t) {
return this._objects[t]
},
isEmpty: function () {
return 0 === this._objects.length
},
size: function () {
return this._objects.length
},
contains: function (t) {
return -1 < this._objects.indexOf(t)
},
complexity: function () {
return this._objects.reduce(function (t, e) {
return t += e.complexity ? e.complexity() : 0
}, 0)
}
}, fabric.CommonMethods = {
_setOptions: function (t) {
for (var e in t)
this.set(e, t[e])
},
_initGradient: function (t, e) {
!t || !t.colorStops || t instanceof fabric.Gradient || this.set(e, new fabric.Gradient(t))
},
_initPattern: function (t, e, i) {
!t || !t.source || t instanceof fabric.Pattern ? i && i() : this.set(e, new fabric.Pattern(t, i))
},
_initClipping: function (t) {
if (t.clipTo && "string" == typeof t.clipTo) {
var e = fabric.util.getFunctionBody(t.clipTo);
void 0 !== e && (this.clipTo = new Function("ctx", e))
}
},
_setObject: function (t) {
for (var e in t)
this._set(e, t[e])
},
set: function (t, e) {
return "object" == typeof t ? this._setObject(t) : "function" == typeof e && "clipTo" !== t ? this._set(t, e(this.get(t))) : this._set(t, e),
this
},
_set: function (t, e) {
this[t] = e
},
toggle: function (t) {
var e = this.get(t);
return "boolean" == typeof e && this.set(t, !e),
this
},
get: function (t) {
return this[t]
}
}, function (s) {
var d = Math.sqrt,
g = Math.atan2,
o = Math.pow,
a = Math.PI / 180,
i = Math.PI / 2;
fabric.util = {
cos: function (t) {
if (0 === t)
return 1;
switch (t < 0 && (t = -t), t / i) {
case 1:
case 3:
return 0;
case 2:
return -1
}
return Math.cos(t)
},
sin: function (t) {
if (0 === t)
return 0;
var e = 1;
switch (t < 0 && (e = -1), t / i) {
case 1:
return e;
case 2:
return 0;
case 3:
return -e
}
return Math.sin(t)
},
removeFromArray: function (t, e) {
var i = t.indexOf(e);
return -1 !== i && t.splice(i, 1),
t
},
getRandomInt: function (t, e) {
return Math.floor(Math.random() * (e - t + 1)) + t
},
degreesToRadians: function (t) {
return t * a
},
radiansToDegrees: function (t) {
return t / a
},
rotatePoint: function (t, e, i) {
t.subtractEquals(e);
var r = fabric.util.rotateVector(t, i);
return new fabric.Point(r.x, r.y).addEquals(e)
},
rotateVector: function (t, e) {
var i = fabric.util.sin(e),
r = fabric.util.cos(e);
return {
x: t.x * r - t.y * i,
y: t.x * i + t.y * r
}
},
transformPoint: function (t, e, i) {
return i ? new fabric.Point(e[0] * t.x + e[2] * t.y, e[1] * t.x + e[3] * t.y) : new fabric.Point(e[0] * t.x + e[2] * t.y + e[4], e[1] * t.x + e[3] * t.y + e[5])
},
makeBoundingBoxFromPoints: function (t, e) {
if (e)
for (var i = 0; i < t.length; i++)
t[i] = fabric.util.transformPoint(t[i], e);
var r = [t[0].x, t[1].x, t[2].x, t[3].x],
n = fabric.util.array.min(r),
s = fabric.util.array.max(r) - n,
o = [t[0].y, t[1].y, t[2].y, t[3].y],
a = fabric.util.array.min(o);
return {
left: n,
top: a,
width: s,
height: fabric.util.array.max(o) - a
}
},
invertTransform: function (t) {
var e = 1 / (t[0] * t[3] - t[1] * t[2]),
i = [e * t[3], -e * t[1], -e * t[2], e * t[0]],
r = fabric.util.transformPoint({
x: t[4],
y: t[5]
}, i, !0);
return i[4] = -r.x,
i[5] = -r.y,
i
},
toFixed: function (t, e) {
return parseFloat(Number(t).toFixed(e))
},
parseUnit: function (t, e) {
var i = /\D{0,2}$/.exec(t),
r = parseFloat(t);
switch (e || (e = fabric.Text.DEFAULT_SVG_FONT_SIZE), i[0]) {
case "mm":
return r * fabric.DPI / 25.4;
case "cm":
return r * fabric.DPI / 2.54;
case "in":
return r * fabric.DPI;
case "pt":
return r * fabric.DPI / 72;
case "pc":
return r * fabric.DPI / 72 * 12;
case "em":
return r * e;
default:
return r
}
},
falseFunction: function () {
return !1
},
getKlass: function (t, e) {
return t = fabric.util.string.camelize(t.charAt(0).toUpperCase() + t.slice(1)),
fabric.util.resolveNamespace(e)[t]
},
getSvgAttributes: function (t) {
var e = ["instantiated_by_use", "style", "id", "class"];
switch (t) {
case "linearGradient":
e = e.concat(["x1", "y1", "x2", "y2", "gradientUnits", "gradientTransform"]);
break;
case "radialGradient":
e = e.concat(["gradientUnits", "gradientTransform", "cx", "cy", "r", "fx", "fy", "fr"]);
break;
case "stop":
e = e.concat(["offset", "stop-color", "stop-opacity"])
}
return e
},
resolveNamespace: function (t) {
if (!t)
return fabric;
var e,
i = t.split("."),
r = i.length,
n = s || fabric.window;
for (e = 0; e < r; ++e)
n = n[i[e]];
return n
},
loadImage: function (t, e, i, r) {
if (t) {
var n = fabric.util.createImage(),
s = function () {
e && e.call(i, n),
n = n.onload = n.onerror = null
};
n.onload = s,
n.onerror = function () {
fabric.log("Error loading " + n.src),
e && e.call(i, null, !0),
n = n.onload = n.onerror = null
},
0 !== t.indexOf("data") && r && (n.crossOrigin = r),
"data:image/svg" === t.substring(0, 14) && (n.onload = null, fabric.util.loadImageInDom(n, s)),
n.src = t
} else
e && e.call(i, t)
},
loadImageInDom: function (t, e) {
var i = fabric.document.createElement("div");
i.style.width = i.style.height = "1px",
i.style.left = i.style.top = "-100%",
i.style.position = "absolute",
i.appendChild(t),
fabric.document.querySelector("body").appendChild(i),
t.onload = function () {
e(),
i.parentNode.removeChild(i),
i = null
}
},
enlivenObjects: function (t, e, n, s) {
var o = [],
i = 0,
r = (t = t || []).length;
function a() {
++i === r && e && e(o.filter(function (t) {
return t
}))
}
r ? t.forEach(function (i, r) {
i && i.type ? fabric.util.getKlass(i.type, n).fromObject(i, function (t, e) {
e || (o[r] = t),
s && s(i, t, e),
a()
}) : a()
}) : e && e(o)
},
enlivenPatterns: function (t, e) {
function i() {
++n === s && e && e(r)
}
var r = [],
n = 0,
s = (t = t || []).length;
s ? t.forEach(function (t, e) {
t && t.source ? new fabric.Pattern(t, function (t) {
r[e] = t,
i()
}) : (r[e] = t, i())
}) : e && e(r)
},
groupSVGElements: function (t, e, i) {
var r;
return t && 1 === t.length ? t[0] : (e && (e.width && e.height ? e.centerPoint = {
x: e.width / 2,
y: e.height / 2
}
: (delete e.width, delete e.height)), r = new fabric.Group(t, e), void 0 !== i && (r.sourcePath = i), r)
},
populateWithProperties: function (t, e, i) {
if (i && "[object Array]" === Object.prototype.toString.call(i))
for (var r = 0, n = i.length; r < n; r++)
i[r]in t && (e[i[r]] = t[i[r]])
},
drawDashedLine: function (t, e, i, r, n, s) {
var o = r - e,
a = n - i,
h = d(o * o + a * a),
c = g(a, o),
l = s.length,
u = 0,
f = !0;
for (t.save(), t.translate(e, i), t.moveTo(0, 0), t.rotate(c), e = 0; e < h; )
h < (e += s[u++ % l]) && (e = h), t[f ? "lineTo" : "moveTo"](e, 0), f = !f;
t.restore()
},
createCanvasElement: function () {
return fabric.document.createElement("canvas")
},
copyCanvasElement: function (t) {
var e = fabric.util.createCanvasElement();
return e.width = t.width,
e.height = t.height,
e.getContext("2d").drawImage(t, 0, 0),
e
},
toDataURL: function (t, e, i) {
return t.toDataURL("image/" + e, i)
},
createImage: function () {
return fabric.document.createElement("img")
},
clipContext: function (t, e) {
e.save(),
e.beginPath(),
t.clipTo(e),
e.clip()
},
multiplyTransformMatrices: function (t, e, i) {
return [t[0] * e[0] + t[2] * e[1], t[1] * e[0] + t[3] * e[1], t[0] * e[2] + t[2] * e[3], t[1] * e[2] + t[3] * e[3], i ? 0 : t[0] * e[4] + t[2] * e[5] + t[4], i ? 0 : t[1] * e[4] + t[3] * e[5] + t[5]]
},
qrDecompose: function (t) {
var e = g(t[1], t[0]),
i = o(t[0], 2) + o(t[1], 2),
r = d(i),
n = (t[0] * t[3] - t[2] * t[1]) / r,
s = g(t[0] * t[2] + t[1] * t[3], i);
return {
angle: e / a,
scaleX: r,
scaleY: n,
skewX: s / a,
skewY: 0,
translateX: t[4],
translateY: t[5]
}
},
calcRotateMatrix: function (t) {
if (!t.angle)
return fabric.iMatrix.concat();
var e = fabric.util.degreesToRadians(t.angle),
i = fabric.util.cos(e),
r = fabric.util.sin(e);
return [i, r, -r, i, 0, 0]
},
calcDimensionsMatrix: function (t) {
var e = void 0 === t.scaleX ? 1 : t.scaleX,
i = void 0 === t.scaleY ? 1 : t.scaleY,
r = [t.flipX ? -e : e, 0, 0, t.flipY ? -i : i, 0, 0],
n = fabric.util.multiplyTransformMatrices,
s = fabric.util.degreesToRadians;
return t.skewX && (r = n(r, [1, 0, Math.tan(s(t.skewX)), 1], !0)),
t.skewY && (r = n(r, [1, Math.tan(s(t.skewY)), 0, 1], !0)),
r
},
composeMatrix: function (t) {
var e = [1, 0, 0, 1, t.translateX || 0, t.translateY || 0],
i = fabric.util.multiplyTransformMatrices;
return t.angle && (e = i(e, fabric.util.calcRotateMatrix(t))),
(t.scaleX || t.scaleY || t.skewX || t.skewY || t.flipX || t.flipY) && (e = i(e, fabric.util.calcDimensionsMatrix(t))),
e
},
customTransformMatrix: function (t, e, i) {
return fabric.util.composeMatrix({
scaleX: t,
scaleY: e,
skewX: i
})
},
resetObjectTransform: function (t) {
t.scaleX = 1,
t.scaleY = 1,
t.skewX = 0,
t.skewY = 0,
t.flipX = !1,
t.flipY = !1,
t.rotate(0)
},
saveObjectTransform: function (t) {
return {
scaleX: t.scaleX,
scaleY: t.scaleY,
skewX: t.skewX,
skewY: t.skewY,
angle: t.angle,
left: t.left,
flipX: t.flipX,
flipY: t.flipY,
top: t.top
}
},
getFunctionBody: function (t) {
return (String(t).match(/function[^{]*\{([\s\S]*)\}/) || {})[1]
},
isTransparent: function (t, e, i, r) {
0 < r && (r < e ? e -= r : e = 0, r < i ? i -= r : i = 0);
var n,
s = !0,
o = t.getImageData(e, i, 2 * r || 1, 2 * r || 1),
a = o.data.length;
for (n = 3; n < a && !1 !== (s = o.data[n] <= 0); n += 4);
return o = null,
s
},
parsePreserveAspectRatioAttribute: function (t) {
var e,
i = "meet",
r = t.split(" ");
return r && r.length && ("meet" !== (i = r.pop()) && "slice" !== i ? (e = i, i = "meet") : r.length && (e = r.pop())), {
meetOrSlice: i,
alignX: "none" !== e ? e.slice(1, 4) : "none",
alignY: "none" !== e ? e.slice(5, 8) : "none"
}
},
clearFabricFontCache: function (t) {
(t = (t || "").toLowerCase()) ? fabric.charWidthsCache[t] && delete fabric.charWidthsCache[t] : fabric.charWidthsCache = {}
},
limitDimsByArea: function (t, e) {
var i = Math.sqrt(e * t),
r = Math.floor(e / i);
return {
x: Math.floor(i),
y: r
}
},
capValue: function (t, e, i) {
return Math.max(t, Math.min(e, i))
},
findScaleToFit: function (t, e) {
return Math.min(e.width / t.width, e.height / t.height)
},
findScaleToCover: function (t, e) {
return Math.max(e.width / t.width, e.height / t.height)
},
matrixToSVG: function (t) {
return "matrix(" + t.map(function (t) {
return fabric.util.toFixed(t, fabric.Object.NUM_FRACTION_DIGITS)
}).join(" ") + ")"
}
}
}
("undefined" != typeof exports ? exports : this), function () {
var Z = Array.prototype.join;
function v(t, e, i, r, n, s, o) {
var a = Z.call(arguments);
if (fabric.arcToSegmentsCache[a])
return fabric.arcToSegmentsCache[a];
var h = Math.PI,
c = o * h / 180,
l = fabric.util.sin(c),
u = fabric.util.cos(c),
f = 0,
d = 0,
g = -u * t * .5 - l * e * .5,
p = -u * e * .5 + l * t * .5,
v = (i = Math.abs(i)) * i,
m = (r = Math.abs(r)) * r,
b = p * p,
_ = g * g,
y = v * m - v * b - m * _,
x = 0;
if (y < 0) {
var C = Math.sqrt(1 - y / (v * m));
i *= C,
r *= C
} else
x = (n === s ? -1 : 1) * Math.sqrt(y / (v * b + m * _));
var S = x * i * p / r,
T = -x * r * g / i,
w = u * S - l * T + .5 * t,
O = l * S + u * T + .5 * e,
k = Q(1, 0, (g - S) / i, (p - T) / r),
P = Q((g - S) / i, (p - T) / r, (-g - S) / i, (-p - T) / r);
0 === s && 0 < P ? P -= 2 * h : 1 === s && P < 0 && (P += 2 * h);
for (var D, E, j, A, M, F, I, L, R, B, X, Y, W, G, z, U, N, V = Math.ceil(Math.abs(P / h * 2)), H = [], q = P / V, K = 8 / 3 * Math.sin(q / 4) * Math.sin(q / 4) / Math.sin(q / 2), J = k + q, $ = 0; $ < V; $++)
H[$] = (D = k, E = J, j = u, A = l, M = i, F = r, I = w, L = O, R = K, B = f, X = d, void 0, Y = fabric.util.cos(D), W = fabric.util.sin(D), G = fabric.util.cos(E), z = fabric.util.sin(E), [B + R * (-j * M * W - A * F * Y), X + R * (-A * M * W + j * F * Y), (U = j * M * G - A * F * z + I) + R * (j * M * z + A * F * G), (N = A * M * G + j * F * z + L) + R * (A * M * z - j * F * G), U, N]), f = H[$][4], d = H[$][5], k = J, J += q;
return fabric.arcToSegmentsCache[a] = H
}
function Q(t, e, i, r) {
var n = Math.atan2(e, t),
s = Math.atan2(r, i);
return n <= s ? s - n : 2 * Math.PI - (n - s)
}
function m(t, e, i, r, n, s, o, a) {
var h;
if (fabric.cachesBoundsOfCurve && (h = Z.call(arguments), fabric.boundsOfCurveCache[h]))
return fabric.boundsOfCurveCache[h];
var c,
l,
u,
f,
d,
g,
p,
v,
m = Math.sqrt,
b = Math.min,
_ = Math.max,
y = Math.abs,
x = [],
C = [[], []];
l = 6 * t - 12 * i + 6 * n,
c = -3 * t + 9 * i - 9 * n + 3 * o,
u = 3 * i - 3 * t;
for (var S = 0; S < 2; ++S)
if (0 < S && (l = 6 * e - 12 * r + 6 * s, c = -3 * e + 9 * r - 9 * s + 3 * a, u = 3 * r - 3 * e), y(c) < 1e-12) {
if (y(l) < 1e-12)
continue;
0 < (f = -u / l) && f < 1 && x.push(f)
} else (p = l * l - 4 * u * c) < 0 || (0 < (d = (-l + (v = m(p))) / (2 * c)) && d < 1 && x.push(d), 0 < (g = (-l - v) / (2 * c)) && g < 1 && x.push(g));
for (var T, w, O, k = x.length, P = k; k--; )
T = (O = 1 - (f = x[k])) * O * O * t + 3 * O * O * f * i + 3 * O * f * f * n + f * f * f * o, C[0][k] = T, w = O * O * O * e + 3 * O * O * f * r + 3 * O * f * f * s + f * f * f * a, C[1][k] = w;
C[0][P] = t,
C[1][P] = e,
C[0][P + 1] = o,
C[1][P + 1] = a;
var D = [{
x: b.apply(null, C[0]),
y: b.apply(null, C[1])
}, {
x: _.apply(null, C[0]),
y: _.apply(null, C[1])
}
];
return fabric.cachesBoundsOfCurve && (fabric.boundsOfCurveCache[h] = D),
D
}
fabric.util.drawArc = function (t, e, i, r) {
for (var n = r[0], s = r[1], o = r[2], a = r[3], h = r[4], c = [[], [], [], []], l = v(r[5] - e, r[6] - i, n, s, a, h, o), u = 0, f = l.length; u < f; u++)
c[u][0] = l[u][0] + e, c[u][1] = l[u][1] + i, c[u][2] = l[u][2] + e, c[u][3] = l[u][3] + i, c[u][4] = l[u][4] + e, c[u][5] = l[u][5] + i, t.bezierCurveTo.apply(t, c[u])
},
fabric.util.getBoundsOfArc = function (t, e, i, r, n, s, o, a, h) {
for (var c, l = 0, u = 0, f = [], d = v(a - t, h - e, i, r, s, o, n), g = 0, p = d.length; g < p; g++)
c = m(l, u, d[g][0], d[g][1], d[g][2], d[g][3], d[g][4], d[g][5]), f.push({
x: c[0].x + t,
y: c[0].y + e
}), f.push({
x: c[1].x + t,
y: c[1].y + e
}), l = d[g][4], u = d[g][5];
return f
},
fabric.util.getBoundsOfCurve = m
}
(), function () {
var o = Array.prototype.slice;
function i(t, e, i) {
if (t && 0 !== t.length) {
var r = t.length - 1,
n = e ? t[r][e] : t[r];
if (e)
for (; r--; )
i(t[r][e], n) && (n = t[r][e]);
else
for (; r--; )
i(t[r], n) && (n = t[r]);
return n
}
}
fabric.util.array = {
fill: function (t, e) {
for (var i = t.length; i--; )
t[i] = e;
return t
},
invoke: function (t, e) {
for (var i = o.call(arguments, 2), r = [], n = 0, s = t.length; n < s; n++)
r[n] = i.length ? t[n][e].apply(t[n], i) : t[n][e].call(t[n]);
return r
},
min: function (t, e) {
return i(t, e, function (t, e) {
return t < e
})
},
max: function (t, e) {
return i(t, e, function (t, e) {
return e <= t
})
}
}
}
(), function () {
function o(t, e, i) {
if (i)
if (!fabric.isLikelyNode && e instanceof Element)
t = e;
else if (e instanceof Array) {
t = [];
for (var r = 0, n = e.length; r < n; r++)
t[r] = o({}, e[r], i)
} else if (e && "object" == typeof e)
for (var s in e)
"canvas" === s ? t[s] = o({}, e[s]) : e.hasOwnProperty(s) && (t[s] = o({}, e[s], i));
else
t = e;
else
for (var s in e)
t[s] = e[s];
return t
}
fabric.util.object = {
extend: o,
clone: function (t, e) {
return o({}, t, e)
}
},
fabric.util.object.extend(fabric.util, fabric.Observable)
}
(), function () {
function n(t, e) {
var i = t.charCodeAt(e);
if (isNaN(i))
return "";
if (i < 55296 || 57343 < i)
return t.charAt(e);
if (55296 <= i && i <= 56319) {
if (t.length <= e + 1)
throw "High surrogate without following low surrogate";
var r = t.charCodeAt(e + 1);
if (r < 56320 || 57343 < r)
throw "High surrogate without following low surrogate";
return t.charAt(e) + t.charAt(e + 1)
}
if (0 === e)
throw "Low surrogate without preceding high surrogate";
var n = t.charCodeAt(e - 1);
if (n < 55296 || 56319 < n)
throw "Low surrogate without preceding high surrogate";
return !1
}
fabric.util.string = {
camelize: function (t) {
return t.replace(/-+(.)?/g, function (t, e) {
return e ? e.toUpperCase() : ""
})
},
capitalize: function (t, e) {
return t.charAt(0).toUpperCase() + (e ? t.slice(1) : t.slice(1).toLowerCase())
},
escapeXml: function (t) {
return t.replace(/&/g, "&").replace(/"/g, """).replace(/'/g, "'").replace(//g, ">")
},
graphemeSplit: function (t) {
var e,
i = 0,
r = [];
for (i = 0; i < t.length; i++)
!1 !== (e = n(t, i)) && r.push(e);
return r
}
}
}
(), function () {
var s = Array.prototype.slice,
o = function () {},
i = function () {
for (var t in {
toString: 1
})
if ("toString" === t)
return !1;
return !0
}
(),
a = function (t, r, n) {
for (var e in r)
e in t.prototype && "function" == typeof t.prototype[e] && -1 < (r[e] + "").indexOf("callSuper") ? t.prototype[e] = function (i) {
return function () {
var t = this.constructor.superclass;
this.constructor.superclass = n;
var e = r[i].apply(this, arguments);
if (this.constructor.superclass = t, "initialize" !== i)
return e
}
}
(e) : t.prototype[e] = r[e],
i && (r.toString !== Object.prototype.toString && (t.prototype.toString = r.toString), r.valueOf !== Object.prototype.valueOf && (t.prototype.valueOf = r.valueOf))
};
function h() {}
function c(t) {
for (var e = null, i = this; i.constructor.superclass; ) {
var r = i.constructor.superclass.prototype[t];
if (i[t] !== r) {
e = r;
break
}
i = i.constructor.superclass.prototype
}
return e ? 1 < arguments.length ? e.apply(this, s.call(arguments, 1)) : e.call(this) : console.log("tried to callSuper " + t + ", method not found in prototype chain", this)
}
fabric.util.createClass = function () {
var t = null,
e = s.call(arguments, 0);
function i() {
this.initialize.apply(this, arguments)
}
"function" == typeof e[0] && (t = e.shift()),
i.superclass = t,
i.subclasses = [],
t && (h.prototype = t.prototype, i.prototype = new h, t.subclasses.push(i));
for (var r = 0, n = e.length; r < n; r++)
a(i, e[r], t);
return i.prototype.initialize || (i.prototype.initialize = o),
(i.prototype.constructor = i).prototype.callSuper = c,
i
}
}
(), function () {
var n = !!fabric.document.createElement("div").attachEvent;
fabric.util.addListener = function (t, e, i, r) {
t && t.addEventListener(e, i, !n && r)
},
fabric.util.removeListener = function (t, e, i, r) {
t && t.removeEventListener(e, i, !n && r)
},
fabric.util.getPointer = function (t) {
var e,
i,
r = t.target,
n = fabric.util.getScrollLeftTop(r),
s = (i = (e = t).changedTouches) && i[0] ? i[0] : e;
return {
x: s.clientX + n.left,
y: s.clientY + n.top
}
}
}
(), function () {
var t = fabric.document.createElement("div"),
e = "string" == typeof t.style.opacity,
i = "string" == typeof t.style.filter,
r = /alpha\s*\(\s*opacity\s*=\s*([^\)]+)\)/,
n = function (t) {
return t
};
e ? n = function (t, e) {
return t.style.opacity = e,
t
}
: i && (n = function (t, e) {
var i = t.style;
return t.currentStyle && !t.currentStyle.hasLayout && (i.zoom = 1),
r.test(i.filter) ? (e = .9999 <= e ? "" : "alpha(opacity=" + 100 * e + ")", i.filter = i.filter.replace(r, e)) : i.filter += " alpha(opacity=" + 100 * e + ")",
t
}),
fabric.util.setStyle = function (t, e) {
var i = t.style;
if (!i)
return t;
if ("string" == typeof e)
return t.style.cssText += ";" + e, -1 < e.indexOf("opacity") ? n(t, e.match(/opacity:\s*(\d?\.?\d*)/)[1]) : t;
for (var r in e)
"opacity" === r ? n(t, e[r]) : i["float" === r || "cssFloat" === r ? void 0 === i.styleFloat ? "cssFloat" : "styleFloat" : r] = e[r];
return t
}
}
(), function () {
var e = Array.prototype.slice;
var t,
h,
i,
r,
n = function (t) {
return e.call(t, 0)
};
try {
t = n(fabric.document.childNodes)instanceof Array
} catch (t) {}
function s(t, e) {
var i = fabric.document.createElement(t);
for (var r in e)
"class" === r ? i.className = e[r] : "for" === r ? i.htmlFor = e[r] : i.setAttribute(r, e[r]);
return i
}
function c(t) {
for (var e = 0, i = 0, r = fabric.document.documentElement, n = fabric.document.body || {
scrollLeft: 0,
scrollTop: 0
}; t && (t.parentNode || t.host) && ((t = t.parentNode || t.host) === fabric.document ? (e = n.scrollLeft || r.scrollLeft || 0, i = n.scrollTop || r.scrollTop || 0) : (e += t.scrollLeft || 0, i += t.scrollTop || 0), 1 !== t.nodeType || "fixed" !== t.style.position); );
return {
left: e,
top: i
}
}
t || (n = function (t) {
for (var e = new Array(t.length), i = t.length; i--; )
e[i] = t[i];
return e
}),
h = fabric.document.defaultView && fabric.document.defaultView.getComputedStyle ? function (t, e) {
var i = fabric.document.defaultView.getComputedStyle(t, null);
return i ? i[e] : void 0
}
: function (t, e) {
var i = t.style[e];
return !i && t.currentStyle && (i = t.currentStyle[e]),
i
},
i = fabric.document.documentElement.style,
r = "userSelect" in i ? "userSelect" : "MozUserSelect" in i ? "MozUserSelect" : "WebkitUserSelect" in i ? "WebkitUserSelect" : "KhtmlUserSelect" in i ? "KhtmlUserSelect" : "",
fabric.util.makeElementUnselectable = function (t) {
return void 0 !== t.onselectstart && (t.onselectstart = fabric.util.falseFunction),
r ? t.style[r] = "none" : "string" == typeof t.unselectable && (t.unselectable = "on"),
t
},
fabric.util.makeElementSelectable = function (t) {
return void 0 !== t.onselectstart && (t.onselectstart = null),
r ? t.style[r] = "" : "string" == typeof t.unselectable && (t.unselectable = ""),
t
},
fabric.util.getScript = function (t, e) {
var i = fabric.document.getElementsByTagName("head")[0],
r = fabric.document.createElement("script"),
n = !0;
r.onload = r.onreadystatechange = function (t) {
if (n) {
if ("string" == typeof this.readyState && "loaded" !== this.readyState && "complete" !== this.readyState)
return;
n = !1,
e(t || fabric.window.event),
r = r.onload = r.onreadystatechange = null
}
},
r.src = t,
i.appendChild(r)
},
fabric.util.getById = function (t) {
return "string" == typeof t ? fabric.document.getElementById(t) : t
},
fabric.util.toArray = n,
fabric.util.makeElement = s,
fabric.util.addClass = function (t, e) {
t && -1 === (" " + t.className + " ").indexOf(" " + e + " ") && (t.className += (t.className ? " " : "") + e)
},
fabric.util.wrapElement = function (t, e, i) {
return "string" == typeof e && (e = s(e, i)),
t.parentNode && t.parentNode.replaceChild(e, t),
e.appendChild(t),
e
},
fabric.util.getScrollLeftTop = c,
fabric.util.getElementOffset = function (t) {
var e,
i,
r = t && t.ownerDocument,
n = {
left: 0,
top: 0
},
s = {
left: 0,
top: 0
},
o = {
borderLeftWidth: "left",
borderTopWidth: "top",
paddingLeft: "left",
paddingTop: "top"
};
if (!r)
return s;
for (var a in o)
s[o[a]] += parseInt(h(t, a), 10) || 0;
return e = r.documentElement,
void 0 !== t.getBoundingClientRect && (n = t.getBoundingClientRect()),
i = c(t), {
left: n.left + i.left - (e.clientLeft || 0) + s.left,
top: n.top + i.top - (e.clientTop || 0) + s.top
}
},
fabric.util.getElementStyle = h,
fabric.util.getNodeCanvas = function (t) {
var e = fabric.jsdomImplForWrapper(t);
return e._canvas || e._image
},
fabric.util.cleanUpJsdomNode = function (t) {
if (fabric.isLikelyNode) {
var e = fabric.jsdomImplForWrapper(t);
e && (e._image = null, e._canvas = null, e._currentSrc = null, e._attributes = null, e._classList = null)
}
}
}
(), function () {
function h() {}
fabric.util.request = function (t, e) {
e || (e = {});
var i,
r,
n = e.method ? e.method.toUpperCase() : "GET",
s = e.onComplete || function () {},
o = new fabric.window.XMLHttpRequest,
a = e.body || e.parameters;
return o.onreadystatechange = function () {
4 === o.readyState && (s(o), o.onreadystatechange = h)
},
"GET" === n && (a = null, "string" == typeof e.parameters && (i = t, r = e.parameters, t = i + (/\?/.test(i) ? "&" : "?") + r)),
o.open(n, t, !0),
"POST" !== n && "PUT" !== n || o.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"),
o.send(a),
o
}
}
(), fabric.log = console.log, fabric.warn = console.warn, function () {
function i() {
return !1
}
function r(t, e, i, r) {
return -i * Math.cos(t / r * (Math.PI / 2)) + i + e
}
var t = fabric.window.requestAnimationFrame || fabric.window.webkitRequestAnimationFrame || fabric.window.mozRequestAnimationFrame || fabric.window.oRequestAnimationFrame || fabric.window.msRequestAnimationFrame || function (t) {
return fabric.window.setTimeout(t, 1e3 / 60)
},
e = fabric.window.cancelAnimationFrame || fabric.window.clearTimeout;
function m() {
return t.apply(fabric.window, arguments)
}
fabric.util.animate = function (e) {
m(function (t) {
e || (e = {});
var o,
a = t || +new Date,
h = e.duration || 500,
c = a + h,
l = e.onChange || i,
u = e.abort || i,
f = e.onComplete || i,
d = e.easing || r,
g = "startValue" in e ? e.startValue : 0,
p = "endValue" in e ? e.endValue : 100,
v = e.byValue || p - g;
e.onStart && e.onStart(),
function t(e) {
o = e || +new Date;
var i = c < o ? h : o - a,
r = i / h,
n = d(i, g, v, h),
s = Math.abs((n - g) / v);
if (!u())
return c < o ? (l(p, 1, 1), void f(p, 1, 1)) : (l(n, s, r), void m(t));
f(p, 1, 1)
}
(a)
})
},
fabric.util.requestAnimFrame = m,
fabric.util.cancelAnimFrame = function () {
return e.apply(fabric.window, arguments)
}
}
(), fabric.util.animateColor = function (t, e, i, c) {
var r = new fabric.Color(t).getSource(),
n = new fabric.Color(e).getSource();
c = c || {},
fabric.util.animate(fabric.util.object.extend(c, {
duration: i || 500,
startValue: r,
endValue: n,
byValue: n,
easing: function (t, e, i, r) {
var n,
s,
o,
a,
h = c.colorEasing ? c.colorEasing(t, r) : 1 - Math.cos(t / r * (Math.PI / 2));
return n = e,
s = i,
o = h,
a = "rgba(" + parseInt(n[0] + o * (s[0] - n[0]), 10) + "," + parseInt(n[1] + o * (s[1] - n[1]), 10) + "," + parseInt(n[2] + o * (s[2] - n[2]), 10),
a += "," + (n && s ? parseFloat(n[3] + o * (s[3] - n[3])) : 1),
a += ")"
}
}))
}, function () {
function o(t, e, i, r) {
return t < Math.abs(e) ? (t = e, r = i / 4) : r = 0 === e && 0 === t ? i / (2 * Math.PI) * Math.asin(1) : i / (2 * Math.PI) * Math.asin(e / t), {
a: t,
c: e,
p: i,
s: r
}
}
function a(t, e, i) {
return t.a * Math.pow(2, 10 * (e -= 1)) * Math.sin((e * i - t.s) * (2 * Math.PI) / t.p)
}
function n(t, e, i, r) {
return i - s(r - t, 0, i, r) + e
}
function s(t, e, i, r) {
return (t /= r) < 1 / 2.75 ? i * (7.5625 * t * t) + e : t < 2 / 2.75 ? i * (7.5625 * (t -= 1.5 / 2.75) * t + .75) + e : t < 2.5 / 2.75 ? i * (7.5625 * (t -= 2.25 / 2.75) * t + .9375) + e : i * (7.5625 * (t -= 2.625 / 2.75) * t + .984375) + e
}
fabric.util.ease = {
easeInQuad: function (t, e, i, r) {
return i * (t /= r) * t + e
},
easeOutQuad: function (t, e, i, r) {
return -i * (t /= r) * (t - 2) + e
},
easeInOutQuad: function (t, e, i, r) {
return (t /= r / 2) < 1 ? i / 2 * t * t + e : -i / 2 * (--t * (t - 2) - 1) + e
},
easeInCubic: function (t, e, i, r) {
return i * (t /= r) * t * t + e
},
easeOutCubic: function (t, e, i, r) {
return i * ((t = t / r - 1) * t * t + 1) + e
},
easeInOutCubic: function (t, e, i, r) {
return (t /= r / 2) < 1 ? i / 2 * t * t * t + e : i / 2 * ((t -= 2) * t * t + 2) + e
},
easeInQuart: function (t, e, i, r) {
return i * (t /= r) * t * t * t + e
},
easeOutQuart: function (t, e, i, r) {
return -i * ((t = t / r - 1) * t * t * t - 1) + e
},
easeInOutQuart: function (t, e, i, r) {
return (t /= r / 2) < 1 ? i / 2 * t * t * t * t + e : -i / 2 * ((t -= 2) * t * t * t - 2) + e
},
easeInQuint: function (t, e, i, r) {
return i * (t /= r) * t * t * t * t + e
},
easeOutQuint: function (t, e, i, r) {
return i * ((t = t / r - 1) * t * t * t * t + 1) + e
},
easeInOutQuint: function (t, e, i, r) {
return (t /= r / 2) < 1 ? i / 2 * t * t * t * t * t + e : i / 2 * ((t -= 2) * t * t * t * t + 2) + e
},
easeInSine: function (t, e, i, r) {
return -i * Math.cos(t / r * (Math.PI / 2)) + i + e
},
easeOutSine: function (t, e, i, r) {
return i * Math.sin(t / r * (Math.PI / 2)) + e
},
easeInOutSine: function (t, e, i, r) {
return -i / 2 * (Math.cos(Math.PI * t / r) - 1) + e
},
easeInExpo: function (t, e, i, r) {
return 0 === t ? e : i * Math.pow(2, 10 * (t / r - 1)) + e
},
easeOutExpo: function (t, e, i, r) {
return t === r ? e + i : i * (1 - Math.pow(2, -10 * t / r)) + e
},
easeInOutExpo: function (t, e, i, r) {
return 0 === t ? e : t === r ? e + i : (t /= r / 2) < 1 ? i / 2 * Math.pow(2, 10 * (t - 1)) + e : i / 2 * (2 - Math.pow(2, -10 * --t)) + e
},
easeInCirc: function (t, e, i, r) {
return -i * (Math.sqrt(1 - (t /= r) * t) - 1) + e
},
easeOutCirc: function (t, e, i, r) {
return i * Math.sqrt(1 - (t = t / r - 1) * t) + e
},
easeInOutCirc: function (t, e, i, r) {
return (t /= r / 2) < 1 ? -i / 2 * (Math.sqrt(1 - t * t) - 1) + e : i / 2 * (Math.sqrt(1 - (t -= 2) * t) + 1) + e
},
easeInElastic: function (t, e, i, r) {
var n = 0;
return 0 === t ? e : 1 == (t /= r) ? e + i : (n || (n = .3 * r), -a(o(i, i, n, 1.70158), t, r) + e)
},
easeOutElastic: function (t, e, i, r) {
var n = 0;
if (0 === t)
return e;
if (1 == (t /= r))
return e + i;
n || (n = .3 * r);
var s = o(i, i, n, 1.70158);
return s.a * Math.pow(2, -10 * t) * Math.sin((t * r - s.s) * (2 * Math.PI) / s.p) + s.c + e
},
easeInOutElastic: function (t, e, i, r) {
var n = 0;
if (0 === t)
return e;
if (2 == (t /= r / 2))
return e + i;
n || (n = r * (.3 * 1.5));
var s = o(i, i, n, 1.70158);
return t < 1 ? - .5 * a(s, t, r) + e : s.a * Math.pow(2, -10 * (t -= 1)) * Math.sin((t * r - s.s) * (2 * Math.PI) / s.p) * .5 + s.c + e
},
easeInBack: function (t, e, i, r, n) {
return void 0 === n && (n = 1.70158),
i * (t /= r) * t * ((n + 1) * t - n) + e
},
easeOutBack: function (t, e, i, r, n) {
return void 0 === n && (n = 1.70158),
i * ((t = t / r - 1) * t * ((n + 1) * t + n) + 1) + e
},
easeInOutBack: function (t, e, i, r, n) {
return void 0 === n && (n = 1.70158),
(t /= r / 2) < 1 ? i / 2 * (t * t * ((1 + (n *= 1.525)) * t - n)) + e : i / 2 * ((t -= 2) * t * ((1 + (n *= 1.525)) * t + n) + 2) + e
},
easeInBounce: n,
easeOutBounce: s,
easeInOutBounce: function (t, e, i, r) {
return t < r / 2 ? .5 * n(2 * t, 0, i, r) + e : .5 * s(2 * t - r, 0, i, r) + .5 * i + e
}
}
}
(), function (t) {
"use strict";
var C = t.fabric || (t.fabric = {}),
p = C.util.object.extend,
f = C.util.object.clone,
v = C.util.toFixed,
S = C.util.parseUnit,
h = C.util.multiplyTransformMatrices,
m = {
cx: "left",
x: "left",
r: "radius",
cy: "top",
y: "top",
display: "visible",
visibility: "visible",
transform: "transformMatrix",
"fill-opacity": "fillOpacity",
"fill-rule": "fillRule",
"font-family": "fontFamily",
"font-size": "fontSize",
"font-style": "fontStyle",
"font-weight": "fontWeight",
"letter-spacing": "charSpacing",
"paint-order": "paintFirst",
"stroke-dasharray": "strokeDashArray",
"stroke-dashoffset": "strokeDashOffset",
"stroke-linecap": "strokeLineCap",
"stroke-linejoin": "strokeLineJoin",
"stroke-miterlimit": "strokeMiterLimit",
"stroke-opacity": "strokeOpacity",
"stroke-width": "strokeWidth",
"text-decoration": "textDecoration",
"text-anchor": "textAnchor",
opacity: "opacity",
"clip-path": "clipPath",
"clip-rule": "clipRule",
"vector-effect": "strokeUniform"
},
b = {
stroke: "strokeOpacity",
fill: "fillOpacity"
},
_ = "font-size",
y = "clip-path";
function x(t, e, i, r) {
var n,
s = "[object Array]" === Object.prototype.toString.call(e);
if ("fill" !== t && "stroke" !== t || "none" !== e)
if ("vector-effect" === t)
e = "non-scaling-stroke" === e;
else if ("strokeDashArray" === t)
e = "none" === e ? null : e.replace(/,/g, " ").split(/\s+/).map(parseFloat);
else if ("transformMatrix" === t)
e = i && i.transformMatrix ? h(i.transformMatrix, C.parseTransformAttribute(e)) : C.parseTransformAttribute(e);
else if ("visible" === t)
e = "none" !== e && "hidden" !== e, i && !1 === i.visible && (e = !1);
else if ("opacity" === t)
e = parseFloat(e), i && void 0 !== i.opacity && (e *= i.opacity);
else if ("textAnchor" === t)
e = "start" === e ? "left" : "end" === e ? "right" : "center";
else if ("charSpacing" === t)
n = S(e, r) / r * 1e3;
else if ("paintFirst" === t) {
var o = e.indexOf("fill"),
a = e.indexOf("stroke");
e = "fill";
-1 < o && -1 < a && a < o ? e = "stroke" : -1 === o && -1 < a && (e = "stroke")
} else {
if ("href" === t || "xlink:href" === t)
return e;
n = s ? e.map(S) : S(e, r)
}
else
e = "";
return !s && isNaN(n) ? e : n
}
function e(t) {
return new RegExp("^(" + t.join("|") + ")\\b", "i")
}
function T(t, e) {
var i,
r,
n,
s,
o = [];
for (n = 0, s = e.length; n < s; n++)
i = e[n], r = t.getElementsByTagName(i), o = o.concat(Array.prototype.slice.call(r));
return o
}
function w(t, e) {
var i,
r = !0;
return (i = n(t, e.pop())) && e.length && (r = function (t, e) {
var i,
r = !0;
for (; t.parentNode && 1 === t.parentNode.nodeType && e.length; )
r && (i = e.pop()), t = t.parentNode, r = n(t, i);
return 0 === e.length
}
(t, e)),
i && r && 0 === e.length
}
function n(t, e) {
var i,
r,
n = t.nodeName,
s = t.getAttribute("class"),
o = t.getAttribute("id");
if (i = new RegExp("^" + n, "i"), e = e.replace(i, ""), o && e.length && (i = new RegExp("#" + o + "(?![a-zA-Z\\-]+)", "i"), e = e.replace(i, "")), s && e.length)
for (r = (s = s.split(" ")).length; r--; )
i = new RegExp("\\." + s[r] + "(?![a-zA-Z\\-]+)", "i"), e = e.replace(i, "");
return 0 === e.length
}
function O(t, e) {
var i;
if (t.getElementById && (i = t.getElementById(e)), i)
return i;
var r,
n,
s,
o = t.getElementsByTagName("*");
for (n = 0, s = o.length; n < s; n++)
if (e === (r = o[n]).getAttribute("id"))
return r
}
C.svgValidTagNamesRegEx = e(["path", "circle", "polygon", "polyline", "ellipse", "rect", "line", "image", "text"]),
C.svgViewBoxElementsRegEx = e(["symbol", "image", "marker", "pattern", "view", "svg"]),
C.svgInvalidAncestorsRegEx = e(["pattern", "defs", "symbol", "metadata", "clipPath", "mask", "desc"]),
C.svgValidParentsRegEx = e(["symbol", "g", "a", "svg", "clipPath", "defs"]),
C.cssRules = {},
C.gradientDefs = {},
C.clipPaths = {},
C.parseTransformAttribute = function () {
function b(t, e, i) {
t[i] = Math.tan(C.util.degreesToRadians(e[0]))
}
var _ = C.iMatrix,
t = C.reNum,
e = "(?:\\s+,?\\s*|,\\s*)",
y = "(?:" + ("(?:(matrix)\\s*\\(\\s*(" + t + ")" + e + "(" + t + ")" + e + "(" + t + ")" + e + "(" + t + ")" + e + "(" + t + ")" + e + "(" + t + ")\\s*\\))") + "|" + ("(?:(translate)\\s*\\(\\s*(" + t + ")(?:" + e + "(" + t + "))?\\s*\\))") + "|" + ("(?:(scale)\\s*\\(\\s*(" + t + ")(?:" + e + "(" + t + "))?\\s*\\))") + "|" + ("(?:(rotate)\\s*\\(\\s*(" + t + ")(?:" + e + "(" + t + ")" + e + "(" + t + "))?\\s*\\))") + "|" + ("(?:(skewX)\\s*\\(\\s*(" + t + ")\\s*\\))") + "|" + ("(?:(skewY)\\s*\\(\\s*(" + t + ")\\s*\\))") + ")",
i = new RegExp("^\\s*(?:" + ("(?:" + y + "(?:" + e + "*" + y + ")*)") + "?)\\s*$"),
r = new RegExp(y, "g");
return function (t) {
var v = _.concat(),
m = [];
if (!t || t && !i.test(t))
return v;
t.replace(r, function (t) {
var e,
i,
r,
n,
s,
o,
a,
h,
c,
l,
u,
f,
d = new RegExp(y).exec(t).filter(function (t) {
return !!t
}),
g = d[1],
p = d.slice(2).map(parseFloat);
switch (g) {
case "translate":
f = p,
(u = v)[4] = f[0],
2 === f.length && (u[5] = f[1]);
break;
case "rotate":
p[0] = C.util.degreesToRadians(p[0]),
s = v,
o = p,
a = C.util.cos(o[0]),
h = C.util.sin(o[0]),
l = c = 0,
3 === o.length && (c = o[1], l = o[2]),
s[0] = a,
s[1] = h,
s[2] = -h,
s[3] = a,
s[4] = c - (a * c - h * l),
s[5] = l - (h * c + a * l);
break;
case "scale":
e = v,
r = (i = p)[0],
n = 2 === i.length ? i[1] : i[0],
e[0] = r,
e[3] = n;
break;
case "skewX":
b(v, p, 2);
break;
case "skewY":
b(v, p, 1);
break;
case "matrix":
v = p
}
m.push(v.concat()),
v = _.concat()
});
for (var e = m[0]; 1 < m.length; )
m.shift(), e = C.util.multiplyTransformMatrices(e, m[0]);
return e
}
}
();
var k = new RegExp("^\\s*(" + C.reNum + "+)\\s*,?\\s*(" + C.reNum + "+)\\s*,?\\s*(" + C.reNum + "+)\\s*,?\\s*(" + C.reNum + "+)\\s*$");
function P(t) {
var e,
i,
r,
n,
s,
o,
a = t.getAttribute("viewBox"),
h = 1,
c = 1,
l = t.getAttribute("width"),
u = t.getAttribute("height"),
f = t.getAttribute("x") || 0,
d = t.getAttribute("y") || 0,
g = t.getAttribute("preserveAspectRatio") || "",
p = !a || !C.svgViewBoxElementsRegEx.test(t.nodeName) || !(a = a.match(k)),
v = !l || !u || "100%" === l || "100%" === u,
m = p && v,
b = {},
_ = "",
y = 0,
x = 0;
if (b.width = 0, b.height = 0, b.toBeParsed = m)
return b;
if (p)
return b.width = S(l), b.height = S(u), b;
if (e = -parseFloat(a[1]), i = -parseFloat(a[2]), r = parseFloat(a[3]), n = parseFloat(a[4]), b.minX = e, b.minY = i, b.viewBoxWidth = r, b.viewBoxHeight = n, v ? (b.width = r, b.height = n) : (b.width = S(l), b.height = S(u), h = b.width / r, c = b.height / n), "none" !== (g = C.util.parsePreserveAspectRatioAttribute(g)).alignX && ("meet" === g.meetOrSlice && (c = h = c < h ? c : h), "slice" === g.meetOrSlice && (c = h = c < h ? h : c), y = b.width - r * h, x = b.height - n * h, "Mid" === g.alignX && (y /= 2), "Mid" === g.alignY && (x /= 2), "Min" === g.alignX && (y = 0), "Min" === g.alignY && (x = 0)), 1 === h && 1 === c && 0 === e && 0 === i && 0 === f && 0 === d)
return b;
if ((f || d) && (_ = " translate(" + S(f) + " " + S(d) + ") "), s = _ + " matrix(" + h + " 0 0 " + c + " " + (e * h + y) + " " + (i * c + x) + ") ", b.viewboxTransform = C.parseTransformAttribute(s), "svg" === t.nodeName) {
for (o = t.ownerDocument.createElementNS(C.svgNS, "g"); t.firstChild; )
o.appendChild(t.firstChild);
t.appendChild(o)
} else
s = (o = t).getAttribute("transform") + s;
return o.setAttribute("transform", s),
b
}
function s(t, e) {
var i = "xlink:href",
r = O(t, e.getAttribute(i).substr(1));
if (r && r.getAttribute(i) && s(t, r), ["gradientTransform", "x1", "x2", "y1", "y2", "gradientUnits", "cx", "cy", "r", "fx", "fy"].forEach(function (t) {
r && !e.hasAttribute(t) && r.hasAttribute(t) && e.setAttribute(t, r.getAttribute(t))
}), !e.children.length)
for (var n = r.cloneNode(!0); n.firstChild; )
e.appendChild(n.firstChild);
e.removeAttribute(i)
}
C.parseSVGDocument = function (t, i, e, r) {
if (t) {
!function (t) {
for (var e = T(t, ["use", "svg:use"]), i = 0; e.length && i < e.length; ) {
var r,
n,
s,
o,
a = e[i],
h = (a.getAttribute("xlink:href") || a.getAttribute("href")).substr(1),
c = a.getAttribute("x") || 0,
l = a.getAttribute("y") || 0,
u = O(t, h).cloneNode(!0),
f = (u.getAttribute("transform") || "") + " translate(" + c + ", " + l + ")",
d = e.length,
g = C.svgNS;
if (P(u), /^svg$/i.test(u.nodeName)) {
var p = u.ownerDocument.createElementNS(g, "g");
for (n = 0, o = (s = u.attributes).length; n < o; n++)
r = s.item(n), p.setAttributeNS(g, r.nodeName, r.nodeValue);
for (; u.firstChild; )
p.appendChild(u.firstChild);
u = p
}
for (n = 0, o = (s = a.attributes).length; n < o; n++)
"x" !== (r = s.item(n)).nodeName && "y" !== r.nodeName && "xlink:href" !== r.nodeName && "href" !== r.nodeName && ("transform" === r.nodeName ? f = r.nodeValue + " " + f : u.setAttribute(r.nodeName, r.nodeValue));
u.setAttribute("transform", f),
u.setAttribute("instantiated_by_use", "1"),
u.removeAttribute("id"),
a.parentNode.replaceChild(u, a),
e.length === d && i++
}
}
(t);
var n,
s,
o = C.Object.__uid++,
a = P(t),
h = C.util.toArray(t.getElementsByTagName("*"));
if (a.crossOrigin = r && r.crossOrigin, a.svgUid = o, 0 === h.length && C.isLikelyNode) {
var c = [];
for (n = 0, s = (h = t.selectNodes('//*[name(.)!="svg"]')).length; n < s; n++)
c[n] = h[n];
h = c
}
var l = h.filter(function (t) {
return P(t),
C.svgValidTagNamesRegEx.test(t.nodeName.replace("svg:", "")) && !function (t, e) {
for (; t && (t = t.parentNode); )
if (t.nodeName && e.test(t.nodeName.replace("svg:", "")) && !t.getAttribute("instantiated_by_use"))
return !0;
return !1
}
(t, C.svgInvalidAncestorsRegEx)
});
if (!l || l && !l.length)
i && i([], {});
else {
var u = {};
h.filter(function (t) {
return "clipPath" === t.nodeName.replace("svg:", "")
}).forEach(function (t) {
var e = t.getAttribute("id");
u[e] = C.util.toArray(t.getElementsByTagName("*")).filter(function (t) {
return C.svgValidTagNamesRegEx.test(t.nodeName.replace("svg:", ""))
})
}),
C.gradientDefs[o] = C.getGradientDefs(t),
C.cssRules[o] = C.getCSSRules(t),
C.clipPaths[o] = u,
C.parseElements(l, function (t, e) {
i && (i(t, a, e, h), delete C.gradientDefs[o], delete C.cssRules[o], delete C.clipPaths[o])
}, f(a), e, r)
}
}
};
var c = new RegExp("(normal|italic)?\\s*(normal|small-caps)?\\s*(normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900)?\\s*(" + C.reNum + "(?:px|cm|mm|em|pt|pc|in)*)(?:\\/(normal|" + C.reNum + "))?\\s+(.*)");
p(C, {
parseFontDeclaration: function (t, e) {
var i = t.match(c);
if (i) {
var r = i[1],
n = i[3],
s = i[4],
o = i[5],
a = i[6];
r && (e.fontStyle = r),
n && (e.fontWeight = isNaN(parseFloat(n)) ? n : parseFloat(n)),
s && (e.fontSize = S(s)),
a && (e.fontFamily = a),
o && (e.lineHeight = "normal" === o ? 1 : o)
}
},
getGradientDefs: function (t) {
var e,
i = T(t, ["linearGradient", "radialGradient", "svg:linearGradient", "svg:radialGradient"]),
r = 0,
n = {};
for (r = i.length; r--; )
(e = i[r]).getAttribute("xlink:href") && s(t, e), n[e.getAttribute("id")] = e;
return n
},
parseAttributes: function (i, t, e) {
if (i) {
var r,
n,
s,
o = {};
void 0 === e && (e = i.getAttribute("svgUid")),
i.parentNode && C.svgValidParentsRegEx.test(i.parentNode.nodeName) && (o = C.parseAttributes(i.parentNode, t, e));
var a = t.reduce(function (t, e) {
return (r = i.getAttribute(e)) && (t[e] = r),
t
}, {}),
h = p(function (t, e) {
var i = {};
for (var r in C.cssRules[e])
if (w(t, r.split(" ")))
for (var n in C.cssRules[e][r])
i[n] = C.cssRules[e][r][n];
return i
}
(i, e), C.parseStyleAttribute(i));
a = p(a, h),
h[y] && i.setAttribute(y, h[y]),
n = s = o.fontSize || C.Text.DEFAULT_SVG_FONT_SIZE,
a[_] && (a[_] = n = S(a[_], s));
var c,
l,
u,
f = {};
for (var d in a)
l = x(c = (u = d)in m ? m[u] : u, a[d], o, n), f[c] = l;
f && f.font && C.parseFontDeclaration(f.font, f);
var g = p(o, f);
return C.svgValidParentsRegEx.test(i.nodeName) ? g : function (t) {
for (var e in b)
if (void 0 !== t[b[e]] && "" !== t[e]) {
if (void 0 === t[e]) {
if (!C.Object.prototype[e])
continue;
t[e] = C.Object.prototype[e]
}
if (0 !== t[e].indexOf("url(")) {
var i = new C.Color(t[e]);
t[e] = i.setAlpha(v(i.getAlpha() * t[b[e]], 2)).toRgba()
}
}
return t
}
(g)
}
},
parseElements: function (t, e, i, r, n) {
new C.ElementsParser(t, e, i, r, n).parse()
},
parseStyleAttribute: function (t) {
var i,
r,
n,
e = {},
s = t.getAttribute("style");
return s && ("string" == typeof s ? (i = e, s.replace(/;\s*$/, "").split(";").forEach(function (t) {
var e = t.split(":");
r = e[0].trim().toLowerCase(),
n = e[1].trim(),
i[r] = n
})) : function (t, e) {
var i,
r;
for (var n in t)
void 0 !== t[n] && (i = n.toLowerCase(), r = t[n], e[i] = r)
}
(s, e)),
e
},
parsePointsAttribute: function (t) {
if (!t)
return null;
var e,
i,
r = [];
for (e = 0, i = (t = (t = t.replace(/,/g, " ").trim()).split(/\s+/)).length; e < i; e += 2)
r.push({
x: parseFloat(t[e]),
y: parseFloat(t[e + 1])
});
return r
},
getCSSRules: function (t) {
var a,
h,
e = t.getElementsByTagName("style"),
c = {};
for (a = 0, h = e.length; a < h; a++) {
var i = e[a].textContent || "";
"" !== (i = i.replace(/\/\*[\s\S]*?\*\//g, "")).trim() && i.match(/[^{]*\{[\s\S]*?\}/g).map(function (t) {
return t.trim()
}).forEach(function (t) {
var e = t.match(/([\s\S]*?)\s*\{([^}]*)\}/),
i = {},
r = e[2].trim().replace(/;$/, "").split(/\s*;\s*/);
for (a = 0, h = r.length; a < h; a++) {
var n = r[a].split(/\s*:\s*/),
s = n[0],
o = n[1];
i[s] = o
}
(t = e[1]).split(",").forEach(function (t) {
"" !== (t = t.replace(/^svg/i, "").trim()) && (c[t] ? C.util.object.extend(c[t], i) : c[t] = C.util.object.clone(i))
})
})
}
return c
},
loadSVGFromURL: function (t, n, i, r) {
t = t.replace(/^\n\s*/, "").trim(),
new C.util.request(t, {
method: "get",
onComplete: function (t) {
var e = t.responseXML;
e && !e.documentElement && C.window.ActiveXObject && t.responseText && ((e = new ActiveXObject("Microsoft.XMLDOM")).async = "false", e.loadXML(t.responseText.replace(//i, "")));
if (!e || !e.documentElement)
return n && n(null), !1;
C.parseSVGDocument(e.documentElement, function (t, e, i, r) {
n && n(t, e, i, r)
}, i, r)
}
})
},
loadSVGFromString: function (t, n, e, i) {
var r;
if (t = t.trim(), void 0 !== C.window.DOMParser) {
var s = new C.window.DOMParser;
s && s.parseFromString && (r = s.parseFromString(t, "text/xml"))
} else
C.window.ActiveXObject && ((r = new ActiveXObject("Microsoft.XMLDOM")).async = "false", r.loadXML(t.replace(//i, "")));
C.parseSVGDocument(r.documentElement, function (t, e, i, r) {
n(t, e, i, r)
}, e, i)
}
})
}
("undefined" != typeof exports ? exports : this), fabric.ElementsParser = function (t, e, i, r, n, s) {
this.elements = t,
this.callback = e,
this.options = i,
this.reviver = r,
this.svgUid = i && i.svgUid || 0,
this.parsingOptions = n,
this.regexUrl = /^url\(['"]?#([^'"]+)['"]?\)/g,
this.doc = s
}, function (t) {
t.parse = function () {
this.instances = new Array(this.elements.length),
this.numElements = this.elements.length,
this.createObjects()
},
t.createObjects = function () {
var i = this;
this.elements.forEach(function (t, e) {
t.setAttribute("svgUid", i.svgUid),
i.createObject(t, e)
})
},
t.findTag = function (t) {
return fabric[fabric.util.string.capitalize(t.tagName.replace("svg:", ""))]
},
t.createObject = function (t, e) {
var i = this.findTag(t);
if (i && i.fromElement)
try {
i.fromElement(t, this.createCallback(e, t), this.options)
} catch (t) {
fabric.log(t)
}
else
this.checkIfDone()
},
t.createCallback = function (i, r) {
var n = this;
return function (t) {
var e;
n.resolveGradient(t, r, "fill"),
n.resolveGradient(t, r, "stroke"),
t instanceof fabric.Image && t._originalElement && (e = t.parsePreserveAspectRatioAttribute(r)),
t._removeTransformMatrix(e),
n.resolveClipPath(t, r),
n.reviver && n.reviver(r, t),
n.instances[i] = t,
n.checkIfDone()
}
},
t.extractPropertyDefinition = function (t, e, i) {
var r = t[e],
n = this.regexUrl;
if (n.test(r)) {
n.lastIndex = 0;
var s = n.exec(r)[1];
return n.lastIndex = 0,
fabric[i][this.svgUid][s]
}
},
t.resolveGradient = function (t, e, i) {
var r = this.extractPropertyDefinition(t, i, "gradientDefs");
if (r) {
var n = e.getAttribute(i + "-opacity"),
s = fabric.Gradient.fromElement(r, t, n, this.options);
t.set(i, s)
}
},
t.createClipPathCallback = function (t, e) {
return function (t) {
t._removeTransformMatrix(),
t.fillRule = t.clipRule,
e.push(t)
}
},
t.resolveClipPath = function (t, e) {
var i,
r,
n,
s,
o = this.extractPropertyDefinition(t, "clipPath", "clipPaths");
if (o) {
n = [],
r = fabric.util.invertTransform(t.calcTransformMatrix());
for (var a = o[0].parentNode, h = e; h.parentNode && h.getAttribute("clip-path") !== t.clipPath; )
h = h.parentNode;
h.parentNode.appendChild(a);
for (var c = 0; c < o.length; c++)
i = o[c], this.findTag(i).fromElement(i, this.createClipPathCallback(t, n), this.options);
o = 1 === n.length ? n[0] : new fabric.Group(n),
s = fabric.util.multiplyTransformMatrices(r, o.calcTransformMatrix()),
o.clipPath && this.resolveClipPath(o, h);
var l = fabric.util.qrDecompose(s);
o.flipX = !1,
o.flipY = !1,
o.set("scaleX", l.scaleX),
o.set("scaleY", l.scaleY),
o.angle = l.angle,
o.skewX = l.skewX,
o.skewY = 0,
o.setPositionByOrigin({
x: l.translateX,
y: l.translateY
}, "center", "center"),
t.clipPath = o
} else
delete t.clipPath
},
t.checkIfDone = function () {
0 == --this.numElements && (this.instances = this.instances.filter(function (t) {
return null != t
}), this.callback(this.instances, this.elements))
}
}
(fabric.ElementsParser.prototype), function (t) {
"use strict";
var e = t.fabric || (t.fabric = {});
function i(t, e) {
this.x = t,
this.y = e
}
e.Point ? e.warn("fabric.Point is already defined") : (e.Point = i).prototype = {
type: "point",
constructor: i,
add: function (t) {
return new i(this.x + t.x, this.y + t.y)
},
addEquals: function (t) {
return this.x += t.x,
this.y += t.y,
this
},
scalarAdd: function (t) {
return new i(this.x + t, this.y + t)
},
scalarAddEquals: function (t) {
return this.x += t,
this.y += t,
this
},
subtract: function (t) {
return new i(this.x - t.x, this.y - t.y)
},
subtractEquals: function (t) {
return this.x -= t.x,
this.y -= t.y,
this
},
scalarSubtract: function (t) {
return new i(this.x - t, this.y - t)
},
scalarSubtractEquals: function (t) {
return this.x -= t,
this.y -= t,
this
},
multiply: function (t) {
return new i(this.x * t, this.y * t)
},
multiplyEquals: function (t) {
return this.x *= t,
this.y *= t,
this
},
divide: function (t) {
return new i(this.x / t, this.y / t)
},
divideEquals: function (t) {
return this.x /= t,
this.y /= t,
this
},
eq: function (t) {
return this.x === t.x && this.y === t.y
},
lt: function (t) {
return this.x < t.x && this.y < t.y
},
lte: function (t) {
return this.x <= t.x && this.y <= t.y
},
gt: function (t) {
return this.x > t.x && this.y > t.y
},
gte: function (t) {
return this.x >= t.x && this.y >= t.y
},
lerp: function (t, e) {
return void 0 === e && (e = .5),
e = Math.max(Math.min(1, e), 0),
new i(this.x + (t.x - this.x) * e, this.y + (t.y - this.y) * e)
},
distanceFrom: function (t) {
var e = this.x - t.x,
i = this.y - t.y;
return Math.sqrt(e * e + i * i)
},
midPointFrom: function (t) {
return this.lerp(t)
},
min: function (t) {
return new i(Math.min(this.x, t.x), Math.min(this.y, t.y))
},
max: function (t) {
return new i(Math.max(this.x, t.x), Math.max(this.y, t.y))
},
toString: function () {
return this.x + "," + this.y
},
setXY: function (t, e) {
return this.x = t,
this.y = e,
this
},
setX: function (t) {
return this.x = t,
this
},
setY: function (t) {
return this.y = t,
this
},
setFromPoint: function (t) {
return this.x = t.x,
this.y = t.y,
this
},
swap: function (t) {
var e = this.x,
i = this.y;
this.x = t.x,
this.y = t.y,
t.x = e,
t.y = i
},
clone: function () {
return new i(this.x, this.y)
}
}
}
("undefined" != typeof exports ? exports : this), function (t) {
"use strict";
var f = t.fabric || (t.fabric = {});
function d(t) {
this.status = t,
this.points = []
}
f.Intersection ? f.warn("fabric.Intersection is already defined") : (f.Intersection = d, f.Intersection.prototype = {
constructor: d,
appendPoint: function (t) {
return this.points.push(t),
this
},
appendPoints: function (t) {
return this.points = this.points.concat(t),
this
}
}, f.Intersection.intersectLineLine = function (t, e, i, r) {
var n,
s = (r.x - i.x) * (t.y - i.y) - (r.y - i.y) * (t.x - i.x),
o = (e.x - t.x) * (t.y - i.y) - (e.y - t.y) * (t.x - i.x),
a = (r.y - i.y) * (e.x - t.x) - (r.x - i.x) * (e.y - t.y);
if (0 !== a) {
var h = s / a,
c = o / a;
0 <= h && h <= 1 && 0 <= c && c <= 1 ? (n = new d("Intersection")).appendPoint(new f.Point(t.x + h * (e.x - t.x), t.y + h * (e.y - t.y))) : n = new d
} else
n = new d(0 === s || 0 === o ? "Coincident" : "Parallel");
return n
}, f.Intersection.intersectLinePolygon = function (t, e, i) {
var r,
n,
s,
o,
a = new d,
h = i.length;
for (o = 0; o < h; o++)
r = i[o], n = i[(o + 1) % h], s = d.intersectLineLine(t, e, r, n), a.appendPoints(s.points);
return 0 < a.points.length && (a.status = "Intersection"),
a
}, f.Intersection.intersectPolygonPolygon = function (t, e) {
var i,
r = new d,
n = t.length;
for (i = 0; i < n; i++) {
var s = t[i],
o = t[(i + 1) % n],
a = d.intersectLinePolygon(s, o, e);
r.appendPoints(a.points)
}
return 0 < r.points.length && (r.status = "Intersection"),
r
}, f.Intersection.intersectPolygonRectangle = function (t, e, i) {
var r = e.min(i),
n = e.max(i),
s = new f.Point(n.x, r.y),
o = new f.Point(r.x, n.y),
a = d.intersectLinePolygon(r, s, t),
h = d.intersectLinePolygon(s, n, t),
c = d.intersectLinePolygon(n, o, t),
l = d.intersectLinePolygon(o, r, t),
u = new d;
return u.appendPoints(a.points),
u.appendPoints(h.points),
u.appendPoints(c.points),
u.appendPoints(l.points),
0 < u.points.length && (u.status = "Intersection"),
u
})
}
("undefined" != typeof exports ? exports : this), function (t) {
"use strict";
var c = t.fabric || (t.fabric = {});
function l(t) {
t ? this._tryParsingColor(t) : this.setSource([0, 0, 0, 1])
}
function u(t, e, i) {
return i < 0 && (i += 1),
1 < i && (i -= 1),
i < 1 / 6 ? t + 6 * (e - t) * i : i < .5 ? e : i < 2 / 3 ? t + (e - t) * (2 / 3 - i) * 6 : t
}
c.Color ? c.warn("fabric.Color is already defined.") : (c.Color = l, c.Color.prototype = {
_tryParsingColor: function (t) {
var e;
t in l.colorNameMap && (t = l.colorNameMap[t]),
"transparent" === t && (e = [255, 255, 255, 0]),
e || (e = l.sourceFromHex(t)),
e || (e = l.sourceFromRgb(t)),
e || (e = l.sourceFromHsl(t)),
e || (e = [0, 0, 0, 1]),
e && this.setSource(e)
},
_rgbToHsl: function (t, e, i) {
t /= 255,
e /= 255,
i /= 255;
var r,
n,
s,
o = c.util.array.max([t, e, i]),
a = c.util.array.min([t, e, i]);
if (s = (o + a) / 2, o === a)
r = n = 0;
else {
var h = o - a;
switch (n = .5 < s ? h / (2 - o - a) : h / (o + a), o) {
case t:
r = (e - i) / h + (e < i ? 6 : 0);
break;
case e:
r = (i - t) / h + 2;
break;
case i:
r = (t - e) / h + 4
}
r /= 6
}
return [Math.round(360 * r), Math.round(100 * n), Math.round(100 * s)]
},
getSource: function () {
return this._source
},
setSource: function (t) {
this._source = t
},
toRgb: function () {
var t = this.getSource();
return "rgb(" + t[0] + "," + t[1] + "," + t[2] + ")"
},
toRgba: function () {
var t = this.getSource();
return "rgba(" + t[0] + "," + t[1] + "," + t[2] + "," + t[3] + ")"
},
toHsl: function () {
var t = this.getSource(),
e = this._rgbToHsl(t[0], t[1], t[2]);
return "hsl(" + e[0] + "," + e[1] + "%," + e[2] + "%)"
},
toHsla: function () {
var t = this.getSource(),
e = this._rgbToHsl(t[0], t[1], t[2]);
return "hsla(" + e[0] + "," + e[1] + "%," + e[2] + "%," + t[3] + ")"
},
toHex: function () {
var t,
e,
i,
r = this.getSource();
return t = 1 === (t = r[0].toString(16)).length ? "0" + t : t,
e = 1 === (e = r[1].toString(16)).length ? "0" + e : e,
i = 1 === (i = r[2].toString(16)).length ? "0" + i : i,
t.toUpperCase() + e.toUpperCase() + i.toUpperCase()
},
toHexa: function () {
var t,
e = this.getSource();
return t = 1 === (t = (t = Math.round(255 * e[3])).toString(16)).length ? "0" + t : t,
this.toHex() + t.toUpperCase()
},
getAlpha: function () {
return this.getSource()[3]
},
setAlpha: function (t) {
var e = this.getSource();
return e[3] = t,
this.setSource(e),
this
},
toGrayscale: function () {
var t = this.getSource(),
e = parseInt((.3 * t[0] + .59 * t[1] + .11 * t[2]).toFixed(0), 10),
i = t[3];
return this.setSource([e, e, e, i]),
this
},
toBlackWhite: function (t) {
var e = this.getSource(),
i = (.3 * e[0] + .59 * e[1] + .11 * e[2]).toFixed(0),
r = e[3];
return t = t || 127,
i = Number(i) < Number(t) ? 0 : 255,
this.setSource([i, i, i, r]),
this
},
overlayWith: function (t) {
t instanceof l || (t = new l(t));
var e,
i = [],
r = this.getAlpha(),
n = this.getSource(),
s = t.getSource();
for (e = 0; e < 3; e++)
i.push(Math.round(.5 * n[e] + .5 * s[e]));
return i[3] = r,
this.setSource(i),
this
}
}, c.Color.reRGBa = /^rgba?\(\s*(\d{1,3}(?:\.\d+)?\%?)\s*,\s*(\d{1,3}(?:\.\d+)?\%?)\s*,\s*(\d{1,3}(?:\.\d+)?\%?)\s*(?:\s*,\s*((?:\d*\.?\d+)?)\s*)?\)$/i, c.Color.reHSLa = /^hsla?\(\s*(\d{1,3})\s*,\s*(\d{1,3}\%)\s*,\s*(\d{1,3}\%)\s*(?:\s*,\s*(\d+(?:\.\d+)?)\s*)?\)$/i, c.Color.reHex = /^#?([0-9a-f]{8}|[0-9a-f]{6}|[0-9a-f]{4}|[0-9a-f]{3})$/i, c.Color.colorNameMap = {
aliceblue: "#F0F8FF",
antiquewhite: "#FAEBD7",
aqua: "#00FFFF",
aquamarine: "#7FFFD4",
azure: "#F0FFFF",
beige: "#F5F5DC",
bisque: "#FFE4C4",
black: "#000000",
blanchedalmond: "#FFEBCD",
blue: "#0000FF",
blueviolet: "#8A2BE2",
brown: "#A52A2A",
burlywood: "#DEB887",
cadetblue: "#5F9EA0",
chartreuse: "#7FFF00",
chocolate: "#D2691E",
coral: "#FF7F50",
cornflowerblue: "#6495ED",
cornsilk: "#FFF8DC",
crimson: "#DC143C",
cyan: "#00FFFF",
darkblue: "#00008B",
darkcyan: "#008B8B",
darkgoldenrod: "#B8860B",
darkgray: "#A9A9A9",
darkgrey: "#A9A9A9",
darkgreen: "#006400",
darkkhaki: "#BDB76B",
darkmagenta: "#8B008B",
darkolivegreen: "#556B2F",
darkorange: "#FF8C00",
darkorchid: "#9932CC",
darkred: "#8B0000",
darksalmon: "#E9967A",
darkseagreen: "#8FBC8F",
darkslateblue: "#483D8B",
darkslategray: "#2F4F4F",
darkslategrey: "#2F4F4F",
darkturquoise: "#00CED1",
darkviolet: "#9400D3",
deeppink: "#FF1493",
deepskyblue: "#00BFFF",
dimgray: "#696969",
dimgrey: "#696969",
dodgerblue: "#1E90FF",
firebrick: "#B22222",
floralwhite: "#FFFAF0",
forestgreen: "#228B22",
fuchsia: "#FF00FF",
gainsboro: "#DCDCDC",
ghostwhite: "#F8F8FF",
gold: "#FFD700",
goldenrod: "#DAA520",
gray: "#808080",
grey: "#808080",
green: "#008000",
greenyellow: "#ADFF2F",
honeydew: "#F0FFF0",
hotpink: "#FF69B4",
indianred: "#CD5C5C",
indigo: "#4B0082",
ivory: "#FFFFF0",
khaki: "#F0E68C",
lavender: "#E6E6FA",
lavenderblush: "#FFF0F5",
lawngreen: "#7CFC00",
lemonchiffon: "#FFFACD",
lightblue: "#ADD8E6",
lightcoral: "#F08080",
lightcyan: "#E0FFFF",
lightgoldenrodyellow: "#FAFAD2",
lightgray: "#D3D3D3",
lightgrey: "#D3D3D3",
lightgreen: "#90EE90",
lightpink: "#FFB6C1",
lightsalmon: "#FFA07A",
lightseagreen: "#20B2AA",
lightskyblue: "#87CEFA",
lightslategray: "#778899",
lightslategrey: "#778899",
lightsteelblue: "#B0C4DE",
lightyellow: "#FFFFE0",
lime: "#00FF00",
limegreen: "#32CD32",
linen: "#FAF0E6",
magenta: "#FF00FF",
maroon: "#800000",
mediumaquamarine: "#66CDAA",
mediumblue: "#0000CD",
mediumorchid: "#BA55D3",
mediumpurple: "#9370DB",
mediumseagreen: "#3CB371",
mediumslateblue: "#7B68EE",
mediumspringgreen: "#00FA9A",
mediumturquoise: "#48D1CC",
mediumvioletred: "#C71585",
midnightblue: "#191970",
mintcream: "#F5FFFA",
mistyrose: "#FFE4E1",
moccasin: "#FFE4B5",
navajowhite: "#FFDEAD",
navy: "#000080",
oldlace: "#FDF5E6",
olive: "#808000",
olivedrab: "#6B8E23",
orange: "#FFA500",
orangered: "#FF4500",
orchid: "#DA70D6",
palegoldenrod: "#EEE8AA",
palegreen: "#98FB98",
paleturquoise: "#AFEEEE",
palevioletred: "#DB7093",
papayawhip: "#FFEFD5",
peachpuff: "#FFDAB9",
peru: "#CD853F",
pink: "#FFC0CB",
plum: "#DDA0DD",
powderblue: "#B0E0E6",
purple: "#800080",
rebeccapurple: "#663399",
red: "#FF0000",
rosybrown: "#BC8F8F",
royalblue: "#4169E1",
saddlebrown: "#8B4513",
salmon: "#FA8072",
sandybrown: "#F4A460",
seagreen: "#2E8B57",
seashell: "#FFF5EE",
sienna: "#A0522D",
silver: "#C0C0C0",
skyblue: "#87CEEB",
slateblue: "#6A5ACD",
slategray: "#708090",
slategrey: "#708090",
snow: "#FFFAFA",
springgreen: "#00FF7F",
steelblue: "#4682B4",
tan: "#D2B48C",
teal: "#008080",
thistle: "#D8BFD8",
tomato: "#FF6347",
turquoise: "#40E0D0",
violet: "#EE82EE",
wheat: "#F5DEB3",
white: "#FFFFFF",
whitesmoke: "#F5F5F5",
yellow: "#FFFF00",
yellowgreen: "#9ACD32"
}, c.Color.fromRgb = function (t) {
return l.fromSource(l.sourceFromRgb(t))
}, c.Color.sourceFromRgb = function (t) {
var e = t.match(l.reRGBa);
if (e) {
var i = parseInt(e[1], 10) / (/%$/.test(e[1]) ? 100 : 1) * (/%$/.test(e[1]) ? 255 : 1),
r = parseInt(e[2], 10) / (/%$/.test(e[2]) ? 100 : 1) * (/%$/.test(e[2]) ? 255 : 1),
n = parseInt(e[3], 10) / (/%$/.test(e[3]) ? 100 : 1) * (/%$/.test(e[3]) ? 255 : 1);
return [parseInt(i, 10), parseInt(r, 10), parseInt(n, 10), e[4] ? parseFloat(e[4]) : 1]
}
}, c.Color.fromRgba = l.fromRgb, c.Color.fromHsl = function (t) {
return l.fromSource(l.sourceFromHsl(t))
}, c.Color.sourceFromHsl = function (t) {
var e = t.match(l.reHSLa);
if (e) {
var i,
r,
n,
s = (parseFloat(e[1]) % 360 + 360) % 360 / 360,
o = parseFloat(e[2]) / (/%$/.test(e[2]) ? 100 : 1),
a = parseFloat(e[3]) / (/%$/.test(e[3]) ? 100 : 1);
if (0 === o)
i = r = n = a;
else {
var h = a <= .5 ? a * (o + 1) : a + o - a * o,
c = 2 * a - h;
i = u(c, h, s + 1 / 3),
r = u(c, h, s),
n = u(c, h, s - 1 / 3)
}
return [Math.round(255 * i), Math.round(255 * r), Math.round(255 * n), e[4] ? parseFloat(e[4]) : 1]
}
}, c.Color.fromHsla = l.fromHsl, c.Color.fromHex = function (t) {
return l.fromSource(l.sourceFromHex(t))
}, c.Color.sourceFromHex = function (t) {
if (t.match(l.reHex)) {
var e = t.slice(t.indexOf("#") + 1),
i = 3 === e.length || 4 === e.length,
r = 8 === e.length || 4 === e.length,
n = i ? e.charAt(0) + e.charAt(0) : e.substring(0, 2),
s = i ? e.charAt(1) + e.charAt(1) : e.substring(2, 4),
o = i ? e.charAt(2) + e.charAt(2) : e.substring(4, 6),
a = r ? i ? e.charAt(3) + e.charAt(3) : e.substring(6, 8) : "FF";
return [parseInt(n, 16), parseInt(s, 16), parseInt(o, 16), parseFloat((parseInt(a, 16) / 255).toFixed(2))]
}
}, c.Color.fromSource = function (t) {
var e = new l;
return e.setSource(t),
e
})
}
("undefined" != typeof exports ? exports : this), function () {
function m(t, e) {
var i,
r,
n,
s,
o = t.getAttribute("style"),
a = t.getAttribute("offset") || 0;
if (a = (a = parseFloat(a) / (/%$/.test(a) ? 100 : 1)) < 0 ? 0 : 1 < a ? 1 : a, o) {
var h = o.split(/\s*;\s*/);
for ("" === h[h.length - 1] && h.pop(), s = h.length; s--; ) {
var c = h[s].split(/\s*:\s*/),
l = c[0].trim(),
u = c[1].trim();
"stop-color" === l ? i = u : "stop-opacity" === l && (n = u)
}
}
return i || (i = t.getAttribute("stop-color") || "rgb(0,0,0)"),
n || (n = t.getAttribute("stop-opacity")),
r = (i = new fabric.Color(i)).getAlpha(),
n = isNaN(parseFloat(n)) ? 1 : parseFloat(n),
n *= r * e, {
offset: a,
color: i.toRgb(),
opacity: n
}
}
var b = fabric.util.object.clone;
function _(t, e, i, r) {
var n,
s;
Object.keys(e).forEach(function (t) {
"Infinity" === (n = e[t]) ? s = 1 : "-Infinity" === n ? s = 0 : (s = parseFloat(e[t], 10), "string" == typeof n && /^(\d+\.\d+)%|(\d+)%$/.test(n) && (s *= .01, "pixels" === r && ("x1" !== t && "x2" !== t && "r2" !== t || (s *= i.viewBoxWidth || i.width), "y1" !== t && "y2" !== t || (s *= i.viewBoxHeight || i.height)))),
e[t] = s
})
}
fabric.Gradient = fabric.util.createClass({
offsetX: 0,
offsetY: 0,
gradientTransform: null,
gradientUnits: "pixels",
type: "linear",
initialize: function (e) {
e || (e = {}),
e.coords || (e.coords = {});
var t,
i = this;
Object.keys(e).forEach(function (t) {
i[t] = e[t]
}),
this.id ? this.id += "_" + fabric.Object.__uid++ : this.id = fabric.Object.__uid++,
t = {
x1: e.coords.x1 || 0,
y1: e.coords.y1 || 0,
x2: e.coords.x2 || 0,
y2: e.coords.y2 || 0
},
"radial" === this.type && (t.r1 = e.coords.r1 || 0, t.r2 = e.coords.r2 || 0),
this.coords = t,
this.colorStops = e.colorStops.slice()
},
addColorStop: function (t) {
for (var e in t) {
var i = new fabric.Color(t[e]);
this.colorStops.push({
offset: parseFloat(e),
color: i.toRgb(),
opacity: i.getAlpha()
})
}
return this
},
toObject: function (t) {
var e = {
type: this.type,
coords: this.coords,
colorStops: this.colorStops,
offsetX: this.offsetX,
offsetY: this.offsetY,
gradientUnits: this.gradientUnits,
gradientTransform: this.gradientTransform ? this.gradientTransform.concat() : this.gradientTransform
};
return fabric.util.populateWithProperties(this, e, t),
e
},
toSVG: function (t, e) {
var i,
r,
n,
s,
o = b(this.coords, !0),
a = (e = e || {}, b(this.colorStops, !0)),
h = o.r1 > o.r2,
c = this.gradientTransform ? this.gradientTransform.concat() : fabric.iMatrix.concat(),
l = -this.offsetX,
u = -this.offsetY,
f = !!e.additionalTransform,
d = "pixels" === this.gradientUnits ? "userSpaceOnUse" : "objectBoundingBox";
if (a.sort(function (t, e) {
return t.offset - e.offset
}), "objectBoundingBox" === d ? (l /= t.width, u /= t.height) : (l += t.width / 2, u += t.height / 2), "path" === t.type && (l -= t.pathOffset.x, u -= t.pathOffset.y), c[4] -= l, c[5] -= u, s = 'id="SVGID_' + this.id + '" gradientUnits="' + d + '"', s += ' gradientTransform="' + (f ? e.additionalTransform + " " : "") + fabric.util.matrixToSVG(c) + '" ', "linear" === this.type ? n = ["\n'] : "radial" === this.type && (n = ["\n']), "radial" === this.type) {
if (h)
for ((a = a.concat()).reverse(), i = 0, r = a.length; i < r; i++)
a[i].offset = 1 - a[i].offset;
var g = Math.min(o.r1, o.r2);
if (0 < g) {
var p = g / Math.max(o.r1, o.r2);
for (i = 0, r = a.length; i < r; i++)
a[i].offset += p * (1 - a[i].offset)
}
}
for (i = 0, r = a.length; i < r; i++) {
var v = a[i];
n.push("\n')
}
return n.push("linear" === this.type ? "\n" : "\n"),
n.join("")
},
toLive: function (t, e) {
var i,
r,
n,
s = fabric.util.object.clone(this.coords),
o = s.x1,
a = s.y1,
h = s.x2,
c = s.y2,
l = this.colorStops;
if (this.type) {
for (e instanceof fabric.Text && "percentage" === this.gradientUnits && (o *= e.width, a *= e.height, h *= e.width, c *= e.height), "linear" === this.type ? i = t.createLinearGradient(o, a, h, c) : "radial" === this.type && (i = t.createRadialGradient(o, a, s.r1, h, c, s.r2)), r = 0, n = l.length; r < n; r++) {
var u = l[r].color,
f = l[r].opacity,
d = l[r].offset;
void 0 !== f && (u = new fabric.Color(u).setAlpha(f).toRgba()),
i.addColorStop(d, u)
}
return i
}
}
}),
fabric.util.object.extend(fabric.Gradient, {
fromElement: function (t, e, i, r) {
var n = parseFloat(i) / (/%$/.test(i) ? 100 : 1);
n = n < 0 ? 0 : 1 < n ? 1 : n,
isNaN(n) && (n = 1);
var s,
o,
a,
h,
c,
l,
u = t.getElementsByTagName("stop"),
f = "userSpaceOnUse" === t.getAttribute("gradientUnits") ? "pixels" : "percentage",
d = t.getAttribute("gradientTransform") || "",
g = [],
p = 0,
v = 0;
for ("linearGradient" === t.nodeName || "LINEARGRADIENT" === t.nodeName ? (s = "linear", o = {
x1: (l = t).getAttribute("x1") || 0,
y1: l.getAttribute("y1") || 0,
x2: l.getAttribute("x2") || "100%",
y2: l.getAttribute("y2") || 0
}) : (s = "radial", o = {
x1: (c = t).getAttribute("fx") || c.getAttribute("cx") || "50%",
y1: c.getAttribute("fy") || c.getAttribute("cy") || "50%",
r1: 0,
x2: c.getAttribute("cx") || "50%",
y2: c.getAttribute("cy") || "50%",
r2: c.getAttribute("r") || "50%"
}), a = u.length; a--; )
g.push(m(u[a], n));
return h = fabric.parseTransformAttribute(d),
_(e, o, r, f),
"pixels" === f && (p = -e.left, v = -e.top),
new fabric.Gradient({
id: t.getAttribute("id"),
type: s,
coords: o,
colorStops: g,
gradientUnits: f,
gradientTransform: h,
offsetX: p,
offsetY: v
})
},
forObject: function (t, e) {
return e || (e = {}),
_(t, e.coords, e.gradientUnits, {
viewBoxWidth: 100,
viewBoxHeight: 100
}),
new fabric.Gradient(e)
}
})
}
(), function () {
"use strict";
var n = fabric.util.toFixed;
fabric.Pattern = fabric.util.createClass({
repeat: "repeat",
offsetX: 0,
offsetY: 0,
crossOrigin: "",
patternTransform: null,
initialize: function (t, e) {
if (t || (t = {}), this.id = fabric.Object.__uid++, this.setOptions(t), !t.source || t.source && "string" != typeof t.source)
e && e(this);
else if (void 0 !== fabric.util.getFunctionBody(t.source))
this.source = new Function(fabric.util.getFunctionBody(t.source)), e && e(this);
else {
var i = this;
this.source = fabric.util.createImage(),
fabric.util.loadImage(t.source, function (t) {
i.source = t,
e && e(i)
}, null, this.crossOrigin)
}
},
toObject: function (t) {
var e,
i,
r = fabric.Object.NUM_FRACTION_DIGITS;
return "function" == typeof this.source ? e = String(this.source) : "string" == typeof this.source.src ? e = this.source.src : "object" == typeof this.source && this.source.toDataURL && (e = this.source.toDataURL()),
i = {
type: "pattern",
source: e,
repeat: this.repeat,
crossOrigin: this.crossOrigin,
offsetX: n(this.offsetX, r),
offsetY: n(this.offsetY, r),
patternTransform: this.patternTransform ? this.patternTransform.concat() : null
},
fabric.util.populateWithProperties(this, i, t),
i
},
toSVG: function (t) {
var e = "function" == typeof this.source ? this.source() : this.source,
i = e.width / t.width,
r = e.height / t.height,
n = this.offsetX / t.width,
s = this.offsetY / t.height,
o = "";
return "repeat-x" !== this.repeat && "no-repeat" !== this.repeat || (r = 1, s && (r += Math.abs(s))),
"repeat-y" !== this.repeat && "no-repeat" !== this.repeat || (i = 1, n && (i += Math.abs(n))),
e.src ? o = e.src : e.toDataURL && (o = e.toDataURL()),
'\n\n\n'
},
setOptions: function (t) {
for (var e in t)
this[e] = t[e]
},
toLive: function (t) {
var e = "function" == typeof this.source ? this.source() : this.source;
if (!e)
return "";
if (void 0 !== e.src) {
if (!e.complete)
return "";
if (0 === e.naturalWidth || 0 === e.naturalHeight)
return ""
}
return t.createPattern(e, this.repeat)
}
})
}
(), function (t) {
"use strict";
var o = t.fabric || (t.fabric = {}),
a = o.util.toFixed;
o.Shadow ? o.warn("fabric.Shadow is already defined.") : (o.Shadow = o.util.createClass({
color: "rgb(0,0,0)",
blur: 0,
offsetX: 0,
offsetY: 0,
affectStroke: !1,
includeDefaultValues: !0,
nonScaling: !1,
initialize: function (t) {
for (var e in "string" == typeof t && (t = this._parseShadow(t)), t)
this[e] = t[e];
this.id = o.Object.__uid++
},
_parseShadow: function (t) {
var e = t.trim(),
i = o.Shadow.reOffsetsAndBlur.exec(e) || [];
return {
color: (e.replace(o.Shadow.reOffsetsAndBlur, "") || "rgb(0,0,0)").trim(),
offsetX: parseInt(i[1], 10) || 0,
offsetY: parseInt(i[2], 10) || 0,
blur: parseInt(i[3], 10) || 0
}
},
toString: function () {
return [this.offsetX, this.offsetY, this.blur, this.color].join("px ")
},
toSVG: function (t) {
var e = 40,
i = 40,
r = o.Object.NUM_FRACTION_DIGITS,
n = o.util.rotateVector({
x: this.offsetX,
y: this.offsetY
}, o.util.degreesToRadians(-t.angle)),
s = new o.Color(this.color);
return t.width && t.height && (e = 100 * a((Math.abs(n.x) + this.blur) / t.width, r) + 20, i = 100 * a((Math.abs(n.y) + this.blur) / t.height, r) + 20),
t.flipX && (n.x *= -1),
t.flipY && (n.y *= -1),
'\n\t\n\t\n\t\n\t\n\t\n\t\t\n\t\t\n\t\n\n'
},
toObject: function () {
if (this.includeDefaultValues)
return {
color: this.color,
blur: this.blur,
offsetX: this.offsetX,
offsetY: this.offsetY,
affectStroke: this.affectStroke,
nonScaling: this.nonScaling
};
var e = {},
i = o.Shadow.prototype;
return ["color", "blur", "offsetX", "offsetY", "affectStroke", "nonScaling"].forEach(function (t) {
this[t] !== i[t] && (e[t] = this[t])
}, this),
e
}
}), o.Shadow.reOffsetsAndBlur = /(?:\s|^)(-?\d+(?:px)?(?:\s?|$))?(-?\d+(?:px)?(?:\s?|$))?(\d+(?:px)?)?(?:\s?|$)(?:$|\s)/)
}
("undefined" != typeof exports ? exports : this), function () {
"use strict";
if (fabric.StaticCanvas)
fabric.warn("fabric.StaticCanvas is already defined.");
else {
var n = fabric.util.object.extend,
t = fabric.util.getElementOffset,
c = fabric.util.removeFromArray,
a = fabric.util.toFixed,
s = fabric.util.transformPoint,
o = fabric.util.invertTransform,
i = fabric.util.getNodeCanvas,
r = fabric.util.createCanvasElement,
e = new Error("Could not initialize `canvas` element");
fabric.StaticCanvas = fabric.util.createClass(fabric.CommonMethods, {
initialize: function (t, e) {
e || (e = {}),
this.renderAndResetBound = this.renderAndReset.bind(this),
this.requestRenderAllBound = this.requestRenderAll.bind(this),
this._initStatic(t, e)
},
backgroundColor: "",
backgroundImage: null,
overlayColor: "",
overlayImage: null,
includeDefaultValues: !0,
stateful: !1,
renderOnAddRemove: !0,
clipTo: null,
controlsAboveOverlay: !1,
allowTouchScrolling: !1,
imageSmoothingEnabled: !0,
viewportTransform: fabric.iMatrix.concat(),
backgroundVpt: !0,
overlayVpt: !0,
onBeforeScaleRotate: function () {},
enableRetinaScaling: !0,
vptCoords: {},
skipOffscreen: !0,
clipPath: void 0,
_initStatic: function (t, e) {
var i = this.requestRenderAllBound;
this._objects = [],
this._createLowerCanvas(t),
this._initOptions(e),
this._setImageSmoothing(),
this.interactive || this._initRetinaScaling(),
e.overlayImage && this.setOverlayImage(e.overlayImage, i),
e.backgroundImage && this.setBackgroundImage(e.backgroundImage, i),
e.backgroundColor && this.setBackgroundColor(e.backgroundColor, i),
e.overlayColor && this.setOverlayColor(e.overlayColor, i),
this.calcOffset()
},
_isRetinaScaling: function () {
return 1 !== fabric.devicePixelRatio && this.enableRetinaScaling
},
getRetinaScaling: function () {
return this._isRetinaScaling() ? fabric.devicePixelRatio : 1
},
_initRetinaScaling: function () {
if (this._isRetinaScaling()) {
var t = fabric.devicePixelRatio;
this.__initRetinaScaling(t, this.lowerCanvasEl, this.contextContainer),
this.upperCanvasEl && this.__initRetinaScaling(t, this.upperCanvasEl, this.contextTop)
}
},
__initRetinaScaling: function (t, e, i) {
e.setAttribute("width", this.width * t),
e.setAttribute("height", this.height * t),
i.scale(t, t)
},
calcOffset: function () {
return this._offset = t(this.lowerCanvasEl),
this
},
setOverlayImage: function (t, e, i) {
return this.__setBgOverlayImage("overlayImage", t, e, i)
},
setBackgroundImage: function (t, e, i) {
return this.__setBgOverlayImage("backgroundImage", t, e, i)
},
setOverlayColor: function (t, e) {
return this.__setBgOverlayColor("overlayColor", t, e)
},
setBackgroundColor: function (t, e) {
return this.__setBgOverlayColor("backgroundColor", t, e)
},
_setImageSmoothing: function () {
var t = this.getContext();
t.imageSmoothingEnabled = t.imageSmoothingEnabled || t.webkitImageSmoothingEnabled || t.mozImageSmoothingEnabled || t.msImageSmoothingEnabled || t.oImageSmoothingEnabled,
t.imageSmoothingEnabled = this.imageSmoothingEnabled
},
__setBgOverlayImage: function (i, t, r, n) {
return "string" == typeof t ? fabric.util.loadImage(t, function (t) {
if (t) {
var e = new fabric.Image(t, n);
(this[i] = e).canvas = this
}
r && r(t)
}, this, n && n.crossOrigin) : (n && t.setOptions(n), (this[i] = t) && (t.canvas = this), r && r(t)),
this
},
__setBgOverlayColor: function (t, e, i) {
return this[t] = e,
this._initGradient(e, t),
this._initPattern(e, t, i),
this
},
_createCanvasElement: function () {
var t = r();
if (!t)
throw e;
if (t.style || (t.style = {}), void 0 === t.getContext)
throw e;
return t
},
_initOptions: function (t) {
var e = this.lowerCanvasEl;
this._setOptions(t),
this.width = this.width || parseInt(e.width, 10) || 0,
this.height = this.height || parseInt(e.height, 10) || 0,
this.lowerCanvasEl.style && (e.width = this.width, e.height = this.height, e.style.width = this.width + "px", e.style.height = this.height + "px", this.viewportTransform = this.viewportTransform.slice())
},
_createLowerCanvas: function (t) {
t && t.getContext ? this.lowerCanvasEl = t : this.lowerCanvasEl = fabric.util.getById(t) || this._createCanvasElement(),
fabric.util.addClass(this.lowerCanvasEl, "lower-canvas"),
this.interactive && this._applyCanvasStyle(this.lowerCanvasEl),
this.contextContainer = this.lowerCanvasEl.getContext("2d")
},
getWidth: function () {
return this.width
},
getHeight: function () {
return this.height
},
setWidth: function (t, e) {
return this.setDimensions({
width: t
}, e)
},
setHeight: function (t, e) {
return this.setDimensions({
height: t
}, e)
},
setDimensions: function (t, e) {
var i;
for (var r in e = e || {}, t)
i = t[r], e.cssOnly || (this._setBackstoreDimension(r, t[r]), i += "px", this.hasLostContext = !0), e.backstoreOnly || this._setCssDimension(r, i);
return this._isCurrentlyDrawing && this.freeDrawingBrush && this.freeDrawingBrush._setBrushStyles(),
this._initRetinaScaling(),
this._setImageSmoothing(),
this.calcOffset(),
e.cssOnly || this.requestRenderAll(),
this
},
_setBackstoreDimension: function (t, e) {
return this.lowerCanvasEl[t] = e,
this.upperCanvasEl && (this.upperCanvasEl[t] = e),
this.cacheCanvasEl && (this.cacheCanvasEl[t] = e),
this[t] = e,
this
},
_setCssDimension: function (t, e) {
return this.lowerCanvasEl.style[t] = e,
this.upperCanvasEl && (this.upperCanvasEl.style[t] = e),
this.wrapperEl && (this.wrapperEl.style[t] = e),
this
},
getZoom: function () {
return this.viewportTransform[0]
},
setViewportTransform: function (t) {
var e,
i,
r,
n = this._activeObject;
for (this.viewportTransform = t, i = 0, r = this._objects.length; i < r; i++)
(e = this._objects[i]).group || e.setCoords(!1, !0);
return n && "activeSelection" === n.type && n.setCoords(!1, !0),
this.calcViewportBoundaries(),
this.renderOnAddRemove && this.requestRenderAll(),
this
},
zoomToPoint: function (t, e) {
var i = t,
r = this.viewportTransform.slice(0);
t = s(t, o(this.viewportTransform)),
r[0] = e,
r[3] = e;
var n = s(t, r);
return r[4] += i.x - n.x,
r[5] += i.y - n.y,
this.setViewportTransform(r)
},
setZoom: function (t) {
return this.zoomToPoint(new fabric.Point(0, 0), t),
this
},
absolutePan: function (t) {
var e = this.viewportTransform.slice(0);
return e[4] = -t.x,
e[5] = -t.y,
this.setViewportTransform(e)
},
relativePan: function (t) {
return this.absolutePan(new fabric.Point(-t.x - this.viewportTransform[4], -t.y - this.viewportTransform[5]))
},
getElement: function () {
return this.lowerCanvasEl
},
_onObjectAdded: function (t) {
this.stateful && t.setupState(),
t._set("canvas", this),
t.setCoords(),
this.fire("object:added", {
target: t
}),
t.fire("added")
},
_onObjectRemoved: function (t) {
this.fire("object:removed", {
target: t
}),
t.fire("removed"),
delete t.canvas
},
clearContext: function (t) {
return t.clearRect(0, 0, this.width, this.height),
this
},
getContext: function () {
return this.contextContainer
},
clear: function () {
return this._objects.length = 0,
this.backgroundImage = null,
this.overlayImage = null,
this.backgroundColor = "",
this.overlayColor = "",
this._hasITextHandlers && (this.off("mouse:up", this._mouseUpITextHandler), this._iTextInstances = null, this._hasITextHandlers = !1),
this.clearContext(this.contextContainer),
this.fire("canvas:cleared"),
this.renderOnAddRemove && this.requestRenderAll(),
this
},
renderAll: function () {
var t = this.contextContainer;
return this.renderCanvas(t, this._objects),
this
},
renderAndReset: function () {
this.isRendering = 0,
this.renderAll()
},
requestRenderAll: function () {
return this.isRendering || (this.isRendering = fabric.util.requestAnimFrame(this.renderAndResetBound)),
this
},
calcViewportBoundaries: function () {
var t = {},
e = this.width,
i = this.height,
r = o(this.viewportTransform);
return t.tl = s({
x: 0,
y: 0
}, r),
t.br = s({
x: e,
y: i
}, r),
t.tr = new fabric.Point(t.br.x, t.tl.y),
t.bl = new fabric.Point(t.tl.x, t.br.y),
this.vptCoords = t
},
cancelRequestedRender: function () {
this.isRendering && (fabric.util.cancelAnimFrame(this.isRendering), this.isRendering = 0)
},
renderCanvas: function (t, e) {
var i = this.viewportTransform,
r = this.clipPath;
this.cancelRequestedRender(),
this.calcViewportBoundaries(),
this.clearContext(t),
this.fire("before:render", {
ctx: t
}),
this.clipTo && fabric.util.clipContext(this, t),
this._renderBackground(t),
t.save(),
t.transform(i[0], i[1], i[2], i[3], i[4], i[5]),
this._renderObjects(t, e),
t.restore(),
!this.controlsAboveOverlay && this.interactive && this.drawControls(t),
this.clipTo && t.restore(),
r && (r.canvas = this, r.shouldCache(), r._transformDone = !0, r.renderCache({
forClipping: !0
}), this.drawClipPathOnCanvas(t)),
this._renderOverlay(t),
this.controlsAboveOverlay && this.interactive && this.drawControls(t),
this.fire("after:render", {
ctx: t
})
},
drawClipPathOnCanvas: function (t) {
var e = this.viewportTransform,
i = this.clipPath;
t.save(),
t.transform(e[0], e[1], e[2], e[3], e[4], e[5]),
t.globalCompositeOperation = "destination-in",
i.transform(t),
t.scale(1 / i.zoomX, 1 / i.zoomY),
t.drawImage(i._cacheCanvas, -i.cacheTranslationX, -i.cacheTranslationY),
t.restore()
},
_renderObjects: function (t, e) {
var i,
r;
for (i = 0, r = e.length; i < r; ++i)
e[i] && e[i].render(t)
},
_renderBackgroundOrOverlay: function (t, e) {
var i = this[e + "Color"],
r = this[e + "Image"],
n = this.viewportTransform,
s = this[e + "Vpt"];
if (i || r) {
if (i) {
t.save(),
t.beginPath(),
t.moveTo(0, 0),
t.lineTo(this.width, 0),
t.lineTo(this.width, this.height),
t.lineTo(0, this.height),
t.closePath(),
t.fillStyle = i.toLive ? i.toLive(t, this) : i,
s && t.transform(n[0], n[1], n[2], n[3], n[4], n[5]),
t.transform(1, 0, 0, 1, i.offsetX || 0, i.offsetY || 0);
var o = i.gradientTransform || i.patternTransform;
o && t.transform(o[0], o[1], o[2], o[3], o[4], o[5]),
t.fill(),
t.restore()
}
r && (t.save(), s && t.transform(n[0], n[1], n[2], n[3], n[4], n[5]), r.render(t), t.restore())
}
},
_renderBackground: function (t) {
this._renderBackgroundOrOverlay(t, "background")
},
_renderOverlay: function (t) {
this._renderBackgroundOrOverlay(t, "overlay")
},
getCenter: function () {
return {
top: this.height / 2,
left: this.width / 2
}
},
centerObjectH: function (t) {
return this._centerObject(t, new fabric.Point(this.getCenter().left, t.getCenterPoint().y))
},
centerObjectV: function (t) {
return this._centerObject(t, new fabric.Point(t.getCenterPoint().x, this.getCenter().top))
},
centerObject: function (t) {
var e = this.getCenter();
return this._centerObject(t, new fabric.Point(e.left, e.top))
},
viewportCenterObject: function (t) {
var e = this.getVpCenter();
return this._centerObject(t, e)
},
viewportCenterObjectH: function (t) {
var e = this.getVpCenter();
return this._centerObject(t, new fabric.Point(e.x, t.getCenterPoint().y)),
this
},
viewportCenterObjectV: function (t) {
var e = this.getVpCenter();
return this._centerObject(t, new fabric.Point(t.getCenterPoint().x, e.y))
},
getVpCenter: function () {
var t = this.getCenter(),
e = o(this.viewportTransform);
return s({
x: t.left,
y: t.top
}, e)
},
_centerObject: function (t, e) {
return t.setPositionByOrigin(e, "center", "center"),
t.setCoords(),
this.renderOnAddRemove && this.requestRenderAll(),
this
},
toDatalessJSON: function (t) {
return this.toDatalessObject(t)
},
toObject: function (t) {
return this._toObjectMethod("toObject", t)
},
toDatalessObject: function (t) {
return this._toObjectMethod("toDatalessObject", t)
},
_toObjectMethod: function (t, e) {
var i = this.clipPath,
r = {
version: fabric.version,
objects: this._toObjects(t, e)
};
return i && (r.clipPath = this._toObject(this.clipPath, t, e)),
n(r, this.__serializeBgOverlay(t, e)),
fabric.util.populateWithProperties(this, r, e),
r
},
_toObjects: function (e, i) {
return this._objects.filter(function (t) {
return !t.excludeFromExport
}).map(function (t) {
return this._toObject(t, e, i)
}, this)
},
_toObject: function (t, e, i) {
var r;
this.includeDefaultValues || (r = t.includeDefaultValues, t.includeDefaultValues = !1);
var n = t[e](i);
return this.includeDefaultValues || (t.includeDefaultValues = r),
n
},
__serializeBgOverlay: function (t, e) {
var i = {},
r = this.backgroundImage,
n = this.overlayImage;
return this.backgroundColor && (i.background = this.backgroundColor.toObject ? this.backgroundColor.toObject(e) : this.backgroundColor),
this.overlayColor && (i.overlay = this.overlayColor.toObject ? this.overlayColor.toObject(e) : this.overlayColor),
r && !r.excludeFromExport && (i.backgroundImage = this._toObject(r, t, e)),
n && !n.excludeFromExport && (i.overlayImage = this._toObject(n, t, e)),
i
},
svgViewportTransformation: !0,
toSVG: function (t, e) {
t || (t = {}),
t.reviver = e;
var i = [];
return this._setSVGPreamble(i, t),
this._setSVGHeader(i, t),
this.clipPath && i.push('\n'),
this._setSVGBgOverlayColor(i, "background"),
this._setSVGBgOverlayImage(i, "backgroundImage", e),
this._setSVGObjects(i, e),
this.clipPath && i.push("\n"),
this._setSVGBgOverlayColor(i, "overlay"),
this._setSVGBgOverlayImage(i, "overlayImage", e),
i.push(""),
i.join("")
},
_setSVGPreamble: function (t, e) {
e.suppressPreamble || t.push('\n', '\n')
},
_setSVGHeader: function (t, e) {
var i,
r = e.width || this.width,
n = e.height || this.height,
s = 'viewBox="0 0 ' + this.width + " " + this.height + '" ',
o = fabric.Object.NUM_FRACTION_DIGITS;
e.viewBox ? s = 'viewBox="' + e.viewBox.x + " " + e.viewBox.y + " " + e.viewBox.width + " " + e.viewBox.height + '" ' : this.svgViewportTransformation && (i = this.viewportTransform, s = 'viewBox="' + a(-i[4] / i[0], o) + " " + a(-i[5] / i[3], o) + " " + a(this.width / i[0], o) + " " + a(this.height / i[3], o) + '" '),
t.push("