2018-02-04 23:05:12 +00:00
|
|
|
/*! Fabric.js Copyright 2008-2015, Printio (Juriy Zaytsev, Maxim Chernyak) */
|
2011-07-15 22:16:14 +00:00
|
|
|
|
2018-06-17 11:56:12 +00:00
|
|
|
var fabric = fabric || { version: '2.3.3' };
|
2013-09-23 12:34:07 +00:00
|
|
|
if (typeof exports !== 'undefined') {
|
|
|
|
|
exports.fabric = fabric;
|
|
|
|
|
}
|
2018-03-11 13:31:23 +00:00
|
|
|
/* _AMD_START_ */
|
|
|
|
|
else if (typeof define === 'function' && define.amd) {
|
|
|
|
|
define([], function() { return fabric; });
|
|
|
|
|
}
|
|
|
|
|
/* _AMD_END_ */
|
2012-11-13 17:06:53 +00:00
|
|
|
if (typeof document !== 'undefined' && typeof window !== 'undefined') {
|
2011-08-11 19:18:18 +00:00
|
|
|
fabric.document = document;
|
|
|
|
|
fabric.window = window;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
// assume we're running under node.js when document/window are not present
|
2017-02-19 04:47:32 +00:00
|
|
|
fabric.document = require('jsdom')
|
2016-12-06 08:59:49 +00:00
|
|
|
.jsdom(
|
2017-02-19 04:47:32 +00:00
|
|
|
decodeURIComponent('%3C!DOCTYPE%20html%3E%3Chtml%3E%3Chead%3E%3C%2Fhead%3E%3Cbody%3E%3C%2Fbody%3E%3C%2Fhtml%3E'),
|
|
|
|
|
{ features: {
|
|
|
|
|
FetchExternalResources: ['img']
|
|
|
|
|
}
|
2017-11-19 19:00:01 +00:00
|
|
|
});
|
2017-11-24 18:00:47 +00:00
|
|
|
fabric.jsdomImplForWrapper = require('jsdom/lib/jsdom/living/generated/utils').implForWrapper;
|
2017-12-10 10:28:14 +00:00
|
|
|
fabric.nodeCanvas = require('jsdom/lib/jsdom/utils').Canvas;
|
2017-02-19 04:47:32 +00:00
|
|
|
fabric.window = fabric.document.defaultView;
|
2017-11-19 19:00:01 +00:00
|
|
|
DOMParser = require('xmldom').DOMParser;
|
2011-09-21 23:29:00 +00:00
|
|
|
}
|
|
|
|
|
|
2011-09-22 16:40:31 +00:00
|
|
|
/**
|
|
|
|
|
* True when in environment that supports touch events
|
|
|
|
|
* @type boolean
|
|
|
|
|
*/
|
2017-09-16 11:06:47 +00:00
|
|
|
fabric.isTouchSupported = 'ontouchstart' in fabric.window;
|
2012-07-29 10:38:01 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* True when in environment that's probably Node.js
|
|
|
|
|
* @type boolean
|
|
|
|
|
*/
|
2013-11-20 11:50:32 +00:00
|
|
|
fabric.isLikelyNode = typeof Buffer !== 'undefined' &&
|
|
|
|
|
typeof window === 'undefined';
|
|
|
|
|
|
2015-03-27 06:36:58 +00:00
|
|
|
/* _FROM_SVG_START_ */
|
2013-11-20 11:50:32 +00:00
|
|
|
/**
|
|
|
|
|
* Attributes parsed from all SVG elements
|
|
|
|
|
* @type array
|
|
|
|
|
*/
|
2013-10-28 13:01:44 +00:00
|
|
|
fabric.SHARED_ATTRIBUTES = [
|
2014-04-10 21:47:36 +00:00
|
|
|
"display",
|
2013-10-28 13:01:44 +00:00
|
|
|
"transform",
|
|
|
|
|
"fill", "fill-opacity", "fill-rule",
|
|
|
|
|
"opacity",
|
2013-11-20 11:50:32 +00:00
|
|
|
"stroke", "stroke-dasharray", "stroke-linecap",
|
|
|
|
|
"stroke-linejoin", "stroke-miterlimit",
|
2015-07-01 14:25:02 +00:00
|
|
|
"stroke-opacity", "stroke-width",
|
2017-09-17 20:47:35 +00:00
|
|
|
"id", "paint-order",
|
2017-08-14 11:52:52 +00:00
|
|
|
"instantiated_by_use"
|
2013-10-28 13:01:44 +00:00
|
|
|
];
|
2015-03-27 06:36:58 +00:00
|
|
|
/* _FROM_SVG_END_ */
|
2014-07-17 14:28:42 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Pixel per Inch as a default value set to 96. Can be changed for more realistic conversion.
|
|
|
|
|
*/
|
|
|
|
|
fabric.DPI = 96;
|
2014-10-21 20:50:34 +00:00
|
|
|
fabric.reNum = '(?:[-+]?(?:\\d+|\\d*\\.\\d+)(?:e[-+]?\\d+)?)';
|
2016-02-11 01:11:17 +00:00
|
|
|
fabric.fontPaths = { };
|
2017-01-30 14:24:32 +00:00
|
|
|
fabric.iMatrix = [1, 0, 0, 1, 0, 0];
|
2017-06-07 12:07:38 +00:00
|
|
|
fabric.canvasModule = 'canvas';
|
2017-06-25 12:50:28 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Pixel limit for cache canvases. 1Mpx , 4Mpx should be fine.
|
|
|
|
|
* @since 1.7.14
|
|
|
|
|
* @type Number
|
|
|
|
|
* @default
|
|
|
|
|
*/
|
|
|
|
|
fabric.perfLimitSizeTotal = 2097152;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Pixel limit for cache canvases width or height. IE fixes the maximum at 5000
|
|
|
|
|
* @since 1.7.14
|
|
|
|
|
* @type Number
|
|
|
|
|
* @default
|
|
|
|
|
*/
|
|
|
|
|
fabric.maxCacheSideLimit = 4096;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Lowest pixel limit for cache canvases, set at 256PX
|
|
|
|
|
* @since 1.7.14
|
|
|
|
|
* @type Number
|
|
|
|
|
* @default
|
|
|
|
|
*/
|
|
|
|
|
fabric.minCacheSideLimit = 256;
|
|
|
|
|
|
2016-05-23 06:16:59 +00:00
|
|
|
/**
|
|
|
|
|
* Cache Object for widths of chars in text rendering.
|
|
|
|
|
*/
|
|
|
|
|
fabric.charWidthsCache = { };
|
|
|
|
|
|
2017-05-29 16:28:24 +00:00
|
|
|
/**
|
|
|
|
|
* if webgl is enabled and available, textureSize will determine the size
|
|
|
|
|
* of the canvas backend
|
|
|
|
|
* @since 2.0.0
|
|
|
|
|
* @type Number
|
|
|
|
|
* @default
|
|
|
|
|
*/
|
|
|
|
|
fabric.textureSize = 2048;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Enable webgl for filtering picture is available
|
|
|
|
|
* A filtering backend will be initialized, this will both take memory and
|
|
|
|
|
* time since a default 2048x2048 canvas will be created for the gl context
|
|
|
|
|
* @since 2.0.0
|
|
|
|
|
* @type Boolean
|
|
|
|
|
* @default
|
|
|
|
|
*/
|
|
|
|
|
fabric.enableGLFiltering = true;
|
|
|
|
|
|
2015-07-10 15:13:51 +00:00
|
|
|
/**
|
|
|
|
|
* Device Pixel Ratio
|
|
|
|
|
* @see https://developer.apple.com/library/safari/documentation/AudioVideo/Conceptual/HTML-canvas-guide/SettingUptheCanvas/SettingUptheCanvas.html
|
|
|
|
|
*/
|
2015-07-22 13:24:51 +00:00
|
|
|
fabric.devicePixelRatio = fabric.window.devicePixelRatio ||
|
|
|
|
|
fabric.window.webkitDevicePixelRatio ||
|
|
|
|
|
fabric.window.mozDevicePixelRatio ||
|
2015-07-10 15:13:51 +00:00
|
|
|
1;
|
2017-10-25 21:33:58 +00:00
|
|
|
/**
|
|
|
|
|
* Browser-specific constant to adjust CanvasRenderingContext2D.shadowBlur value,
|
|
|
|
|
* which is unitless and not rendered equally across browsers.
|
|
|
|
|
*
|
|
|
|
|
* Values that work quite well (as of October 2017) are:
|
|
|
|
|
* - Chrome: 1.5
|
|
|
|
|
* - Edge: 1.75
|
|
|
|
|
* - Firefox: 0.9
|
|
|
|
|
* - Safari: 0.95
|
|
|
|
|
*
|
|
|
|
|
* @since 2.0.0
|
|
|
|
|
* @type Number
|
|
|
|
|
* @default 1
|
|
|
|
|
*/
|
|
|
|
|
fabric.browserShadowBlurConstant = 1;
|
2017-05-29 16:28:24 +00:00
|
|
|
|
|
|
|
|
fabric.initFilterBackend = function() {
|
2017-08-09 21:17:07 +00:00
|
|
|
if (fabric.enableGLFiltering && fabric.isWebglSupported && fabric.isWebglSupported(fabric.textureSize)) {
|
2017-05-29 16:28:24 +00:00
|
|
|
console.log('max texture size: ' + fabric.maxTextureSize);
|
|
|
|
|
return (new fabric.WebglFilterBackend({ tileSize: fabric.textureSize }));
|
|
|
|
|
}
|
|
|
|
|
else if (fabric.Canvas2dFilterBackend) {
|
|
|
|
|
return (new fabric.Canvas2dFilterBackend());
|
|
|
|
|
}
|
|
|
|
|
};
|