Add few sample fonts and cufon.js (which is a dependency for fabric.Text).

This commit is contained in:
kangax 2010-10-15 00:56:54 -04:00
parent 639aa12e2a
commit 2f168d05a9
19 changed files with 2260 additions and 177 deletions

973
dist/all.js vendored
View file

@ -436,6 +436,967 @@ replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
};
}
}());
(function(){
var view = document.defaultView;
if (view && view.getComputedStyle) {
var style = view.getComputedStyle(document.documentElement, '');
if (style === null) {
view.getComputedStyle = function getComputedStyle(element, pseudoElement) {
return element.style;
}
}
}
})();
/*!
* Copyright (c) 2009 Simo Kinnunen.
* Licensed under the MIT license.
*/
var Cufon = (function() {
var api = function() {
return api.replace.apply(null, arguments);
};
var DOM = api.DOM = {
ready: (function() {
var complete = false, readyStatus = { loaded: 1, complete: 1 };
var queue = [], perform = function() {
if (complete) return;
complete = true;
for (var fn; fn = queue.shift(); fn());
};
if (document.addEventListener) {
document.addEventListener('DOMContentLoaded', perform, false);
window.addEventListener('pageshow', perform, false); // For cached Gecko pages
}
if (!window.opera && document.readyState) (function() {
readyStatus[document.readyState] ? perform() : setTimeout(arguments.callee, 10);
})();
if (document.readyState && document.createStyleSheet) (function() {
try {
document.body.doScroll('left');
perform();
}
catch (e) {
setTimeout(arguments.callee, 1);
}
})();
addEvent(window, 'load', perform); // Fallback
return function(listener) {
if (!arguments.length) perform();
else complete ? listener() : queue.push(listener);
};
})()
};
var CSS = api.CSS = {
Size: function(value, base) {
this.value = parseFloat(value);
this.unit = String(value).match(/[a-z%]*$/)[0] || 'px';
this.convert = function(value) {
return value / base * this.value;
};
this.convertFrom = function(value) {
return value / this.value * base;
};
this.toString = function() {
return this.value + this.unit;
};
},
getStyle: function(el) {
return new Style(el.style);
/*
var view = document.defaultView;
if (view && view.getComputedStyle) return new Style(view.getComputedStyle(el, null));
if (el.currentStyle) return new Style(el.currentStyle);
return new Style(el.style);
*/
},
quotedList: cached(function(value) {
var list = [], re = /\s*((["'])([\s\S]*?[^\\])\2|[^,]+)\s*/g, match;
while (match = re.exec(value)) list.push(match[3] || match[1]);
return list;
}),
ready: (function() {
var complete = false;
var queue = [], perform = function() {
complete = true;
for (var fn; fn = queue.shift(); fn());
};
var styleElements = Object.prototype.propertyIsEnumerable ? elementsByTagName('style') : { length: 0 };
var linkElements = elementsByTagName('link');
DOM.ready(function() {
var linkStyles = 0, link;
for (var i = 0, l = linkElements.length; link = linkElements[i], i < l; ++i) {
if (!link.disabled && link.rel.toLowerCase() == 'stylesheet') ++linkStyles;
}
if (document.styleSheets.length >= styleElements.length + linkStyles) perform();
else setTimeout(arguments.callee, 10);
});
return function(listener) {
if (complete) listener();
else queue.push(listener);
};
})(),
supports: function(property, value) {
var checker = document.createElement('span').style;
if (checker[property] === undefined) return false;
checker[property] = value;
return checker[property] === value;
},
textAlign: function(word, style, position, wordCount) {
if (style.get('textAlign') == 'right') {
if (position > 0) word = ' ' + word;
}
else if (position < wordCount - 1) word += ' ';
return word;
},
textDecoration: function(el, style) {
if (!style) style = this.getStyle(el);
var types = {
underline: null,
overline: null,
'line-through': null
};
for (var search = el; search.parentNode && search.parentNode.nodeType == 1; ) {
var foundAll = true;
for (var type in types) {
if (types[type]) continue;
if (style.get('textDecoration').indexOf(type) != -1) types[type] = style.get('color');
foundAll = false;
}
if (foundAll) break; // this is rather unlikely to happen
style = this.getStyle(search = search.parentNode);
}
return types;
},
textShadow: cached(function(value) {
if (value == 'none') return null;
var shadows = [], currentShadow = {}, result, offCount = 0;
var re = /(#[a-f0-9]+|[a-z]+\(.*?\)|[a-z]+)|(-?[\d.]+[a-z%]*)|,/ig;
while (result = re.exec(value)) {
if (result[0] == ',') {
shadows.push(currentShadow);
currentShadow = {}, offCount = 0;
}
else if (result[1]) {
currentShadow.color = result[1];
}
else {
currentShadow[[ 'offX', 'offY', 'blur' ][offCount++]] = result[2];
}
}
shadows.push(currentShadow);
return shadows;
}),
color: cached(function(value) {
var parsed = {};
parsed.color = value.replace(/^rgba\((.*?),\s*([\d.]+)\)/, function($0, $1, $2) {
parsed.opacity = parseFloat($2);
return 'rgb(' + $1 + ')';
});
return parsed;
}),
textTransform: function(text, style) {
return text[{
uppercase: 'toUpperCase',
lowercase: 'toLowerCase'
}[style.get('textTransform')] || 'toString']();
}
};
function Font(data) {
var face = this.face = data.face;
this.glyphs = data.glyphs;
this.w = data.w;
this.baseSize = parseInt(face['units-per-em'], 10);
this.family = face['font-family'].toLowerCase();
this.weight = face['font-weight'];
this.style = face['font-style'] || 'normal';
this.viewBox = (function () {
var parts = face.bbox.split(/\s+/);
var box = {
minX: parseInt(parts[0], 10),
minY: parseInt(parts[1], 10),
maxX: parseInt(parts[2], 10),
maxY: parseInt(parts[3], 10)
};
box.width = box.maxX - box.minX,
box.height = box.maxY - box.minY;
box.toString = function() {
return [ this.minX, this.minY, this.width, this.height ].join(' ');
};
return box;
})();
this.ascent = -parseInt(face.ascent, 10);
this.descent = -parseInt(face.descent, 10);
this.height = -this.ascent + this.descent;
}
function FontFamily() {
var styles = {}, mapping = {
oblique: 'italic',
italic: 'oblique'
};
this.add = function(font) {
(styles[font.style] || (styles[font.style] = {}))[font.weight] = font;
};
this.get = function(style, weight) {
var weights = styles[style] || styles[mapping[style]]
|| styles.normal || styles.italic || styles.oblique;
if (!weights) return null;
weight = {
normal: 400,
bold: 700
}[weight] || parseInt(weight, 10);
if (weights[weight]) return weights[weight];
var up = {
1: 1,
99: 0
}[weight % 100], alts = [], min, max;
if (up === undefined) up = weight > 400;
if (weight == 500) weight = 400;
for (var alt in weights) {
alt = parseInt(alt, 10);
if (!min || alt < min) min = alt;
if (!max || alt > max) max = alt;
alts.push(alt);
}
if (weight < min) weight = min;
if (weight > max) weight = max;
alts.sort(function(a, b) {
return (up
? (a > weight && b > weight) ? a < b : a > b
: (a < weight && b < weight) ? a > b : a < b) ? -1 : 1;
});
return weights[alts[0]];
};
}
function HoverHandler() {
function contains(node, anotherNode) {
if (node.contains) return node.contains(anotherNode);
return node.compareDocumentPosition(anotherNode) & 16;
}
function onOverOut(e) {
var related = e.relatedTarget;
if (!related || contains(this, related)) return;
trigger(this);
}
function onEnterLeave(e) {
trigger(this);
}
function trigger(el) {
setTimeout(function() {
api.replace(el, sharedStorage.get(el).options, true);
}, 10);
}
this.attach = function(el) {
if (el.onmouseenter === undefined) {
addEvent(el, 'mouseover', onOverOut);
addEvent(el, 'mouseout', onOverOut);
}
else {
addEvent(el, 'mouseenter', onEnterLeave);
addEvent(el, 'mouseleave', onEnterLeave);
}
};
}
function Storage() {
var map = {}, at = 0;
function identify(el) {
return el.cufid || (el.cufid = ++at);
}
this.get = function(el) {
var id = identify(el);
return map[id] || (map[id] = {});
};
}
function Style(style) {
var custom = {}, sizes = {};
this.get = function(property) {
return custom[property] != undefined ? custom[property] : style[property];
};
this.getSize = function(property, base) {
return sizes[property] || (sizes[property] = new CSS.Size(this.get(property), base));
};
this.extend = function(styles) {
for (var property in styles) custom[property] = styles[property];
return this;
};
}
function addEvent(el, type, listener) {
if (el.addEventListener) {
el.addEventListener(type, listener, false);
}
else if (el.attachEvent) {
el.attachEvent('on' + type, function() {
return listener.call(el, window.event);
});
}
}
function attach(el, options) {
var storage = sharedStorage.get(el);
if (storage.options) return el;
if (options.hover && options.hoverables[el.nodeName.toLowerCase()]) {
hoverHandler.attach(el);
}
storage.options = options;
return el;
}
function cached(fun) {
var cache = {};
return function(key) {
if (!cache.hasOwnProperty(key)) cache[key] = fun.apply(null, arguments);
return cache[key];
};
}
function getFont(el, style) {
if (!style) style = CSS.getStyle(el);
var families = CSS.quotedList(style.get('fontFamily').toLowerCase()), family;
for (var i = 0, l = families.length; i < l; ++i) {
family = families[i];
if (fonts[family]) return fonts[family].get(style.get('fontStyle'), style.get('fontWeight'));
}
return null;
}
function elementsByTagName(query) {
return document.getElementsByTagName(query);
}
function merge() {
var merged = {}, key;
for (var i = 0, l = arguments.length; i < l; ++i) {
for (key in arguments[i]) merged[key] = arguments[i][key];
}
return merged;
}
function process(font, text, style, options, node, el) {
var separate = options.separate;
if (separate == 'none') return engines[options.engine].apply(null, arguments);
var fragment = document.createDocumentFragment(), processed;
var parts = text.split(separators[separate]), needsAligning = (separate == 'words');
if (needsAligning && HAS_BROKEN_REGEXP) {
if (/^\s/.test(text)) parts.unshift('');
if (/\s$/.test(text)) parts.push('');
}
for (var i = 0, l = parts.length; i < l; ++i) {
processed = engines[options.engine](font,
needsAligning ? CSS.textAlign(parts[i], style, i, l) : parts[i],
style, options, node, el, i < l - 1);
if (processed) fragment.appendChild(processed);
}
return fragment;
}
function replaceElement(el, options) {
var font, style, nextNode, redraw;
for (var node = attach(el, options).firstChild; node; node = nextNode) {
nextNode = node.nextSibling;
redraw = false;
if (node.nodeType == 1) {
if (!node.firstChild) continue;
if (!/cufon/.test(node.className)) {
arguments.callee(node, options);
continue;
}
else redraw = true;
}
if (!style) style = CSS.getStyle(el).extend(options);
if (!font) font = getFont(el, style);
if (!font) continue;
if (redraw) {
engines[options.engine](font, null, style, options, node, el);
continue;
}
var text = node.data;
if (text === '') continue;
var processed = process(font, text, style, options, node, el);
if (processed) node.parentNode.replaceChild(processed, node);
else node.parentNode.removeChild(node);
}
}
var HAS_BROKEN_REGEXP = ' '.split(/\s+/).length == 0;
var sharedStorage = new Storage();
var hoverHandler = new HoverHandler();
var replaceHistory = [];
var engines = {}, fonts = {}, defaultOptions = {
enableTextDecoration: false,
engine: null,
hover: false,
hoverables: {
a: true
},
printable: true,
selector: (
window.Sizzle
|| (window.jQuery && function(query) { return jQuery(query); }) // avoid noConflict issues
|| (window.dojo && dojo.query)
|| (window.$$ && function(query) { return $$(query); })
|| (window.$ && function(query) { return $(query); })
|| (document.querySelectorAll && function(query) { return document.querySelectorAll(query); })
|| elementsByTagName
),
separate: 'words', // 'none' and 'characters' are also accepted
textShadow: 'none'
};
var separators = {
words: /\s+/,
characters: ''
};
api.now = function() {
DOM.ready();
return api;
};
api.refresh = function() {
var currentHistory = replaceHistory.splice(0, replaceHistory.length);
for (var i = 0, l = currentHistory.length; i < l; ++i) {
api.replace.apply(null, currentHistory[i]);
}
return api;
};
api.registerEngine = function(id, engine) {
if (!engine) return api;
engines[id] = engine;
return api.set('engine', id);
};
api.registerFont = function(data) {
var font = new Font(data), family = font.family;
if (!fonts[family]) fonts[family] = new FontFamily();
fonts[family].add(font);
return api.set('fontFamily', '"' + family + '"');
};
api.replace = function(elements, options, ignoreHistory) {
options = merge(defaultOptions, options);
if (!options.engine) return api; // there's no browser support so we'll just stop here
if (typeof options.textShadow == 'string')
options.textShadow = CSS.textShadow(options.textShadow);
if (!ignoreHistory) replaceHistory.push(arguments);
if (elements.nodeType || typeof elements == 'string') elements = [ elements ];
CSS.ready(function() {
for (var i = 0, l = elements.length; i < l; ++i) {
var el = elements[i];
if (typeof el == 'string') api.replace(options.selector(el), options, true);
else replaceElement(el, options);
}
});
return api;
};
api.replaceElement = function(el, options) {
options = merge(defaultOptions, options);
if (typeof options.textShadow == 'string')
options.textShadow = CSS.textShadow(options.textShadow);
return replaceElement(el, options);
};
api.engines = engines;
api.fonts = fonts;
api.getOptions = function() {
return merge(defaultOptions);
}
api.set = function(option, value) {
defaultOptions[option] = value;
return api;
};
return api;
})();
Cufon.registerEngine('canvas', (function() {
var check = document.createElement('canvas');
if (!check || !check.getContext || !check.getContext.apply) return;
check = null;
var HAS_INLINE_BLOCK = Cufon.CSS.supports('display', 'inline-block');
var HAS_BROKEN_LINEHEIGHT = !HAS_INLINE_BLOCK && (document.compatMode == 'BackCompat' || /frameset|transitional/i.test(document.doctype.publicId));
var styleSheet = document.createElement('style');
styleSheet.type = 'text/css';
styleSheet.appendChild(document.createTextNode(
'.cufon-canvas{text-indent:0}' +
'@media screen,projection{' +
'.cufon-canvas{display:inline;display:inline-block;position:relative;vertical-align:middle' +
(HAS_BROKEN_LINEHEIGHT
? ''
: ';font-size:1px;line-height:1px') +
'}.cufon-canvas .cufon-alt{display:-moz-inline-box;display:inline-block;width:0;height:0;overflow:hidden}' +
(HAS_INLINE_BLOCK
? '.cufon-canvas canvas{position:relative}'
: '.cufon-canvas canvas{position:absolute}') +
'}' +
'@media print{' +
'.cufon-canvas{padding:0 !important}' +
'.cufon-canvas canvas{display:none}' +
'.cufon-canvas .cufon-alt{display:inline}' +
'}'
));
document.getElementsByTagName('head')[0].appendChild(styleSheet);
function generateFromVML(path, context) {
var atX = 0, atY = 0;
var code = [], re = /([mrvxe])([^a-z]*)/g, match;
generate: for (var i = 0; match = re.exec(path); ++i) {
var c = match[2].split(',');
switch (match[1]) {
case 'v':
code[i] = { m: 'bezierCurveTo', a: [ atX + ~~c[0], atY + ~~c[1], atX + ~~c[2], atY + ~~c[3], atX += ~~c[4], atY += ~~c[5] ] };
break;
case 'r':
code[i] = { m: 'lineTo', a: [ atX += ~~c[0], atY += ~~c[1] ] };
break;
case 'm':
code[i] = { m: 'moveTo', a: [ atX = ~~c[0], atY = ~~c[1] ] };
break;
case 'x':
code[i] = { m: 'closePath' };
break;
case 'e':
break generate;
}
context[code[i].m].apply(context, code[i].a);
}
return code;
}
function interpret(code, context) {
for (var i = 0, l = code.length; i < l; ++i) {
var line = code[i];
context[line.m].apply(context, line.a);
}
}
return function(font, text, style, options, node, el) {
var redraw = (text === null);
var viewBox = font.viewBox;
var size = style.getSize('fontSize', font.baseSize);
var letterSpacing = style.get('letterSpacing');
letterSpacing = (letterSpacing == 'normal') ? 0 : size.convertFrom(parseInt(letterSpacing, 10));
var expandTop = 0, expandRight = 0, expandBottom = 0, expandLeft = 0;
var shadows = options.textShadow, shadowOffsets = [];
if (shadows) {
for (var i = 0, l = shadows.length; i < l; ++i) {
var shadow = shadows[i];
var x = size.convertFrom(parseFloat(shadow.offX));
var y = size.convertFrom(parseFloat(shadow.offY));
shadowOffsets[i] = [ x, y ];
if (y < expandTop) expandTop = y;
if (x > expandRight) expandRight = x;
if (y > expandBottom) expandBottom = y;
if (x < expandLeft) expandLeft = x;
}
}
var chars = Cufon.CSS.textTransform(redraw ? node.alt : text, style).split('');
var width = 0, lastWidth = null;
for (var i = 0, l = chars.length; i < l; ++i) {
var glyph = font.glyphs[chars[i]] || font.missingGlyph;
if (!glyph) continue;
width += lastWidth = Number(glyph.w || font.w) + letterSpacing;
}
if (lastWidth === null) return null; // there's nothing to render
expandRight += (viewBox.width - lastWidth);
expandLeft += viewBox.minX;
var wrapper, canvas;
if (redraw) {
wrapper = node;
canvas = node.firstChild;
}
else {
wrapper = document.createElement('span');
wrapper.className = 'cufon cufon-canvas';
wrapper.alt = text;
canvas = document.createElement('canvas');
wrapper.appendChild(canvas);
if (options.printable) {
var print = document.createElement('span');
print.className = 'cufon-alt';
print.appendChild(document.createTextNode(text));
wrapper.appendChild(print);
}
}
var wStyle = wrapper.style;
var cStyle = canvas.style;
var height = size.convert(viewBox.height - expandTop + expandBottom);
var roundedHeight = Math.ceil(height);
var roundingFactor = roundedHeight / height;
canvas.width = Math.ceil(size.convert(width + expandRight - expandLeft) * roundingFactor);
canvas.height = roundedHeight;
expandTop += viewBox.minY;
cStyle.top = Math.round(size.convert(expandTop - font.ascent)) + 'px';
cStyle.left = Math.round(size.convert(expandLeft)) + 'px';
var _width = Math.ceil(size.convert(width * roundingFactor));
var wrapperWidth = _width + 'px';
var _height = size.convert(font.height);
Cufon.textOptions.width = _width;
Cufon.textOptions.height = _height;
if (HAS_INLINE_BLOCK) {
wStyle.width = wrapperWidth;
wStyle.height = _height + 'px';
}
else {
wStyle.paddingLeft = wrapperWidth;
wStyle.paddingBottom = (_height - 1) + 'px';
}
var g = Cufon.textOptions.context || canvas.getContext('2d'),
scale = roundedHeight / viewBox.height;
g.save();
g.scale(scale, scale);
g.translate(
-expandLeft - ((1/scale * canvas.width) / 2) + (Cufon.fonts[font.family].offsetLeft || 0),
-expandTop - (1/scale * canvas.height) / 2
);
g.lineWidth = font.face['underline-thickness'];
g.save();
function line(y, color) {
g.strokeStyle = color;
g.beginPath();
g.moveTo(0, y);
g.lineTo(width, y);
g.stroke();
}
var textDecoration = options.enableTextDecoration ? Cufon.CSS.textDecoration(el, style) : {};
if (textDecoration.underline) line(-font.face['underline-position'], textDecoration.underline);
if (textDecoration.overline) line(font.ascent, textDecoration.overline);
g.fillStyle = Cufon.textOptions.color || style.get('color');
function renderText() {
for (var i = 0, l = chars.length; i < l; ++i) {
var glyph = font.glyphs[chars[i]] || font.missingGlyph;
if (!glyph) continue;
g.beginPath();
if (glyph.d) {
if (glyph.code) interpret(glyph.code, g);
else glyph.code = generateFromVML('m' + glyph.d, g);
}
g.fill();
g.translate(Number(glyph.w || font.w) + letterSpacing, 0);
}
}
if (shadows) {
for (var i = 0, l = shadows.length; i < l; ++i) {
var shadow = shadows[i];
g.save();
g.fillStyle = shadow.color;
g.translate.apply(g, shadowOffsets[i]);
renderText();
g.restore();
}
}
renderText();
g.restore();
g.restore();
if (textDecoration['line-through']) line(-font.descent, textDecoration['line-through']);
return wrapper;
};
})());
Cufon.registerEngine('vml', (function() {
if (!document.namespaces) return;
if (document.namespaces.cvml == null) {
document.namespaces.add('cvml', 'urn:schemas-microsoft-com:vml');
}
var check = document.createElement('cvml:shape');
check.style.behavior = 'url(#default#VML)';
if (!check.coordsize) return; // VML isn't supported
check = null;
document.write('<style type="text/css">' +
'.cufon-vml-canvas{text-indent:0}' +
'@media screen{' +
'cvml\\:shape,cvml\\:shadow{behavior:url(#default#VML);display:block;antialias:true;position:absolute}' +
'.cufon-vml-canvas{position:absolute;text-align:left}' +
'.cufon-vml{display:inline-block;position:relative;vertical-align:middle}' +
'.cufon-vml .cufon-alt{position:absolute;left:-10000in;font-size:1px}' +
'a .cufon-vml{cursor:pointer}' +
'}' +
'@media print{' +
'.cufon-vml *{display:none}' +
'.cufon-vml .cufon-alt{display:inline}' +
'}' +
'</style>');
function getFontSizeInPixels(el, value) {
return getSizeInPixels(el, /(?:em|ex|%)$/i.test(value) ? '1em' : value);
}
function getSizeInPixels(el, value) {
if (/px$/i.test(value)) return parseFloat(value);
var style = el.style.left, runtimeStyle = el.runtimeStyle.left;
el.runtimeStyle.left = el.currentStyle.left;
el.style.left = value;
var result = el.style.pixelLeft;
el.style.left = style;
el.runtimeStyle.left = runtimeStyle;
return result;
}
return function(font, text, style, options, node, el, hasNext) {
var redraw = (text === null);
if (redraw) text = node.alt;
var viewBox = font.viewBox;
var size = style.computedFontSize || (style.computedFontSize = new Cufon.CSS.Size(getFontSizeInPixels(el, style.get('fontSize')) + 'px', font.baseSize));
var letterSpacing = style.computedLSpacing;
if (letterSpacing == undefined) {
letterSpacing = style.get('letterSpacing');
style.computedLSpacing = letterSpacing = (letterSpacing == 'normal') ? 0 : ~~size.convertFrom(getSizeInPixels(el, letterSpacing));
}
var wrapper, canvas;
if (redraw) {
wrapper = node;
canvas = node.firstChild;
}
else {
wrapper = document.createElement('span');
wrapper.className = 'cufon cufon-vml';
wrapper.alt = text;
canvas = document.createElement('span');
canvas.className = 'cufon-vml-canvas';
wrapper.appendChild(canvas);
if (options.printable) {
var print = document.createElement('span');
print.className = 'cufon-alt';
print.appendChild(document.createTextNode(text));
wrapper.appendChild(print);
}
if (!hasNext) wrapper.appendChild(document.createElement('cvml:shape'));
}
var wStyle = wrapper.style;
var cStyle = canvas.style;
var height = size.convert(viewBox.height), roundedHeight = Math.ceil(height);
var roundingFactor = roundedHeight / height;
var minX = viewBox.minX, minY = viewBox.minY;
cStyle.height = roundedHeight;
cStyle.top = Math.round(size.convert(minY - font.ascent));
cStyle.left = Math.round(size.convert(minX));
wStyle.height = size.convert(font.height) + 'px';
var textDecoration = options.enableTextDecoration ? Cufon.CSS.textDecoration(el, style) : {};
var color = style.get('color');
var chars = Cufon.CSS.textTransform(text, style).split('');
var width = 0, offsetX = 0, advance = null;
var glyph, shape, shadows = options.textShadow;
for (var i = 0, k = 0, l = chars.length; i < l; ++i) {
glyph = font.glyphs[chars[i]] || font.missingGlyph;
if (glyph) width += advance = ~~(glyph.w || font.w) + letterSpacing;
}
if (advance === null) return null;
var fullWidth = -minX + width + (viewBox.width - advance);
var shapeWidth = size.convert(fullWidth * roundingFactor), roundedShapeWidth = Math.round(shapeWidth);
var coordSize = fullWidth + ',' + viewBox.height, coordOrigin;
var stretch = 'r' + coordSize + 'nsnf';
for (i = 0; i < l; ++i) {
glyph = font.glyphs[chars[i]] || font.missingGlyph;
if (!glyph) continue;
if (redraw) {
shape = canvas.childNodes[k];
if (shape.firstChild) shape.removeChild(shape.firstChild); // shadow
}
else {
shape = document.createElement('cvml:shape');
canvas.appendChild(shape);
}
shape.stroked = 'f';
shape.coordsize = coordSize;
shape.coordorigin = coordOrigin = (minX - offsetX) + ',' + minY;
shape.path = (glyph.d ? 'm' + glyph.d + 'xe' : '') + 'm' + coordOrigin + stretch;
shape.fillcolor = color;
var sStyle = shape.style;
sStyle.width = roundedShapeWidth;
sStyle.height = roundedHeight;
if (shadows) {
var shadow1 = shadows[0], shadow2 = shadows[1];
var color1 = Cufon.CSS.color(shadow1.color), color2;
var shadow = document.createElement('cvml:shadow');
shadow.on = 't';
shadow.color = color1.color;
shadow.offset = shadow1.offX + ',' + shadow1.offY;
if (shadow2) {
color2 = Cufon.CSS.color(shadow2.color);
shadow.type = 'double';
shadow.color2 = color2.color;
shadow.offset2 = shadow2.offX + ',' + shadow2.offY;
}
shadow.opacity = color1.opacity || (color2 && color2.opacity) || 1;
shape.appendChild(shadow);
}
offsetX += ~~(glyph.w || font.w) + letterSpacing;
++k;
}
wStyle.width = Math.max(Math.ceil(size.convert(width * roundingFactor)), 0);
return wrapper;
};
})());
(function (global) {
@ -2484,17 +3445,17 @@ fabric.util.animate = animate;
height: 150
};
config = config || { };
options = options || { };
this._initElement(el);
this._initConfig(config);
this._initConfig(options);
if (config.overlayImage) {
this.setOverlayImage(config.overlayImage);
if (options.overlayImage) {
this.setOverlayImage(options.overlayImage);
}
if (config.afterRender) {
this.afterRender = config.afterRender;
if (options.afterRender) {
this.afterRender = options.afterRender;
}
this._createCanvasBackground();

358
dist/all.min.js vendored
View file

@ -1,168 +1,196 @@
var fabric=fabric||{version:0.1};fabric.log=function(){};fabric.warn=function(){};if(typeof console!=="undefined"){if(typeof console.log!=="undefined"&&console.log.apply)fabric.log=function(){return console.log.apply(console,arguments)};if(typeof console.warn!=="undefined"&&console.warn.apply)fabric.warn=function(){return console.warn.apply(console,arguments)}}if(!this.JSON)this.JSON={};
(function(){function l(d){return d<10?"0"+d:d}function n(d){p.lastIndex=0;return p.test(d)?'"'+d.replace(p,function(m){var q=a[m];return typeof q==="string"?q:"\\u"+("0000"+m.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+d+'"'}function c(d,m){var q,r,v,w,x=g,s,t=m[d];if(t&&typeof t==="object"&&typeof t.toJSON==="function")t=t.toJSON(d);if(typeof b==="function")t=b.call(m,d,t);switch(typeof t){case "string":return n(t);case "number":return isFinite(t)?String(t):"null";case "boolean":case "null":return String(t);
case "object":if(!t)return"null";g+=f;s=[];if(Object.prototype.toString.apply(t)==="[object Array]"){w=t.length;for(q=0;q<w;q+=1)s[q]=c(q,t)||"null";v=s.length===0?"[]":g?"[\n"+g+s.join(",\n"+g)+"\n"+x+"]":"["+s.join(",")+"]";g=x;return v}if(b&&typeof b==="object"){w=b.length;for(q=0;q<w;q+=1){r=b[q];if(typeof r==="string")if(v=c(r,t))s.push(n(r)+(g?": ":":")+v)}}else for(r in t)if(Object.hasOwnProperty.call(t,r))if(v=c(r,t))s.push(n(r)+(g?": ":":")+v);v=s.length===0?"{}":g?"{\n"+g+s.join(",\n"+g)+
"\n"+x+"}":"{"+s.join(",")+"}";g=x;return v}}if(typeof Date.prototype.toJSON!=="function"){Date.prototype.toJSON=function(){return isFinite(this.valueOf())?this.getUTCFullYear()+"-"+l(this.getUTCMonth()+1)+"-"+l(this.getUTCDate())+"T"+l(this.getUTCHours())+":"+l(this.getUTCMinutes())+":"+l(this.getUTCSeconds())+"Z":null};String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(){return this.valueOf()}}var h=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
p=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,g,f,a={"\u0008":"\\b","\t":"\\t","\n":"\\n","\u000c":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},b;if(typeof JSON.stringify!=="function")JSON.stringify=function(d,m,q){var r;f=g="";if(typeof q==="number")for(r=0;r<q;r+=1)f+=" ";else if(typeof q==="string")f=q;if((b=m)&&typeof m!=="function"&&(typeof m!=="object"||typeof m.length!=="number"))throw Error("JSON.stringify");return c("",
{"":d})};if(typeof JSON.parse!=="function")JSON.parse=function(d,m){function q(v,w){var x,s,t=v[w];if(t&&typeof t==="object")for(x in t)if(Object.hasOwnProperty.call(t,x)){s=q(t,x);if(s!==undefined)t[x]=s;else delete t[x]}return m.call(v,w,t)}var r;d=String(d);h.lastIndex=0;if(h.test(d))d=d.replace(h,function(v){return"\\u"+("0000"+v.charCodeAt(0).toString(16)).slice(-4)});if(/^[\],:{}\s]*$/.test(d.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("("+d+")");return typeof m==="function"?q({"":r},""):r}throw new SyntaxError("JSON.parse");}})();
(function(){function l(g,f){for(var a in f)g[a]=f[a];return g}function n(g,f){var a=document.createElement(g);for(var b in f)if(b==="class")a.className=f[b];else if(b==="for")a.htmlFor=f[b];else a.setAttribute(b,f[b]);return a}var c=this.fabric||(this.fabric={}),h=Array.prototype.slice,p=Function.prototype.apply;c.util={};(function(){var g=Math.PI/180;c.util.removeFromArray=function(f,a){var b=f.indexOf(a);b!==-1&&f.splice(b,1);return f};c.util.degreesToRadians=function(f){return f*g};c.util.toFixed=
function(f,a){return parseFloat(Number(f).toFixed(a))};c.util.getRandomInt=function(f,a){return Math.floor(Math.random()*(a-f+1))+f};c.util.falseFunction=function(){return false}})();if(!Array.prototype.indexOf)Array.prototype.indexOf=function(g,f){var a=this.length>>>0;f=Number(f)||0;f=Math[f<0?"ceil":"floor"](f);if(f<0)f+=a;for(;f<a;f++)if(f in this&&this[f]===g)return f;return-1};if(!Array.prototype.forEach)Array.prototype.forEach=function(g,f){for(var a=0,b=this.length>>>0;a<b;a++)a in this&&
g.call(f,this[a],a,this)};if(!Array.prototype.map)Array.prototype.map=function(g,f){for(var a=[],b=0,d=this.length>>>0;b<d;b++)if(b in this)a[b]=g.call(f,this[b],b,this);return a};if(!Array.prototype.every)Array.prototype.every=function(g,f){for(var a=0,b=this.length>>>0;a<b;a++)if(a in this&&!g.call(f,this[a],a,this))return false;return true};if(!Array.prototype.some)Array.prototype.some=function(g,f){for(var a=0,b=this.length>>>0;a<b;a++)if(a in this&&g.call(f,this[a],a,this))return true;return false};
if(!Array.prototype.filter)Array.prototype.filter=function(g,f){for(var a=[],b,d=0,m=this.length>>>0;d<m;d++)if(d in this){b=this[d];g.call(f,b,d,this)&&a.push(b)}return a};if(!Array.prototype.reduce)Array.prototype.reduce=function(g){var f=this.length>>>0,a=0,b;if(arguments.length>1)b=arguments[1];else{do{if(a in this){b=this[a++];break}if(++a>=f)throw new TypeError;}while(1)}for(;a<f;a++)if(a in this)b=g.call(null,b,this[a],a,this);return b};c.util.array={invoke:function(g,f){for(var a=h.call(arguments,
2),b=[],d=0,m=g.length;d<m;d++)b[d]=a.length?g[d][f].apply(g[d],a):g[d][f].call(g[d]);return b},min:function(g,f){var a=g.length-1,b=f?g[a][f]:g[a];if(f)for(;a--;){if(g[a][f]<b)b=g[a][f]}else for(;a--;)if(g[a]<b)b=g[a];return b},max:function(g,f){var a=g.length-1,b=f?g[a][f]:g[a];if(f)for(;a--;){if(g[a][f]>=b)b=g[a][f]}else for(;a--;)if(g[a]>=b)b=g[a];return b}};c.util.object={extend:l,clone:function(g){return l({},g)}};if(!String.prototype.trim)String.prototype.trim=function(){return this.replace(/^[\s\xA0]+/,
"").replace(/[\s\xA0]+$/,"")};c.util.string={camelize:function(g){return g.replace(/-+(.)?/g,function(f,a){return a?a.toUpperCase():""})},capitalize:function(g){return g.charAt(0).toUpperCase()+g.slice(1).toLowerCase()}};if(!Function.prototype.bind)Function.prototype.bind=function(g){var f=this,a=h.call(arguments,1);return a.length?function(){return p.call(f,g,a.concat(h.call(arguments)))}:function(){return p.call(f,g,arguments)}};(function(){function g(){}var f;f=function(){for(var a in{toString:1})if(a===
"toString")return false;return true}()?function(a,b){if(b.toString!==Object.prototype.toString)a.prototype.toString=b.toString;if(b.valueOf!==Object.prototype.valueOf)a.prototype.valueOf=b.valueOf;for(var d in b)a.prototype[d]=b[d]}:function(a,b){for(var d in b)a.prototype[d]=b[d]};c.util.createClass=function(){function a(){this.initialize.apply(this,arguments)}var b=null,d=h.call(arguments,0);if(typeof d[0]==="function")b=d.shift();a.superclass=b;a.subclasses=[];if(b){g.prototype=b.prototype;a.prototype=
new g;b.subclasses.push(a)}b=0;for(var m=d.length;b<m;b++)f(a,d[b]);if(!a.prototype.initialize)a.prototype.initialize=emptyFunction;return a.prototype.constructor=a}})();(function(){function g(s){var t=Array.prototype.slice.call(arguments,1),B,A,E=t.length;for(A=0;A<E;A++){B=typeof s[t[A]];if(!/^(?:function|object|unknown)$/.test(B))return false}return true}function f(s,t){return function(B){t.call(d(s),B||window.event)}}function a(s,t){return function(B){if(w[s]&&w[s][t])for(var A=w[s][t],E=0,e=
A.length;E<e;E++)A[E].call(this,B||window.event)}}var b=function(){if(typeof document.documentElement.uniqueID!=="undefined")return function(t){return t.uniqueID};var s=0;return function(t){return t.__uniqueID||(t.__uniqueID="uniqueID__"+s++)}}(),d,m;(function(){var s={};d=function(t){return s[t]};m=function(t,B){s[t]=B}})();var q=g(document.documentElement,"addEventListener","removeEventListener")&&g(window,"addEventListener","removeEventListener"),r=g(document.documentElement,"attachEvent","detachEvent")&&
g(window,"attachEvent","detachEvent"),v={},w={};if(q){q=function(s,t,B){s.addEventListener(t,B,false)};r=function(s,t,B){s.removeEventListener(t,B,false)}}else if(r){q=function(s,t,B){var A=b(s);m(A,s);v[A]||(v[A]={});v[A][t]||(v[A][t]=[]);B={handler:B,wrappedHandler:f(A,B)};v[A][t].push(B);s.attachEvent("on"+t,B.wrappedHandler)};r=function(s,t,B){var A=b(s),E;if(v[A]&&v[A][t])for(var e=0,k=v[A][t].length;e<k;e++)if((E=v[A][t][e])&&E.handler===B){s.detachEvent("on"+t,E.wrappedHandler);v[A][t][e]=
null}}}else{q=function(s,t,B){var A=b(s);w[A]||(w[A]={});if(!w[A][t]){w[A][t]=[];var E=s["on"+t];E&&w[A][t].push(E);s["on"+t]=a(A,t)}w[A][t].push(B)};r=function(s,t,B){s=b(s);if(w[s]&&w[s][t]){t=w[s][t];s=0;for(var A=t.length;s<A;s++)t[s]===B&&t.splice(s,1)}}}c.util.addListener=q;c.util.removeListener=r;var x={};c.util.getPointer=function(s){var t=document.documentElement,B=document.body||{scrollLeft:0},A=document.documentElement,E=document.body||{scrollTop:0};return{x:s.pageX||(typeof s.clientX!=
"unknown"?s.clientX:0)+(t.scrollLeft||B.scrollLeft)-(t.clientLeft||0),y:s.pageY||(typeof s.clientY!="unknown"?s.clientY:0)+(A.scrollTop||E.scrollTop)-(A.clientTop||0)}};c.util.observeEvent=function(s,t){x[s]||(x[s]=[]);x[s].push(t)};c.util.fireEvent=function(s,t){var B=x[s];if(B)for(var A=0,E=B.length;A<E;A++)B[A]({memo:t})}})(this);(function(){var g=document.createElement("div"),f=typeof g.style.filter==="string",a=/alpha\s*\(\s*opacity\s*=\s*([^\)]+)\)/,b=function(d){return d};if(typeof g.style.opacity===
"string")b=function(d,m){d.style.opacity=m;return d};else if(f)b=function(d,m){var q=d.style;if(d.currentStyle&&!d.currentStyle.hasLayout)q.zoom=1;if(a.test(q.filter)){m=m>=0.9999?"":"alpha(opacity="+m*100+")";q.filter=q.filter.replace(a,m)}else q.filter+=" alpha(opacity="+m*100+")";return d};c.util.setStyle=function(d,m){var q=d.style;if(typeof m==="string"){d.style.cssText+=";"+m;return m.indexOf("opacity")>-1?b(d,m.match(/opacity:\s*(\d?\.?\d*)/)[1]):d}for(var r in m)if(r==="opacity")b(d,m[r]);
else q[r==="float"||r==="cssFloat"?typeof q.styleFloat==="undefined"?"cssFloat":"styleFloat":r]=m[r];return d}})();(function(){var g=document.documentElement.style,f="userSelect"in g?"userSelect":"MozUserSelect"in g?"MozUserSelect":"WebkitUserSelect"in g?"WebkitUserSelect":"KhtmlUserSelect"in g?"KhtmlUserSelect":"";c.util.makeElementUnselectable=function(a){if(typeof a.onselectstart!=="undefined")a.onselectstart=c.util.falseFunction;if(f)a.style[f]="none";else if(typeof a.unselectable=="string")a.unselectable=
"on";return a}})();(function(){function g(a,b){f.load(a);b()}c.util.getScript=function(a,b){var d=document.getElementsByTagName("head")[0],m=document.createElement("script"),q=true;m.type="text/javascript";m.setAttribute("runat","server");m.onload=m.onreadystatechange=function(r){if(q)if(!(typeof this.readyState=="string"&&this.readyState!=="loaded"&&this.readyState!=="complete")){q=false;b(r||window.event);m=m.onload=m.onreadystatechange=null}};m.src=a;d.appendChild(m)};var f=this.Jaxer;if(f&&f.load)c.util.getScript=
g})();c.util.getById=function(g){return typeof g==="string"?document.getElementById(g):g};c.util.toArray=function(g){for(var f=[],a=g.length;a--;)f[a]=g[a];return f};c.util.makeElement=n;c.util.addClass=function(g,f){if((" "+g.className+" ").indexOf(" "+f+" ")===-1)g.className+=(g.className?" ":"")+f};c.util.wrapElement=function(g,f,a){if(typeof f==="string")f=n(f,a);g.parentNode&&g.parentNode.replaceChild(f,g);f.appendChild(g);return f};c.util.getElementOffset=function(g){var f=0,a=0;do{f+=g.offsetTop||
0;a+=g.offsetLeft||0;g=g.offsetParent}while(g);return{left:a,top:f}};c.util.animate=function(g){g||(g={});var f=+new Date,a=g.duration||500,b=f+a,d,m,q=g.onChange||function(){},r=g.easing||function(t){return-Math.cos(t*Math.PI)/2+0.5},v="startValue"in g?g.startValue:0,w="endValue"in g?g.endValue:100,x=v>w;g.onStart&&g.onStart();var s=setInterval(function(){d=+new Date;m=d>b?1:(d-f)/a;q(x?v-(v-w)*r(m):v+(w-v)*r(m));if(d>b){clearInterval(s);g.onComplete&&g.onComplete()}},10)};(function(){function g(){}
var f=function(){for(var a=[function(){return new ActiveXObject("Microsoft.XMLHTTP")},function(){return new ActiveXObject("Msxml2.XMLHTTP")},function(){return new ActiveXObject("Msxml2.XMLHTTP.3.0")},function(){return new XMLHttpRequest}],b=a.length;b--;)try{if(a[b]())return a[b]}catch(d){}}();c.util.request=function(a,b){b||(b={});var d=b.method?b.method.toUpperCase():"GET",m=b.onComplete||function(){},q=f(),r;q.onreadystatechange=function(){if(q.readyState===4){m(q);q.onreadystatechange=g}};if(d===
"GET"){r=null;if(typeof b.parameters=="string")a=a+(/\?/.test(a)?"&":"?")+b.parameters}q.open(d,a,true);if(d==="POST"||d==="PUT")q.setRequestHeader("Content-Type","application/x-www-form-urlencoded");q.send(r);return q}})()})(this);
(function(){var l=this.fabric||(this.fabric={}),n=l.util.object.extend,c=l.util.string.capitalize,h=l.util.object.clone,p={cx:"left",x:"left",cy:"top",y:"top",r:"radius","fill-opacity":"opacity","fill-rule":"fillRule","stroke-width":"strokeWidth",transform:"transformMatrix"};l.parseTransformAttribute=function(){function g(q,r){var v=r[0];q[0]=Math.cos(v);q[1]=Math.sin(v);q[2]=-Math.sin(v);q[3]=Math.cos(v)}function f(q,r){var v=r.length===2?r[1]:r[0];q[0]=r[0];q[3]=v}function a(q,r){q[4]=r[0];if(r.length===
2)q[5]=r[1]}var b=[1,0,0,1,0,0],d=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*$"),
m=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=b.concat();if(!q||q&&!d.test(q))return r;q.replace(m,function(v){var w=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(v).filter(function(x){return x!==
""&&x!=null});v=w[1];w=w.slice(2).map(parseFloat);switch(v){case "translate":a(r,w);break;case "rotate":g(r,w);break;case "scale":f(r,w);break;case "skewX":r[2]=w[0];break;case "skewY":r[1]=w[0];break;case "matrix":r=w;break}});return r}}();l.parseSVGDocument=function(){var g=/^(path|circle|polygon|polyline|ellipse|rect|line)$/,f=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,b){if(a){var d=l.util.toArray(a.getElementsByTagName("*")).filter(function(x){var s;if(s=g.test(x.tagName)){a:{for(x=x;x&&(x=x.parentNode);)if(x.nodeName==="pattern"){x=true;break a}x=false}s=!x}return s});if(!(!d||d&&!d.length)){var m=a.getAttribute("viewBox"),q=a.getAttribute("width"),r=a.getAttribute("height"),v=null,w=null;if(m&&(m=m.match(f))){parseInt(m[1],10);parseInt(m[2],10);v=parseInt(m[3],10);w=parseInt(m[4],10)}v=q?parseFloat(q):v;w=r?parseFloat(r):w;m={width:v,height:w};
d=l.parseElements(d,h(m));!d||d&&!d.length||b&&b(d,m)}}}}();n(l,{parseAttributes:function(g,f){if(g){var a,b,d={};if(g.parentNode&&/^g$/i.test(g.parentNode.nodeName))d=l.parseAttributes(g.parentNode,f);var m=f.reduce(function(q,r){a=g.getAttribute(r);b=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=l.parseTransformAttribute(a);if(r in p)r=p[r];q[r]=isNaN(b)?a:b}return q},{});m=n(l.parseStyleAttribute(g),
m);return n(d,m)}},parseElements:function(g,f){var a=g.map(function(b){var d=l[c(b.tagName)];if(d&&d.fromElement)try{return d.fromElement(b,f)}catch(m){l.log(m.message||m)}});return a=a.filter(function(b){return b!=null})},parseStyleAttribute:function(g){var f={};if(g=g.getAttribute("style"))if(typeof g=="string"){g=g.split(";");g.pop();f=g.reduce(function(b,d){var m=d.split(":"),q=m[0].trim();m=m[1].trim();b[q]=m;return b},{})}else for(var a in g)if(typeof g[a]!=="undefined")f[a]=g[a];return f},
parsePointsAttribute:function(g){if(!g)return null;g=g.trim();var f=g.indexOf(",")>-1;g=g.split(/\s+/);var a=[];if(f){f=0;for(var b=g.length;f<b;f++){var d=g[f].split(",");a.push({x:parseFloat(d[0]),y:parseFloat(d[1])})}}else{f=0;for(b=g.length;f<b;f+=2)a.push({x:parseFloat(g[f]),y:parseFloat(g[f+1])})}return a}})})();
(function(){function l(c,h){arguments.length>0&&this.init(c,h)}var n=this.fabric||(this.fabric={});if(n.Point)n.warn("fabric.Point is already defined");else{n.Point=l;l.prototype={constructor:l,init:function(c,h){this.x=c;this.y=h},add:function(c){return new l(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 l(this.x+c,this.y+c)},scalarAddEquals:function(c){this.x+=c;this.y+=c;return this},subtract:function(c){return new l(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 l(this.x-c,this.y-c)},scalarSubtractEquals:function(c){this.x-=c;this.y-=c;return this},multiply:function(c){return new l(this.x*c,this.y*c)},multiplyEquals:function(c){this.x*=c;this.y*=c;return this},divide:function(c){return new l(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,h){return new l(this.x+(c.x-this.x)*h,this.y+(c.y-this.y)*h)},distanceFrom:function(c){var h=this.x-c.x;c=this.y-c.y;return Math.sqrt(h*h+c*c)},min:function(c){return new l(Math.min(this.x,c.x),Math.min(this.y,c.y))},max:function(c){return new l(Math.max(this.x,c.x),Math.max(this.y,c.y))},toString:function(){return this.x+
","+this.y},setXY:function(c,h){this.x=c;this.y=h},setFromPoint:function(c){this.x=c.x;this.y=c.y},swap:function(c){var h=this.x,p=this.y;this.x=c.x;this.y=c.y;c.x=h;c.y=p}}}})();
(function(){function l(c){arguments.length>0&&this.init(c)}var n=this.fabric||(this.fabric={});if(n.Intersection)n.warn("fabric.Intersection is already defined");else{n.Intersection=l;n.Intersection.prototype={init:function(c){this.status=c;this.points=[]},appendPoint:function(c){this.points.push(c)},appendPoints:function(c){this.points=this.points.concat(c)}};n.Intersection.intersectLineLine=function(c,h,p,g){var f,a=(g.x-p.x)*(c.y-p.y)-(g.y-p.y)*(c.x-p.x);f=(h.x-c.x)*(c.y-p.y)-(h.y-c.y)*(c.x-p.x);
p=(g.y-p.y)*(h.x-c.x)-(g.x-p.x)*(h.y-c.y);if(p!=0){a=a/p;f=f/p;if(0<=a&&a<=1&&0<=f&&f<=1){f=new l("Intersection");f.points.push(new n.Point(c.x+a*(h.x-c.x),c.y+a*(h.y-c.y)))}else f=new l("No Intersection")}else f=a==0||f==0?new l("Coincident"):new l("Parallel");return f};n.Intersection.intersectLinePolygon=function(c,h,p){for(var g=new l("No Intersection"),f=p.length,a=0;a<f;a++){var b=l.intersectLineLine(c,h,p[a],p[(a+1)%f]);g.appendPoints(b.points)}if(g.points.length>0)g.status="Intersection";return g};
n.Intersection.intersectPolygonPolygon=function(c,h){for(var p=new l("No Intersection"),g=c.length,f=0;f<g;f++){var a=l.intersectLinePolygon(c[f],c[(f+1)%g],h);p.appendPoints(a.points)}if(p.points.length>0)p.status="Intersection";return p};n.Intersection.intersectPolygonRectangle=function(c,h,p){var g=h.min(p),f=h.max(p);p=new n.Point(f.x,g.y);var a=new n.Point(g.x,f.y);h=l.intersectLinePolygon(g,p,c);p=l.intersectLinePolygon(p,f,c);f=l.intersectLinePolygon(f,a,c);c=l.intersectLinePolygon(a,g,c);
g=new l("No Intersection");g.appendPoints(h.points);g.appendPoints(p.points);g.appendPoints(f.points);g.appendPoints(c.points);if(g.points.length>0)g.status="Intersection";return g}}})();
(function(){function l(c){c?this._tryParsingColor(c):this.setSource([0,0,0,1])}var n=this.fabric||(this.fabric={});if(n.Color)n.warn("fabric.Color is already defined.");else{n.Color=l;n.Color.prototype={_tryParsingColor:function(c){var h=l.sourceFromHex(c);h||(h=l.sourceFromRgb(c));h&&this.setSource(h)},getSource:function(){return this._source},setSource:function(c){this._source=c},toRgb:function(){var c=this.getSource();return"rgb("+c[0]+","+c[1]+","+c[2]+")"},toRgba:function(){var c=this.getSource();
return"rgba("+c[0]+","+c[1]+","+c[2]+","+c[3]+")"},toHex:function(){var c=this.getSource(),h=c[0].toString(16);h=h.length==1?"0"+h:h;var p=c[1].toString(16);p=p.length==1?"0"+p:p;c=c[2].toString(16);c=c.length==1?"0"+c:c;return h.toUpperCase()+p.toUpperCase()+c.toUpperCase()},getAlpha:function(){return this.getSource()[3]},setAlpha:function(c){var h=this.getSource();h[3]=c;this.setSource(h);return this},toGrayscale:function(){var c=this.getSource(),h=parseInt((c[0]*0.3+c[1]*0.59+c[2]*0.11).toFixed(0),
10);this.setSource([h,h,h,c[3]]);return this},toBlackWhite:function(c){var h=this.getSource(),p=(h[0]*0.3+h[1]*0.59+h[2]*0.11).toFixed(0);h=h[3];c=c||127;p=Number(p)<Number(c)?0:255;this.setSource([p,p,p,h]);return this},overlayWith:function(c){c instanceof l||(c=new l(c));var h=[],p=this.getAlpha(),g=this.getSource();c=c.getSource();for(var f=0;f<3;f++)h.push(Math.round(g[f]*0.5+c[f]*0.5));h[4]=p;this.setSource(h);return this}};n.Color.reRGBa=/^rgba?\((\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})(?:\s*,\s*(\d+(?:\.\d+)?))?\)$/;
n.Color.reHex=/^#?([0-9a-f]{6}|[0-9a-f]{3})$/i;n.Color.fromRgb=function(c){return l.fromSource(l.sourceFromRgb(c))};n.Color.sourceFromRgb=function(c){if(c=c.match(l.reRGBa))return[parseInt(c[1],10),parseInt(c[2],10),parseInt(c[3],10),c[4]?parseFloat(c[4]):1]};n.Color.fromRgba=l.fromRgb;n.Color.fromHex=function(c){return l.fromSource(l.sourceFromHex(c))};n.Color.sourceFromHex=function(c){if(c.match(l.reHex)){var h=c.slice(c.indexOf("#")+1),p=h.length===3;c=p?h.charAt(0)+h.charAt(0):h.substring(0,2);
var g=p?h.charAt(1)+h.charAt(1):h.substring(2,4);h=p?h.charAt(2)+h.charAt(2):h.substring(4,6);return[parseInt(c,16),parseInt(g,16),parseInt(h,16),1]}};n.Color.fromSource=function(c){var h=new l;h.setSource(c);return h}}})();
(function(){if(fabric.Element)fabric.warn("fabric.Element is already defined.");else{var l=this.window,n=l.document,c=fabric.util.object.extend,h=fabric.util.string.capitalize,p=fabric.util.string.camelize,g=fabric.util.fireEvent,f=fabric.util.getPointer,a=fabric.util.getElementOffset,b=fabric.util.removeFromArray,d=fabric.util.addListener,m=fabric.util.removeListener,q=fabric.util.array.min,r=fabric.util.array.max,v=Math.sqrt,w=Math.pow,x=Math.atan2,s=Math.abs,t=Math.min,B=Math.max,A=Error("Could not initialize `canvas` element"),
E={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(e){this._groupSelector=null;this._objects=[];this._activeGroup=this._currentTransform=this._element=this._context=null;this._freeDrawingXPoints=[];this._freeDrawingYPoints=[];this._config={width:300,height:150};config=config||{};this._initElement(e);this._initConfig(config);config.overlayImage&&this.setOverlayImage(config.overlayImage);if(config.afterRender)this.afterRender=
config.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=
a(this.getElement());return this},setOverlayImage:function(e,k){if(e){var o=this,u=new Image;u.onload=function(){o.overlayImage=u;k&&k();u=u.onload=null};u.src=e}return this},_initElement:function(e){this._element=fabric.util.getById(e)||n.createElement("canvas");typeof this._element.getContext==="undefined"&&typeof G_vmlCanvasManager!=="undefined"&&G_vmlCanvasManager.initElement(this._element);if(typeof this._element.getContext==="undefined")throw A;if(!(this.contextTop=this._element.getContext("2d")))throw A;
e=this._element.width||0;var k=this._element.height||0;this._initWrapperElement(e,k);this._setElementStyle(e,k)},_initWrapperElement:function(e,k){var o=fabric.util.wrapElement(this.getElement(),"div",{"class":"canvas_container"});fabric.util.setStyle(o,{width:e+"px",height:k+"px"});fabric.util.makeElementUnselectable(o);this.wrapper=o},_setElementStyle:function(e,k){fabric.util.setStyle(this.getElement(),{position:"absolute",width:e+"px",height:k+"px",left:0,top:0})},_initConfig:function(e){c(this._config,
e||{});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 e=this;this._onMouseDown=function(k){e.__onMouseDown(k)};this._onMouseUp=function(k){e.__onMouseUp(k)};this._onMouseMove=function(k){e.__onMouseMove(k)};this._onResize=function(){e.calcOffset()};d(this._element,"mousedown",this._onMouseDown);d(n,"mousemove",
this._onMouseMove);d(n,"mouseup",this._onMouseUp);d(l,"resize",this._onResize)},_createCanvasElement:function(e){var k=n.createElement("canvas");if(k){k.className=e;e=this._element.parentNode.insertBefore(k,this._element);e.width=this.getWidth();e.height=this.getHeight();e.style.width=this.getWidth()+"px";e.style.height=this.getHeight()+"px";e.style.position="absolute";e.style.left=0;e.style.top=0;typeof k.getContext==="undefined"&&typeof G_vmlCanvasManager!=="undefined"&&G_vmlCanvasManager.initElement(k);
if(typeof k.getContext==="undefined")throw A;fabric.util.makeElementUnselectable(e);return e}},_createCanvasContainer:function(){var e=this._createCanvasElement("canvas-container");this.contextContainerEl=e;this.contextContainer=e.getContext("2d")},_createCanvasBackground:function(){var e=this._createCanvasElement("canvas-container");this._contextBackgroundEl=e;this._contextBackground=e.getContext("2d")},getWidth:function(){return this._config.width},getHeight:function(){return this._config.height},
setWidth:function(e){return this._setDimension("width",e)},setHeight:function(e){return this._setDimension("height",e)},setDimensions:function(e){for(var k in e)this._setDimension(k,e[k]);return this},_setDimension:function(e,k){this.contextContainerEl[e]=k;this.contextContainerEl.style[e]=k+"px";this._contextBackgroundEl[e]=k;this._contextBackgroundEl.style[e]=k+"px";this._element[e]=k;this._element.style[e]=k+"px";this._element.parentNode.style[e]=k+"px";this._config[e]=k;this.calcOffset();this.renderAll();
return this},__onMouseUp:function(e){if(this.isDrawingMode&&this._isCurrentlyDrawing)this._finalizeDrawingPath();else{if(this._currentTransform){var k=this._currentTransform.target;if(k._scaling){g("object:scaled",{target:k});k._scaling=false}for(var o=this._objects.length;o--;)this._objects[o].setCoords();if(k.hasStateChanged()){k.isMoving=false;g("object:modified",{target:k})}}this._currentTransform=null;this._groupSelector&&this._findSelectedObjects(e);if(o=this.getActiveGroup()){o.hasStateChanged()&&
o.containsPoint(this.getPointer(e))&&g("group:modified",{target:o});o.setObjectsCoords();o.set("isMoving",false);this._setCursor("default")}this._groupSelector=null;this.renderAll();this._setCursorFromEvent(e,k);this._setCursor("");var u=this;setTimeout(function(){u._setCursorFromEvent(e,k)},50)}},_shouldClearSelection:function(e){var k=this.findTarget(e),o=this.getActiveGroup();return!k||k&&o&&!o.contains(k)&&o!==k&&!e.shiftKey},__onMouseDown:function(e){if(this.isDrawingMode){this._prepareForDrawing(e);
this._captureDrawingPath(e)}else if(!this._currentTransform){var k=this.findTarget(e),o=this.getPointer(e),u=this.getActiveGroup();if(this._shouldClearSelection(e)){this._groupSelector={ex:o.x,ey:o.y,top:0,left:0};this.deactivateAllWithDispatch()}else{k.saveState();k._findTargetCorner(e,this._offset)&&this.onBeforeScaleRotate(k);this._setupCurrentTransform(e,k);if(e.shiftKey&&(u||this.getActiveObject()))this._handleGroupLogic(e,k);else{k!==this.getActiveGroup()&&this.deactivateAll();this.setActiveObject(k)}}this.renderAll()}},
getElement:function(){return this._element},deactivateAllWithDispatch:function(){var e=this.getActiveGroup();e&&g("before:group:destroyed",{target:e});this.deactivateAll();e&&g("after:group:destroyed");g("selection:cleared");return this},_setupCurrentTransform:function(e,k){var o="drag",u,y=f(e);if(u=k._findTargetCorner(e,this._offset))o=u==="ml"||u==="mr"?"scaleX":u==="mt"||u==="mb"?"scaleY":"rotate";this._currentTransform={target:k,action:o,scaleX:k.scaleX,scaleY:k.scaleY,offsetX:y.x-k.left,offsetY:y.y-
k.top,ex:y.x,ey:y.y,left:k.left,top:k.top,theta:k.theta,width:k.width*k.scaleX};this._currentTransform.original={left:k.left,top:k.top}},_handleGroupLogic:function(e,k){if(k.isType("group")){k=this.findTarget(e,true);if(!k||k.isType("group"))return}var o=this.getActiveGroup();if(o){if(o.contains(k)){o.remove(k);k.setActive(false);o.size()===1&&this.removeActiveGroup()}else o.add(k);g("group:selected",{target:o});o.setActive(true)}else{if(this._activeObject)if(k!==this._activeObject){this.setActiveGroup(new fabric.Group([this._activeObject,
k]));o=this.getActiveGroup()}k.setActive(true)}o&&o.saveCoords()},_prepareForDrawing:function(e){this._isCurrentlyDrawing=true;this.removeActiveObject().renderAll();e=this.getPointer(e);this._freeDrawingXPoints.length=this._freeDrawingYPoints.length=0;this._freeDrawingXPoints.push(e.x);this._freeDrawingYPoints.push(e.y);this.contextTop.beginPath();this.contextTop.moveTo(e.x,e.y);this.contextTop.strokeStyle=this.freeDrawingColor;this.contextTop.lineWidth=this.freeDrawingLineWidth;this.contextTop.lineCap=
this.contextTop.lineJoin="round"},_captureDrawingPath:function(e){e=this.getPointer(e);this._freeDrawingXPoints.push(e.x);this._freeDrawingYPoints.push(e.y);this.contextTop.lineTo(e.x,e.y);this.contextTop.stroke()},_finalizeDrawingPath:function(){this.contextTop.closePath();this._isCurrentlyDrawing=false;var e=q(this._freeDrawingXPoints),k=q(this._freeDrawingYPoints),o=r(this._freeDrawingXPoints),u=r(this._freeDrawingYPoints),y=[],z=this._freeDrawingXPoints,C=this._freeDrawingYPoints;y.push("M ",
z[0]-e," ",C[0]-k," ");for(var D=1;xPoint=z[D],yPoint=C[D];D++)y.push("L ",xPoint-e," ",yPoint-k," ");y=new fabric.Path(y.join(""));y.fill=null;y.stroke=this.freeDrawingColor;y.strokeWidth=this.freeDrawingLineWidth;this.add(y);y.set("left",e+(o-e)/2).set("top",k+(u-k)/2).setCoords();this.renderAll();g("path:created",{path:y})},__onMouseMove:function(e){if(this.isDrawingMode)this._isCurrentlyDrawing&&this._captureDrawingPath(e);else{var k=this._groupSelector;if(k!==null){var o=f(e);k.left=o.x-this._offset.left-
k.ex;k.top=o.y-this._offset.top-k.ey;this.renderTop()}else if(this._currentTransform){o=f(e);k=o.x;o=o.y;this._currentTransform.target.isMoving=true;if(this._currentTransform.action==="rotate"){e.shiftKey||this._rotateObject(k,o);this._scaleObject(k,o)}else if(this._currentTransform.action==="scaleX")this._scaleObject(k,o,"x");else this._currentTransform.action==="scaleY"?this._scaleObject(k,o,"y"):this._translateObject(k,o);this.renderAll()}else{o=this._element.style;if(k=this.findTarget(e)){this._setCursorFromEvent(e,
k);k.isActive()&&k.setCornersVisibility&&k.setCornersVisibility(true)}else{for(e=this._objects.length;e--;)this._objects[e].active||this._objects[e].setActive(false);o.cursor="default"}}}},_translateObject:function(e,k){var o=this._currentTransform.target;o.lockHorizontally||o.set("left",e-this._currentTransform.offsetX);o.lockVertically||o.set("top",k-this._currentTransform.offsetY)},_scaleObject:function(e,k,o){var u=this._currentTransform,y=this._offset,z=u.target;if(!z.lockScaling){var C=v(w(u.ey-
u.top-y.top,2)+w(u.ex-u.left-y.left,2));e=v(w(k-u.top-y.top,2)+w(e-u.left-y.left,2));z._scaling=true;if(o)if(o==="x")z.set("scaleX",u.scaleX*e/C);else o==="y"&&z.set("scaleY",u.scaleY*e/C);else{z.set("scaleX",u.scaleX*e/C);z.set("scaleY",u.scaleY*e/C)}}},_rotateObject:function(e,k){var o=this._currentTransform,u=this._offset;if(!o.target.lockRotation){var y=x(o.ey-o.top-u.top,o.ex-o.left-u.left);u=x(k-o.top-u.top,e-o.left-u.left);o.target.set("theta",u-y+o.theta)}},_setCursor:function(e){this._element.style.cursor=
e},_setCursorFromEvent:function(e,k){var o=this._element.style;if(k){var u=this.getActiveGroup();if(u=!!k._findTargetCorner&&(!u||!u.contains(k))&&k._findTargetCorner(e,this._offset))if(u in E)o.cursor=E[u];else{o.cursor="default";return false}else o.cursor="move"}else{o.cursor="default";return false}return true},_draw:function(e,k){k&&k.render(e)},_drawSelection:function(){var e=this._groupSelector,k=e.left,o=e.top,u=s(k),y=s(o);this.contextTop.fillStyle=this.selectionColor;this.contextTop.fillRect(e.ex-
(k>0?0:-k),e.ey-(o>0?0:-o),u,y);this.contextTop.lineWidth=this.selectionLineWidth;this.contextTop.strokeStyle=this.selectionBorderColor;this.contextTop.strokeRect(e.ex+0.5-(k>0?0:u),e.ey+0.5-(o>0?0:y),u,y)},_findSelectedObjects:function(){var e=[],k=this._groupSelector.ex,o=this._groupSelector.ey,u=k+this._groupSelector.left,y=o+this._groupSelector.top,z=new fabric.Point(t(k,u),t(o,y));o=new fabric.Point(B(k,u),B(o,y));u=0;for(y=this._objects.length;u<y;++u){k=this._objects[u];if(k.intersectsWithRect(z,
o)||k.isContainedWithinRect(z,o)){k.setActive(true);e.push(k)}}if(e.length===1){this.setActiveObject(e[0]);g("object:selected",{target:e[0]})}else if(e.length>1){e=new fabric.Group(e);this.setActiveGroup(e);e.saveCoords();g("group:selected",{target:e})}this.renderAll()},add:function(){this._objects.push.apply(this._objects,arguments);this.renderAll();return this},insertAt:function(e,k){this._objects.splice(k,0,e);this.renderAll();return this},getObjects:function(){return this._objects},getContext:function(){return this.contextTop},
clearContext:function(e){e.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(e){var k=this._config.width,o=this._config.height,u=e?this.contextTop:this.contextContainer;this.clearContext(this.contextTop);e||this.clearContext(u);u.fillStyle=this.backgroundColor;u.fillRect(0,0,k,o);e=this._objects.length;k=this.getActiveGroup();
o=new Date;if(e)for(var y=0;y<e;++y)if(!k||k&&!k.contains(this._objects[y]))this._draw(u,this._objects[y]);k&&this._draw(this.contextTop,k);this.overlayImage&&this.contextTop.drawImage(this.overlayImage,0,0);this.onFpsUpdate(~~(1E3/(new Date-o)));this.afterRender&&this.afterRender();return this},renderTop:function(){this.clearContext(this.contextTop);this.overlayImage&&this.contextTop.drawImage(this.overlayImage,0,0);this._groupSelector&&this._drawSelection();var e=this.getActiveGroup();e&&e.render(this.contextTop);
this.afterRender&&this.afterRender();return this},containsPoint:function(e,k){var o=this.getPointer(e),u=this._normalizePointer(k,o);o=u.x;u=u.y;var y=k._getImageLines(k.oCoords);if((o=k._findCrossPoints(o,u,y))&&o%2===1||k._findTargetCorner(e,this._offset))return true;return false},_normalizePointer:function(e,k){var o=this.getActiveGroup(),u=k.x,y=k.y;if(o&&e.type!=="group"&&o.contains(e)){u-=o.left;y-=o.top}return{x:u,y:y}},findTarget:function(e,k){var o;this.getPointer(e);var u=this.getActiveGroup();
if(u&&!k&&this.containsPoint(e,u))return o=u;for(u=this._objects.length;u--;)if(this.containsPoint(e,this._objects[u])){this.relatedTarget=o=this._objects[u];break}return o},toDataURL:function(e){var k;e||(e="png");if(e==="jpeg"||e==="png"){this.renderAll(true);k=this.getElement().toDataURL("image/"+e);this.renderAll()}return k},toDataURLWithMultiplier:function(e,k){var o=this.getWidth(),u=this.getHeight(),y=o*k,z=u*k,C=this.getActiveObject();this.setWidth(y).setHeight(z);this.contextTop.scale(k,
k);C&&this.deactivateAll().renderAll();y=this.toDataURL(e);this.contextTop.scale(1/k,1/k);this.setWidth(o).setHeight(u);C&&this.setActiveObject(C);this.renderAll();return y},getPointer:function(e){e=f(e);return{x:e.x-this._offset.left,y:e.y-this._offset.top}},getCenter:function(){return{top:this.getHeight()/2,left:this.getWidth()/2}},centerObjectH:function(e){e.set("left",this.getCenter().left);this.renderAll();return this},fxCenterObjectH:function(e,k){k=k||{};var o=function(){},u=k.onComplete||
o,y=k.onChange||o,z=this;fabric.util.animate({startValue:e.get("left"),endValue:this.getCenter().left,duration:this.FX_DURATION,onChange:function(C){e.set("left",C);z.renderAll();y()},onComplete:function(){e.setCoords();u()}});return this},centerObjectV:function(e){e.set("top",this.getCenter().top);this.renderAll();return this},fxCenterObjectV:function(e,k){k=k||{};var o=function(){},u=k.onComplete||o,y=k.onChange||o,z=this;fabric.util.animate({startValue:e.get("top"),endValue:this.getCenter().top,
duration:this.FX_DURATION,onChange:function(C){e.set("top",C);z.renderAll();y()},onComplete:function(){e.setCoords();u()}});return this},straightenObject:function(e){e.straighten();this.renderAll();return this},fxStraightenObject:function(e){e.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(e){return{objects:this._objects.map(function(k){if(!this.includeDefaultValues){var o=k.includeDefaultValues;k.includeDefaultValues=false}var u=k[e]();if(!this.includeDefaultValues)k.includeDefaultValues=o;return u},this),background:this.backgroundColor}},isEmpty:function(){return this._objects.length===0},loadFromJSON:function(e,k){if(e){var o=JSON.parse(e);if(!(!o||o&&!o.objects)){this.clear();var u=this;this._enlivenObjects(o.objects,function(){u.backgroundColor=o.background;
k&&k()});return this}}},_enlivenObjects:function(e,k){var o=0,u=e.filter(function(z){return z.type==="image"}).length,y=this;e.forEach(function(z,C){if(z.type)switch(z.type){case "image":case "font":fabric[h(z.type)].fromObject(z,function(G){y.insertAt(G,C);++o===u&&k&&k()});break;default:var D=fabric[p(h(z.type))];D&&D.fromObject&&y.insertAt(D.fromObject(z),C);break}});u===0&&k&&k()},loadFromDatalessJSON:function(e,k){if(e){var o=typeof e==="string"?JSON.parse(e):e;if(!(!o||o&&!o.objects)){this.clear();
this.backgroundColor=o.background;this._enlivenDatalessObjects(o.objects,k)}}},_enlivenDatalessObjects:function(e,k){function o(D,G){u.insertAt(D,G);D.setCoords();++y===z&&k&&k()}var u=this,y=0,z=e.length;z===0&&k&&k();try{e.forEach(function(D,G){var I=D.paths?"paths":"path",H=D[I];delete D[I];if(typeof H!=="string")switch(D.type){case "image":case "text":fabric[h(D.type)].fromObject(D,function(F){o(F,G)});break;default:(I=fabric[p(h(D.type))])&&I.fromObject&&o(I.fromObject(D),G);break}else if(D.type===
"image")u.loadImageFromURL(H,function(F){F.setSourcePath(H);c(F,D);F.setAngle(D.angle);o(F,G)});else if(D.type==="text"){D.path=H;var J=fabric.Text.fromObject(D);fabric.util.getScript(H,function(){Object.prototype.toString.call(l.opera)==="[object Opera]"?setTimeout(function(){o(J,G)},500):o(J,G)})}else u.loadSVGFromURL(H,function(F){F=F.length>1?new fabric.PathGroup(F,D):F[0];F.setSourcePath(H);if(!(F instanceof fabric.PathGroup)){c(F,D);typeof D.angle!=="undefined"&&F.setAngle(D.angle)}o(F,G)})},
this)}catch(C){fabric.log(C.message)}},loadImageFromURL:function(){var e={};return function(k,o){function u(){var C=n.getElementById(e[k]);C.width&&C.height?o(new fabric.Image(C)):setTimeout(u,50)}var y=this;if(e[k])u();else{var z=new Image;z.onload=function(){z.onload=null;y._resizeImageToFit(z);var C=new fabric.Image(z);o(C)};z.className="canvas-img-clone";z.src=k;if(this.shouldCacheImages)e[k]=Element.identify(z);n.body.appendChild(z)}}}(),loadSVGFromURL:function(e,k){function o(z){if(z=z.responseXML)(z=
z.documentElement)&&fabric.parseSVGDocument(z,function(C,D){y.cache.set(e,{objects:C.invoke("toObject"),options:D});k(C,D)})}function u(){fabric.log("ERROR!")}var y=this;e=e.replace(/^\n\s*/,"").replace(/\?.*$/,"").trim();this.cache.has(e,function(z){if(z)y.cache.get(e,function(C){C=y._enlivenCachedObject(C);k(C.objects,C.options)});else new Ajax.Request(e,{method:"get",onComplete:o,onFailure:u})})},_enlivenCachedObject:function(e){var k=e.objects;e=e.options;k=k.map(function(o){return fabric[h(o.type)].fromObject(o)});
return{objects:k,options:e}},remove:function(e){b(this._objects,e);this.renderAll();return e},fxRemove:function(e,k){var o=this;e.fxRemove({onChange:this.renderAll.bind(this),onComplete:function(){o.remove(e);typeof k==="function"&&k()}});return this},sendToBack:function(e){b(this._objects,e);this._objects.unshift(e);return this.renderAll()},bringToFront:function(e){b(this._objects,e);this._objects.push(e);return this.renderAll()},sendBackwards:function(e){var k=this._objects.indexOf(e),o=k;if(k!==
0){for(k=k-1;k>=0;--k)if(e.intersectsWithObject(this._objects[k])){o=k;break}b(this._objects,e);this._objects.splice(o,0,e)}return this.renderAll()},bringForward:function(e){var k=this.getObjects(),o=k.indexOf(e),u=o;if(o!==k.length-1){o=o+1;for(var y=this._objects.length;o<y;++o)if(e.intersectsWithObject(k[o])){u=o;break}b(k,e);k.splice(u,0,e)}this.renderAll()},setActiveObject:function(e){this._activeObject&&this._activeObject.setActive(false);this._activeObject=e;e.setActive(true);this.renderAll();
g("object:selected",{target:e});return this},getActiveObject:function(){return this._activeObject},removeActiveObject:function(){this._activeObject&&this._activeObject.setActive(false);this._activeObject=null;return this},setActiveGroup:function(e){this._activeGroup=e;return this},getActiveGroup:function(){return this._activeGroup},removeActiveGroup:function(){var e=this.getActiveGroup();e&&e.destroy();return this.setActiveGroup(null)},item:function(e){return this.getObjects()[e]},deactivateAll:function(){for(var e=
this.getObjects(),k=0,o=e.length;k<o;k++)e[k].setActive(false);this.removeActiveGroup();this.removeActiveObject();return this},complexity:function(){return this.getObjects().reduce(function(e,k){e+=k.complexity?k.complexity():0;return e},0)},dispose:function(){this.clear();m(this.getElement(),"mousedown",this._onMouseDown);m(n,"mouseup",this._onMouseUp);m(n,"mousemove",this._onMouseMove);m(l,"resize",this._onResize);return this},clone:function(e){var k=n.createElement("canvas");k.width=this.getWidth();
k.height=this.getHeight();var o=this.__clone||(this.__clone=new fabric.Element(k));return o.loadFromJSON(JSON.stringify(this.toJSON()),function(){e&&e(o)})},_toDataURL:function(e,k){this.clone(function(o){k(o.toDataURL(e))})},_toDataURLWithMultiplier:function(e,k,o){this.clone(function(u){o(u.toDataURLWithMultiplier(e,k))})},_resizeImageToFit:function(e){var k=e.width||e.offsetWidth,o=this.getWidth()/k;if(k)e.width=k*o},cache:{has:function(e,k){k(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(e){var k=e.getContext("2d");e=k.getImageData(0,0,e.width,e.height);var o=e.data,u=e.width,y=e.height,z,C;for(i=0;i<u;i++)for(j=0;j<y;j++){z=i*4*y+j*4;C=(o[z]+o[z+1]+o[z+2])/3;o[z]=C;o[z+1]=C;o[z+2]=C}k.putImageData(e,0,0)},supports:function(e){var k=n.createElement("canvas");typeof G_vmlCanvasManager!=="undefined"&&
G_vmlCanvasManager.initElement(k);if(!k||!k.getContext)return null;var o=k.getContext("2d");if(!o)return null;switch(e){case "getImageData":return typeof o.getImageData!=="undefined";case "toDataURL":return typeof k.toDataURL!=="undefined";default:return null}}});fabric.Element.prototype.toJSON=fabric.Element.prototype.toObject}})();
(function(){var l=this.fabric||(this.fabric={}),n=l.util.object.extend,c=l.util.object.clone,h=l.util.toFixed,p=l.util.string.capitalize,g=l.util.getPointer,f=Array.prototype.slice;if(!l.Object){l.Object=l.util.createClass({type:"object",includeDefaultValues:true,NUM_FRACTION_DIGITS:2,FX_DURATION:500,FX_TRANSITION:"decel",MIN_SCALE_LIMIT:0.1,stateProperties:"top left width height scaleX scaleY flipX flipY theta angle opacity cornersize fill overlayFill stroke strokeWidth fillRule borderScaleFactor transformMatrix".split(" "),
options:{top:0,left:0,width:100,height:100,scaleX:1,scaleY:1,flipX:false,flipY:false,theta:0,opacity:1,angle:0,cornersize:10,padding:0,borderColor:"rgba(102,153,255,0.75)",cornerColor:"rgba(102,153,255,0.5)",fill:"rgb(0,0,0)",overlayFill:null,stroke:null,strokeWidth:1,fillRule:"source-over",borderOpacityWhenMoving:0.4,borderScaleFactor:1,transformMatrix:null},callSuper:function(a){var b=this.constructor.superclass.prototype[a];return arguments.length>1?b.apply(this,f.call(arguments,1)):b.call(this)},
initialize:function(a){this.setOptions(a);this._importProperties();this.originalState={};this.setCoords();this.saveState()},setOptions:function(a){this.options=n(this._getOptions(),a)},_getOptions:function(){return n(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"?
(function(){function m(e){return e<10?"0"+e:e}function p(e){o.lastIndex=0;return o.test(e)?'"'+e.replace(o,function(n){var q=a[n];return typeof q==="string"?q:"\\u"+("0000"+n.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+e+'"'}function f(e,n){var q,s,x,y,A=l,u,v=n[e];if(v&&typeof v==="object"&&typeof v.toJSON==="function")v=v.toJSON(e);if(typeof c==="function")v=c.call(n,e,v);switch(typeof v){case "string":return p(v);case "number":return isFinite(v)?String(v):"null";case "boolean":case "null":return String(v);
case "object":if(!v)return"null";l+=g;u=[];if(Object.prototype.toString.apply(v)==="[object Array]"){y=v.length;for(q=0;q<y;q+=1)u[q]=f(q,v)||"null";x=u.length===0?"[]":l?"[\n"+l+u.join(",\n"+l)+"\n"+A+"]":"["+u.join(",")+"]";l=A;return x}if(c&&typeof c==="object"){y=c.length;for(q=0;q<y;q+=1){s=c[q];if(typeof s==="string")if(x=f(s,v))u.push(p(s)+(l?": ":":")+x)}}else for(s in v)if(Object.hasOwnProperty.call(v,s))if(x=f(s,v))u.push(p(s)+(l?": ":":")+x);x=u.length===0?"{}":l?"{\n"+l+u.join(",\n"+l)+
"\n"+A+"}":"{"+u.join(",")+"}";l=A;return x}}if(typeof Date.prototype.toJSON!=="function"){Date.prototype.toJSON=function(){return isFinite(this.valueOf())?this.getUTCFullYear()+"-"+m(this.getUTCMonth()+1)+"-"+m(this.getUTCDate())+"T"+m(this.getUTCHours())+":"+m(this.getUTCMinutes())+":"+m(this.getUTCSeconds())+"Z":null};String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(){return this.valueOf()}}var h=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
o=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,l,g,a={"\u0008":"\\b","\t":"\\t","\n":"\\n","\u000c":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},c;if(typeof JSON.stringify!=="function")JSON.stringify=function(e,n,q){var s;g=l="";if(typeof q==="number")for(s=0;s<q;s+=1)g+=" ";else if(typeof q==="string")g=q;if((c=n)&&typeof n!=="function"&&(typeof n!=="object"||typeof n.length!=="number"))throw Error("JSON.stringify");return f("",
{"":e})};if(typeof JSON.parse!=="function")JSON.parse=function(e,n){function q(x,y){var A,u,v=x[y];if(v&&typeof v==="object")for(A in v)if(Object.hasOwnProperty.call(v,A)){u=q(v,A);if(u!==undefined)v[A]=u;else delete v[A]}return n.call(x,y,v)}var s;e=String(e);h.lastIndex=0;if(h.test(e))e=e.replace(h,function(x){return"\\u"+("0000"+x.charCodeAt(0).toString(16)).slice(-4)});if(/^[\],:{}\s]*$/.test(e.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,
"]").replace(/(?:^|:|,)(?:\s*\[)+/g,""))){s=eval("("+e+")");return typeof n==="function"?q({"":s},""):s}throw new SyntaxError("JSON.parse");}})();(function(){var m=document.defaultView;if(m&&m.getComputedStyle)if(m.getComputedStyle(document.documentElement,"")===null)m.getComputedStyle=function(p){return p.style}})();
var Cufon=function(){function m(t){var b=this.face=t.face;this.glyphs=t.glyphs;this.w=t.w;this.baseSize=parseInt(b["units-per-em"],10);this.family=b["font-family"].toLowerCase();this.weight=b["font-weight"];this.style=b["font-style"]||"normal";this.viewBox=function(){var d=b.bbox.split(/\s+/);d={minX:parseInt(d[0],10),minY:parseInt(d[1],10),maxX:parseInt(d[2],10),maxY:parseInt(d[3],10)};d.width=d.maxX-d.minX;d.height=d.maxY-d.minY;d.toString=function(){return[this.minX,this.minY,this.width,this.height].join(" ")};
return d}();this.ascent=-parseInt(b.ascent,10);this.descent=-parseInt(b.descent,10);this.height=-this.ascent+this.descent}function p(){var t={},b={oblique:"italic",italic:"oblique"};this.add=function(d){(t[d.style]||(t[d.style]={}))[d.weight]=d};this.get=function(d,k){var r=t[d]||t[b[d]]||t.normal||t.italic||t.oblique;if(!r)return null;k={normal:400,bold:700}[k]||parseInt(k,10);if(r[k])return r[k];var w={1:1,99:0}[k%100],z=[],B,D;if(w===undefined)w=k>400;if(k==500)k=400;for(var G in r){G=parseInt(G,
10);if(!B||G<B)B=G;if(!D||G>D)D=G;z.push(G)}if(k<B)k=B;if(k>D)k=D;z.sort(function(F,H){return(w?F>k&&H>k?F<H:F>H:F<k&&H<k?F>H:F<H)?-1:1});return r[z[0]]}}function f(t){var b={},d={};this.get=function(k){return b[k]!=undefined?b[k]:t[k]};this.getSize=function(k,r){return d[k]||(d[k]=new q.Size(this.get(k),r))};this.extend=function(k){for(var r in k)b[r]=k[r];return this}}function h(t,b,d){if(t.addEventListener)t.addEventListener(b,d,false);else t.attachEvent&&t.attachEvent("on"+b,function(){return d.call(t,
window.event)})}function o(t){var b={};return function(d){b.hasOwnProperty(d)||(b[d]=t.apply(null,arguments));return b[d]}}function l(t){return document.getElementsByTagName(t)}function g(){for(var t={},b,d=0,k=arguments.length;d<k;++d)for(b in arguments[d])t[b]=arguments[d][b];return t}function a(t,b,d,k,r,w){var z=k.separate;if(z=="none")return u[k.engine].apply(null,arguments);var B=document.createDocumentFragment(),D=b.split(C[z]),G=z=="words";if(G&&s){/^\s/.test(b)&&D.unshift("");/\s$/.test(b)&&
D.push("")}for(var F=0,H=D.length;F<H;++F)(z=u[k.engine](t,G?q.textAlign(D[F],d,F,H):D[F],d,k,r,w,F<H-1))&&B.appendChild(z);return B}function c(t,b){var d,k,r,w;r=x.get(t);if(!r.options){b.hover&&b.hoverables[t.nodeName.toLowerCase()]&&y.attach(t);r.options=b}for(var z=t.firstChild;z;z=r){r=z.nextSibling;w=false;if(z.nodeType==1){if(!z.firstChild)continue;if(/cufon/.test(z.className))w=true;else{arguments.callee(z,b);continue}}k||(k=q.getStyle(t).extend(b));if(!d)a:{(d=k)||(d=q.getStyle(t));for(var B=
q.quotedList(d.get("fontFamily").toLowerCase()),D=void 0,G=0,F=B.length;G<F;++G){D=B[G];if(v[D]){d=v[D].get(d.get("fontStyle"),d.get("fontWeight"));break a}}d=null}if(d)if(w)u[b.engine](d,null,k,b,z,t);else{w=z.data;if(w!=="")(w=a(d,w,k,b,z,t))?z.parentNode.replaceChild(w,z):z.parentNode.removeChild(z)}}}var e=function(){return e.replace.apply(null,arguments)},n=e.DOM={ready:function(){var t=false,b={loaded:1,complete:1},d=[],k=function(){if(!t){t=true;for(var r;r=d.shift();r());}};if(document.addEventListener){document.addEventListener("DOMContentLoaded",
k,false);window.addEventListener("pageshow",k,false)}!window.opera&&document.readyState&&function(){b[document.readyState]?k():setTimeout(arguments.callee,10)}();document.readyState&&document.createStyleSheet&&function(){try{document.body.doScroll("left");k()}catch(r){setTimeout(arguments.callee,1)}}();h(window,"load",k);return function(r){if(arguments.length)t?r():d.push(r);else k()}}()},q=e.CSS={Size:function(t,b){this.value=parseFloat(t);this.unit=String(t).match(/[a-z%]*$/)[0]||"px";this.convert=
function(d){return d/b*this.value};this.convertFrom=function(d){return d/this.value*b};this.toString=function(){return this.value+this.unit}},getStyle:function(t){return new f(t.style)},quotedList:o(function(t){for(var b=[],d=/\s*((["'])([\s\S]*?[^\\])\2|[^,]+)\s*/g,k;k=d.exec(t);)b.push(k[3]||k[1]);return b}),ready:function(){var t=false,b=[],d=Object.prototype.propertyIsEnumerable?l("style"):{length:0},k=l("link");n.ready(function(){for(var r=0,w,z=0,B=k.length;w=k[z],z<B;++z)!w.disabled&&w.rel.toLowerCase()==
"stylesheet"&&++r;if(document.styleSheets.length>=d.length+r)for(t=true;r=b.shift();r());else setTimeout(arguments.callee,10)});return function(r){t?r():b.push(r)}}(),supports:function(t,b){var d=document.createElement("span").style;if(d[t]===undefined)return false;d[t]=b;return d[t]===b},textAlign:function(t,b,d,k){if(b.get("textAlign")=="right"){if(d>0)t=" "+t}else if(d<k-1)t+=" ";return t},textDecoration:function(t,b){b||(b=this.getStyle(t));for(var d={underline:null,overline:null,"line-through":null},
k=t;k.parentNode&&k.parentNode.nodeType==1;){var r=true;for(var w in d)if(!d[w]){if(b.get("textDecoration").indexOf(w)!=-1)d[w]=b.get("color");r=false}if(r)break;b=this.getStyle(k=k.parentNode)}return d},textShadow:o(function(t){if(t=="none")return null;for(var b=[],d={},k,r=0,w=/(#[a-f0-9]+|[a-z]+\(.*?\)|[a-z]+)|(-?[\d.]+[a-z%]*)|,/ig;k=w.exec(t);)if(k[0]==","){b.push(d);d={};r=0}else if(k[1])d.color=k[1];else d[["offX","offY","blur"][r++]]=k[2];b.push(d);return b}),color:o(function(t){var b={};
b.color=t.replace(/^rgba\((.*?),\s*([\d.]+)\)/,function(d,k,r){b.opacity=parseFloat(r);return"rgb("+k+")"});return b}),textTransform:function(t,b){return t[{uppercase:"toUpperCase",lowercase:"toLowerCase"}[b.get("textTransform")]||"toString"]()}},s=" ".split(/\s+/).length==0,x=new function(){var t={},b=0;this.get=function(d){d=d.cufid||(d.cufid=++b);return t[d]||(t[d]={})}},y=new (function(){function t(k){k=k.relatedTarget;var r;if(!(r=!k))r=this.contains?this.contains(k):this.compareDocumentPosition(k)&
16;r||d(this)}function b(){d(this)}function d(k){setTimeout(function(){e.replace(k,x.get(k).options,true)},10)}this.attach=function(k){if(k.onmouseenter===undefined){h(k,"mouseover",t);h(k,"mouseout",t)}else{h(k,"mouseenter",b);h(k,"mouseleave",b)}}}),A=[],u={},v={},E={enableTextDecoration:false,engine:null,hover:false,hoverables:{a:true},printable:true,selector:window.Sizzle||window.jQuery&&function(t){return jQuery(t)}||window.dojo&&dojo.query||window.$$&&function(t){return $$(t)}||window.$&&function(t){return $(t)}||
document.querySelectorAll&&function(t){return document.querySelectorAll(t)}||l,separate:"words",textShadow:"none"},C={words:/\s+/,characters:""};e.now=function(){n.ready();return e};e.refresh=function(){for(var t=A.splice(0,A.length),b=0,d=t.length;b<d;++b)e.replace.apply(null,t[b]);return e};e.registerEngine=function(t,b){if(!b)return e;u[t]=b;return e.set("engine",t)};e.registerFont=function(t){t=new m(t);var b=t.family;v[b]||(v[b]=new p);v[b].add(t);return e.set("fontFamily",'"'+b+'"')};e.replace=
function(t,b,d){b=g(E,b);if(!b.engine)return e;if(typeof b.textShadow=="string")b.textShadow=q.textShadow(b.textShadow);d||A.push(arguments);if(t.nodeType||typeof t=="string")t=[t];q.ready(function(){for(var k=0,r=t.length;k<r;++k){var w=t[k];typeof w=="string"?e.replace(b.selector(w),b,true):c(w,b)}});return e};e.replaceElement=function(t,b){b=g(E,b);if(typeof b.textShadow=="string")b.textShadow=q.textShadow(b.textShadow);return c(t,b)};e.engines=u;e.fonts=v;e.getOptions=function(){return g(E)};
e.set=function(t,b){E[t]=b;return e};return e}();
Cufon.registerEngine("canvas",function(){var m=document.createElement("canvas");if(!(!m||!m.getContext||!m.getContext.apply)){m=null;var p=Cufon.CSS.supports("display","inline-block");m=!p&&(document.compatMode=="BackCompat"||/frameset|transitional/i.test(document.doctype.publicId));var f=document.createElement("style");f.type="text/css";f.appendChild(document.createTextNode(".cufon-canvas{text-indent:0}@media screen,projection{.cufon-canvas{display:inline;display:inline-block;position:relative;vertical-align:middle"+(m?
"":";font-size:1px;line-height:1px")+"}.cufon-canvas .cufon-alt{display:-moz-inline-box;display:inline-block;width:0;height:0;overflow:hidden}"+(p?".cufon-canvas canvas{position:relative}":".cufon-canvas canvas{position:absolute}")+"}@media print{.cufon-canvas{padding:0 !important}.cufon-canvas canvas{display:none}.cufon-canvas .cufon-alt{display:inline}}"));document.getElementsByTagName("head")[0].appendChild(f);return function(h,o,l,g,a,c){function e(D,G){B.strokeStyle=G;B.beginPath();B.moveTo(0,
D);B.lineTo(z,D);B.stroke()}function n(){for(var D=0,G=w.length;D<G;++D){var F=h.glyphs[w[D]]||h.missingGlyph;if(F){B.beginPath();if(F.d)if(F.code)for(var H=F.code,L=B,I=0,M=H.length;I<M;++I){var K=H[I];L[K.m].apply(L,K.a)}else{H=F;L="m"+F.d;I=B;K=M=0;var N=[],Q=/([mrvxe])([^a-z]*)/g,P=void 0,O=0;a:for(;P=Q.exec(L);++O){var J=P[2].split(",");switch(P[1]){case "v":N[O]={m:"bezierCurveTo",a:[M+~~J[0],K+~~J[1],M+~~J[2],K+~~J[3],M+=~~J[4],K+=~~J[5]]};break;case "r":N[O]={m:"lineTo",a:[M+=~~J[0],K+=~~J[1]]};
break;case "m":N[O]={m:"moveTo",a:[M=~~J[0],K=~~J[1]]};break;case "x":N[O]={m:"closePath"};break;case "e":break a}I[N[O].m].apply(I,N[O].a)}H.code=N}B.fill();B.translate(Number(F.w||h.w)+y,0)}}}var q=o===null,s=h.viewBox,x=l.getSize("fontSize",h.baseSize),y=l.get("letterSpacing");y=y=="normal"?0:x.convertFrom(parseInt(y,10));var A=0,u=0,v=0,E=0,C=g.textShadow,t=[];if(C)for(var b=0,d=C.length;b<d;++b){var k=C[b],r=x.convertFrom(parseFloat(k.offX));k=x.convertFrom(parseFloat(k.offY));t[b]=[r,k];if(k<
A)A=k;if(r>u)u=r;if(k>v)v=k;if(r<E)E=r}var w=Cufon.CSS.textTransform(q?a.alt:o,l).split(""),z=0;k=null;b=0;for(d=w.length;b<d;++b)if(r=h.glyphs[w[b]]||h.missingGlyph)z+=k=Number(r.w||h.w)+y;if(k===null)return null;u+=s.width-k;E+=s.minX;if(q){q=a;b=a.firstChild}else{q=document.createElement("span");q.className="cufon cufon-canvas";q.alt=o;b=document.createElement("canvas");q.appendChild(b);if(g.printable){d=document.createElement("span");d.className="cufon-alt";d.appendChild(document.createTextNode(o));
q.appendChild(d)}}o=q.style;d=b.style;a=x.convert(s.height-A+v);v=Math.ceil(a);a=v/a;b.width=Math.ceil(x.convert(z+u-E)*a);b.height=v;A+=s.minY;d.top=Math.round(x.convert(A-h.ascent))+"px";d.left=Math.round(x.convert(E))+"px";u=Math.ceil(x.convert(z*a));d=u+"px";x=x.convert(h.height);Cufon.textOptions.width=u;Cufon.textOptions.height=x;if(p){o.width=d;o.height=x+"px"}else{o.paddingLeft=d;o.paddingBottom=x-1+"px"}var B=Cufon.textOptions.context||b.getContext("2d");s=v/s.height;B.save();B.scale(s,s);
B.translate(-E-1/s*b.width/2+(Cufon.fonts[h.family].offsetLeft||0),-A-1/s*b.height/2);B.lineWidth=h.face["underline-thickness"];B.save();g=g.enableTextDecoration?Cufon.CSS.textDecoration(c,l):{};g.underline&&e(-h.face["underline-position"],g.underline);g.overline&&e(h.ascent,g.overline);B.fillStyle=Cufon.textOptions.color||l.get("color");if(C){b=0;for(d=C.length;b<d;++b){k=C[b];B.save();B.fillStyle=k.color;B.translate.apply(B,t[b]);n();B.restore()}}n();B.restore();B.restore();g["line-through"]&&e(-h.descent,
g["line-through"]);return q}}}());
Cufon.registerEngine("vml",function(){function m(f,h){if(/px$/i.test(h))return parseFloat(h);var o=f.style.left,l=f.runtimeStyle.left;f.runtimeStyle.left=f.currentStyle.left;f.style.left=h;var g=f.style.pixelLeft;f.style.left=o;f.runtimeStyle.left=l;return g}if(document.namespaces){document.namespaces.cvml==null&&document.namespaces.add("cvml","urn:schemas-microsoft-com:vml");var p=document.createElement("cvml:shape");p.style.behavior="url(#default#VML)";if(p.coordsize){p=null;document.write('<style type="text/css">.cufon-vml-canvas{text-indent:0}@media screen{cvml\\:shape,cvml\\:shadow{behavior:url(#default#VML);display:block;antialias:true;position:absolute}.cufon-vml-canvas{position:absolute;text-align:left}.cufon-vml{display:inline-block;position:relative;vertical-align:middle}.cufon-vml .cufon-alt{position:absolute;left:-10000in;font-size:1px}a .cufon-vml{cursor:pointer}}@media print{.cufon-vml *{display:none}.cufon-vml .cufon-alt{display:inline}}</style>');
return function(f,h,o,l,g,a,c){var e=h===null;if(e)h=g.alt;var n=f.viewBox,q;if(!(q=o.computedFontSize)){q=Cufon.CSS.Size;var s;s=o.get("fontSize");s=m(a,/(?:em|ex|%)$/i.test(s)?"1em":s);q=o.computedFontSize=new q(s+"px",f.baseSize)}q=q;s=o.computedLSpacing;if(s==undefined){s=o.get("letterSpacing");o.computedLSpacing=s=s=="normal"?0:~~q.convertFrom(m(a,s))}var x;if(e){x=g;g=g.firstChild}else{x=document.createElement("span");x.className="cufon cufon-vml";x.alt=h;g=document.createElement("span");g.className=
"cufon-vml-canvas";x.appendChild(g);if(l.printable){var y=document.createElement("span");y.className="cufon-alt";y.appendChild(document.createTextNode(h));x.appendChild(y)}c||x.appendChild(document.createElement("cvml:shape"))}c=x.style;var A=g.style,u=q.convert(n.height);y=Math.ceil(u);u=y/u;var v=n.minX,E=n.minY;A.height=y;A.top=Math.round(q.convert(E-f.ascent));A.left=Math.round(q.convert(v));c.height=q.convert(f.height)+"px";l.enableTextDecoration&&Cufon.CSS.textDecoration(a,o);a=o.get("color");
h=Cufon.CSS.textTransform(h,o).split("");A=o=0;var C=null,t;l=l.textShadow;for(var b=0,d=0,k=h.length;b<k;++b)if(t=f.glyphs[h[b]]||f.missingGlyph)o+=C=~~(t.w||f.w)+s;if(C===null)return null;t=-v+o+(n.width-C);b=q.convert(t*u);C=Math.round(b);var r=t+","+n.height,w,z="r"+r+"nsnf";for(b=0;b<k;++b)if(t=f.glyphs[h[b]]||f.missingGlyph){if(e){n=g.childNodes[d];n.firstChild&&n.removeChild(n.firstChild)}else{n=document.createElement("cvml:shape");g.appendChild(n)}n.stroked="f";n.coordsize=r;n.coordorigin=
w=v-A+","+E;n.path=(t.d?"m"+t.d+"xe":"")+"m"+w+z;n.fillcolor=a;w=n.style;w.width=C;w.height=y;if(l){w=l[0];var B=l[1],D=Cufon.CSS.color(w.color),G,F=document.createElement("cvml:shadow");F.on="t";F.color=D.color;F.offset=w.offX+","+w.offY;if(B){G=Cufon.CSS.color(B.color);F.type="double";F.color2=G.color;F.offset2=B.offX+","+B.offY}F.opacity=D.opacity||G&&G.opacity||1;n.appendChild(F)}A+=~~(t.w||f.w)+s;++d}c.width=Math.max(Math.ceil(q.convert(o*u)),0);return x}}}}());
(function(){function m(l,g){for(var a in g)l[a]=g[a];return l}function p(l,g){var a=document.createElement(l);for(var c in g)if(c==="class")a.className=g[c];else if(c==="for")a.htmlFor=g[c];else a.setAttribute(c,g[c]);return a}var f=this.fabric||(this.fabric={}),h=Array.prototype.slice,o=Function.prototype.apply;f.util={};(function(){var l=Math.PI/180;f.util.removeFromArray=function(g,a){var c=g.indexOf(a);c!==-1&&g.splice(c,1);return g};f.util.degreesToRadians=function(g){return g*l};f.util.toFixed=
function(g,a){return parseFloat(Number(g).toFixed(a))};f.util.getRandomInt=function(g,a){return Math.floor(Math.random()*(a-g+1))+g};f.util.falseFunction=function(){return false}})();if(!Array.prototype.indexOf)Array.prototype.indexOf=function(l,g){var a=this.length>>>0;g=Number(g)||0;g=Math[g<0?"ceil":"floor"](g);if(g<0)g+=a;for(;g<a;g++)if(g in this&&this[g]===l)return g;return-1};if(!Array.prototype.forEach)Array.prototype.forEach=function(l,g){for(var a=0,c=this.length>>>0;a<c;a++)a in this&&
l.call(g,this[a],a,this)};if(!Array.prototype.map)Array.prototype.map=function(l,g){for(var a=[],c=0,e=this.length>>>0;c<e;c++)if(c in this)a[c]=l.call(g,this[c],c,this);return a};if(!Array.prototype.every)Array.prototype.every=function(l,g){for(var a=0,c=this.length>>>0;a<c;a++)if(a in this&&!l.call(g,this[a],a,this))return false;return true};if(!Array.prototype.some)Array.prototype.some=function(l,g){for(var a=0,c=this.length>>>0;a<c;a++)if(a in this&&l.call(g,this[a],a,this))return true;return false};
if(!Array.prototype.filter)Array.prototype.filter=function(l,g){for(var a=[],c,e=0,n=this.length>>>0;e<n;e++)if(e in this){c=this[e];l.call(g,c,e,this)&&a.push(c)}return a};if(!Array.prototype.reduce)Array.prototype.reduce=function(l){var g=this.length>>>0,a=0,c;if(arguments.length>1)c=arguments[1];else{do{if(a in this){c=this[a++];break}if(++a>=g)throw new TypeError;}while(1)}for(;a<g;a++)if(a in this)c=l.call(null,c,this[a],a,this);return c};f.util.array={invoke:function(l,g){for(var a=h.call(arguments,
2),c=[],e=0,n=l.length;e<n;e++)c[e]=a.length?l[e][g].apply(l[e],a):l[e][g].call(l[e]);return c},min:function(l,g){var a=l.length-1,c=g?l[a][g]:l[a];if(g)for(;a--;){if(l[a][g]<c)c=l[a][g]}else for(;a--;)if(l[a]<c)c=l[a];return c},max:function(l,g){var a=l.length-1,c=g?l[a][g]:l[a];if(g)for(;a--;){if(l[a][g]>=c)c=l[a][g]}else for(;a--;)if(l[a]>=c)c=l[a];return c}};f.util.object={extend:m,clone:function(l){return m({},l)}};if(!String.prototype.trim)String.prototype.trim=function(){return this.replace(/^[\s\xA0]+/,
"").replace(/[\s\xA0]+$/,"")};f.util.string={camelize:function(l){return l.replace(/-+(.)?/g,function(g,a){return a?a.toUpperCase():""})},capitalize:function(l){return l.charAt(0).toUpperCase()+l.slice(1).toLowerCase()}};if(!Function.prototype.bind)Function.prototype.bind=function(l){var g=this,a=h.call(arguments,1);return a.length?function(){return o.call(g,l,a.concat(h.call(arguments)))}:function(){return o.call(g,l,arguments)}};(function(){function l(){}var g;g=function(){for(var a in{toString:1})if(a===
"toString")return false;return true}()?function(a,c){if(c.toString!==Object.prototype.toString)a.prototype.toString=c.toString;if(c.valueOf!==Object.prototype.valueOf)a.prototype.valueOf=c.valueOf;for(var e in c)a.prototype[e]=c[e]}:function(a,c){for(var e in c)a.prototype[e]=c[e]};f.util.createClass=function(){function a(){this.initialize.apply(this,arguments)}var c=null,e=h.call(arguments,0);if(typeof e[0]==="function")c=e.shift();a.superclass=c;a.subclasses=[];if(c){l.prototype=c.prototype;a.prototype=
new l;c.subclasses.push(a)}c=0;for(var n=e.length;c<n;c++)g(a,e[c]);if(!a.prototype.initialize)a.prototype.initialize=emptyFunction;return a.prototype.constructor=a}})();(function(){function l(u){var v=Array.prototype.slice.call(arguments,1),E,C,t=v.length;for(C=0;C<t;C++){E=typeof u[v[C]];if(!/^(?:function|object|unknown)$/.test(E))return false}return true}function g(u,v){return function(E){v.call(e(u),E||window.event)}}function a(u,v){return function(E){if(y[u]&&y[u][v])for(var C=y[u][v],t=0,b=
C.length;t<b;t++)C[t].call(this,E||window.event)}}var c=function(){if(typeof document.documentElement.uniqueID!=="undefined")return function(v){return v.uniqueID};var u=0;return function(v){return v.__uniqueID||(v.__uniqueID="uniqueID__"+u++)}}(),e,n;(function(){var u={};e=function(v){return u[v]};n=function(v,E){u[v]=E}})();var q=l(document.documentElement,"addEventListener","removeEventListener")&&l(window,"addEventListener","removeEventListener"),s=l(document.documentElement,"attachEvent","detachEvent")&&
l(window,"attachEvent","detachEvent"),x={},y={};if(q){q=function(u,v,E){u.addEventListener(v,E,false)};s=function(u,v,E){u.removeEventListener(v,E,false)}}else if(s){q=function(u,v,E){var C=c(u);n(C,u);x[C]||(x[C]={});x[C][v]||(x[C][v]=[]);E={handler:E,wrappedHandler:g(C,E)};x[C][v].push(E);u.attachEvent("on"+v,E.wrappedHandler)};s=function(u,v,E){var C=c(u),t;if(x[C]&&x[C][v])for(var b=0,d=x[C][v].length;b<d;b++)if((t=x[C][v][b])&&t.handler===E){u.detachEvent("on"+v,t.wrappedHandler);x[C][v][b]=
null}}}else{q=function(u,v,E){var C=c(u);y[C]||(y[C]={});if(!y[C][v]){y[C][v]=[];var t=u["on"+v];t&&y[C][v].push(t);u["on"+v]=a(C,v)}y[C][v].push(E)};s=function(u,v,E){u=c(u);if(y[u]&&y[u][v]){v=y[u][v];u=0;for(var C=v.length;u<C;u++)v[u]===E&&v.splice(u,1)}}}f.util.addListener=q;f.util.removeListener=s;var A={};f.util.getPointer=function(u){var v=document.documentElement,E=document.body||{scrollLeft:0},C=document.documentElement,t=document.body||{scrollTop:0};return{x:u.pageX||(typeof u.clientX!=
"unknown"?u.clientX:0)+(v.scrollLeft||E.scrollLeft)-(v.clientLeft||0),y:u.pageY||(typeof u.clientY!="unknown"?u.clientY:0)+(C.scrollTop||t.scrollTop)-(C.clientTop||0)}};f.util.observeEvent=function(u,v){A[u]||(A[u]=[]);A[u].push(v)};f.util.fireEvent=function(u,v){var E=A[u];if(E)for(var C=0,t=E.length;C<t;C++)E[C]({memo:v})}})(this);(function(){var l=document.createElement("div"),g=typeof l.style.filter==="string",a=/alpha\s*\(\s*opacity\s*=\s*([^\)]+)\)/,c=function(e){return e};if(typeof l.style.opacity===
"string")c=function(e,n){e.style.opacity=n;return e};else if(g)c=function(e,n){var q=e.style;if(e.currentStyle&&!e.currentStyle.hasLayout)q.zoom=1;if(a.test(q.filter)){n=n>=0.9999?"":"alpha(opacity="+n*100+")";q.filter=q.filter.replace(a,n)}else q.filter+=" alpha(opacity="+n*100+")";return e};f.util.setStyle=function(e,n){var q=e.style;if(typeof n==="string"){e.style.cssText+=";"+n;return n.indexOf("opacity")>-1?c(e,n.match(/opacity:\s*(\d?\.?\d*)/)[1]):e}for(var s in n)if(s==="opacity")c(e,n[s]);
else q[s==="float"||s==="cssFloat"?typeof q.styleFloat==="undefined"?"cssFloat":"styleFloat":s]=n[s];return e}})();(function(){var l=document.documentElement.style,g="userSelect"in l?"userSelect":"MozUserSelect"in l?"MozUserSelect":"WebkitUserSelect"in l?"WebkitUserSelect":"KhtmlUserSelect"in l?"KhtmlUserSelect":"";f.util.makeElementUnselectable=function(a){if(typeof a.onselectstart!=="undefined")a.onselectstart=f.util.falseFunction;if(g)a.style[g]="none";else if(typeof a.unselectable=="string")a.unselectable=
"on";return a}})();(function(){function l(a,c){g.load(a);c()}f.util.getScript=function(a,c){var e=document.getElementsByTagName("head")[0],n=document.createElement("script"),q=true;n.type="text/javascript";n.setAttribute("runat","server");n.onload=n.onreadystatechange=function(s){if(q)if(!(typeof this.readyState=="string"&&this.readyState!=="loaded"&&this.readyState!=="complete")){q=false;c(s||window.event);n=n.onload=n.onreadystatechange=null}};n.src=a;e.appendChild(n)};var g=this.Jaxer;if(g&&g.load)f.util.getScript=
l})();f.util.getById=function(l){return typeof l==="string"?document.getElementById(l):l};f.util.toArray=function(l){for(var g=[],a=l.length;a--;)g[a]=l[a];return g};f.util.makeElement=p;f.util.addClass=function(l,g){if((" "+l.className+" ").indexOf(" "+g+" ")===-1)l.className+=(l.className?" ":"")+g};f.util.wrapElement=function(l,g,a){if(typeof g==="string")g=p(g,a);l.parentNode&&l.parentNode.replaceChild(g,l);g.appendChild(l);return g};f.util.getElementOffset=function(l){var g=0,a=0;do{g+=l.offsetTop||
0;a+=l.offsetLeft||0;l=l.offsetParent}while(l);return{left:a,top:g}};f.util.animate=function(l){l||(l={});var g=+new Date,a=l.duration||500,c=g+a,e,n,q=l.onChange||function(){},s=l.easing||function(v){return-Math.cos(v*Math.PI)/2+0.5},x="startValue"in l?l.startValue:0,y="endValue"in l?l.endValue:100,A=x>y;l.onStart&&l.onStart();var u=setInterval(function(){e=+new Date;n=e>c?1:(e-g)/a;q(A?x-(x-y)*s(n):x+(y-x)*s(n));if(e>c){clearInterval(u);l.onComplete&&l.onComplete()}},10)};(function(){function l(){}
var g=function(){for(var a=[function(){return new ActiveXObject("Microsoft.XMLHTTP")},function(){return new ActiveXObject("Msxml2.XMLHTTP")},function(){return new ActiveXObject("Msxml2.XMLHTTP.3.0")},function(){return new XMLHttpRequest}],c=a.length;c--;)try{if(a[c]())return a[c]}catch(e){}}();f.util.request=function(a,c){c||(c={});var e=c.method?c.method.toUpperCase():"GET",n=c.onComplete||function(){},q=g(),s;q.onreadystatechange=function(){if(q.readyState===4){n(q);q.onreadystatechange=l}};if(e===
"GET"){s=null;if(typeof c.parameters=="string")a=a+(/\?/.test(a)?"&":"?")+c.parameters}q.open(e,a,true);if(e==="POST"||e==="PUT")q.setRequestHeader("Content-Type","application/x-www-form-urlencoded");q.send(s);return q}})()})(this);
(function(){var m=this.fabric||(this.fabric={}),p=m.util.object.extend,f=m.util.string.capitalize,h=m.util.object.clone,o={cx:"left",x:"left",cy:"top",y:"top",r:"radius","fill-opacity":"opacity","fill-rule":"fillRule","stroke-width":"strokeWidth",transform:"transformMatrix"};m.parseTransformAttribute=function(){function l(q,s){var x=s[0];q[0]=Math.cos(x);q[1]=Math.sin(x);q[2]=-Math.sin(x);q[3]=Math.cos(x)}function g(q,s){var x=s.length===2?s[1]:s[0];q[0]=s[0];q[3]=x}function a(q,s){q[4]=s[0];if(s.length===
2)q[5]=s[1]}var c=[1,0,0,1,0,0],e=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*$"),
n=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 s=c.concat();if(!q||q&&!e.test(q))return s;q.replace(n,function(x){var y=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(x).filter(function(A){return A!==
""&&A!=null});x=y[1];y=y.slice(2).map(parseFloat);switch(x){case "translate":a(s,y);break;case "rotate":l(s,y);break;case "scale":g(s,y);break;case "skewX":s[2]=y[0];break;case "skewY":s[1]=y[0];break;case "matrix":s=y;break}});return s}}();m.parseSVGDocument=function(){var l=/^(path|circle|polygon|polyline|ellipse|rect|line)$/,g=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 e=m.util.toArray(a.getElementsByTagName("*")).filter(function(A){var u;if(u=l.test(A.tagName)){a:{for(A=A;A&&(A=A.parentNode);)if(A.nodeName==="pattern"){A=true;break a}A=false}u=!A}return u});if(!(!e||e&&!e.length)){var n=a.getAttribute("viewBox"),q=a.getAttribute("width"),s=a.getAttribute("height"),x=null,y=null;if(n&&(n=n.match(g))){parseInt(n[1],10);parseInt(n[2],10);x=parseInt(n[3],10);y=parseInt(n[4],10)}x=q?parseFloat(q):x;y=s?parseFloat(s):y;n={width:x,height:y};
e=m.parseElements(e,h(n));!e||e&&!e.length||c&&c(e,n)}}}}();p(m,{parseAttributes:function(l,g){if(l){var a,c,e={};if(l.parentNode&&/^g$/i.test(l.parentNode.nodeName))e=m.parseAttributes(l.parentNode,g);var n=g.reduce(function(q,s){a=l.getAttribute(s);c=parseFloat(a);if(a){if((s==="fill"||s==="stroke")&&a==="none")a="";if(s==="fill-rule")a=a==="evenodd"?"destination-over":a;if(s==="transform")a=m.parseTransformAttribute(a);if(s in o)s=o[s];q[s]=isNaN(c)?a:c}return q},{});n=p(m.parseStyleAttribute(l),
n);return p(e,n)}},parseElements:function(l,g){var a=l.map(function(c){var e=m[f(c.tagName)];if(e&&e.fromElement)try{return e.fromElement(c,g)}catch(n){m.log(n.message||n)}});return a=a.filter(function(c){return c!=null})},parseStyleAttribute:function(l){var g={};if(l=l.getAttribute("style"))if(typeof l=="string"){l=l.split(";");l.pop();g=l.reduce(function(c,e){var n=e.split(":"),q=n[0].trim();n=n[1].trim();c[q]=n;return c},{})}else for(var a in l)if(typeof l[a]!=="undefined")g[a]=l[a];return g},
parsePointsAttribute:function(l){if(!l)return null;l=l.trim();var g=l.indexOf(",")>-1;l=l.split(/\s+/);var a=[];if(g){g=0;for(var c=l.length;g<c;g++){var e=l[g].split(",");a.push({x:parseFloat(e[0]),y:parseFloat(e[1])})}}else{g=0;for(c=l.length;g<c;g+=2)a.push({x:parseFloat(l[g]),y:parseFloat(l[g+1])})}return a}})})();
(function(){function m(f,h){arguments.length>0&&this.init(f,h)}var p=this.fabric||(this.fabric={});if(p.Point)p.warn("fabric.Point is already defined");else{p.Point=m;m.prototype={constructor:m,init:function(f,h){this.x=f;this.y=h},add:function(f){return new m(this.x+f.x,this.y+f.y)},addEquals:function(f){this.x+=f.x;this.y+=f.y;return this},scalarAdd:function(f){return new m(this.x+f,this.y+f)},scalarAddEquals:function(f){this.x+=f;this.y+=f;return this},subtract:function(f){return new m(this.x-
f.x,this.y-f.y)},subtractEquals:function(f){this.x-=f.x;this.y-=f.y;return this},scalarSubtract:function(f){return new m(this.x-f,this.y-f)},scalarSubtractEquals:function(f){this.x-=f;this.y-=f;return this},multiply:function(f){return new m(this.x*f,this.y*f)},multiplyEquals:function(f){this.x*=f;this.y*=f;return this},divide:function(f){return new m(this.x/f,this.y/f)},divideEquals:function(f){this.x/=f;this.y/=f;return this},eq:function(f){return this.x==f.x&&this.y==f.y},lt:function(f){return this.x<
f.x&&this.y<f.y},lte:function(f){return this.x<=f.x&&this.y<=f.y},gt:function(f){return this.x>f.x&&this.y>f.y},gte:function(f){return this.x>=f.x&&this.y>=f.y},lerp:function(f,h){return new m(this.x+(f.x-this.x)*h,this.y+(f.y-this.y)*h)},distanceFrom:function(f){var h=this.x-f.x;f=this.y-f.y;return Math.sqrt(h*h+f*f)},min:function(f){return new m(Math.min(this.x,f.x),Math.min(this.y,f.y))},max:function(f){return new m(Math.max(this.x,f.x),Math.max(this.y,f.y))},toString:function(){return this.x+
","+this.y},setXY:function(f,h){this.x=f;this.y=h},setFromPoint:function(f){this.x=f.x;this.y=f.y},swap:function(f){var h=this.x,o=this.y;this.x=f.x;this.y=f.y;f.x=h;f.y=o}}}})();
(function(){function m(f){arguments.length>0&&this.init(f)}var p=this.fabric||(this.fabric={});if(p.Intersection)p.warn("fabric.Intersection is already defined");else{p.Intersection=m;p.Intersection.prototype={init:function(f){this.status=f;this.points=[]},appendPoint:function(f){this.points.push(f)},appendPoints:function(f){this.points=this.points.concat(f)}};p.Intersection.intersectLineLine=function(f,h,o,l){var g,a=(l.x-o.x)*(f.y-o.y)-(l.y-o.y)*(f.x-o.x);g=(h.x-f.x)*(f.y-o.y)-(h.y-f.y)*(f.x-o.x);
o=(l.y-o.y)*(h.x-f.x)-(l.x-o.x)*(h.y-f.y);if(o!=0){a=a/o;g=g/o;if(0<=a&&a<=1&&0<=g&&g<=1){g=new m("Intersection");g.points.push(new p.Point(f.x+a*(h.x-f.x),f.y+a*(h.y-f.y)))}else g=new m("No Intersection")}else g=a==0||g==0?new m("Coincident"):new m("Parallel");return g};p.Intersection.intersectLinePolygon=function(f,h,o){for(var l=new m("No Intersection"),g=o.length,a=0;a<g;a++){var c=m.intersectLineLine(f,h,o[a],o[(a+1)%g]);l.appendPoints(c.points)}if(l.points.length>0)l.status="Intersection";return l};
p.Intersection.intersectPolygonPolygon=function(f,h){for(var o=new m("No Intersection"),l=f.length,g=0;g<l;g++){var a=m.intersectLinePolygon(f[g],f[(g+1)%l],h);o.appendPoints(a.points)}if(o.points.length>0)o.status="Intersection";return o};p.Intersection.intersectPolygonRectangle=function(f,h,o){var l=h.min(o),g=h.max(o);o=new p.Point(g.x,l.y);var a=new p.Point(l.x,g.y);h=m.intersectLinePolygon(l,o,f);o=m.intersectLinePolygon(o,g,f);g=m.intersectLinePolygon(g,a,f);f=m.intersectLinePolygon(a,l,f);
l=new m("No Intersection");l.appendPoints(h.points);l.appendPoints(o.points);l.appendPoints(g.points);l.appendPoints(f.points);if(l.points.length>0)l.status="Intersection";return l}}})();
(function(){function m(f){f?this._tryParsingColor(f):this.setSource([0,0,0,1])}var p=this.fabric||(this.fabric={});if(p.Color)p.warn("fabric.Color is already defined.");else{p.Color=m;p.Color.prototype={_tryParsingColor:function(f){var h=m.sourceFromHex(f);h||(h=m.sourceFromRgb(f));h&&this.setSource(h)},getSource:function(){return this._source},setSource:function(f){this._source=f},toRgb:function(){var f=this.getSource();return"rgb("+f[0]+","+f[1]+","+f[2]+")"},toRgba:function(){var f=this.getSource();
return"rgba("+f[0]+","+f[1]+","+f[2]+","+f[3]+")"},toHex:function(){var f=this.getSource(),h=f[0].toString(16);h=h.length==1?"0"+h:h;var o=f[1].toString(16);o=o.length==1?"0"+o:o;f=f[2].toString(16);f=f.length==1?"0"+f:f;return h.toUpperCase()+o.toUpperCase()+f.toUpperCase()},getAlpha:function(){return this.getSource()[3]},setAlpha:function(f){var h=this.getSource();h[3]=f;this.setSource(h);return this},toGrayscale:function(){var f=this.getSource(),h=parseInt((f[0]*0.3+f[1]*0.59+f[2]*0.11).toFixed(0),
10);this.setSource([h,h,h,f[3]]);return this},toBlackWhite:function(f){var h=this.getSource(),o=(h[0]*0.3+h[1]*0.59+h[2]*0.11).toFixed(0);h=h[3];f=f||127;o=Number(o)<Number(f)?0:255;this.setSource([o,o,o,h]);return this},overlayWith:function(f){f instanceof m||(f=new m(f));var h=[],o=this.getAlpha(),l=this.getSource();f=f.getSource();for(var g=0;g<3;g++)h.push(Math.round(l[g]*0.5+f[g]*0.5));h[4]=o;this.setSource(h);return this}};p.Color.reRGBa=/^rgba?\((\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})(?:\s*,\s*(\d+(?:\.\d+)?))?\)$/;
p.Color.reHex=/^#?([0-9a-f]{6}|[0-9a-f]{3})$/i;p.Color.fromRgb=function(f){return m.fromSource(m.sourceFromRgb(f))};p.Color.sourceFromRgb=function(f){if(f=f.match(m.reRGBa))return[parseInt(f[1],10),parseInt(f[2],10),parseInt(f[3],10),f[4]?parseFloat(f[4]):1]};p.Color.fromRgba=m.fromRgb;p.Color.fromHex=function(f){return m.fromSource(m.sourceFromHex(f))};p.Color.sourceFromHex=function(f){if(f.match(m.reHex)){var h=f.slice(f.indexOf("#")+1),o=h.length===3;f=o?h.charAt(0)+h.charAt(0):h.substring(0,2);
var l=o?h.charAt(1)+h.charAt(1):h.substring(2,4);h=o?h.charAt(2)+h.charAt(2):h.substring(4,6);return[parseInt(f,16),parseInt(l,16),parseInt(h,16),1]}};p.Color.fromSource=function(f){var h=new m;h.setSource(f);return h}}})();
(function(){if(fabric.Element)fabric.warn("fabric.Element is already defined.");else{var m=this.window,p=m.document,f=fabric.util.object.extend,h=fabric.util.string.capitalize,o=fabric.util.string.camelize,l=fabric.util.fireEvent,g=fabric.util.getPointer,a=fabric.util.getElementOffset,c=fabric.util.removeFromArray,e=fabric.util.addListener,n=fabric.util.removeListener,q=fabric.util.array.min,s=fabric.util.array.max,x=Math.sqrt,y=Math.pow,A=Math.atan2,u=Math.abs,v=Math.min,E=Math.max,C=Error("Could not initialize `canvas` element"),
t={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(b,d){this._groupSelector=null;this._objects=[];this._activeGroup=this._currentTransform=this._element=this._context=null;this._freeDrawingXPoints=[];this._freeDrawingYPoints=[];this._config={width:300,height:150};d=d||{};this._initElement(b);this._initConfig(d);d.overlayImage&&this.setOverlayImage(d.overlayImage);if(d.afterRender)this.afterRender=d.afterRender;
this._createCanvasBackground();this._createCanvasContainer();this._initEvents();this.calcOffset()};f(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(b,d){if(b){var k=this,r=new Image;r.onload=function(){k.overlayImage=r;d&&d();r=r.onload=null};r.src=b}return this},_initElement:function(b){this._element=fabric.util.getById(b)||p.createElement("canvas");typeof this._element.getContext==="undefined"&&typeof G_vmlCanvasManager!=="undefined"&&G_vmlCanvasManager.initElement(this._element);if(typeof this._element.getContext==="undefined")throw C;if(!(this.contextTop=this._element.getContext("2d")))throw C;
b=this._element.width||0;var d=this._element.height||0;this._initWrapperElement(b,d);this._setElementStyle(b,d)},_initWrapperElement:function(b,d){var k=fabric.util.wrapElement(this.getElement(),"div",{"class":"canvas_container"});fabric.util.setStyle(k,{width:b+"px",height:d+"px"});fabric.util.makeElementUnselectable(k);this.wrapper=k},_setElementStyle:function(b,d){fabric.util.setStyle(this.getElement(),{position:"absolute",width:b+"px",height:d+"px",left:0,top:0})},_initConfig:function(b){f(this._config,
b||{});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 b=this;this._onMouseDown=function(d){b.__onMouseDown(d)};this._onMouseUp=function(d){b.__onMouseUp(d)};this._onMouseMove=function(d){b.__onMouseMove(d)};this._onResize=function(){b.calcOffset()};e(this._element,"mousedown",this._onMouseDown);e(p,"mousemove",
this._onMouseMove);e(p,"mouseup",this._onMouseUp);e(m,"resize",this._onResize)},_createCanvasElement:function(b){var d=p.createElement("canvas");if(d){d.className=b;b=this._element.parentNode.insertBefore(d,this._element);b.width=this.getWidth();b.height=this.getHeight();b.style.width=this.getWidth()+"px";b.style.height=this.getHeight()+"px";b.style.position="absolute";b.style.left=0;b.style.top=0;typeof d.getContext==="undefined"&&typeof G_vmlCanvasManager!=="undefined"&&G_vmlCanvasManager.initElement(d);
if(typeof d.getContext==="undefined")throw C;fabric.util.makeElementUnselectable(b);return b}},_createCanvasContainer:function(){var b=this._createCanvasElement("canvas-container");this.contextContainerEl=b;this.contextContainer=b.getContext("2d")},_createCanvasBackground:function(){var b=this._createCanvasElement("canvas-container");this._contextBackgroundEl=b;this._contextBackground=b.getContext("2d")},getWidth:function(){return this._config.width},getHeight:function(){return this._config.height},
setWidth:function(b){return this._setDimension("width",b)},setHeight:function(b){return this._setDimension("height",b)},setDimensions:function(b){for(var d in b)this._setDimension(d,b[d]);return this},_setDimension:function(b,d){this.contextContainerEl[b]=d;this.contextContainerEl.style[b]=d+"px";this._contextBackgroundEl[b]=d;this._contextBackgroundEl.style[b]=d+"px";this._element[b]=d;this._element.style[b]=d+"px";this._element.parentNode.style[b]=d+"px";this._config[b]=d;this.calcOffset();this.renderAll();
return this},__onMouseUp:function(b){if(this.isDrawingMode&&this._isCurrentlyDrawing)this._finalizeDrawingPath();else{if(this._currentTransform){var d=this._currentTransform.target;if(d._scaling){l("object:scaled",{target:d});d._scaling=false}for(var k=this._objects.length;k--;)this._objects[k].setCoords();if(d.hasStateChanged()){d.isMoving=false;l("object:modified",{target:d})}}this._currentTransform=null;this._groupSelector&&this._findSelectedObjects(b);if(k=this.getActiveGroup()){k.hasStateChanged()&&
k.containsPoint(this.getPointer(b))&&l("group:modified",{target:k});k.setObjectsCoords();k.set("isMoving",false);this._setCursor("default")}this._groupSelector=null;this.renderAll();this._setCursorFromEvent(b,d);this._setCursor("");var r=this;setTimeout(function(){r._setCursorFromEvent(b,d)},50)}},_shouldClearSelection:function(b){var d=this.findTarget(b),k=this.getActiveGroup();return!d||d&&k&&!k.contains(d)&&k!==d&&!b.shiftKey},__onMouseDown:function(b){if(this.isDrawingMode){this._prepareForDrawing(b);
this._captureDrawingPath(b)}else if(!this._currentTransform){var d=this.findTarget(b),k=this.getPointer(b),r=this.getActiveGroup();if(this._shouldClearSelection(b)){this._groupSelector={ex:k.x,ey:k.y,top:0,left:0};this.deactivateAllWithDispatch()}else{d.saveState();d._findTargetCorner(b,this._offset)&&this.onBeforeScaleRotate(d);this._setupCurrentTransform(b,d);if(b.shiftKey&&(r||this.getActiveObject()))this._handleGroupLogic(b,d);else{d!==this.getActiveGroup()&&this.deactivateAll();this.setActiveObject(d)}}this.renderAll()}},
getElement:function(){return this._element},deactivateAllWithDispatch:function(){var b=this.getActiveGroup();b&&l("before:group:destroyed",{target:b});this.deactivateAll();b&&l("after:group:destroyed");l("selection:cleared");return this},_setupCurrentTransform:function(b,d){var k="drag",r,w=g(b);if(r=d._findTargetCorner(b,this._offset))k=r==="ml"||r==="mr"?"scaleX":r==="mt"||r==="mb"?"scaleY":"rotate";this._currentTransform={target:d,action:k,scaleX:d.scaleX,scaleY:d.scaleY,offsetX:w.x-d.left,offsetY:w.y-
d.top,ex:w.x,ey:w.y,left:d.left,top:d.top,theta:d.theta,width:d.width*d.scaleX};this._currentTransform.original={left:d.left,top:d.top}},_handleGroupLogic:function(b,d){if(d.isType("group")){d=this.findTarget(b,true);if(!d||d.isType("group"))return}var k=this.getActiveGroup();if(k){if(k.contains(d)){k.remove(d);d.setActive(false);k.size()===1&&this.removeActiveGroup()}else k.add(d);l("group:selected",{target:k});k.setActive(true)}else{if(this._activeObject)if(d!==this._activeObject){this.setActiveGroup(new fabric.Group([this._activeObject,
d]));k=this.getActiveGroup()}d.setActive(true)}k&&k.saveCoords()},_prepareForDrawing:function(b){this._isCurrentlyDrawing=true;this.removeActiveObject().renderAll();b=this.getPointer(b);this._freeDrawingXPoints.length=this._freeDrawingYPoints.length=0;this._freeDrawingXPoints.push(b.x);this._freeDrawingYPoints.push(b.y);this.contextTop.beginPath();this.contextTop.moveTo(b.x,b.y);this.contextTop.strokeStyle=this.freeDrawingColor;this.contextTop.lineWidth=this.freeDrawingLineWidth;this.contextTop.lineCap=
this.contextTop.lineJoin="round"},_captureDrawingPath:function(b){b=this.getPointer(b);this._freeDrawingXPoints.push(b.x);this._freeDrawingYPoints.push(b.y);this.contextTop.lineTo(b.x,b.y);this.contextTop.stroke()},_finalizeDrawingPath:function(){this.contextTop.closePath();this._isCurrentlyDrawing=false;var b=q(this._freeDrawingXPoints),d=q(this._freeDrawingYPoints),k=s(this._freeDrawingXPoints),r=s(this._freeDrawingYPoints),w=[],z=this._freeDrawingXPoints,B=this._freeDrawingYPoints;w.push("M ",
z[0]-b," ",B[0]-d," ");for(var D=1;xPoint=z[D],yPoint=B[D];D++)w.push("L ",xPoint-b," ",yPoint-d," ");w=new fabric.Path(w.join(""));w.fill=null;w.stroke=this.freeDrawingColor;w.strokeWidth=this.freeDrawingLineWidth;this.add(w);w.set("left",b+(k-b)/2).set("top",d+(r-d)/2).setCoords();this.renderAll();l("path:created",{path:w})},__onMouseMove:function(b){if(this.isDrawingMode)this._isCurrentlyDrawing&&this._captureDrawingPath(b);else{var d=this._groupSelector;if(d!==null){var k=g(b);d.left=k.x-this._offset.left-
d.ex;d.top=k.y-this._offset.top-d.ey;this.renderTop()}else if(this._currentTransform){k=g(b);d=k.x;k=k.y;this._currentTransform.target.isMoving=true;if(this._currentTransform.action==="rotate"){b.shiftKey||this._rotateObject(d,k);this._scaleObject(d,k)}else if(this._currentTransform.action==="scaleX")this._scaleObject(d,k,"x");else this._currentTransform.action==="scaleY"?this._scaleObject(d,k,"y"):this._translateObject(d,k);this.renderAll()}else{k=this._element.style;if(d=this.findTarget(b)){this._setCursorFromEvent(b,
d);d.isActive()&&d.setCornersVisibility&&d.setCornersVisibility(true)}else{for(b=this._objects.length;b--;)this._objects[b].active||this._objects[b].setActive(false);k.cursor="default"}}}},_translateObject:function(b,d){var k=this._currentTransform.target;k.lockHorizontally||k.set("left",b-this._currentTransform.offsetX);k.lockVertically||k.set("top",d-this._currentTransform.offsetY)},_scaleObject:function(b,d,k){var r=this._currentTransform,w=this._offset,z=r.target;if(!z.lockScaling){var B=x(y(r.ey-
r.top-w.top,2)+y(r.ex-r.left-w.left,2));b=x(y(d-r.top-w.top,2)+y(b-r.left-w.left,2));z._scaling=true;if(k)if(k==="x")z.set("scaleX",r.scaleX*b/B);else k==="y"&&z.set("scaleY",r.scaleY*b/B);else{z.set("scaleX",r.scaleX*b/B);z.set("scaleY",r.scaleY*b/B)}}},_rotateObject:function(b,d){var k=this._currentTransform,r=this._offset;if(!k.target.lockRotation){var w=A(k.ey-k.top-r.top,k.ex-k.left-r.left);r=A(d-k.top-r.top,b-k.left-r.left);k.target.set("theta",r-w+k.theta)}},_setCursor:function(b){this._element.style.cursor=
b},_setCursorFromEvent:function(b,d){var k=this._element.style;if(d){var r=this.getActiveGroup();if(r=!!d._findTargetCorner&&(!r||!r.contains(d))&&d._findTargetCorner(b,this._offset))if(r in t)k.cursor=t[r];else{k.cursor="default";return false}else k.cursor="move"}else{k.cursor="default";return false}return true},_draw:function(b,d){d&&d.render(b)},_drawSelection:function(){var b=this._groupSelector,d=b.left,k=b.top,r=u(d),w=u(k);this.contextTop.fillStyle=this.selectionColor;this.contextTop.fillRect(b.ex-
(d>0?0:-d),b.ey-(k>0?0:-k),r,w);this.contextTop.lineWidth=this.selectionLineWidth;this.contextTop.strokeStyle=this.selectionBorderColor;this.contextTop.strokeRect(b.ex+0.5-(d>0?0:r),b.ey+0.5-(k>0?0:w),r,w)},_findSelectedObjects:function(){var b=[],d=this._groupSelector.ex,k=this._groupSelector.ey,r=d+this._groupSelector.left,w=k+this._groupSelector.top,z=new fabric.Point(v(d,r),v(k,w));k=new fabric.Point(E(d,r),E(k,w));r=0;for(w=this._objects.length;r<w;++r){d=this._objects[r];if(d.intersectsWithRect(z,
k)||d.isContainedWithinRect(z,k)){d.setActive(true);b.push(d)}}if(b.length===1){this.setActiveObject(b[0]);l("object:selected",{target:b[0]})}else if(b.length>1){b=new fabric.Group(b);this.setActiveGroup(b);b.saveCoords();l("group:selected",{target:b})}this.renderAll()},add:function(){this._objects.push.apply(this._objects,arguments);this.renderAll();return this},insertAt:function(b,d){this._objects.splice(d,0,b);this.renderAll();return this},getObjects:function(){return this._objects},getContext:function(){return this.contextTop},
clearContext:function(b){b.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(b){var d=this._config.width,k=this._config.height,r=b?this.contextTop:this.contextContainer;this.clearContext(this.contextTop);b||this.clearContext(r);r.fillStyle=this.backgroundColor;r.fillRect(0,0,d,k);b=this._objects.length;d=this.getActiveGroup();
k=new Date;if(b)for(var w=0;w<b;++w)if(!d||d&&!d.contains(this._objects[w]))this._draw(r,this._objects[w]);d&&this._draw(this.contextTop,d);this.overlayImage&&this.contextTop.drawImage(this.overlayImage,0,0);this.onFpsUpdate(~~(1E3/(new Date-k)));this.afterRender&&this.afterRender();return this},renderTop:function(){this.clearContext(this.contextTop);this.overlayImage&&this.contextTop.drawImage(this.overlayImage,0,0);this._groupSelector&&this._drawSelection();var b=this.getActiveGroup();b&&b.render(this.contextTop);
this.afterRender&&this.afterRender();return this},containsPoint:function(b,d){var k=this.getPointer(b),r=this._normalizePointer(d,k);k=r.x;r=r.y;var w=d._getImageLines(d.oCoords);if((k=d._findCrossPoints(k,r,w))&&k%2===1||d._findTargetCorner(b,this._offset))return true;return false},_normalizePointer:function(b,d){var k=this.getActiveGroup(),r=d.x,w=d.y;if(k&&b.type!=="group"&&k.contains(b)){r-=k.left;w-=k.top}return{x:r,y:w}},findTarget:function(b,d){var k;this.getPointer(b);var r=this.getActiveGroup();
if(r&&!d&&this.containsPoint(b,r))return k=r;for(r=this._objects.length;r--;)if(this.containsPoint(b,this._objects[r])){this.relatedTarget=k=this._objects[r];break}return k},toDataURL:function(b){var d;b||(b="png");if(b==="jpeg"||b==="png"){this.renderAll(true);d=this.getElement().toDataURL("image/"+b);this.renderAll()}return d},toDataURLWithMultiplier:function(b,d){var k=this.getWidth(),r=this.getHeight(),w=k*d,z=r*d,B=this.getActiveObject();this.setWidth(w).setHeight(z);this.contextTop.scale(d,
d);B&&this.deactivateAll().renderAll();w=this.toDataURL(b);this.contextTop.scale(1/d,1/d);this.setWidth(k).setHeight(r);B&&this.setActiveObject(B);this.renderAll();return w},getPointer:function(b){b=g(b);return{x:b.x-this._offset.left,y:b.y-this._offset.top}},getCenter:function(){return{top:this.getHeight()/2,left:this.getWidth()/2}},centerObjectH:function(b){b.set("left",this.getCenter().left);this.renderAll();return this},fxCenterObjectH:function(b,d){d=d||{};var k=function(){},r=d.onComplete||
k,w=d.onChange||k,z=this;fabric.util.animate({startValue:b.get("left"),endValue:this.getCenter().left,duration:this.FX_DURATION,onChange:function(B){b.set("left",B);z.renderAll();w()},onComplete:function(){b.setCoords();r()}});return this},centerObjectV:function(b){b.set("top",this.getCenter().top);this.renderAll();return this},fxCenterObjectV:function(b,d){d=d||{};var k=function(){},r=d.onComplete||k,w=d.onChange||k,z=this;fabric.util.animate({startValue:b.get("top"),endValue:this.getCenter().top,
duration:this.FX_DURATION,onChange:function(B){b.set("top",B);z.renderAll();w()},onComplete:function(){b.setCoords();r()}});return this},straightenObject:function(b){b.straighten();this.renderAll();return this},fxStraightenObject:function(b){b.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(b){return{objects:this._objects.map(function(d){if(!this.includeDefaultValues){var k=d.includeDefaultValues;d.includeDefaultValues=false}var r=d[b]();if(!this.includeDefaultValues)d.includeDefaultValues=k;return r},this),background:this.backgroundColor}},isEmpty:function(){return this._objects.length===0},loadFromJSON:function(b,d){if(b){var k=JSON.parse(b);if(!(!k||k&&!k.objects)){this.clear();var r=this;this._enlivenObjects(k.objects,function(){r.backgroundColor=k.background;
d&&d()});return this}}},_enlivenObjects:function(b,d){var k=0,r=b.filter(function(z){return z.type==="image"}).length,w=this;b.forEach(function(z,B){if(z.type)switch(z.type){case "image":case "font":fabric[h(z.type)].fromObject(z,function(G){w.insertAt(G,B);++k===r&&d&&d()});break;default:var D=fabric[o(h(z.type))];D&&D.fromObject&&w.insertAt(D.fromObject(z),B);break}});r===0&&d&&d()},loadFromDatalessJSON:function(b,d){if(b){var k=typeof b==="string"?JSON.parse(b):b;if(!(!k||k&&!k.objects)){this.clear();
this.backgroundColor=k.background;this._enlivenDatalessObjects(k.objects,d)}}},_enlivenDatalessObjects:function(b,d){function k(D,G){r.insertAt(D,G);D.setCoords();++w===z&&d&&d()}var r=this,w=0,z=b.length;z===0&&d&&d();try{b.forEach(function(D,G){var F=D.paths?"paths":"path",H=D[F];delete D[F];if(typeof H!=="string")switch(D.type){case "image":case "text":fabric[h(D.type)].fromObject(D,function(I){k(I,G)});break;default:(F=fabric[o(h(D.type))])&&F.fromObject&&k(F.fromObject(D),G);break}else if(D.type===
"image")r.loadImageFromURL(H,function(I){I.setSourcePath(H);f(I,D);I.setAngle(D.angle);k(I,G)});else if(D.type==="text"){D.path=H;var L=fabric.Text.fromObject(D);fabric.util.getScript(H,function(){Object.prototype.toString.call(m.opera)==="[object Opera]"?setTimeout(function(){k(L,G)},500):k(L,G)})}else r.loadSVGFromURL(H,function(I){I=I.length>1?new fabric.PathGroup(I,D):I[0];I.setSourcePath(H);if(!(I instanceof fabric.PathGroup)){f(I,D);typeof D.angle!=="undefined"&&I.setAngle(D.angle)}k(I,G)})},
this)}catch(B){fabric.log(B.message)}},loadImageFromURL:function(){var b={};return function(d,k){function r(){var B=p.getElementById(b[d]);B.width&&B.height?k(new fabric.Image(B)):setTimeout(r,50)}var w=this;if(b[d])r();else{var z=new Image;z.onload=function(){z.onload=null;w._resizeImageToFit(z);var B=new fabric.Image(z);k(B)};z.className="canvas-img-clone";z.src=d;if(this.shouldCacheImages)b[d]=Element.identify(z);p.body.appendChild(z)}}}(),loadSVGFromURL:function(b,d){function k(z){if(z=z.responseXML)(z=
z.documentElement)&&fabric.parseSVGDocument(z,function(B,D){w.cache.set(b,{objects:B.invoke("toObject"),options:D});d(B,D)})}function r(){fabric.log("ERROR!")}var w=this;b=b.replace(/^\n\s*/,"").replace(/\?.*$/,"").trim();this.cache.has(b,function(z){if(z)w.cache.get(b,function(B){B=w._enlivenCachedObject(B);d(B.objects,B.options)});else new Ajax.Request(b,{method:"get",onComplete:k,onFailure:r})})},_enlivenCachedObject:function(b){var d=b.objects;b=b.options;d=d.map(function(k){return fabric[h(k.type)].fromObject(k)});
return{objects:d,options:b}},remove:function(b){c(this._objects,b);this.renderAll();return b},fxRemove:function(b,d){var k=this;b.fxRemove({onChange:this.renderAll.bind(this),onComplete:function(){k.remove(b);typeof d==="function"&&d()}});return this},sendToBack:function(b){c(this._objects,b);this._objects.unshift(b);return this.renderAll()},bringToFront:function(b){c(this._objects,b);this._objects.push(b);return this.renderAll()},sendBackwards:function(b){var d=this._objects.indexOf(b),k=d;if(d!==
0){for(d=d-1;d>=0;--d)if(b.intersectsWithObject(this._objects[d])){k=d;break}c(this._objects,b);this._objects.splice(k,0,b)}return this.renderAll()},bringForward:function(b){var d=this.getObjects(),k=d.indexOf(b),r=k;if(k!==d.length-1){k=k+1;for(var w=this._objects.length;k<w;++k)if(b.intersectsWithObject(d[k])){r=k;break}c(d,b);d.splice(r,0,b)}this.renderAll()},setActiveObject:function(b){this._activeObject&&this._activeObject.setActive(false);this._activeObject=b;b.setActive(true);this.renderAll();
l("object:selected",{target:b});return this},getActiveObject:function(){return this._activeObject},removeActiveObject:function(){this._activeObject&&this._activeObject.setActive(false);this._activeObject=null;return this},setActiveGroup:function(b){this._activeGroup=b;return this},getActiveGroup:function(){return this._activeGroup},removeActiveGroup:function(){var b=this.getActiveGroup();b&&b.destroy();return this.setActiveGroup(null)},item:function(b){return this.getObjects()[b]},deactivateAll:function(){for(var b=
this.getObjects(),d=0,k=b.length;d<k;d++)b[d].setActive(false);this.removeActiveGroup();this.removeActiveObject();return this},complexity:function(){return this.getObjects().reduce(function(b,d){b+=d.complexity?d.complexity():0;return b},0)},dispose:function(){this.clear();n(this.getElement(),"mousedown",this._onMouseDown);n(p,"mouseup",this._onMouseUp);n(p,"mousemove",this._onMouseMove);n(m,"resize",this._onResize);return this},clone:function(b){var d=p.createElement("canvas");d.width=this.getWidth();
d.height=this.getHeight();var k=this.__clone||(this.__clone=new fabric.Element(d));return k.loadFromJSON(JSON.stringify(this.toJSON()),function(){b&&b(k)})},_toDataURL:function(b,d){this.clone(function(k){d(k.toDataURL(b))})},_toDataURLWithMultiplier:function(b,d,k){this.clone(function(r){k(r.toDataURLWithMultiplier(b,d))})},_resizeImageToFit:function(b){var d=b.width||b.offsetWidth,k=this.getWidth()/d;if(d)b.width=d*k},cache:{has:function(b,d){d(false)},get:function(){},set:function(){}}});fabric.Element.prototype.toString=
function(){return"#<fabric.Element ("+this.complexity()+"): { objects: "+this.getObjects().length+" }>"};f(fabric.Element,{EMPTY_JSON:'{"objects": [], "background": "white"}',toGrayscale:function(b){var d=b.getContext("2d");b=d.getImageData(0,0,b.width,b.height);var k=b.data,r=b.width,w=b.height,z,B;for(i=0;i<r;i++)for(j=0;j<w;j++){z=i*4*w+j*4;B=(k[z]+k[z+1]+k[z+2])/3;k[z]=B;k[z+1]=B;k[z+2]=B}d.putImageData(b,0,0)},supports:function(b){var d=p.createElement("canvas");typeof G_vmlCanvasManager!=="undefined"&&
G_vmlCanvasManager.initElement(d);if(!d||!d.getContext)return null;var k=d.getContext("2d");if(!k)return null;switch(b){case "getImageData":return typeof k.getImageData!=="undefined";case "toDataURL":return typeof d.toDataURL!=="undefined";default:return null}}});fabric.Element.prototype.toJSON=fabric.Element.prototype.toObject}})();
(function(){var m=this.fabric||(this.fabric={}),p=m.util.object.extend,f=m.util.object.clone,h=m.util.toFixed,o=m.util.string.capitalize,l=m.util.getPointer,g=Array.prototype.slice;if(!m.Object){m.Object=m.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,g.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(f(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:h(this.left,this.NUM_FRACTION_DIGITS),top:h(this.top,this.NUM_FRACTION_DIGITS),width:h(this.width,this.NUM_FRACTION_DIGITS),height:h(this.height,this.NUM_FRACTION_DIGITS),fill:this.fill,overlayFill:this.overlayFill,stroke:this.stroke,
strokeWidth:this.strokeWidth,scaleX:h(this.scaleX,this.NUM_FRACTION_DIGITS),scaleY:h(this.scaleY,this.NUM_FRACTION_DIGITS),angle:h(this.getAngle(),this.NUM_FRACTION_DIGITS),flipX:this.flipX,flipY:this.flipY,opacity:h(this.opacity,this.NUM_FRACTION_DIGITS)};this.includeDefaultValues||(a=this._removeDefaultValues(a));return a},toDatalessObject:function(){return this.toObject()},_removeDefaultValues:function(a){var b=l.Object.prototype.options;this.stateProperties.forEach(function(d){a[d]===b[d]&&delete a[d]});
return a},isActive:function(){return!!this.active},setActive:function(a){this.active=!!a;return this},toString:function(){return"#<fabric."+p(this.type)+">"},set:function(a,b){if((a==="scaleX"||a==="scaleY")&&b<this.MIN_SCALE_LIMIT)b=this.MIN_SCALE_LIMIT;if(a==="angle")this.setAngle(b);else this[a]=b;return this},toggle:function(a){var b=this.get(a);typeof b==="boolean"&&this.set(a,!b);return this},setSourcePath:function(a){this.sourcePath=a;return this},get:function(a){return a==="angle"?this.getAngle():
this[a]},render:function(a,b){if(!(this.width===0||this.height===0)){a.save();var d=this.transformMatrix;d&&a.setTransform(d[0],d[1],d[2],d[3],d[4],d[5]);b||this.transform(a);if(this.stroke){a.lineWidth=this.strokeWidth;a.strokeStyle=this.stroke}if(this.overlayFill)a.fillStyle=this.overlayFill;else if(this.fill)a.fillStyle=this.fill;this._render(a,b);if(this.active&&!b){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:h(this.scaleX,this.NUM_FRACTION_DIGITS),scaleY:h(this.scaleY,this.NUM_FRACTION_DIGITS),angle:h(this.getAngle(),this.NUM_FRACTION_DIGITS),flipX:this.flipX,flipY:this.flipY,opacity:h(this.opacity,this.NUM_FRACTION_DIGITS)};this.includeDefaultValues||(a=this._removeDefaultValues(a));return a},toDatalessObject:function(){return this.toObject()},_removeDefaultValues:function(a){var c=m.Object.prototype.options;this.stateProperties.forEach(function(e){a[e]===c[e]&&delete a[e]});
return a},isActive:function(){return!!this.active},setActive:function(a){this.active=!!a;return this},toString:function(){return"#<fabric."+o(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 e=this.transformMatrix;e&&a.setTransform(e[0],e[1],e[2],e[3],e[4],e[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,c);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,b=Math.sin(this._angle+this.theta)*this._hypotenuse,d=this.theta,m=Math.sin(d);d=Math.cos(d);a={x:this.left-a,y:this.top-b};b={x:a.x+this.currentWidth*d,y:a.y+this.currentWidth*m};var q={x:a.x-this.currentHeight*m,y:a.y+this.currentHeight*d};this.oCoords={tl:a,tr:b,br:{x:b.x-this.currentHeight*m,y:b.y+this.currentHeight*d},bl:q,ml:{x:a.x-this.currentHeight/
2*m,y:a.y+this.currentHeight/2*d},mt:{x:a.x+this.currentWidth/2*d,y:a.y+this.currentWidth/2*m},mr:{x:b.x-this.currentHeight/2*m,y:b.y+this.currentHeight/2*d},mb:{x:q.x+this.currentWidth/2*d,y:q.y+this.currentWidth/2*m}};this._setCornerCoords();return this},drawBorders:function(a){var b=this.options,d=b.padding,m=d*2;a.save();a.globalAlpha=this.isMoving?b.borderOpacityWhenMoving:1;a.strokeStyle=b.borderColor;b=1/(this.scaleX<this.MIN_SCALE_LIMIT?this.MIN_SCALE_LIMIT:this.scaleX);var q=1/(this.scaleY<
this.MIN_SCALE_LIMIT?this.MIN_SCALE_LIMIT:this.scaleY);a.lineWidth=1/this.borderScaleFactor;a.scale(b,q);b=this.getWidth();q=this.getHeight();a.strokeRect(~~(-(b/2)-d)+0.5,~~(-(q/2)-d)+0.5,~~(b+m),~~(q+m));a.restore();return this},drawCorners:function(a){var b=this.options.cornersize,d=b/2,m=this.options.padding,q=-(this.width/2),r=-(this.height/2),v=b/this.scaleX,w=b/this.scaleY,x=(m+d)/this.scaleY,s=(m+d)/this.scaleX,t=(m+d-b)/this.scaleX;m=(m+d-b)/this.scaleY;a.save();a.globalAlpha=this.isMoving?
this.options.borderOpacityWhenMoving:1;a.fillStyle=this.options.cornerColor;b=q-s;d=r-x;a.fillRect(b,d,v,w);b=q+this.width-s;d=r-x;a.fillRect(b,d,v,w);b=q-s;d=r+this.height+m;a.fillRect(b,d,v,w);b=q+this.width+t;d=r+this.height+m;a.fillRect(b,d,v,w);b=q+this.width/2-s;d=r-x;a.fillRect(b,d,v,w);b=q+this.width/2-s;d=r+this.height+m;a.fillRect(b,d,v,w);b=q+this.width+t;d=r+this.height/2-x;a.fillRect(b,d,v,w);b=q-s;d=r+this.height/2-x;a.fillRect(b,d,v,w);a.restore();return this},clone:function(a){if(this.constructor.fromObject)return this.constructor.fromObject(this.toObject(),
a);return new l.Object(this.toObject())},cloneAsImage:function(a){if(l.Image){var b=new Image;b.onload=function(){a&&a(new l.Image(b),d);b=b.onload=null};var d={angle:this.get("angle"),flipX:this.get("flipX"),flipY:this.get("flipY")};this.set("angle",0).set("flipX",false).set("flipY",false);b.src=this.toDataURL()}return this},toDataURL:function(){var a=document.createElement("canvas");a.width=this.getWidth();a.height=this.getHeight();l.util.wrapElement(a,"div");var b=new l.Element(a);b.backgroundColor=
"transparent";b.renderAll();var d=this.clone();d.left=a.width/2;d.top=a.height/2;d.setActive(false);b.add(d);a=b.toDataURL("png");b.dispose();return a},hasStateChanged:function(){return this.stateProperties.some(function(a){return this[a]!==this.originalState[a]},this)},saveState:function(){this.stateProperties.forEach(function(a){this.originalState[a]=this.get(a)},this);return this},intersectsWithRect:function(a,b){var d=this.oCoords,m=new l.Point(d.tl.x,d.tl.y),q=new l.Point(d.tr.x,d.tr.y),r=new l.Point(d.bl.x,
d.bl.y);d=new l.Point(d.br.x,d.br.y);return l.Intersection.intersectPolygonRectangle([m,q,d,r],a,b).status==="Intersection"},intersectsWithObject:function(a){function b(m){return{tl:new l.Point(m.tl.x,m.tl.y),tr:new l.Point(m.tr.x,m.tr.y),bl:new l.Point(m.bl.x,m.bl.y),br:new l.Point(m.br.x,m.br.y)}}var d=b(this.oCoords);a=b(a.oCoords);return l.Intersection.intersectPolygonPolygon([d.tl,d.tr,d.br,d.bl],[a.tl,a.tr,a.br,a.bl]).status==="Intersection"},isContainedWithinRect:function(a,b){var d=this.oCoords,
m=new l.Point(d.tl.x,d.tl.y),q=new l.Point(d.tr.x,d.tr.y),r=new l.Point(d.bl.x,d.bl.y);new l.Point(d.br.x,d.br.y);return m.x>a.x&&q.x<b.x&&m.y>a.y&&r.y<b.y},isType:function(a){return this.type===a},_findTargetCorner:function(a,b){var d=g(a),m=d.x-b.left;d=d.y-b.top;var q;for(var r in this.oCoords){q=this._getImageLines(this.oCoords[r].corner,r);q=this._findCrossPoints(m,d,q);if(q%2==1&&q!=0)return this.__corner=r}return false},_findCrossPoints:function(a,b,d){var m,q,r,v=0;for(var w in d){r=d[w];
if(!(r.o.y<b&&r.d.y<b))if(!(r.o.y>=b&&r.d.y>=b)){if(r.o.x==r.d.x&&r.o.x>=a)m=r.o.x;else{m=(r.d.y-r.o.y)/(r.d.x-r.o.x);q=b-0*a;r=r.o.y-m*r.o.x;m=-(q-r)/(0-m)}if(m>=a)v+=1;if(v==2)break}}return v},_getImageLines:function(a){return{topline:{o:a.tl,d:a.tr},rightline:{o:a.tr,d:a.br},bottomline:{o:a.br,d:a.bl},leftline:{o:a.bl,d:a.tl}}},_setCornerCoords:function(){var a=this.oCoords,b=this.theta,d=this.cornersize*Math.cos(b),m=this.cornersize*Math.sin(b);b=this.cornersize/2;var q=b-m;a.tl.x-=q;a.tl.y-=
b;a.tl.corner={tl:{x:a.tl.x,y:a.tl.y},tr:{x:a.tl.x+d,y:a.tl.y+m},bl:{x:a.tl.x-m,y:a.tl.y+d}};a.tl.corner.br={x:a.tl.corner.tr.x-m,y:a.tl.corner.tr.y+d};a.tl.x+=q;a.tl.y+=b;a.tr.x+=b;a.tr.y-=b;a.tr.corner={tl:{x:a.tr.x-d,y:a.tr.y-m},tr:{x:a.tr.x,y:a.tr.y},br:{x:a.tr.x-m,y:a.tr.y+d}};a.tr.corner.bl={x:a.tr.corner.tl.x-m,y:a.tr.corner.tl.y+d};a.tr.x-=b;a.tr.y+=b;a.bl.x-=b;a.bl.y+=b;a.bl.corner={tl:{x:a.bl.x+m,y:a.bl.y-d},bl:{x:a.bl.x,y:a.bl.y},br:{x:a.bl.x+d,y:a.bl.y+m}};a.bl.corner.tr={x:a.bl.corner.br.x+
m,y:a.bl.corner.br.y-d};a.bl.x+=b;a.bl.y-=b;a.br.x+=b;a.br.y+=b;a.br.corner={tr:{x:a.br.x+m,y:a.br.y-d},bl:{x:a.br.x-d,y:a.br.y-m},br:{x:a.br.x,y:a.br.y}};a.br.corner.tl={x:a.br.corner.bl.x+m,y:a.br.corner.bl.y-d};a.br.x-=b;a.br.y-=b;a.ml.x-=b;a.ml.y-=b;a.ml.corner={tl:{x:a.ml.x,y:a.ml.y},tr:{x:a.ml.x+d,y:a.ml.y+m},bl:{x:a.ml.x-m,y:a.ml.y+d}};a.ml.corner.br={x:a.ml.corner.tr.x-m,y:a.ml.corner.tr.y+d};a.ml.x+=b;a.ml.y+=b;a.mt.x-=b;a.mt.y-=b;a.mt.corner={tl:{x:a.mt.x,y:a.mt.y},tr:{x:a.mt.x+d,y:a.mt.y+
m},bl:{x:a.mt.x-m,y:a.mt.y+d}};a.mt.corner.br={x:a.mt.corner.tr.x-m,y:a.mt.corner.tr.y+d};a.mt.x+=b;a.mt.y+=b;a.mr.x-=b;a.mr.y-=b;a.mr.corner={tl:{x:a.mr.x,y:a.mr.y},tr:{x:a.mr.x+d,y:a.mr.y+m},bl:{x:a.mr.x-m,y:a.mr.y+d}};a.mr.corner.br={x:a.mr.corner.tr.x-m,y:a.mr.corner.tr.y+d};a.mr.x+=b;a.mr.y+=b;a.mb.x-=b;a.mb.y-=b;a.mb.corner={tl:{x:a.mb.x,y:a.mb.y},tr:{x:a.mb.x+d,y:a.mb.y+m},bl:{x:a.mb.x-m,y:a.mb.y+d}};a.mb.corner.br={x:a.mb.corner.tr.x-m,y:a.mb.corner.tr.y+d};a.mb.x+=b;a.mb.y+=b;a=a.mb.corner;
a.tl.x-=b;a.tl.y-=b;a.tr.x-=b;a.tr.y-=b;a.br.x-=b;a.br.y-=b;a.bl.x-=b;a.bl.y-=b},toGrayscale:function(){var a=this.get("fill");a&&this.set("overlayFill",(new l.Color(a)).toGrayscale().toRgb());return this},complexity:function(){return 0},getCenter:function(){return{x:this.get("left")+this.width/2,y:this.get("top")+this.height/2}},straighten:function(){this.setAngle(this._getAngleValueForStraighten());return this},fxStraighten:function(a){a=a||{};var b=function(){},d=a.onComplete||b,m=a.onChange||
b,q=this;l.util.animate({startValue:this.get("angle"),endValue:this._getAngleValueForStraighten(),duration:this.FX_DURATION,onChange:function(r){q.setAngle(r);m()},onComplete:function(){q.setCoords();d()},onStart:function(){q.setActive(false)}});return this},fxRemove:function(a){a||(a={});var b=function(){},d=a.onComplete||b,m=a.onChange||b,q=this;l.util.animate({startValue:this.get("opacity"),endValue:0,duration:this.FX_DURATION,onChange:function(r){q.set("opacity",r);m()},onComplete:d,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()}});l.Object.prototype.rotate=l.Object.prototype.setAngle}})();
(function(){var l=this.fabric||(this.fabric={}),n=l.util.object.extend;if(l.Line)l.warn("fabric.Line is already defined");else{l.Line=l.util.createClass(l.Object,{type:"line",initialize:function(c,h){c||(c=[0,0,0,0]);this.callSuper("initialize",h);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 h=c.strokeStyle;c.strokeStyle=c.fillStyle;c.stroke();c.strokeStyle=h},complexity:function(){return 1},toObject:function(){return n(this.callSuper("toObject"),{x1:this.get("x1"),y1:this.get("y1"),x2:this.get("x2"),y2:this.get("y2")})}});l.Element.ATTRIBUTE_NAMES="x1 y1 x2 y2 stroke stroke-width transform".split(" ");l.Line.fromElement=function(c,h){var p=l.parseAttributes(c,l.Element.ATTRIBUTE_NAMES);return new l.Line([p.x1||
0,p.y1||0,p.x2||0,p.y2||0],n(p,h))};l.Line.fromObject=function(c){return new l.Line([c.x1,c.y1,c.x2,c.y2],c)}}})();
(function(){var l=this.fabric||(this.fabric={}),n=Math.PI*2,c=l.util.object.extend;if(l.Circle)l.warn("fabric.Circle is already defined.");else{l.Circle=l.util.createClass(l.Object,{type:"circle",initialize:function(h){h=h||{};this.set("radius",h.radius||0);this.callSuper("initialize",h);h=this.get("radius")*2*this.get("scaleX");this.set("width",h).set("height",h)},toObject:function(){return c(this.callSuper("toObject"),{radius:this.get("radius")})},_render:function(h,p){h.beginPath();h.arc(p?this.left:
0,p?this.top:0,this.radius,0,n,false);h.closePath();this.fill&&h.fill();this.stroke&&h.stroke()},complexity:function(){return 1}});l.Circle.ATTRIBUTE_NAMES="cx cy r fill fill-opacity stroke stroke-width transform".split(" ");l.Circle.fromElement=function(h,p){p||(p={});var g=l.parseAttributes(h,l.Circle.ATTRIBUTE_NAMES);if(!("radius"in g&&g.radius>0))throw Error("value of `r` attribute is required and can not be negative");if("left"in g)g.left-=p.width/2||0;if("top"in g)g.top-=p.height/2||0;return new l.Circle(c(g,
p))};l.Circle.fromObject=function(h){return new l.Circle(h)}}})();
(function(){var l=this.fabric||(this.fabric={});if(l.Triangle)l.warn("fabric.Triangle is already defined");else{l.Triangle=l.util.createClass(l.Object,{type:"triangle",initialize:function(n){n=n||{};this.callSuper("initialize",n);this.set("width",n.width||100).set("height",n.height||100)},_render:function(n){var c=this.width/2,h=this.height/2;n.beginPath();n.moveTo(-c,h);n.lineTo(0,-h);n.lineTo(c,h);n.closePath();this.fill&&n.fill();this.stroke&&n.stroke()},complexity:function(){return 1}});l.Triangle.fromObject=
function(n){return new l.Triangle(n)}}})();
(function(){var l=this.fabric||(this.fabric={}),n=Math.PI*2,c=l.util.object.extend;if(l.Ellipse)l.warn("fabric.Ellipse is already defined.");else{l.Ellipse=l.util.createClass(l.Object,{type:"ellipse",initialize:function(h){h=h||{};this.callSuper("initialize",h);this.set("rx",h.rx||0);this.set("ry",h.ry||0);this.set("width",this.get("rx")*2);this.set("height",this.get("ry")*2)},toObject:function(){return c(this.callSuper("toObject"),{rx:this.get("rx"),ry:this.get("ry")})},render:function(h,p){if(!(this.rx===
0||this.ry===0))return this.callSuper("render",h,p)},_render:function(h,p){h.beginPath();h.save();h.transform(1,0,0,this.ry/this.rx,0,0);h.arc(p?this.left:0,p?this.top:0,this.rx,0,n,false);h.restore();this.stroke&&h.stroke();this.fill&&h.fill()},complexity:function(){return 1}});l.Ellipse.ATTRIBUTE_NAMES="cx cy rx ry fill fill-opacity stroke stroke-width transform".split(" ");l.Ellipse.fromElement=function(h,p){p||(p={});var g=l.parseAttributes(h,l.Ellipse.ATTRIBUTE_NAMES);if("left"in g)g.left-=p.width/
2||0;if("top"in g)g.top-=p.height/2||0;return new l.Ellipse(c(g,p))};l.Ellipse.fromObject=function(h){return new l.Ellipse(h)}}})();
(function(){var l=this.fabric||(this.fabric={});if(l.Rect)console.warn("fabric.Rect is already defined");else{l.Rect=l.util.createClass(l.Object,{type:"rect",options:{rx:0,ry:0},initialize:function(n){this.callSuper("initialize",n);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(n){var c=this.options.rx||0,h=this.options.ry||0,p=-this.width/2,g=-this.height/
2,f=this.width,a=this.height;n.beginPath();n.moveTo(p+c,g);n.lineTo(p+f-c,g);n.bezierCurveTo(p+f,g,p+f,g+h,p+f,g+h);n.lineTo(p+f,g+a-h);n.bezierCurveTo(p+f,g+a,p+f-c,g+a,p+f-c,g+a);n.lineTo(p+c,g+a);n.bezierCurveTo(p,g+a,p,g+a-h,p,g+a-h);n.lineTo(p,g+h);n.bezierCurveTo(p,g,p+c,g,p+c,g);n.closePath();this.fill&&n.fill();this.stroke&&n.stroke()},_normalizeLeftTopProperties:function(n){n.left&&this.set("left",n.left+this.getWidth()/2);n.top&&this.set("top",n.top+this.getHeight()/2);return this},complexity:function(){return 1}});
l.Rect.ATTRIBUTE_NAMES="x y width height rx ry fill fill-opacity stroke stroke-width transform".split(" ");l.Rect.fromElement=function(n,c){if(!n)return null;var h=l.parseAttributes(n,l.Rect.ATTRIBUTE_NAMES);h=h;h.left=h.left||0;h.top=h.top||0;h=h;var p=new l.Rect(l.util.object.extend(c||{},h));p._normalizeLeftTopProperties(h);return p};l.Rect.fromObject=function(n){return new l.Rect(n)}}})();
(function(){var l=this.fabric||(this.fabric={});if(l.Polyline)l.warn("fabric.Polyline is already defined");else{l.Polyline=l.util.createClass(l.Object,{type:"polyline",initialize:function(c,h){h=h||{};this.set("points",c);this.callSuper("initialize",h);this._calcDimensions()},_calcDimensions:function(){return l.Polygon.prototype._calcDimensions.call(this)},toObject:function(){return l.Polygon.prototype.toObject.call(this)},_render:function(c){var h;c.beginPath();for(var p=0,g=this.points.length;p<
g;p++){h=this.points[p];c.lineTo(h.x,h.y)}this.fill&&c.fill();this.stroke&&c.stroke()},complexity:function(){return this.get("points").length}});var n="fill fill-opacity stroke stroke-width transform".split(" ");l.Polyline.fromElement=function(c,h){if(!c)return null;h||(h={});for(var p=l.parsePointsAttribute(c.getAttribute("points")),g=l.parseAttributes(c,n),f=0,a=p.length;f<a;f++){p[f].x-=h.width/2||0;p[f].y-=h.height/2||0}return new l.Polyline(p,l.util.object.extend(g,h))};l.Polyline.fromObject=
function(c){return new l.Polyline(c.points,c)}}})();
(function(){var l=this.fabric||(this.fabric={}),n=l.util.object.extend,c=l.util.array.min,h=l.util.array.max;if(l.Polygon)l.warn("fabric.Polygon is already defined");else{l.Polygon=l.util.createClass(l.Object,{type:"polygon",initialize:function(p,g){g=g||{};this.points=p;this.callSuper("initialize",g);this._calcDimensions()},_calcDimensions:function(){var p=this.points,g=c(p,"x"),f=c(p,"y"),a=h(p,"x");p=h(p,"y");this.width=a-g;this.height=p-f;this.minX=g;this.minY=f},toObject:function(){return n(this.callSuper("toObject"),
{points:this.points.concat()})},_render:function(p){var g;p.beginPath();for(var f=0,a=this.points.length;f<a;f++){g=this.points[f];p.lineTo(g.x,g.y)}this.fill&&p.fill();if(this.stroke){p.closePath();p.stroke()}},complexity:function(){return this.points.length}});l.Polygon.ATTRIBUTE_NAMES="fill fill-opacity stroke stroke-width transform".split(" ");l.Polygon.fromElement=function(p,g){if(!p)return null;g||(g={});for(var f=l.parsePointsAttribute(p.getAttribute("points")),a=l.parseAttributes(p,l.Polygon.ATTRIBUTE_NAMES),
b=0,d=f.length;b<d;b++){f[b].x-=g.width/2||0;f[b].y-=g.height/2||0}return new l.Polygon(f,n(a,g))};l.Polygon.fromObject=function(p){return new l.Polygon(p.points,p)}}})();
(function(){function l(a){if(a[0]==="H")return a[1];return a[a.length-2]}function n(a){if(a[0]==="V")return a[1];return a[a.length-1]}var c=this.fabric||(this.fabric={}),h=c.util.array.min,p=c.util.array.max,g=c.util.object.extend;if(c.Path)c.warn("fabric.Path is already defined");else if(c.Object){c.Path=c.util.createClass(c.Object,{type:"path",initialize:function(a,b){b=b||{};this.setOptions(b);this._importProperties();this.originalState={};if(!a)throw Error("`path` argument is required");var d=
Object.prototype.toString.call(a)==="[object Array]";if(this.path=d?a:a.match&&a.match(/[a-zA-Z][^a-zA-Z]*/g)){d||this._initializeFromArray(b);this.setCoords();b.sourcePath&&this.setSourcePath(b.sourcePath)}},_initializeFromArray:function(a){var b="width"in a;a="height"in a;this.path=this._parsePath();if(!b||!a){g(this,this._parseDimensions());if(b)this.width=this.options.width;if(a)this.height=this.options.height}},_render:function(a){for(var b,d=0,m=0,q=0,r=0,v,w,x=-(this.width/2),s=-(this.height/
2),t=0,B=this.path.length;t<B;++t){b=this.path[t];switch(b[0]){case "l":d+=b[1];m+=b[2];a.lineTo(d+x,m+s);break;case "L":d=b[1];m=b[2];a.lineTo(d+x,m+s);break;case "h":d+=b[1];a.lineTo(d+x,m+s);break;case "H":d=b[1];a.lineTo(d+x,m+s);break;case "v":m+=b[1];a.lineTo(d+x,m+s);break;case "V":m=b[1];a.lineTo(d+x,m+s);break;case "m":d+=b[1];m+=b[2];a.moveTo(d+x,m+s);break;case "M":d=b[1];m=b[2];a.moveTo(d+x,m+s);break;case "c":v=d+b[5];w=m+b[6];q=d+b[3];r=m+b[4];a.bezierCurveTo(d+b[1]+x,m+b[2]+s,q+x,r+
s,v+x,w+s);d=v;m=w;break;case "C":d=b[5];m=b[6];q=b[3];r=b[4];a.bezierCurveTo(b[1]+x,b[2]+s,q+x,r+s,d+x,m+s);break;case "s":v=d+b[3];w=m+b[4];q=2*d-q;r=2*m-r;a.bezierCurveTo(q+x,r+s,d+b[1]+x,m+b[2]+s,v+x,w+s);d=v;m=w;break;case "S":v=b[3];w=b[4];q=2*d-q;r=2*m-r;a.bezierCurveTo(q+x,r+s,b[1]+x,b[2]+s,v+x,w+s);d=v;m=w;break;case "q":d+=b[3];m+=b[4];a.quadraticCurveTo(b[1]+x,b[2]+s,d+x,m+s);break;case "Q":d=b[3];m=b[4];q=b[1];r=b[2];a.quadraticCurveTo(q+x,r+s,d+x,m+s);break;case "T":v=d;w=m;d=b[1];m=
b[2];q=-q+2*v;r=-r+2*w;a.quadraticCurveTo(q+x,r+s,d+x,m+s);break;case "a":break;case "A":break;case "z":case "Z":a.closePath();break}}},render:function(a,b){a.save();var d=this.transformMatrix;d&&a.transform(d[0],d[1],d[2],d[3],d[4],d[5]);b||this.transform(a);if(this.overlayFill)a.fillStyle=this.overlayFill;else if(this.fill)a.fillStyle=this.fill;if(this.stroke)a.strokeStyle=this.stroke;a.beginPath();this._render(a);this.fill&&a.fill();if(this.stroke){a.strokeStyle=this.stroke;a.lineWidth=this.strokeWidth;
a.lineCap=a.lineJoin="round";a.stroke()}if(!b&&this.active){this.drawBorders(a);this.hideCorners||this.drawCorners(a)}a.restore()},toString:function(){return"#<fabric.Path ("+this.complexity()+"): "+JSON.stringify({top:this.top,left:this.left})+">"},toObject:function(){var a=g(this.callSuper("toObject"),{path:this.path});if(this.sourcePath)a.sourcePath=this.sourcePath;if(this.transformMatrix)a.transformMatrix=this.transformMatrix;return a},toDatalessObject:function(){var a=this.toObject();if(this.sourcePath)a.path=
this.sourcePath;delete a.sourcePath;return a},complexity:function(){return this.path.length},set:function(a,b){return this.callSuper("set",a,b)},_parsePath:function(){for(var a=[],b,d,m=0,q=this.path.length;m<q;m++){b=this.path[m];d=b.slice(1).trim().replace(/(\d)-/g,"$1###-").split(/\s|,|###/);a.push([b.charAt(0)].concat(d.map(parseFloat)))}return a},_parseDimensions:function(){var a=[],b=[],d,m,q=false,r,v;this.path.forEach(function(t,B){if(t[0]!=="H")d=B===0?l(t):l(this.path[B-1]);if(t[0]!=="V")m=
B===0?n(t):n(this.path[B-1]);if(t[0]===t[0].toLowerCase())q=true;r=q?d+l(t):t[0]==="V"?d:l(t);v=q?m+n(t):t[0]==="H"?m:n(t);var A=parseInt(r,10);isNaN(A)||a.push(A);A=parseInt(v,10);isNaN(A)||b.push(A)},this);var w=h(a),x=h(b),s=deltaY=0;w={top:x-deltaY,left:w-s,bottom:p(b)-deltaY,right:p(a)-s};w.width=w.right-w.left;w.height=w.bottom-w.top;return w}});c.Path.fromObject=function(a){return new c.Path(a.path,a)};var f=c.Path.ATTRIBUTE_NAMES="d fill fill-opacity fill-rule stroke stroke-width transform".split(" ");
c.Path.fromElement=function(a,b){var d=c.parseAttributes(a,f),m=d.d;delete d.d;return new c.Path(m,g(d,b))}}else c.warn("fabric.Path requires fabric.Object")})();
(function(){var l=this.fabric||(this.fabric={}),n=l.util.object.extend,c=l.util.array.invoke,h=l.Object.prototype.set,p=l.Object.prototype.toObject,g=l.util.string.camelize,f=l.util.string.capitalize;if(l.PathGroup)l.warn("fabric.PathGroup is already defined");else{l.PathGroup=l.util.createClass(l.Path,{type:"path-group",forceFillOverwrite:false,initialize:function(a,b){b=b||{};this.originalState={};this.paths=a;this.setOptions(b);this.initProperties();this.setCoords();b.sourcePath&&this.setSourcePath(b.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 b=this.transformMatrix;b&&a.transform(b[0],b[1],b[2],b[3],b[4],b[5]);this.transform(a);b=0;for(var d=this.paths.length;b<d;++b)this.paths[b].render(a,
true);if(this.active){this.drawBorders(a);this.hideCorners||this.drawCorners(a)}}a.restore()},set:function(a,b){if((a==="fill"||a==="overlayFill")&&this.isSameColor()){this[a]=b;for(var d=this.paths.length;d--;)this.paths[d].set(a,b)}else h.call(this,a,b);return this},toObject:function(){return n(p.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(b){return b.get("fill")===a})},complexity:function(){return this.paths.reduce(function(a,b){return a+(b&&b.complexity?b.complexity():0)},0)},toGrayscale:function(){for(var a=this.paths.length;a--;)this.paths[a].toGrayscale();return this},getObjects:function(){return this.paths}});l.PathGroup.fromObject=function(a){for(var b=a.paths,
d=0,m=b.length;d<m;d++)if(!(b[d]instanceof l.Object)){var q=g(f(b[d].type));b[d]=l[q].fromObject(b[d])}return new l.PathGroup(b,a)}}})();
(function(){var l=this.fabric||(this.fabric={}),n=l.util.object.extend,c=l.util.array.min,h=l.util.array.max,p=l.util.array.invoke,g=l.util.removeFromArray;if(!l.Group){l.Group=l.util.createClass(l.Object,{type:"group",initialize:function(f,a){this.objects=f||[];this.originalState={};this.callSuper("initialize");this._calcBounds();this._updateObjectsCoords();a&&n(this,a);this._setOpacityIfSame();this.setCoords(true);this.saveCoords();this.activateAllObjects()},_updateObjectsCoords:function(){var f=
this.left,a=this.top;this.forEachObject(function(b){var d=b.get("left"),m=b.get("top");b.set("originalLeft",d);b.set("originalTop",m);b.set("left",d-f);b.set("top",m-a);b.setCoords();b.hideCorners=true},this)},toString:function(){return"#<fabric.Group: ("+this.complexity()+")>"},getObjects:function(){return this.objects},add:function(f){this._restoreObjectsState();this.objects.push(f);f.setActive(true);this._calcBounds();this._updateObjectsCoords();return this},remove:function(f){this._restoreObjectsState();
g(this.objects,f);f.setActive(false);this._calcBounds();this._updateObjectsCoords();return this},size:function(){return this.getObjects().length},set:function(f,a){if(typeof a=="function")this.set(f,a(this[f]));else if(f==="fill"||f==="opacity"){var b=this.objects.length;for(this[f]=a;b--;)this.objects[b].set(f,a)}else this[f]=a;return this},contains:function(f){return this.objects.indexOf(f)>-1},toObject:function(){return n(this.callSuper("toObject"),{objects:p(this.objects,"clone")})},render:function(f){f.save();
this.transform(f);for(var a=Math.max(this.scaleX,this.scaleY),b=0,d;d=this.objects[b];b++){var m=d.borderScaleFactor;d.borderScaleFactor=a;d.render(f);d.borderScaleFactor=m}this.hideBorders||this.drawBorders(f);this.hideCorners||this.drawCorners(f);f.restore();this.setCoords()},item:function(f){return this.getObjects()[f]},complexity:function(){return this.getObjects().reduce(function(f,a){f+=typeof a.complexity=="function"?a.complexity():0;return f},0)},_restoreObjectsState:function(){this.objects.forEach(this._restoreObjectState,
this);return this},_restoreObjectState:function(f){var a=this.get("left"),b=this.get("top"),d=this.getAngle()*(Math.PI/180);f.get("originalLeft");f.get("originalTop");var m=Math.cos(d)*f.get("top")+Math.sin(d)*f.get("left");d=-Math.sin(d)*f.get("top")+Math.cos(d)*f.get("left");f.setAngle(f.getAngle()+this.getAngle());f.set("left",a+d*this.get("scaleX"));f.set("top",b+m*this.get("scaleY"));f.set("scaleX",f.get("scaleX")*this.get("scaleX"));f.set("scaleY",f.get("scaleY")*this.get("scaleY"));f.setCoords();
f.hideCorners=false;f.setActive(false);f.setCoords();return this},destroy:function(){return this._restoreObjectsState()},saveCoords:function(){this._originalLeft=this.get("left");this._originalTop=this.get("top");return this},hasMoved:function(){return this._originalLeft!==this.get("left")||this._originalTop!==this.get("top")},setObjectsCoords:function(){this.forEachObject(function(f){f.setCoords()});return this},activateAllObjects:function(){return this.setActive(true)},setActive:function(f){this.forEachObject(function(a){a.setActive(f)});
return this},forEachObject:function(f,a){for(var b=this.getObjects(),d=b.length;d--;)f.call(a,b[d],d,b);return this},_setOpacityIfSame:function(){var f=this.getObjects(),a=f[0]?f[0].get("opacity"):1;if(f.every(function(b){return b.get("opacity")===a}))this.opacity=a},_calcBounds:function(){var f=[],a=[],b,d;d=0;for(var m=this.objects.length;d<m;++d){b=this.objects[d];b.setCoords();for(var q in b.oCoords){f.push(b.oCoords[q].x);a.push(b.oCoords[q].y)}}b=c(f);d=h(f);f=c(a);a=h(a);d=d-b;a=a-f;this.width=
d;this.height=a;this.left=b+d/2;this.top=f+a/2},containsPoint:function(f){var a=this.get("width")/2,b=this.get("height")/2,d=this.get("left"),m=this.get("top");return d-a<f.x&&d+a>f.x&&m-b<f.y&&m+b>f.y},toGrayscale:function(){for(var f=this.objects.length;f--;)this.objects[f].toGrayscale()}});l.Group.fromObject=function(f){return new l.Group(f.objects,f)}}})();
(function(){var l=this.fabric||(this.fabric={}),n=l.util.object.extend,c=l.util.object.clone;if(l.Text)l.warn("fabric.Text is already defined");else if(l.Object){l.Text=l.util.createClass(l.Object,{options:{top:10,left:10,fontsize:20,fontweight:100,fontfamily:"Modernist_One_400",path:null},type:"text",initialize:function(h,p){this.originalState={};this.initStateProperties();this.text=h;this.setOptions(p);n(this,this.options);this.theta=this.angle*(Math.PI/180);this.width=this.getWidth();this.setCoords()},
initStateProperties:function(){var h;if((h=this.constructor)&&(h=h.superclass)&&(h=h.prototype)&&(h=h.stateProperties)&&h.clone){this.stateProperties=h.clone();this.stateProperties.push("fontfamily","fontweight","path")}},toString:function(){return"#<fabric.Text ("+this.complexity()+"): "+JSON.stringify({text:this.text,fontfamily:this.fontfamily})+">"},_render:function(h){var p=Cufon.textOptions||(Cufon.textOptions={});p.left=this.left;p.top=this.top;p.context=h;p.color=this.fill;var g=this._initDummyElement();
this.transform(h);Cufon.replaceElement(g,{separate:"none",fontFamily:this.fontfamily});this.width=p.width;this.height=p.height},_initDummyElement:function(){var h=document.createElement("div");h.innerHTML=this.text;h.style.fontSize="40px";h.style.fontWeight="400";h.style.fontStyle="normal";h.style.letterSpacing="normal";h.style.color="#000000";h.style.fontWeight="600";h.style.fontFamily="Verdana";return h},render:function(h){h.save();this._render(h);if(this.active){this.drawBorders(h);this.drawCorners(h)}h.restore()},
toObject:function(){return n(this.callSuper("toObject"),{text:this.text,fontsize:this.fontsize,fontweight:this.fontweight,fontfamily:this.fontfamily,path:this.path})},setColor:function(h){this.set("fill",h);return this},setFontsize:function(h){this.set("fontsize",h);this.setCoords();return this},getText:function(){return this.text},setText:function(h){this.set("text",h);this.setCoords();return this},set:function(h,p){this[h]=p;if(h==="fontfamily")this.path=this.path.replace(/(.*?)([^\/]*)(\.font\.js)/,
"$1"+p+"$3");return this}});l.Text.fromObject=function(h){return new l.Text(h.text,c(h))};l.Text.fromElement=function(){}}else l.warn("fabric.Text requires fabric.Object")})();
(function(){var l=fabric.util.object.extend;if(!this.fabric)this.fabric={};if(this.fabric.Image)fabric.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(n,c){this.callSuper("initialize",c);this._initElement(n);this._initConfig(c||{})},getElement:function(){return this._element},setElement:function(n){this._element=
n;return this},getNormalizedSize:function(n,c,h){if(h&&c&&n.width>n.height&&n.width/n.height<c/h){normalizedWidth=~~(n.width*h/n.height);normalizedHeight=h}else if(h&&(n.height==n.width||n.height>n.width||n.height>h)){normalizedWidth=~~(n.width*h/n.height);normalizedHeight=h}else if(c&&c<n.width){normalizedHeight=~~(n.height*c/n.width);normalizedWidth=c}else{normalizedWidth=n.width;normalizedHeight=n.height}return{width:normalizedWidth,height:normalizedHeight}},getOriginalSize:function(){var n=this.getElement();
return{width:n.width,height:n.height}},setBorderVisibility:function(){this._resetWidthHeight();this._adjustWidthHeightToBorders(showBorder);this.setCoords()},setCornersVisibility:function(n){this.cornervisibility=!!n},render:function(n,c){n.save();c||this.transform(n);this._render(n);if(this.active&&!c){this.drawBorders(n);this.hideCorners||this.drawCorners(n)}n.restore()},toObject:function(){return l(this.callSuper("toObject"),{src:this.getSrc()})},getSrc:function(){return this.getElement().src},
toString:function(){return'#<fabric.Image: { src: "'+this.getSrc()+'" }>'},clone:function(n){this.constructor.fromObject(this.toObject(),n)},toGrayscale:function(n){if(!this.__isGrayscaled){var c=this.getElement(),h=document.createElement("canvas"),p=document.createElement("img"),g=this;h.width=c.width;h.height=c.height;h.getContext("2d").drawImage(c,0,0);fabric.Element.toGrayscale(h);p.onload=function(){g.setElement(p);n&&n();p.onload=h=c=imageData=null};p.width=c.width;p.height=c.height;p.src=h.toDataURL("image/png");
this.__isGrayscaled=true;return this}},_render:function(n){var c=this.getOriginalSize();n.drawImage(this.getElement(),-c.width/2,-c.height/2,c.width,c.height)},_adjustWidthHeightToBorders:function(n){if(n){this.currentBorder=this.borderwidth;this.width+=2*this.currentBorder;this.height+=2*this.currentBorder}else this.currentBorder=0},_resetWidthHeight:function(){var n=this.getElement();this.set("width",n.width);this.set("height",n.height)},_initElement:function(n){this.setElement(fabric.util.getById(n));
fabric.util.addClass(this.getElement(),fabric.Image.CSS_CANVAS)},_initConfig:function(n){this.setOptions(n);this._setBorder();this._setWidthHeight(n)},_setBorder:function(){this.currentBorder=this.bordervisibility?this.borderwidth:0},_setWidthHeight:function(){var n=2*this.currentBorder;this.width=(this.getElement().width||0)+n;this.height=(this.getElement().height||0)+n},complexity:function(){return 1}});fabric.Image.CSS_CANVAS="canvas-img";fabric.Image.fromObject=function(n,c){var h=document.createElement("img"),
p=n.src;if(n.width)h.width=n.width;if(n.height)h.height=n.height;h.onload=function(){c&&c(new fabric.Image(h,n));h=h.onload=null};h.src=p};fabric.Image.fromURL=function(n,c,h){var p=document.createElement("img");p.onload=function(){c&&c(new fabric.Image(p,h));p=p.onload=null};p.src=n}}else fabric.warn("fabric.Object is required for fabric.Image initialization")})();
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,e=this.theta,n=Math.sin(e);e=Math.cos(e);a={x:this.left-a,y:this.top-c};c={x:a.x+this.currentWidth*e,y:a.y+this.currentWidth*n};var q={x:a.x-this.currentHeight*n,y:a.y+this.currentHeight*e};this.oCoords={tl:a,tr:c,br:{x:c.x-this.currentHeight*n,y:c.y+this.currentHeight*e},bl:q,ml:{x:a.x-this.currentHeight/
2*n,y:a.y+this.currentHeight/2*e},mt:{x:a.x+this.currentWidth/2*e,y:a.y+this.currentWidth/2*n},mr:{x:c.x-this.currentHeight/2*n,y:c.y+this.currentHeight/2*e},mb:{x:q.x+this.currentWidth/2*e,y:q.y+this.currentWidth/2*n}};this._setCornerCoords();return this},drawBorders:function(a){var c=this.options,e=c.padding,n=e*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)-e)+0.5,~~(-(q/2)-e)+0.5,~~(c+n),~~(q+n));a.restore();return this},drawCorners:function(a){var c=this.options.cornersize,e=c/2,n=this.options.padding,q=-(this.width/2),s=-(this.height/2),x=c/this.scaleX,y=c/this.scaleY,A=(n+e)/this.scaleY,u=(n+e)/this.scaleX,v=(n+e-c)/this.scaleX;n=(n+e-c)/this.scaleY;a.save();a.globalAlpha=this.isMoving?
this.options.borderOpacityWhenMoving:1;a.fillStyle=this.options.cornerColor;c=q-u;e=s-A;a.fillRect(c,e,x,y);c=q+this.width-u;e=s-A;a.fillRect(c,e,x,y);c=q-u;e=s+this.height+n;a.fillRect(c,e,x,y);c=q+this.width+v;e=s+this.height+n;a.fillRect(c,e,x,y);c=q+this.width/2-u;e=s-A;a.fillRect(c,e,x,y);c=q+this.width/2-u;e=s+this.height+n;a.fillRect(c,e,x,y);c=q+this.width+v;e=s+this.height/2-A;a.fillRect(c,e,x,y);c=q-u;e=s+this.height/2-A;a.fillRect(c,e,x,y);a.restore();return this},clone:function(a){if(this.constructor.fromObject)return this.constructor.fromObject(this.toObject(),
a);return new m.Object(this.toObject())},cloneAsImage:function(a){if(m.Image){var c=new Image;c.onload=function(){a&&a(new m.Image(c),e);c=c.onload=null};var e={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();m.util.wrapElement(a,"div");var c=new m.Element(a);c.backgroundColor=
"transparent";c.renderAll();var e=this.clone();e.left=a.width/2;e.top=a.height/2;e.setActive(false);c.add(e);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 e=this.oCoords,n=new m.Point(e.tl.x,e.tl.y),q=new m.Point(e.tr.x,e.tr.y),s=new m.Point(e.bl.x,
e.bl.y);e=new m.Point(e.br.x,e.br.y);return m.Intersection.intersectPolygonRectangle([n,q,e,s],a,c).status==="Intersection"},intersectsWithObject:function(a){function c(n){return{tl:new m.Point(n.tl.x,n.tl.y),tr:new m.Point(n.tr.x,n.tr.y),bl:new m.Point(n.bl.x,n.bl.y),br:new m.Point(n.br.x,n.br.y)}}var e=c(this.oCoords);a=c(a.oCoords);return m.Intersection.intersectPolygonPolygon([e.tl,e.tr,e.br,e.bl],[a.tl,a.tr,a.br,a.bl]).status==="Intersection"},isContainedWithinRect:function(a,c){var e=this.oCoords,
n=new m.Point(e.tl.x,e.tl.y),q=new m.Point(e.tr.x,e.tr.y),s=new m.Point(e.bl.x,e.bl.y);new m.Point(e.br.x,e.br.y);return n.x>a.x&&q.x<c.x&&n.y>a.y&&s.y<c.y},isType:function(a){return this.type===a},_findTargetCorner:function(a,c){var e=l(a),n=e.x-c.left;e=e.y-c.top;var q;for(var s in this.oCoords){q=this._getImageLines(this.oCoords[s].corner,s);q=this._findCrossPoints(n,e,q);if(q%2==1&&q!=0)return this.__corner=s}return false},_findCrossPoints:function(a,c,e){var n,q,s,x=0;for(var y in e){s=e[y];
if(!(s.o.y<c&&s.d.y<c))if(!(s.o.y>=c&&s.d.y>=c)){if(s.o.x==s.d.x&&s.o.x>=a)n=s.o.x;else{n=(s.d.y-s.o.y)/(s.d.x-s.o.x);q=c-0*a;s=s.o.y-n*s.o.x;n=-(q-s)/(0-n)}if(n>=a)x+=1;if(x==2)break}}return x},_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,e=this.cornersize*Math.cos(c),n=this.cornersize*Math.sin(c);c=this.cornersize/2;var q=c-n;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+e,y:a.tl.y+n},bl:{x:a.tl.x-n,y:a.tl.y+e}};a.tl.corner.br={x:a.tl.corner.tr.x-n,y:a.tl.corner.tr.y+e};a.tl.x+=q;a.tl.y+=c;a.tr.x+=c;a.tr.y-=c;a.tr.corner={tl:{x:a.tr.x-e,y:a.tr.y-n},tr:{x:a.tr.x,y:a.tr.y},br:{x:a.tr.x-n,y:a.tr.y+e}};a.tr.corner.bl={x:a.tr.corner.tl.x-n,y:a.tr.corner.tl.y+e};a.tr.x-=c;a.tr.y+=c;a.bl.x-=c;a.bl.y+=c;a.bl.corner={tl:{x:a.bl.x+n,y:a.bl.y-e},bl:{x:a.bl.x,y:a.bl.y},br:{x:a.bl.x+e,y:a.bl.y+n}};a.bl.corner.tr={x:a.bl.corner.br.x+
n,y:a.bl.corner.br.y-e};a.bl.x+=c;a.bl.y-=c;a.br.x+=c;a.br.y+=c;a.br.corner={tr:{x:a.br.x+n,y:a.br.y-e},bl:{x:a.br.x-e,y:a.br.y-n},br:{x:a.br.x,y:a.br.y}};a.br.corner.tl={x:a.br.corner.bl.x+n,y:a.br.corner.bl.y-e};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+e,y:a.ml.y+n},bl:{x:a.ml.x-n,y:a.ml.y+e}};a.ml.corner.br={x:a.ml.corner.tr.x-n,y:a.ml.corner.tr.y+e};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+e,y:a.mt.y+
n},bl:{x:a.mt.x-n,y:a.mt.y+e}};a.mt.corner.br={x:a.mt.corner.tr.x-n,y:a.mt.corner.tr.y+e};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+e,y:a.mr.y+n},bl:{x:a.mr.x-n,y:a.mr.y+e}};a.mr.corner.br={x:a.mr.corner.tr.x-n,y:a.mr.corner.tr.y+e};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+e,y:a.mb.y+n},bl:{x:a.mb.x-n,y:a.mb.y+e}};a.mb.corner.br={x:a.mb.corner.tr.x-n,y:a.mb.corner.tr.y+e};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 m.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(){},e=a.onComplete||c,n=a.onChange||
c,q=this;m.util.animate({startValue:this.get("angle"),endValue:this._getAngleValueForStraighten(),duration:this.FX_DURATION,onChange:function(s){q.setAngle(s);n()},onComplete:function(){q.setCoords();e()},onStart:function(){q.setActive(false)}});return this},fxRemove:function(a){a||(a={});var c=function(){},e=a.onComplete||c,n=a.onChange||c,q=this;m.util.animate({startValue:this.get("opacity"),endValue:0,duration:this.FX_DURATION,onChange:function(s){q.set("opacity",s);n()},onComplete:e,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()}});m.Object.prototype.rotate=m.Object.prototype.setAngle}})();
(function(){var m=this.fabric||(this.fabric={}),p=m.util.object.extend;if(m.Line)m.warn("fabric.Line is already defined");else{m.Line=m.util.createClass(m.Object,{type:"line",initialize:function(f,h){f||(f=[0,0,0,0]);this.callSuper("initialize",h);this.set("x1",f[0]);this.set("y1",f[1]);this.set("x2",f[2]);this.set("y2",f[3]);this.set("width",this.x2-this.x1);this.set("height",this.y2-this.y1);this.set("left",this.x1+this.width/2);this.set("top",this.y1+this.height/2)},_render:function(f){f.beginPath();
f.moveTo(-this.width/2,-this.height/2);f.lineTo(this.width/2,this.height/2);var h=f.strokeStyle;f.strokeStyle=f.fillStyle;f.stroke();f.strokeStyle=h},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")})}});m.Element.ATTRIBUTE_NAMES="x1 y1 x2 y2 stroke stroke-width transform".split(" ");m.Line.fromElement=function(f,h){var o=m.parseAttributes(f,m.Element.ATTRIBUTE_NAMES);return new m.Line([o.x1||
0,o.y1||0,o.x2||0,o.y2||0],p(o,h))};m.Line.fromObject=function(f){return new m.Line([f.x1,f.y1,f.x2,f.y2],f)}}})();
(function(){var m=this.fabric||(this.fabric={}),p=Math.PI*2,f=m.util.object.extend;if(m.Circle)m.warn("fabric.Circle is already defined.");else{m.Circle=m.util.createClass(m.Object,{type:"circle",initialize:function(h){h=h||{};this.set("radius",h.radius||0);this.callSuper("initialize",h);h=this.get("radius")*2*this.get("scaleX");this.set("width",h).set("height",h)},toObject:function(){return f(this.callSuper("toObject"),{radius:this.get("radius")})},_render:function(h,o){h.beginPath();h.arc(o?this.left:
0,o?this.top:0,this.radius,0,p,false);h.closePath();this.fill&&h.fill();this.stroke&&h.stroke()},complexity:function(){return 1}});m.Circle.ATTRIBUTE_NAMES="cx cy r fill fill-opacity stroke stroke-width transform".split(" ");m.Circle.fromElement=function(h,o){o||(o={});var l=m.parseAttributes(h,m.Circle.ATTRIBUTE_NAMES);if(!("radius"in l&&l.radius>0))throw Error("value of `r` attribute is required and can not be negative");if("left"in l)l.left-=o.width/2||0;if("top"in l)l.top-=o.height/2||0;return new m.Circle(f(l,
o))};m.Circle.fromObject=function(h){return new m.Circle(h)}}})();
(function(){var m=this.fabric||(this.fabric={});if(m.Triangle)m.warn("fabric.Triangle is already defined");else{m.Triangle=m.util.createClass(m.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 f=this.width/2,h=this.height/2;p.beginPath();p.moveTo(-f,h);p.lineTo(0,-h);p.lineTo(f,h);p.closePath();this.fill&&p.fill();this.stroke&&p.stroke()},complexity:function(){return 1}});m.Triangle.fromObject=
function(p){return new m.Triangle(p)}}})();
(function(){var m=this.fabric||(this.fabric={}),p=Math.PI*2,f=m.util.object.extend;if(m.Ellipse)m.warn("fabric.Ellipse is already defined.");else{m.Ellipse=m.util.createClass(m.Object,{type:"ellipse",initialize:function(h){h=h||{};this.callSuper("initialize",h);this.set("rx",h.rx||0);this.set("ry",h.ry||0);this.set("width",this.get("rx")*2);this.set("height",this.get("ry")*2)},toObject:function(){return f(this.callSuper("toObject"),{rx:this.get("rx"),ry:this.get("ry")})},render:function(h,o){if(!(this.rx===
0||this.ry===0))return this.callSuper("render",h,o)},_render:function(h,o){h.beginPath();h.save();h.transform(1,0,0,this.ry/this.rx,0,0);h.arc(o?this.left:0,o?this.top:0,this.rx,0,p,false);h.restore();this.stroke&&h.stroke();this.fill&&h.fill()},complexity:function(){return 1}});m.Ellipse.ATTRIBUTE_NAMES="cx cy rx ry fill fill-opacity stroke stroke-width transform".split(" ");m.Ellipse.fromElement=function(h,o){o||(o={});var l=m.parseAttributes(h,m.Ellipse.ATTRIBUTE_NAMES);if("left"in l)l.left-=o.width/
2||0;if("top"in l)l.top-=o.height/2||0;return new m.Ellipse(f(l,o))};m.Ellipse.fromObject=function(h){return new m.Ellipse(h)}}})();
(function(){var m=this.fabric||(this.fabric={});if(m.Rect)console.warn("fabric.Rect is already defined");else{m.Rect=m.util.createClass(m.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 f=this.options.rx||0,h=this.options.ry||0,o=-this.width/2,l=-this.height/
2,g=this.width,a=this.height;p.beginPath();p.moveTo(o+f,l);p.lineTo(o+g-f,l);p.bezierCurveTo(o+g,l,o+g,l+h,o+g,l+h);p.lineTo(o+g,l+a-h);p.bezierCurveTo(o+g,l+a,o+g-f,l+a,o+g-f,l+a);p.lineTo(o+f,l+a);p.bezierCurveTo(o,l+a,o,l+a-h,o,l+a-h);p.lineTo(o,l+h);p.bezierCurveTo(o,l,o+f,l,o+f,l);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}});
m.Rect.ATTRIBUTE_NAMES="x y width height rx ry fill fill-opacity stroke stroke-width transform".split(" ");m.Rect.fromElement=function(p,f){if(!p)return null;var h=m.parseAttributes(p,m.Rect.ATTRIBUTE_NAMES);h=h;h.left=h.left||0;h.top=h.top||0;h=h;var o=new m.Rect(m.util.object.extend(f||{},h));o._normalizeLeftTopProperties(h);return o};m.Rect.fromObject=function(p){return new m.Rect(p)}}})();
(function(){var m=this.fabric||(this.fabric={});if(m.Polyline)m.warn("fabric.Polyline is already defined");else{m.Polyline=m.util.createClass(m.Object,{type:"polyline",initialize:function(f,h){h=h||{};this.set("points",f);this.callSuper("initialize",h);this._calcDimensions()},_calcDimensions:function(){return m.Polygon.prototype._calcDimensions.call(this)},toObject:function(){return m.Polygon.prototype.toObject.call(this)},_render:function(f){var h;f.beginPath();for(var o=0,l=this.points.length;o<
l;o++){h=this.points[o];f.lineTo(h.x,h.y)}this.fill&&f.fill();this.stroke&&f.stroke()},complexity:function(){return this.get("points").length}});var p="fill fill-opacity stroke stroke-width transform".split(" ");m.Polyline.fromElement=function(f,h){if(!f)return null;h||(h={});for(var o=m.parsePointsAttribute(f.getAttribute("points")),l=m.parseAttributes(f,p),g=0,a=o.length;g<a;g++){o[g].x-=h.width/2||0;o[g].y-=h.height/2||0}return new m.Polyline(o,m.util.object.extend(l,h))};m.Polyline.fromObject=
function(f){return new m.Polyline(f.points,f)}}})();
(function(){var m=this.fabric||(this.fabric={}),p=m.util.object.extend,f=m.util.array.min,h=m.util.array.max;if(m.Polygon)m.warn("fabric.Polygon is already defined");else{m.Polygon=m.util.createClass(m.Object,{type:"polygon",initialize:function(o,l){l=l||{};this.points=o;this.callSuper("initialize",l);this._calcDimensions()},_calcDimensions:function(){var o=this.points,l=f(o,"x"),g=f(o,"y"),a=h(o,"x");o=h(o,"y");this.width=a-l;this.height=o-g;this.minX=l;this.minY=g},toObject:function(){return p(this.callSuper("toObject"),
{points:this.points.concat()})},_render:function(o){var l;o.beginPath();for(var g=0,a=this.points.length;g<a;g++){l=this.points[g];o.lineTo(l.x,l.y)}this.fill&&o.fill();if(this.stroke){o.closePath();o.stroke()}},complexity:function(){return this.points.length}});m.Polygon.ATTRIBUTE_NAMES="fill fill-opacity stroke stroke-width transform".split(" ");m.Polygon.fromElement=function(o,l){if(!o)return null;l||(l={});for(var g=m.parsePointsAttribute(o.getAttribute("points")),a=m.parseAttributes(o,m.Polygon.ATTRIBUTE_NAMES),
c=0,e=g.length;c<e;c++){g[c].x-=l.width/2||0;g[c].y-=l.height/2||0}return new m.Polygon(g,p(a,l))};m.Polygon.fromObject=function(o){return new m.Polygon(o.points,o)}}})();
(function(){function m(a){if(a[0]==="H")return a[1];return a[a.length-2]}function p(a){if(a[0]==="V")return a[1];return a[a.length-1]}var f=this.fabric||(this.fabric={}),h=f.util.array.min,o=f.util.array.max,l=f.util.object.extend;if(f.Path)f.warn("fabric.Path is already defined");else if(f.Object){f.Path=f.util.createClass(f.Object,{type:"path",initialize:function(a,c){c=c||{};this.setOptions(c);this._importProperties();this.originalState={};if(!a)throw Error("`path` argument is required");var e=
Object.prototype.toString.call(a)==="[object Array]";if(this.path=e?a:a.match&&a.match(/[a-zA-Z][^a-zA-Z]*/g)){e||this._initializeFromArray(c);this.setCoords();c.sourcePath&&this.setSourcePath(c.sourcePath)}},_initializeFromArray:function(a){var c="width"in a;a="height"in a;this.path=this._parsePath();if(!c||!a){l(this,this._parseDimensions());if(c)this.width=this.options.width;if(a)this.height=this.options.height}},_render:function(a){for(var c,e=0,n=0,q=0,s=0,x,y,A=-(this.width/2),u=-(this.height/
2),v=0,E=this.path.length;v<E;++v){c=this.path[v];switch(c[0]){case "l":e+=c[1];n+=c[2];a.lineTo(e+A,n+u);break;case "L":e=c[1];n=c[2];a.lineTo(e+A,n+u);break;case "h":e+=c[1];a.lineTo(e+A,n+u);break;case "H":e=c[1];a.lineTo(e+A,n+u);break;case "v":n+=c[1];a.lineTo(e+A,n+u);break;case "V":n=c[1];a.lineTo(e+A,n+u);break;case "m":e+=c[1];n+=c[2];a.moveTo(e+A,n+u);break;case "M":e=c[1];n=c[2];a.moveTo(e+A,n+u);break;case "c":x=e+c[5];y=n+c[6];q=e+c[3];s=n+c[4];a.bezierCurveTo(e+c[1]+A,n+c[2]+u,q+A,s+
u,x+A,y+u);e=x;n=y;break;case "C":e=c[5];n=c[6];q=c[3];s=c[4];a.bezierCurveTo(c[1]+A,c[2]+u,q+A,s+u,e+A,n+u);break;case "s":x=e+c[3];y=n+c[4];q=2*e-q;s=2*n-s;a.bezierCurveTo(q+A,s+u,e+c[1]+A,n+c[2]+u,x+A,y+u);e=x;n=y;break;case "S":x=c[3];y=c[4];q=2*e-q;s=2*n-s;a.bezierCurveTo(q+A,s+u,c[1]+A,c[2]+u,x+A,y+u);e=x;n=y;break;case "q":e+=c[3];n+=c[4];a.quadraticCurveTo(c[1]+A,c[2]+u,e+A,n+u);break;case "Q":e=c[3];n=c[4];q=c[1];s=c[2];a.quadraticCurveTo(q+A,s+u,e+A,n+u);break;case "T":x=e;y=n;e=c[1];n=
c[2];q=-q+2*x;s=-s+2*y;a.quadraticCurveTo(q+A,s+u,e+A,n+u);break;case "a":break;case "A":break;case "z":case "Z":a.closePath();break}}},render:function(a,c){a.save();var e=this.transformMatrix;e&&a.transform(e[0],e[1],e[2],e[3],e[4],e[5]);c||this.transform(a);if(this.overlayFill)a.fillStyle=this.overlayFill;else if(this.fill)a.fillStyle=this.fill;if(this.stroke)a.strokeStyle=this.stroke;a.beginPath();this._render(a);this.fill&&a.fill();if(this.stroke){a.strokeStyle=this.stroke;a.lineWidth=this.strokeWidth;
a.lineCap=a.lineJoin="round";a.stroke()}if(!c&&this.active){this.drawBorders(a);this.hideCorners||this.drawCorners(a)}a.restore()},toString:function(){return"#<fabric.Path ("+this.complexity()+"): "+JSON.stringify({top:this.top,left:this.left})+">"},toObject:function(){var a=l(this.callSuper("toObject"),{path:this.path});if(this.sourcePath)a.sourcePath=this.sourcePath;if(this.transformMatrix)a.transformMatrix=this.transformMatrix;return a},toDatalessObject:function(){var a=this.toObject();if(this.sourcePath)a.path=
this.sourcePath;delete a.sourcePath;return a},complexity:function(){return this.path.length},set:function(a,c){return this.callSuper("set",a,c)},_parsePath:function(){for(var a=[],c,e,n=0,q=this.path.length;n<q;n++){c=this.path[n];e=c.slice(1).trim().replace(/(\d)-/g,"$1###-").split(/\s|,|###/);a.push([c.charAt(0)].concat(e.map(parseFloat)))}return a},_parseDimensions:function(){var a=[],c=[],e,n,q=false,s,x;this.path.forEach(function(v,E){if(v[0]!=="H")e=E===0?m(v):m(this.path[E-1]);if(v[0]!=="V")n=
E===0?p(v):p(this.path[E-1]);if(v[0]===v[0].toLowerCase())q=true;s=q?e+m(v):v[0]==="V"?e:m(v);x=q?n+p(v):v[0]==="H"?n:p(v);var C=parseInt(s,10);isNaN(C)||a.push(C);C=parseInt(x,10);isNaN(C)||c.push(C)},this);var y=h(a),A=h(c),u=deltaY=0;y={top:A-deltaY,left:y-u,bottom:o(c)-deltaY,right:o(a)-u};y.width=y.right-y.left;y.height=y.bottom-y.top;return y}});f.Path.fromObject=function(a){return new f.Path(a.path,a)};var g=f.Path.ATTRIBUTE_NAMES="d fill fill-opacity fill-rule stroke stroke-width transform".split(" ");
f.Path.fromElement=function(a,c){var e=f.parseAttributes(a,g),n=e.d;delete e.d;return new f.Path(n,l(e,c))}}else f.warn("fabric.Path requires fabric.Object")})();
(function(){var m=this.fabric||(this.fabric={}),p=m.util.object.extend,f=m.util.array.invoke,h=m.Object.prototype.set,o=m.Object.prototype.toObject,l=m.util.string.camelize,g=m.util.string.capitalize;if(m.PathGroup)m.warn("fabric.PathGroup is already defined");else{m.PathGroup=m.util.createClass(m.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 e=this.paths.length;c<e;++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 e=this.paths.length;e--;)this.paths[e].set(a,c)}else h.call(this,a,c);return this},toObject:function(){return p(o.call(this),{paths:f(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}});m.PathGroup.fromObject=function(a){for(var c=a.paths,
e=0,n=c.length;e<n;e++)if(!(c[e]instanceof m.Object)){var q=l(g(c[e].type));c[e]=m[q].fromObject(c[e])}return new m.PathGroup(c,a)}}})();
(function(){var m=this.fabric||(this.fabric={}),p=m.util.object.extend,f=m.util.array.min,h=m.util.array.max,o=m.util.array.invoke,l=m.util.removeFromArray;if(!m.Group){m.Group=m.util.createClass(m.Object,{type:"group",initialize:function(g,a){this.objects=g||[];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 g=
this.left,a=this.top;this.forEachObject(function(c){var e=c.get("left"),n=c.get("top");c.set("originalLeft",e);c.set("originalTop",n);c.set("left",e-g);c.set("top",n-a);c.setCoords();c.hideCorners=true},this)},toString:function(){return"#<fabric.Group: ("+this.complexity()+")>"},getObjects:function(){return this.objects},add:function(g){this._restoreObjectsState();this.objects.push(g);g.setActive(true);this._calcBounds();this._updateObjectsCoords();return this},remove:function(g){this._restoreObjectsState();
l(this.objects,g);g.setActive(false);this._calcBounds();this._updateObjectsCoords();return this},size:function(){return this.getObjects().length},set:function(g,a){if(typeof a=="function")this.set(g,a(this[g]));else if(g==="fill"||g==="opacity"){var c=this.objects.length;for(this[g]=a;c--;)this.objects[c].set(g,a)}else this[g]=a;return this},contains:function(g){return this.objects.indexOf(g)>-1},toObject:function(){return p(this.callSuper("toObject"),{objects:o(this.objects,"clone")})},render:function(g){g.save();
this.transform(g);for(var a=Math.max(this.scaleX,this.scaleY),c=0,e;e=this.objects[c];c++){var n=e.borderScaleFactor;e.borderScaleFactor=a;e.render(g);e.borderScaleFactor=n}this.hideBorders||this.drawBorders(g);this.hideCorners||this.drawCorners(g);g.restore();this.setCoords()},item:function(g){return this.getObjects()[g]},complexity:function(){return this.getObjects().reduce(function(g,a){g+=typeof a.complexity=="function"?a.complexity():0;return g},0)},_restoreObjectsState:function(){this.objects.forEach(this._restoreObjectState,
this);return this},_restoreObjectState:function(g){var a=this.get("left"),c=this.get("top"),e=this.getAngle()*(Math.PI/180);g.get("originalLeft");g.get("originalTop");var n=Math.cos(e)*g.get("top")+Math.sin(e)*g.get("left");e=-Math.sin(e)*g.get("top")+Math.cos(e)*g.get("left");g.setAngle(g.getAngle()+this.getAngle());g.set("left",a+e*this.get("scaleX"));g.set("top",c+n*this.get("scaleY"));g.set("scaleX",g.get("scaleX")*this.get("scaleX"));g.set("scaleY",g.get("scaleY")*this.get("scaleY"));g.setCoords();
g.hideCorners=false;g.setActive(false);g.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(g){g.setCoords()});return this},activateAllObjects:function(){return this.setActive(true)},setActive:function(g){this.forEachObject(function(a){a.setActive(g)});
return this},forEachObject:function(g,a){for(var c=this.getObjects(),e=c.length;e--;)g.call(a,c[e],e,c);return this},_setOpacityIfSame:function(){var g=this.getObjects(),a=g[0]?g[0].get("opacity"):1;if(g.every(function(c){return c.get("opacity")===a}))this.opacity=a},_calcBounds:function(){var g=[],a=[],c,e;e=0;for(var n=this.objects.length;e<n;++e){c=this.objects[e];c.setCoords();for(var q in c.oCoords){g.push(c.oCoords[q].x);a.push(c.oCoords[q].y)}}c=f(g);e=h(g);g=f(a);a=h(a);e=e-c;a=a-g;this.width=
e;this.height=a;this.left=c+e/2;this.top=g+a/2},containsPoint:function(g){var a=this.get("width")/2,c=this.get("height")/2,e=this.get("left"),n=this.get("top");return e-a<g.x&&e+a>g.x&&n-c<g.y&&n+c>g.y},toGrayscale:function(){for(var g=this.objects.length;g--;)this.objects[g].toGrayscale()}});m.Group.fromObject=function(g){return new m.Group(g.objects,g)}}})();
(function(){var m=this.fabric||(this.fabric={}),p=m.util.object.extend,f=m.util.object.clone;if(m.Text)m.warn("fabric.Text is already defined");else if(m.Object){m.Text=m.util.createClass(m.Object,{options:{top:10,left:10,fontsize:20,fontweight:100,fontfamily:"Modernist_One_400",path:null},type:"text",initialize:function(h,o){this.originalState={};this.initStateProperties();this.text=h;this.setOptions(o);p(this,this.options);this.theta=this.angle*(Math.PI/180);this.width=this.getWidth();this.setCoords()},
initStateProperties:function(){var h;if((h=this.constructor)&&(h=h.superclass)&&(h=h.prototype)&&(h=h.stateProperties)&&h.clone){this.stateProperties=h.clone();this.stateProperties.push("fontfamily","fontweight","path")}},toString:function(){return"#<fabric.Text ("+this.complexity()+"): "+JSON.stringify({text:this.text,fontfamily:this.fontfamily})+">"},_render:function(h){var o=Cufon.textOptions||(Cufon.textOptions={});o.left=this.left;o.top=this.top;o.context=h;o.color=this.fill;var l=this._initDummyElement();
this.transform(h);Cufon.replaceElement(l,{separate:"none",fontFamily:this.fontfamily});this.width=o.width;this.height=o.height},_initDummyElement:function(){var h=document.createElement("div");h.innerHTML=this.text;h.style.fontSize="40px";h.style.fontWeight="400";h.style.fontStyle="normal";h.style.letterSpacing="normal";h.style.color="#000000";h.style.fontWeight="600";h.style.fontFamily="Verdana";return h},render:function(h){h.save();this._render(h);if(this.active){this.drawBorders(h);this.drawCorners(h)}h.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(h){this.set("fill",h);return this},setFontsize:function(h){this.set("fontsize",h);this.setCoords();return this},getText:function(){return this.text},setText:function(h){this.set("text",h);this.setCoords();return this},set:function(h,o){this[h]=o;if(h==="fontfamily")this.path=this.path.replace(/(.*?)([^\/]*)(\.font\.js)/,
"$1"+o+"$3");return this}});m.Text.fromObject=function(h){return new m.Text(h.text,f(h))};m.Text.fromElement=function(){}}else m.warn("fabric.Text requires fabric.Object")})();
(function(){var m=fabric.util.object.extend;if(!this.fabric)this.fabric={};if(this.fabric.Image)fabric.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,f){this.callSuper("initialize",f);this._initElement(p);this._initConfig(f||{})},getElement:function(){return this._element},setElement:function(p){this._element=
p;return this},getNormalizedSize:function(p,f,h){if(h&&f&&p.width>p.height&&p.width/p.height<f/h){normalizedWidth=~~(p.width*h/p.height);normalizedHeight=h}else if(h&&(p.height==p.width||p.height>p.width||p.height>h)){normalizedWidth=~~(p.width*h/p.height);normalizedHeight=h}else if(f&&f<p.width){normalizedHeight=~~(p.height*f/p.width);normalizedWidth=f}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(){this._resetWidthHeight();this._adjustWidthHeightToBorders(showBorder);this.setCoords()},setCornersVisibility:function(p){this.cornervisibility=!!p},render:function(p,f){p.save();f||this.transform(p);this._render(p);if(this.active&&!f){this.drawBorders(p);this.hideCorners||this.drawCorners(p)}p.restore()},toObject:function(){return m(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 f=this.getElement(),h=document.createElement("canvas"),o=document.createElement("img"),l=this;h.width=f.width;h.height=f.height;h.getContext("2d").drawImage(f,0,0);fabric.Element.toGrayscale(h);o.onload=function(){l.setElement(o);p&&p();o.onload=h=f=imageData=null};o.width=f.width;o.height=f.height;o.src=h.toDataURL("image/png");
this.__isGrayscaled=true;return this}},_render:function(p){var f=this.getOriginalSize();p.drawImage(this.getElement(),-f.width/2,-f.height/2,f.width,f.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,f){var h=document.createElement("img"),
o=p.src;if(p.width)h.width=p.width;if(p.height)h.height=p.height;h.onload=function(){f&&f(new fabric.Image(h,p));h=h.onload=null};h.src=o};fabric.Image.fromURL=function(p,f,h){var o=document.createElement("img");o.onload=function(){f&&f(new fabric.Image(o,h));o=o.onload=null};o.src=p}}else fabric.warn("fabric.Object is required for fabric.Image initialization")})();

View file

@ -30,6 +30,7 @@ if (typeof console !== 'undefined') {
}
//= require "lib/json2"
//= require "lib/cufon"
//= require "src/util"
//= require "src/parser"

1001
lib/cufon.js Normal file

File diff suppressed because it is too large Load diff

View file

@ -116,17 +116,17 @@
height: 150
};
config = config || { };
options = options || { };
this._initElement(el);
this._initConfig(config);
this._initConfig(options);
if (config.overlayImage) {
this.setOverlayImage(config.overlayImage);
if (options.overlayImage) {
this.setOverlayImage(options.overlayImage);
}
if (config.afterRender) {
this.afterRender = config.afterRender;
if (options.afterRender) {
this.afterRender = options.afterRender;
}
this._createCanvasBackground();

View file

@ -316,4 +316,12 @@
canvas.freeDrawingColor = drawingColorEl.value;
canvas.freeDrawingLineWidth = parseInt(drawingLineWidthEl.value, 10) || 1;
var helloWorld = new fabric.Text('Hello world!', {
left: getRandomInt(50, 650),
top: getRandomInt(50, 650),
fontfamily: 'delicious_500'
});
canvas.add(helloWorld);
})();

View file

@ -12,6 +12,8 @@
<script src="../../dist/all.js" type="text/javascript"></script>
<script src="../fonts/Delicious_500.font.js"></script>
<link rel="stylesheet" href="demo.css" type="text/css">
</head>
<body>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long