diff --git a/dist/all.js b/dist/all.js
index 221e2e86..64b17279 100644
--- a/dist/all.js
+++ b/dist/all.js
@@ -2967,11 +2967,11 @@ fabric.util.string = {
}
/**
- * Helper for creation of "classes". Note that pr
+ * Helper for creation of "classes".
+ * @memberOf fabric.util
* @param parent optional "Class" to inherit from
* @param properties Properties shared by all instances of this class
* (be careful modifying objects defined here as this would affect all instances)
- * @memberOf fabric.util
*/
function createClass() {
var parent = null,
@@ -3156,9 +3156,8 @@ fabric.util.string = {
/**
* Adds an event listener to an element
- * @mthod addListener
- * @memberOf fabric.util
* @function
+ * @memberOf fabric.util
* @param {HTMLElement} element
* @param {String} eventName
* @param {Function} handler
@@ -3167,9 +3166,8 @@ fabric.util.string = {
/**
* Removes an event listener from an element
- * @mthod removeListener
- * @memberOf fabric.util
* @function
+ * @memberOf fabric.util
* @param {HTMLElement} element
* @param {String} eventName
* @param {Function} handler
@@ -5675,6 +5673,7 @@ fabric.util.string = {
* @static
* @field
* @memberOf fabric.Color
+ * @see: http://www.w3.org/TR/CSS2/syndata.html#color-units
*/
fabric.Color.colorNameMap = {
'aqua': '#00FFFF',
@@ -5714,8 +5713,8 @@ fabric.util.string = {
/**
* Returns new color object, when given a color in RGB format
- * @param {String} color ex: rgb(0-255,0-255,0-255)
* @memberOf fabric.Color
+ * @param {String} color ex: rgb(0-255,0-255,0-255)
* @return {fabric.Color}
*/
fabric.Color.fromRgb = function(color) {
@@ -5724,8 +5723,8 @@ fabric.util.string = {
/**
* Returns array represenatation (ex: [100, 100, 200, 1]) of a color that's in RGB or RGBA format
- * @param {String} color ex: rgb(0-255,0-255,0-255), rgb(0%-100%,0%-100%,0%-100%)
* @memberOf fabric.Color
+ * @param {String} color ex: rgb(0-255,0-255,0-255), rgb(0%-100%,0%-100%,0%-100%)
* @return {Array} source
*/
fabric.Color.sourceFromRgb = function(color) {
@@ -5748,8 +5747,8 @@ fabric.util.string = {
* Returns new color object, when given a color in RGBA format
* @static
* @function
- * @param {String} color
* @memberOf fabric.Color
+ * @param {String} color
* @return {fabric.Color}
*/
fabric.Color.fromRgba = Color.fromRgb;
@@ -5767,8 +5766,8 @@ fabric.util.string = {
/**
* Returns array represenatation (ex: [100, 100, 200, 1]) of a color that's in HSL or HSLA format.
* Adapted from https://github.com/mjijackson
- * @param {String} color ex: hsl(0-360,0%-100%,0%-100%) or hsla(0-360,0%-100%,0%-100%, 0-1)
* @memberOf fabric.Color
+ * @param {String} color ex: hsl(0-360,0%-100%,0%-100%) or hsla(0-360,0%-100%,0%-100%, 0-1)
* @return {Array} source
* @see http://http://www.w3.org/TR/css3-color/#hsl-color
*/
@@ -5805,8 +5804,8 @@ fabric.util.string = {
* Returns new color object, when given a color in HSLA format
* @static
* @function
- * @param {String} color
* @memberOf fabric.Color
+ * @param {String} color
* @return {fabric.Color}
*/
fabric.Color.fromHsla = Color.fromHsl;
@@ -5824,8 +5823,8 @@ fabric.util.string = {
/**
* Returns array represenatation (ex: [100, 100, 200, 1]) of a color that's in HEX format
* @static
- * @param {String} color ex: FF5555
* @memberOf fabric.Color
+ * @param {String} color ex: FF5555
* @return {Array} source
*/
fabric.Color.sourceFromHex = function(color) {
@@ -5848,8 +5847,8 @@ fabric.util.string = {
/**
* Returns new color object, when given color in array representation (ex: [200, 100, 100, 0.5])
* @static
- * @param {Array} source
* @memberOf fabric.Color
+ * @param {Array} source
* @return {fabric.Color}
*/
fabric.Color.fromSource = function(source) {
@@ -6083,6 +6082,8 @@ fabric.util.string = {
* Returns {@link fabric.Gradient} instance from an SVG element
* @static
* @memberof fabric.Gradient
+ * @param {SVGGradientElement} el SVG gradient element
+ * @param {Object} instance
* @see http://www.w3.org/TR/SVG/pservers.html#LinearGradientElement
* @see http://www.w3.org/TR/SVG/pservers.html#RadialGradientElement
*/
@@ -6164,9 +6165,9 @@ fabric.util.string = {
/**
* Returns {@link fabric.Gradient} instance from its object representation
* @static
+ * @memberof fabric.Gradient
* @param {Object} obj
* @param {Object} [options] Options object
- * @memberof fabric.Gradient
*/
forObject: function(obj, options) {
options || (options = { });
@@ -6235,18 +6236,21 @@ fabric.Pattern = fabric.util.createClass(/** @lends fabric.Pattern.prototype */
/**
* Repeat property of a pattern (one of repeat, repeat-x, repeat-y)
* @type String
+ * @default
*/
repeat: 'repeat',
/**
* Pattern horizontal offset from object's left/top corner
* @type Number
+ * @default
*/
offsetX: 0,
/**
* Pattern vertical offset from object's left/top corner
* @type Number
+ * @default
*/
offsetY: 0,
@@ -6293,7 +6297,7 @@ fabric.Pattern = fabric.util.createClass(/** @lends fabric.Pattern.prototype */
/**
* Returns object representation of a pattern
- * @return {Object}
+ * @return {Object} Object representation of a pattern instance
*/
toObject: function() {
@@ -6319,6 +6323,7 @@ fabric.Pattern = fabric.util.createClass(/** @lends fabric.Pattern.prototype */
/* _TO_SVG_START_ */
/**
* Returns SVG representation of a pattern
+ * @param {Object} object
* @return {String} SVG representation of a pattern
*/
toSVG: function(object) {
@@ -6350,7 +6355,7 @@ fabric.Pattern = fabric.util.createClass(/** @lends fabric.Pattern.prototype */
/**
* Returns an instance of CanvasPattern
- * @param ctx
+ * @param {CanvasRenderingContext2D} ctx Context to create pattern
* @return {CanvasPattern}
*/
toLive: function(ctx) {
@@ -6369,6 +6374,7 @@ fabric.Shadow = fabric.util.createClass(/** @lends fabric.Shadow.prototype */ {
/**
* Shadow color
* @type String
+ * @default
*/
color: 'rgb(0,0,0)',
@@ -6381,24 +6387,27 @@ fabric.Shadow = fabric.util.createClass(/** @lends fabric.Shadow.prototype */ {
/**
* Shadow horizontal offset
* @type Number
+ * @default
*/
offsetX: 0,
/**
* Shadow vertical offset
* @type Number
+ * @default
*/
offsetY: 0,
/**
* Whether the shadow should affect stroke operations
* @type Boolean
+ * @default
*/
affectStroke: false,
/**
* Constructor
- * @param [options] Options object with any of color, blur, offsetX, offsetX properties
+ * @param {Object} [options] Options object with any of color, blur, offsetX, offsetX properties
* @return {fabric.Shadow} thisArg
*/
initialize: function(options) {
@@ -6412,6 +6421,7 @@ fabric.Shadow = fabric.util.createClass(/** @lends fabric.Shadow.prototype */ {
/* _TO_SVG_START_ */
/**
* Returns SVG representation of a shadow
+ * @param {Object} object
* @return {String} SVG representation of a shadow
*/
toSVG: function(object) {
@@ -6437,7 +6447,7 @@ fabric.Shadow = fabric.util.createClass(/** @lends fabric.Shadow.prototype */ {
/**
* Returns object representation of a shadow
- * @return {Object}
+ * @return {Object} Object representation of a shadow instance
*/
toObject: function() {
return {
@@ -7456,6 +7466,7 @@ fabric.Shadow = fabric.util.createClass(/** @lends fabric.Shadow.prototype */ {
/**
* @static
* @type String
+ * @default
*/
EMPTY_JSON: '{"objects": [], "background": "white"}',
@@ -10310,6 +10321,7 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @lends fabric.Stati
/**
* Shadow object representing shadow of this shape
* @type fabric.Shadow
+ * @default
*/
shadow: null,
@@ -11220,6 +11232,7 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @lends fabric.Stati
/**
* Alias for {@link fabric.Object.prototype.setAngle}
* @alias rotate -> setAngle
+ * @memberof fabric.Object
*/
fabric.Object.prototype.rotate = fabric.Object.prototype.setAngle;
@@ -11228,6 +11241,7 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @lends fabric.Stati
/**
* Defines the number of fraction digits when serializing object values. You can use it to increase/decrease precision of such values like left, top, scaleX, scaleY, etc.
* @static
+ * @memberof fabric.Object
* @constant
* @type Number
*/
@@ -11235,6 +11249,7 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @lends fabric.Stati
/**
* @static
+ * @memberof fabric.Object
* @type Number
*/
fabric.Object.__uid = 0;
@@ -12330,6 +12345,7 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @lends fabric.Stati
/**
* Animation duration (in ms) for fx* methods
* @type Number
+ * @default
*/
FX_DURATION: 500,
@@ -12722,6 +12738,7 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot
/**
* List of attribute names to account for when parsing SVG element (used by {@link fabric.Line.fromElement})
* @static
+ * @memberOf fabric.Line
* @see http://www.w3.org/TR/SVG/shapes.html#LineElement
*/
fabric.Line.ATTRIBUTE_NAMES = fabric.SHARED_ATTRIBUTES.concat('x1 y1 x2 y2'.split(' '));
@@ -12729,6 +12746,7 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot
/**
* Returns fabric.Line instance from an SVG element
* @static
+ * @memberOf fabric.Line
* @param {SVGElement} element Element to parse
* @param {Object} [options] Options object
* @return {fabric.Line} instance of fabric.Line
@@ -12748,6 +12766,7 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot
/**
* Returns fabric.Line instance from an object representation
* @static
+ * @memberOf fabric.Line
* @param {Object} object Object to create an instance from
* @return {fabric.Line} instance of fabric.Line
*/
@@ -12886,6 +12905,7 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot
/**
* List of attribute names to account for when parsing SVG element (used by {@link fabric.Circle.fromElement})
* @static
+ * @memberOf fabric.Circle
* @see: http://www.w3.org/TR/SVG/shapes.html#CircleElement
*/
fabric.Circle.ATTRIBUTE_NAMES = fabric.SHARED_ATTRIBUTES.concat('cx cy r'.split(' '));
@@ -12893,6 +12913,7 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot
/**
* Returns {@link fabric.Circle} instance from an SVG element
* @static
+ * @memberOf fabric.Circle
* @param {SVGElement} element Element to parse
* @param {Object} [options] Options object
* @throws {Error} If value of `r` attribute is missing or invalid
@@ -12929,6 +12950,7 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot
/**
* Returns {@link fabric.Circle} instance from an object representation
* @static
+ * @memberOf fabric.Circle
* @param {Object} object Object to create an instance from
* @return {Object} Instance of fabric.Circle
*/
@@ -13052,6 +13074,7 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot
/**
* Returns fabric.Triangle instance from an object representation
* @static
+ * @memberOf fabric.Triangle
* @param object {Object} object to create an instance from
* @return {Object} instance of Canvas.Triangle
*/
@@ -13197,6 +13220,7 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot
/**
* List of attribute names to account for when parsing SVG element (used by {@link fabric.Ellipse.fromElement})
* @static
+ * @memberOf fabric.Ellipse
* @see http://www.w3.org/TR/SVG/shapes.html#EllipseElement
*/
fabric.Ellipse.ATTRIBUTE_NAMES = fabric.SHARED_ATTRIBUTES.concat('cx cy rx ry'.split(' '));
@@ -13204,6 +13228,7 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot
/**
* Returns {@link fabric.Ellipse} instance from an SVG element
* @static
+ * @memberOf fabric.Ellipse
* @param {SVGElement} element Element to parse
* @param {Object} [options] Options object
* @return {fabric.Ellipse}
@@ -13234,6 +13259,7 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot
/**
* Returns {@link fabric.Ellipse} instance from an object representation
* @static
+ * @memberOf fabric.Ellipse
* @param {Object} object Object to create an instance from
* @return {fabric.Ellipse}
*/
@@ -13456,6 +13482,8 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot
/**
* List of attribute names to account for when parsing SVG element (used by `fabric.Rect.fromElement`)
* @static
+ * @memberOf fabric.Rect
+ * @see: http://www.w3.org/TR/SVG/shapes.html#RectElement
*/
fabric.Rect.ATTRIBUTE_NAMES = fabric.SHARED_ATTRIBUTES.concat('x y rx ry width height'.split(' '));
@@ -13471,6 +13499,7 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot
/**
* Returns {@link fabric.Rect} instance from an SVG element
* @static
+ * @memberOf fabric.Rect
* @param {SVGElement} element Element to parse
* @param {Object} [options] Options object
* @return {fabric.Rect} Instance of fabric.Rect
@@ -13493,6 +13522,7 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot
/**
* Returns {@link fabric.Rect} instance from an object representation
* @static
+ * @memberOf fabric.Rect
* @param object {Object} object to create an instance from
* @return {Object} instance of fabric.Rect
*/
@@ -13631,6 +13661,7 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot
/**
* List of attribute names to account for when parsing SVG element (used by {@link fabric.Polyline.fromElement})
* @static
+ * @memberOf fabric.Polyline
* @see: http://www.w3.org/TR/SVG/shapes.html#PolylineElement
*/
fabric.Polyline.ATTRIBUTE_NAMES = fabric.SHARED_ATTRIBUTES.concat();
@@ -13638,6 +13669,7 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot
/**
* Returns fabric.Polyline instance from an SVG element
* @static
+ * @memberOf fabric.Polyline
* @param {SVGElement} element Element to parse
* @param {Object} [options] Options object
* @return {fabric.Polyline} Instance of fabric.Polyline
@@ -13669,6 +13701,7 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot
/**
* Returns fabric.Polyline instance from an object representation
* @static
+ * @memberOf fabric.Polyline
* @param object {Object} object Object to create an instance from
* @return {fabric.Polyline} Instance of fabric.Polyline
*/
@@ -13837,6 +13870,7 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot
/**
* List of attribute names to account for when parsing SVG element (used by `fabric.Polygon.fromElement`)
* @static
+ * @memberOf fabric.Polygon
* @see: http://www.w3.org/TR/SVG/shapes.html#PolygonElement
*/
fabric.Polygon.ATTRIBUTE_NAMES = fabric.SHARED_ATTRIBUTES.concat();
@@ -13844,6 +13878,7 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot
/**
* Returns {@link fabric.Polygon} instance from an SVG element
* @static
+ * @memberOf fabric.Polygon
* @param {SVGElement} element Element to parse
* @param {Object} [options] Options object
* @return {fabric.Polygon} Instance of fabric.Polygon
@@ -13875,6 +13910,7 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot
/**
* Returns fabric.Polygon instance from an object representation
* @static
+ * @memberOf fabric.Polygon
* @param object {Object} object Object to create an instance from
* @return {fabric.Polygon} Instance of fabric.Polygon
*/
@@ -14559,6 +14595,7 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot
/**
* Creates an instance of fabric.Path from an object
* @static
+ * @memberOf fabric.Path
* @param {Object} object
* @param {Function} callback Callback to invoke when an fabric.Path instance is created
*/
@@ -14585,6 +14622,7 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot
/**
* List of attribute names to account for when parsing SVG element (used by `fabric.Path.fromElement`)
* @static
+ * @memberOf fabric.Path
* @see http://www.w3.org/TR/SVG/paths.html#PathElement
*/
fabric.Path.ATTRIBUTE_NAMES = fabric.SHARED_ATTRIBUTES.concat(['d']);
@@ -14592,6 +14630,7 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot
/**
* Creates an instance of fabric.Path from an SVG element
* @static
+ * @memberOf fabric.Path
* @param {SVGElement} element to parse
* @param {Function} callback Callback to invoke when an fabric.Path instance is created
* @param {Object} [options] Options object
@@ -14605,7 +14644,9 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot
/**
* Indicates that instances of this type are async
* @static
+ * @memberOf fabric.Path
* @type Boolean
+ * @default
*/
fabric.Path.async = true;
@@ -14822,6 +14863,7 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot
/**
* Creates fabric.PathGroup instance from an object representation
* @static
+ * @memberOf fabric.PathGroup
* @param {Object} object
* @param {Function} callback Callback to invoke when an fabric.PathGroup instance is created
*/
@@ -14848,7 +14890,9 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot
/**
* Indicates that instances of this type are async
* @static
+ * @memberOf fabric.PathGroup
* @type Boolean
+ * @default
*/
fabric.PathGroup.async = true;
@@ -15289,6 +15333,7 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot
/**
* Returns {@link fabric.Group} instance from an object representation
* @static
+ * @memberOf fabric.Group
* @param {Object} object Object to create a group from
* @param {Object} [options] Options object
* @return {fabric.Group} An instance of fabric.Group
@@ -15303,7 +15348,9 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot
/**
* Indicates that instances of this type are async
* @static
+ * @memberOf fabric.Group
* @type Boolean
+ * @default
*/
fabric.Group.async = true;
@@ -15348,13 +15395,12 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot
initialize: function(element, options) {
options || (options = { });
+ this.filters = [ ];
+
this.callSuper('initialize', options);
this._initElement(element);
- this._originalImage = this.getElement();
this._initConfig(options);
- this.filters = [ ];
-
if (options.filters) {
this.filters = options.filters;
this.applyFilters();
@@ -15370,14 +15416,23 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot
},
/**
- * Sets image element for this instance to a specified one
+ * Sets image element for this instance to a specified one.
+ * If filters defined they are applied to new image.
+ * You might need to call `canvas.renderAll` and `object.setCoords` after replacing, to render new image and update controls area.
* @param {HTMLImageElement} element
+ * @param {Function} [callback] Callback is invoked when all filters have been applied and new image is generated
* @return {fabric.Image} thisArg
* @chainable
*/
- setElement: function(element) {
+ setElement: function(element, callback) {
this._element = element;
+ this._originalElement = element;
this._initConfig();
+
+ if (this.filters.length !== 0) {
+ this.applyFilters(callback);
+ }
+
return this;
},
@@ -15486,12 +15541,14 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot
/**
* Returns object representation of an instance
* @param {Array} propertiesToInclude
- * @return {Object} propertiesToInclude Object representation of an instance
+ * @return {Object} Object representation of an instance
*/
toObject: function(propertiesToInclude) {
return extend(this.callSuper('toObject', propertiesToInclude), {
- src: this._originalImage.src || this._originalImage._src,
- filters: this.filters.concat()
+ src: this._originalElement.src || this._originalElement._src,
+ filters: this.filters.map(function(filterObj) {
+ return filterObj && filterObj.toObject();
+ })
});
},
@@ -15570,12 +15627,12 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot
applyFilters: function(callback) {
if (this.filters.length === 0) {
- this._element = this._originalImage;
+ this._element = this._originalElement;
callback && callback();
return;
}
- var imgEl = this._originalImage,
+ var imgEl = this._originalElement,
canvasEl = fabric.util.createCanvasElement(),
replacement = fabric.util.createImage(),
_this = this;
@@ -15709,21 +15766,13 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot
/**
* Creates an instance of fabric.Image from its object representation
* @static
- * @param {Object} object
+ * @param {Object} object Object to create an instance from
* @param {Function} [callback] Callback to invoke when an image instance is created
*/
fabric.Image.fromObject = function(object, callback) {
var img = fabric.document.createElement('img'),
src = object.src;
- if (object.width) {
- img.width = object.width;
- }
-
- if (object.height) {
- img.height = object.height;
- }
-
/** @ignore */
img.onload = function() {
fabric.Image.prototype._initFilters.call(object, object);
@@ -15760,7 +15809,7 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot
/**
* List of attribute names to account for when parsing SVG element (used by {@link fabric.Image.fromElement})
* @static
- * @see http://www.w3.org/TR/SVG/struct.html#ImageElement
+ * @see {@link http://www.w3.org/TR/SVG/struct.html#ImageElement}
*/
fabric.Image.ATTRIBUTE_NAMES = fabric.SHARED_ATTRIBUTES.concat('x y width height xlink:href'.split(' '));
@@ -15784,12 +15833,14 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot
* Indicates that instances of this type are async
* @static
* @type Boolean
+ * @default
*/
fabric.Image.async = true;
/**
* Indicates compression level used when generating PNG under Node (in applyFilters). Any of 0-9
* @static
+ * @default
* @type Number
*/
fabric.Image.pngCompression = 1;
@@ -15894,6 +15945,7 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @lends fabric.Stati
*/
fabric.Image.filters = fabric.Image.filters || { };
+
/**
* Brightness filter class
* @class fabric.Image.filters.Brightness
@@ -15938,14 +15990,23 @@ fabric.Image.filters.Brightness = fabric.util.createClass(/** @lends fabric.Imag
},
/**
- * Returns json representation of filter
- * @return {String} json representation of filter
+ * Returns object representation of an instance
+ * @return {Object} Object representation of an instance
*/
- toJSON: function() {
+ toObject: function() {
return {
type: this.type,
brightness: this.brightness
};
+ },
+
+ /**
+ * Returns a JSON representation of an instance
+ * @return {Object} JSON
+ */
+ toJSON: function() {
+ // delegate, not alias
+ return this.toObject();
}
});
@@ -15960,12 +16021,6 @@ fabric.Image.filters.Brightness.fromObject = function(object) {
};
-/**
- * @namespace fabric.Image.filters
- * @memberOf fabric.Image
- */
-fabric.Image.filters = fabric.Image.filters || { };
-
/**
* Adapted from html5rocks article
* @class fabric.Image.filters.Convolute
@@ -16061,15 +16116,24 @@ fabric.Image.filters.Convolute = fabric.util.createClass(/** @lends fabric.Image
},
/**
- * Returns json representation of filter
- * @return {String} json representation of filter
+ * Returns object representation of an instance
+ * @return {Object} Object representation of an instance
*/
- toJSON: function() {
+ toObject: function() {
return {
type: this.type,
opaque: this.opaque,
matrix: this.matrix
};
+ },
+
+ /**
+ * Returns a JSON representation of an instance
+ * @return {Object} JSON
+ */
+ toJSON: function() {
+ // delegate, not alias
+ return this.toObject();
}
});
@@ -16084,12 +16148,6 @@ fabric.Image.filters.Convolute.fromObject = function(object) {
};
-/**
- * @namespace fabric.Image.filters
- * @memberOf fabric.Image
- */
-fabric.Image.filters = fabric.Image.filters || { };
-
/**
* GradientTransparency filter class
* @class fabric.Image.filters.GradientTransparency
@@ -16133,14 +16191,23 @@ fabric.Image.filters.GradientTransparency = fabric.util.createClass(/** @lends f
},
/**
- * Returns json representation of filter
- * @return {String} json representation of filter
+ * Returns object representation of an instance
+ * @return {Object} Object representation of an instance
*/
- toJSON: function() {
+ toObject: function() {
return {
type: this.type,
threshold: this.threshold
};
+ },
+
+ /**
+ * Returns a JSON representation of an instance
+ * @return {Object} JSON
+ */
+ toJSON: function() {
+ // delegate, not alias
+ return this.toObject();
}
});
@@ -16155,12 +16222,6 @@ fabric.Image.filters.GradientTransparency.fromObject = function(object) {
};
-/**
- * @namespace fabric.Image.filters
- * @memberOf fabric.Image
- */
-fabric.Image.filters = fabric.Image.filters || { };
-
/**
* Grayscale image filter class
* @class fabric.Image.filters.Grayscale
@@ -16200,11 +16261,20 @@ fabric.Image.filters.Grayscale = fabric.util.createClass(/** @lends fabric.Image
},
/**
- * Returns json representation of filter
- * @return {Object} JSON representation of filter
+ * Returns object representation of an instance
+ * @return {Object} Object representation of an instance
+ */
+ toObject: function() {
+ return { type: this.type };
+ },
+
+ /**
+ * Returns a JSON representation of an instance
+ * @return {Object} JSON
*/
toJSON: function() {
- return { type: this.type };
+ // delegate, not alias
+ return this.toObject();
}
});
@@ -16218,12 +16288,6 @@ fabric.Image.filters.Grayscale.fromObject = function() {
};
-/**
- * @namespace fabric.Image.filters
- * @memberOf fabric.Image
- */
-fabric.Image.filters = fabric.Image.filters || { };
-
/**
* Invert filter class
* @class fabric.Image.filters.Invert
@@ -16259,11 +16323,20 @@ fabric.Image.filters.Invert = fabric.util.createClass(/** @lends fabric.Image.fi
},
/**
- * Returns json representation of filter
- * @return {String} json representation of filter
+ * Returns object representation of an instance
+ * @return {Object} Object representation of an instance
+ */
+ toObject: function() {
+ return { type: this.type };
+ },
+
+ /**
+ * Returns a JSON representation of an instance
+ * @return {Object} JSON
*/
toJSON: function() {
- return { type: this.type };
+ // delegate, not alias
+ return this.toObject();
}
});
@@ -16277,12 +16350,6 @@ fabric.Image.filters.Invert.fromObject = function() {
};
-/**
- * @namespace fabric.Image.filters
- * @memberOf fabric.Image
- */
-fabric.Image.filters = fabric.Image.filters || { };
-
/**
* Noise filter class
* @class fabric.Image.filters.Noise
@@ -16330,14 +16397,23 @@ fabric.Image.filters.Noise = fabric.util.createClass(/** @lends fabric.Image.fil
},
/**
- * Returns json representation of filter
- * @return {String} json representation of filter
+ * Returns object representation of an instance
+ * @return {Object} Object representation of an instance
*/
- toJSON: function() {
+ toObject: function() {
return {
type: this.type,
noise: this.noise
};
+ },
+
+ /**
+ * Returns a JSON representation of an instance
+ * @return {Object} JSON
+ */
+ toJSON: function() {
+ // delegate, not alias
+ return this.toObject();
}
});
@@ -16352,12 +16428,6 @@ fabric.Image.filters.Noise.fromObject = function(object) {
};
-/**
- * @namespace fabric.Image.filters
- * @memberOf fabric.Image
- */
-fabric.Image.filters = fabric.Image.filters || { };
-
/**
* Pixelate filter class
* @class fabric.Image.filters.Pixelate
@@ -16430,14 +16500,23 @@ fabric.Image.filters.Pixelate = fabric.util.createClass(/** @lends fabric.Image.
},
/**
- * Returns json representation of filter
- * @return {String} json representation of filter
+ * Returns object representation of an instance
+ * @return {Object} Object representation of an instance
*/
- toJSON: function() {
+ toObject: function() {
return {
type: this.type,
blocksize: this.blocksize
};
+ },
+
+ /**
+ * Returns a JSON representation of an instance
+ * @return {Object} JSON
+ */
+ toJSON: function() {
+ // delegate, not alias
+ return this.toObject();
}
});
@@ -16452,12 +16531,6 @@ fabric.Image.filters.Pixelate.fromObject = function(object) {
};
-/**
- * @namespace fabric.Image.filters
- * @memberOf fabric.Image
- */
-fabric.Image.filters = fabric.Image.filters || { };
-
/**
* Remove white filter class
* @class fabric.Image.filters.RemoveWhite
@@ -16517,15 +16590,24 @@ fabric.Image.filters.RemoveWhite = fabric.util.createClass(/** @lends fabric.Ima
},
/**
- * Returns json representation of filter
- * @return {Object} JSON representation of filter
+ * Returns object representation of an instance
+ * @return {Object} Object representation of an instance
*/
- toJSON: function() {
+ toObject: function() {
return {
type: this.type,
threshold: this.threshold,
distance: this.distance
};
+ },
+
+ /**
+ * Returns a JSON representation of an instance
+ * @return {Object} JSON
+ */
+ toJSON: function() {
+ // delegate, not alias
+ return this.toObject();
}
});
@@ -16540,12 +16622,6 @@ fabric.Image.filters.RemoveWhite.fromObject = function(object) {
};
-/**
- * @namespace fabric.Image.filters
- * @memberOf fabric.Image
- */
-fabric.Image.filters = fabric.Image.filters || { };
-
/**
* Sepia filter class
* @class fabric.Image.filters.Sepia
@@ -16582,11 +16658,20 @@ fabric.Image.filters.Sepia = fabric.util.createClass(/** @lends fabric.Image.fil
},
/**
- * Returns json representation of filter
- * @return {String} json representation of filter
+ * Returns object representation of an instance
+ * @return {Object} Object representation of an instance
+ */
+ toObject: function() {
+ return { type: this.type };
+ },
+
+ /**
+ * Returns a JSON representation of an instance
+ * @return {Object} JSON
*/
toJSON: function() {
- return { type: this.type };
+ // delegate, not alias
+ return this.toObject();
}
});
@@ -16600,12 +16685,6 @@ fabric.Image.filters.Sepia.fromObject = function() {
};
-/**
- * @namespace fabric.Image.filters
- * @memberOf fabric.Image
- */
-fabric.Image.filters = fabric.Image.filters || { };
-
/**
* Sepia2 filter class
* @class fabric.Image.filters.Sepia2
@@ -16645,11 +16724,20 @@ fabric.Image.filters.Sepia2 = fabric.util.createClass(/** @lends fabric.Image.fi
},
/**
- * Returns json representation of filter
- * @return {String} json representation of filter
+ * Returns object representation of an instance
+ * @return {Object} Object representation of an instance
+ */
+ toObject: function() {
+ return { type: this.type };
+ },
+
+ /**
+ * Returns a JSON representation of an instance
+ * @return {Object} JSON
*/
toJSON: function() {
- return { type: this.type };
+ // delegate, not alias
+ return this.toObject();
}
});
@@ -16663,12 +16751,6 @@ fabric.Image.filters.Sepia2.fromObject = function() {
};
-/**
- * @namespace fabric.Image.filters
- * @memberOf fabric.Image
- */
-fabric.Image.filters = fabric.Image.filters || { };
-
/**
* Tint filter class
* @class fabric.Image.filters.Tint
@@ -16723,14 +16805,23 @@ fabric.Image.filters.Tint = fabric.util.createClass(/** @lends fabric.Image.filt
},
/**
- * Returns json representation of filter
- * @return {Object} json representation of filter
+ * Returns object representation of an instance
+ * @return {Object} Object representation of an instance
*/
- toJSON: function() {
+ toObject: function() {
return {
type: this.type,
color: this.color
};
+ },
+
+ /**
+ * Returns a JSON representation of an instance
+ * @return {Object} JSON
+ */
+ toJSON: function() {
+ // delegate, not alias
+ return this.toObject();
}
});
@@ -17640,6 +17731,8 @@ fabric.Image.filters.Tint.fromObject = function(object) {
/**
* List of attribute names to account for when parsing SVG element (used by {@link fabric.Text.fromElement})
* @static
+ * @memberOf fabric.Text
+ * @see: http://www.w3.org/TR/SVG/text.html#TextElement
*/
fabric.Text.ATTRIBUTE_NAMES = fabric.SHARED_ATTRIBUTES.concat(
'x y font-family font-style font-weight font-size text-decoration'.split(' '));
@@ -17647,12 +17740,12 @@ fabric.Image.filters.Tint.fromObject = function(object) {
/**
* Returns fabric.Text instance from an SVG element (not yet implemented)
* @static
+ * @memberOf fabric.Text
* @param {SVGElement} element Element to parse
* @param {Object} [options] Options object
* @return {fabric.Text} Instance of fabric.Text
*/
fabric.Text.fromElement = function(element, options) {
-
if (!element) {
return null;
}
@@ -17680,6 +17773,7 @@ fabric.Image.filters.Tint.fromObject = function(object) {
/**
* Returns fabric.Text instance from an object representation
* @static
+ * @memberOf fabric.Text
* @param object {Object} object Object to create an instance from
* @return {fabric.Text} Instance of fabric.Text
*/
diff --git a/dist/all.min.js b/dist/all.min.js
index 4163617c..b597ac90 100644
--- a/dist/all.min.js
+++ b/dist/all.min.js
@@ -2,5 +2,5 @@
[i][n].length;o-1?s(e,t.match(/opacity:\s*(\d?\.?\d*)/)[1]):e;for(var r in t)if(r==="opacity")s(e,t[r]);else{var i=r==="float"||r==="cssFloat"?typeof n.styleFloat=="undefined"?"cssFloat":"styleFloat":r;n[i]=t[r]}return e}var t=fabric.document.createElement("div"),n=typeof t.style.opacity=="string",r=typeof t.style.filter=="string",i=/alpha\s*\(\s*opacity\s*=\s*([^\)]+)\)/,s=function(e){return e};n?s=function(e,t){return e.style.opacity=t,e}:r&&(s=function(e,t){var n=e.style;return e.currentStyle&&!e.currentStyle.hasLayout&&(n.zoom=1),i.test(n.filter)?(t=t>=.9999?"":"alpha(opacity="+t*100+")",n.filter=n.filter.replace(i,t)):n.filter+=" alpha(opacity="+t*100+")",e}),fabric.util.setStyle=e}(),function(){function t(e){return typeof e=="string"?fabric.document.getElementById(e):e}function s(e,t){var n=fabric.document.createElement(e);for(var r in t)r==="class"?n.className=t[r]:r==="for"?n.htmlFor=t[r]:n.setAttribute(r,t[r]);return n}function o(e,t){(" "+e.className+" ").indexOf(" "+t+" ")===-1&&(e.className+=(e.className?" ":"")+t)}function u(e,t,n){return typeof t=="string"&&(t=s(t,n)),e.parentNode&&e.parentNode.replaceChild(t,e),t.appendChild(e),t}function a(e){var t,n,r={left:0,top:0},i=e&&e.ownerDocument,s={left:0,top:0},o={borderLeftWidth:"left",borderTopWidth:"top",paddingLeft:"left",paddingTop:"top"};if(!i)return{left:0,top:0};for(var u in o)s[o[u]]+=parseInt(f(e,u),10)||0;return t=i.documentElement,typeof e.getBoundingClientRect!="undefined"&&(r=e.getBoundingClientRect()),i!=null&&i===i.window?n=i:n=i.nodeType===9&&(i.defaultView||i.parentWindow),{left:r.left+(n.pageXOffset||t.scrollLeft)-(t.clientLeft||0)+s.left,top:r.top+(n.pageYOffset||t.scrollTop)-(t.clientTop||0)+s.top}}function f(e,t){e.style||(e.style={});if(fabric.document.defaultView&&fabric.document.defaultView.getComputedStyle)return fabric.document.defaultView.getComputedStyle(e,null)[t];var n=e.style[t];return!n&&e.currentStyle&&(n=e.currentStyle[t]),n}var e=Array.prototype.slice,n=function(t){return e.call(t,0)},r;try{r=n(fabric.document.childNodes)instanceof Array}catch(i){}r||(n=function(e){var t=new Array(e.length),n=e.length;while(n--)t[n]=e[n];return t}),function(){function n(e){return typeof e.onselectstart!="undefined"&&(e.onselectstart=fabric.util.falseFunction),t?e.style[t]="none":typeof e.unselectable=="string"&&(e.unselectable="on"),e}function r(e){return typeof e.onselectstart!="undefined"&&(e.onselectstart=null),t?e.style[t]="":typeof e.unselectable=="string"&&(e.unselectable=""),e}var e=fabric.document.documentElement.style,t="userSelect"in e?"userSelect":"MozUserSelect"in e?"MozUserSelect":"WebkitUserSelect"in e?"WebkitUserSelect":"KhtmlUserSelect"in e?"KhtmlUserSelect":"";fabric.util.makeElementUnselectable=n,fabric.util.makeElementSelectable=r}(),function(){function e(e,t){var n=fabric.document.getElementsByTagName("head")[0],r=fabric.document.createElement("script"),i=!0;r.onload=r.onreadystatechange=function(e){if(i){if(typeof this.readyState=="string"&&this.readyState!=="loaded"&&this.readyState!=="complete")return;i=!1,t(e||fabric.window.event),r=r.onload=r.onreadystatechange=null}},r.src=e,n.appendChild(r)}fabric.util.getScript=e}(),fabric.util.getById=t,fabric.util.toArray=n,fabric.util.makeElement=s,fabric.util.addClass=o,fabric.util.wrapElement=u,fabric.util.getElementOffset=a,fabric.util.getElementStyle=f}(),function(){function e(e,t){return e+(/\?/.test(e)?"&":"?")+t}function n(){}function r(r,i){i||(i={});var s=i.method?i.method.toUpperCase():"GET",o=i.onComplete||function(){},u=t(),a;return u.onreadystatechange=function(){u.readyState===4&&(o(u),u.onreadystatechange=n)},s==="GET"&&(a=null,typeof i.parameters=="string"&&(r=e(r,i.parameters))),u.open(s,r,!0),(s==="POST"||s==="PUT")&&u.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),u.send(a),u}var t=function(){var e=[function(){return new ActiveXObject("Microsoft.XMLHTTP")},function(){return new ActiveXObject("Msxml2.XMLHTTP")},function(){return new ActiveXObject("Msxml2.XMLHTTP.3.0")},function(){return new XMLHttpRequest}];for(var t=e.length;t--;)try{var n=e[t]();if(n)return e[t]}catch(r){}}();fabric.util.request=r}(),function(){function e(e){e||(e={});var t=+(new Date),r=e.duration||500,i=t+r,s,o=e.onChange||function(){},u=e.abort||function(){return!1},a=e.easing||function(e,t,n,r){return-n*Math.cos(e/r*(Math.PI/2))+n+t},f="startValue"in e?e.startValue:0,l="endValue"in e?e.endValue:100,c=e.byValue||l-f;e.onStart&&e.onStart(),function h(){s=+(new Date);var l=s>i?r:s-t;o(a(l,f,c,r));if(s>i||u()){e.onComplete&&e.onComplete();return}n(h)}()}var t=fabric.window.requestAnimationFrame||fabric.window.webkitRequestAnimationFrame||fabric.window.mozRequestAnimationFrame||fabric.window.oRequestAnimationFrame||fabric.window.msRequestAnimationFrame||function(e){fabric.window.setTimeout(e,1e3/60)},n=function(){return t.apply(fabric.window,arguments)};fabric.util.animate=e,fabric.util.requestAnimFrame=n}(),function(){function e(e,t,n,r){return n*(e/=r)*e+t}function t(e,t,n,r){return-n*(e/=r)*(e-2)+t}function n(e,t,n,r){return e/=r/2,e<1?n/2*e*e+t:-n/2*(--e*(e-2)-1)+t}function r(e,t,n,r){return n*(e/=r)*e*e+t}function i(e,t,n,r){return n*((e=e/r-1)*e*e+1)+t}function s(e,t,n,r){return e/=r/2,e<1?n/2*e*e*e+t:n/2*((e-=2)*e*e+2)+t}function o(e,t,n,r){return n*(e/=r)*e*e*e+t}function u(e,t,n,r){return-n*((e=e/r-1)*e*e*e-1)+t}function a(e,t,n,r){return e/=r/2,e<1?n/2*e*e*e*e+t:-n/2*((e-=2)*e*e*e-2)+t}function f(e,t,n,r){return n*(e/=r)*e*e*e*e+t}function l(e,t,n,r){return n*((e=e/r-1)*e*e*e*e+1)+t}function c(e,t,n,r){return e/=r/2,e<1?n/2*e*e*e*e*e+t:n/2*((e-=2)*e*e*e*e+2)+t}function h(e,t,n,r){return-n*Math.cos(e/r*(Math.PI/2))+n+t}function p(e,t,n,r){return n*Math.sin(e/r*(Math.PI/2))+t}function d(e,t,n,r){return-n/2*(Math.cos(Math.PI*e/r)-1)+t}function v(e,t,n,r){return e===0?t:n*Math.pow(2,10*(e/r-1))+t}function m(e,t,n,r){return e===r?t+n:n*(-Math.pow(2,-10*e/r)+1)+t}function g(e,t,n,r){return e===0?t:e===r?t+n:(e/=r/2,e<1?n/2*Math.pow(2,10*(e-1))+t:n/2*(-Math.pow(2,-10*--e)+2)+t)}function y(e,t,n,r){return-n*(Math.sqrt(1-(e/=r)*e)-1)+t}function b(e,t,n,r){return n*Math.sqrt(1-(e=e/r-1)*e)+t}function w(e,t,n,r){return e/=r/2,e<1?-n/2*(Math.sqrt(1-e*e)-1)+t:n/2*(Math.sqrt(1-(e-=2)*e)+1)+t}function E(e,t,n,r){var i=1.70158,s=0,o=n;return e===0?t:(e/=r,e===1?t+n:(s||(s=r*.3),o-1;e=e.split(/\s+/);var n=[],r,i;if(t){r=0,i=e.length;for(;r/i,"")));if(!s.documentElement)return;t.parseSVGDocument(s.documentElement,function(r,i){w.set(e,{objects:t.util.array.invoke(r,"toObject"),options:i}),n(r,i)},r)}e=e.replace(/^\n\s*/,"").trim(),w.has(e,function(r){r?w.get(e,function(e){var t=S(e);n(t.objects,t.options)}):new t.util.request(e,{method:"get",onComplete:i})})}function S(e){var n=e.objects,i=e.options;return n=n.map(function(e){return t[r(e.type)].fromObject(e)}),{objects:n,options:i}}function x(e,n,r){e=e.trim();var i;if(typeof DOMParser!="undefined"){var s=new DOMParser;s&&s.parseFromString&&(i=s.parseFromString(e,"text/xml"))}else t.window.ActiveXObject&&(i=new ActiveXObject("Microsoft.XMLDOM"),i.async="false",i.loadXML(e.replace(//i,"")));t.parseSVGDocument(i.documentElement,function(e,t){n(e,t)},r)}function T(e){var t="";for(var n=0,r=e.length;n',"",""].join("")),t}function N(e){var t="";return e.backgroundColor&&e.backgroundColor.source&&(t=['',''].join("")),t}function C(e){var t=e.getElementsByTagName("linearGradient"),n=e.getElementsByTagName("radialGradient"),r,i,s={};i=t.length;for(;i--;)r=t[i],s[r.getAttribute("id")]=r;i=n.length;for(;i--;)r=n[i],s[r.getAttribute("id")]=r;return s}var t=e.fabric||(e.fabric={}),n=t.util.object.extend,r=t.util.string.capitalize,i=t.util.object.clone,s=t.util.toFixed,o=t.util.multiplyTransformMatrices;t.SHARED_ATTRIBUTES=["transform","fill","fill-opacity","fill-rule","opacity","stroke","stroke-dasharray","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width"];var u={"fill-opacity":"fillOpacity","fill-rule":"fillRule","font-family":"fontFamily","font-size":"fontSize","font-style":"fontStyle","font-weight":"fontWeight",cx:"left",x:"left",r:"radius","stroke-dasharray":"strokeDashArray","stroke-linecap":"strokeLineCap","stroke-linejoin":"strokeLineJoin","stroke-miterlimit":"strokeMiterLimit","stroke-opacity":"strokeOpacity","stroke-width":"strokeWidth","text-decoration":"textDecoration",cy:"top",y:"top",transform:"transformMatrix"},a={stroke:"strokeOpacity",fill:"fillOpacity"};t.parseTransformAttribute=function(){function e(e,t){var n=t[0];e[0]=Math.cos(n),e[1]=Math.sin(n),e[2]=-Math.sin(n),e[3]=Math.cos(n)}function n(e,t){var n=t[0],r=t.length===2?t[1]:t[0];e[0]=n,e[3]=r}function r(e,t){e[2]=t[0]}function i(e,t){e[1]=t[0]}function s(e,t){e[4]=t[0],t.length===2&&(e[5]=t[1])}var o=[1,0,0,1,0,0],u="(?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?)",a="(?:\\s+,?\\s*|,\\s*)",f="(?:(skewX)\\s*\\(\\s*("+u+")\\s*\\))",l="(?:(skewY)\\s*\\(\\s*("+u+")\\s*\\))",c="(?:(rotate)\\s*\\(\\s*("+u+")(?:"+a+"("+u+")"+a+"("+u+"))?\\s*\\))",h="(?:(scale)\\s*\\(\\s*("+u+")(?:"+a+"("+u+"))?\\s*\\))",p="(?:(translate)\\s*\\(\\s*("+u+")(?:"+a+"("+u+"))?\\s*\\))",d="(?:(matrix)\\s*\\(\\s*("+u+")"+a+"("+u+")"+a+"("+u+")"+a+"("+u+")"+a+"("+u+")"+a+"("+u+")"+"\\s*\\))",v="(?:"+d+"|"+p+"|"+h+"|"+c+"|"+f+"|"+l+")",m="(?:"+v+"(?:"+a+v+")*"+")",g="^\\s*(?:"+m+"?)\\s*$",y=new RegExp(g),b=new RegExp(v,"g");return function(u){var a=o.concat(),f=[];if(!u||u&&!y.test(u))return a;u.replace(b,function(t){var u=(new RegExp(v)).exec(t).filter(function(e){return e!==""&&e!=null}),l=u[1],c=u.slice(2).map(parseFloat);switch(l){case"translate":s(a,c);break;case"rotate":e(a,c);break;case"scale":n(a,c);break;case"skewX":r(a,c);break;case"skewY":i(a,c);break;case"matrix":a=c}f.push(a.concat()),a=o.concat()});var l=f[0];while(f.length>1)f.shift(),l=t.util.multiplyTransformMatrices(l,f[0]);return l}}(),t.parseSVGDocument=function(){function s(e,t){while(e&&(e=e.parentNode))if(t.test(e.nodeName))return!0;return!1}var e=/^(path|circle|polygon|polyline|ellipse|rect|line|image|text)$/,n="(?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?)",r=new RegExp("^\\s*("+n+"+)\\s*,?"+"\\s*("+n+"+)\\s*,?"+"\\s*("+n+"+)\\s*,?"+"\\s*("+n+"+)\\s*"+"$");return function(n,o,u){if(!n)return;var a=new Date,f=t.util.toArray(n.getElementsByTagName("*"));if(f.length===0){f=n.selectNodes("//*[name(.)!='svg']");var l=[];for(var c=0,h=f.length;ce.x&&this.y>e.y},gte:function(e){return this.x>=e.x&&this.y>=e.y},lerp:function(e,t){return new n(this.x+(e.x-this.x)*t,this.y+(e.y-this.y)*t)},distanceFrom:function(e){var t=this.x-e.x,n=this.y-e.y;return Math.sqrt(t*t+n*n)},midPointFrom:function(e){return new n(this.x+(e.x-this.x)/2,this.y+(e.y-this.y)/2)},min:function(e){return new n(Math.min(this.x,e.x),Math.min(this.y,e.y))},max:function(e){return new n(Math.max(this.x,e.x),Math.max(this.y,e.y))},toString:function(){return this.x+","+this.y},setXY:function(e,t){this.x=e,this.y=t},setFromPoint:function(e){this.x=e.x,this.y=e.y},swap:function(e){var t=this.x,n=this.y;this.x=e.x,this.y=e.y,e.x=t,e.y=n}}}(typeof exports!="undefined"?exports:this),function(e){"use strict";function n(e){this.status=e,this.points=[]}var t=e.fabric||(e.fabric={});if(t.Intersection){t.warn("fabric.Intersection is already defined");return}t.Intersection=n,t.Intersection.prototype={appendPoint:function(e){this.points.push(e)},appendPoints:function(e){this.points=this.points.concat(e)}},t.Intersection.intersectLineLine=function(e,r,i,s){var o,u=(s.x-i.x)*(e.y-i.y)-(s.y-i.y)*(e.x-i.x),a=(r.x-e.x)*(e.y-i.y)-(r.y-e.y)*(e.x-i.x),f=(s.y-i.y)*(r.x-e.x)-(s.x-i.x)*(r.y-e.y);if(f!==0){var l=u/f,c=a/f;0<=l&&l<=1&&0<=c&&c<=1?(o=new n("Intersection"),o.points.push(new t.Point(e.x+l*(r.x-e.x),e.y+l*(r.y-e.y)))):o=new n}else u===0||a===0?o=new n("Coincident"):o=new n("Parallel");return o},t.Intersection.intersectLinePolygon=function(e,t,r){var i=new n,s=r.length;for(var o=0;o0&&(i.status="Intersection"),i},t.Intersection.intersectPolygonPolygon=function(e,t){var r=new n,i=e.length;for(var s=0;s0&&(r.status="Intersection"),r},t.Intersection.intersectPolygonRectangle=function(e,r,i){var s=r.min(i),o=r.max(i),u=new t.Point(o.x,s.y),a=new t.Point(s.x,o.y),f=n.intersectLinePolygon(s,u,e),l=n.intersectLinePolygon(u,o,e),c=n.intersectLinePolygon(o,a,e),h=n.intersectLinePolygon(a,s,e),p=new n;return p.appendPoints(f.points),p.appendPoints(l.points),p.appendPoints(c.points),p.appendPoints(h.points),p.points.length>0&&(p.status="Intersection"),p}}(typeof exports!="undefined"?exports:this),function(e){"use strict";function n(e){e?this._tryParsingColor(e):this.setSource([0,0,0,1])}function r(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+(t-e)*6*n:n<.5?t:n<2/3?e+(t-e)*(2/3-n)*6:e}var t=e.fabric||(e.fabric={});if(t.Color){t.warn("fabric.Color is already defined.");return}t.Color=n,t.Color.prototype={_tryParsingColor:function(e){var t;e in n.colorNameMap&&(e=n.colorNameMap[e]),t=n.sourceFromHex(e),t||(t=n.sourceFromRgb(e)),t||(t=n.sourceFromHsl(e)),t&&this.setSource(t)},_rgbToHsl:function(e,n,r){e/=255,n/=255,r/=255;var i,s,o,u=t.util.array.max([e,n,r]),a=t.util.array.min([e,n,r]);o=(u+a)/2;if(u===a)i=s=0;else{var f=u-a;s=o>.5?f/(2-u-a):f/(u+a);switch(u){case e:i=(n-r)/f+(n']:this.type==="radial"&&(i=["']);for(var s=0;s');return i.push(this.type==="linear"?"":""),i.join("")},toLive:function(e){var t;if(!this.type)return;this.type==="linear"?t=e.createLinearGradient(this.coords.x1,this.coords.y1,this.coords.x2,this.coords.y2):this.type==="radial"&&(t=e.createRadialGradient(this.coords.x1,this.coords.y1,this.coords.r1,this.coords.x2,this.coords.y2,this.coords.r2));for(var n=0,r=this.colorStops.length;n'+''+""},toLive:function(e){var t=typeof this.source=="function"?this.source():this.source;return e.createPattern(t,this.repeat)}}),fabric.Shadow=fabric.util.createClass({color:"rgb(0,0,0)",blur:0,offsetX:0,offsetY:0,affectStroke:!1,initialize:function(e){for(var t in e)this[t]=e[t];this.id=fabric.Object.__uid++},toSVG:function(e){var t="SourceAlpha";if(e.fill===this.color||e.stroke===this.color)t="SourceGraphic";return''+''+''+""+""+''+""+""},toObject:function(){return{color:this.color,blur:this.blur,offsetX:this.offsetX,offsetY:this.offsetY}}}),function(){"use strict";if(fabric.StaticCanvas){fabric.warn("fabric.StaticCanvas is already defined.");return}var e=fabric.util.object.extend,t=fabric.util.getElementOffset,n=fabric.util.removeFromArray,r=fabric.util.removeListener,i=new Error("Could not initialize `canvas` element");fabric.StaticCanvas=function(e,t){t||(t={}),this._initStatic(e,t),fabric.StaticCanvas.activeInstance=this},e(fabric.StaticCanvas.prototype,fabric.Observable),e(fabric.StaticCanvas.prototype,fabric.Collection),e(fabric.StaticCanvas.prototype,fabric.DataURLExporter),e(fabric.StaticCanvas.prototype,{backgroundColor:"",backgroundImage:"",backgroundImageOpacity
:1,backgroundImageStretch:!0,overlayImage:"",overlayImageLeft:0,overlayImageTop:0,includeDefaultValues:!0,stateful:!0,renderOnAddRemove:!0,clipTo:null,controlsAboveOverlay:!1,onBeforeScaleRotate:function(){},_initStatic:function(e,t){this._objects=[],this._createLowerCanvas(e),this._initOptions(t),t.overlayImage&&this.setOverlayImage(t.overlayImage,this.renderAll.bind(this)),t.backgroundImage&&this.setBackgroundImage(t.backgroundImage,this.renderAll.bind(this)),t.backgroundColor&&this.setBackgroundColor(t.backgroundColor,this.renderAll.bind(this)),this.calcOffset()},calcOffset:function(){return this._offset=t(this.lowerCanvasEl),this},setOverlayImage:function(e,t,n){return fabric.util.loadImage(e,function(e){this.overlayImage=e,n&&"overlayImageLeft"in n&&(this.overlayImageLeft=n.overlayImageLeft),n&&"overlayImageTop"in n&&(this.overlayImageTop=n.overlayImageTop),t&&t()},this),this},setBackgroundImage:function(e,t,n){return fabric.util.loadImage(e,function(e){this.backgroundImage=e,n&&"backgroundImageOpacity"in n&&(this.backgroundImageOpacity=n.backgroundImageOpacity),n&&"backgroundImageStretch"in n&&(this.backgroundImageStretch=n.backgroundImageStretch),t&&t()},this),this},setBackgroundColor:function(e,t){if(e.source){var n=this;fabric.util.loadImage(e.source,function(r){n.backgroundColor=new fabric.Pattern({source:r,repeat:e.repeat}),t&&t()})}else this.backgroundColor=e,t&&t();return this},_createCanvasElement:function(){var e=fabric.document.createElement("canvas");e.style||(e.style={});if(!e)throw i;return this._initCanvasElement(e),e},_initCanvasElement:function(e){fabric.util.createCanvasElement(e);if(typeof e.getContext=="undefined")throw i},_initOptions:function(e){for(var t in e)this[t]=e[t];this.width=parseInt(this.lowerCanvasEl.width,10)||0,this.height=parseInt(this.lowerCanvasEl.height,10)||0;if(!this.lowerCanvasEl.style)return;this.lowerCanvasEl.style.width=this.width+"px",this.lowerCanvasEl.style.height=this.height+"px"},_createLowerCanvas:function(e){this.lowerCanvasEl=fabric.util.getById(e)||this._createCanvasElement(),this._initCanvasElement(this.lowerCanvasEl),fabric.util.addClass(this.lowerCanvasEl,"lower-canvas"),this.interactive&&this._applyCanvasStyle(this.lowerCanvasEl),this.contextContainer=this.lowerCanvasEl.getContext("2d")},getWidth:function(){return this.width},getHeight:function(){return this.height},setWidth:function(e){return this._setDimension("width",e)},setHeight:function(e){return this._setDimension("height",e)},setDimensions:function(e){for(var t in e)this._setDimension(t,e[t]);return this},_setDimension:function(e,t){return this.lowerCanvasEl[e]=t,this.lowerCanvasEl.style[e]=t+"px",this.upperCanvasEl&&(this.upperCanvasEl[e]=t,this.upperCanvasEl.style[e]=t+"px"),this.cacheCanvasEl&&(this.cacheCanvasEl[e]=t),this.wrapperEl&&(this.wrapperEl.style[e]=t+"px"),this[e]=t,this.calcOffset(),this.renderAll(),this},getElement:function(){return this.lowerCanvasEl},getActiveObject:function(){return null},getActiveGroup:function(){return null},_draw:function(e,t){if(!t)return;if(this.controlsAboveOverlay){var n=t.hasBorders,r=t.hasControls;t.hasBorders=t.hasControls=!1,t.render(e),t.hasBorders=n,t.hasControls=r}else t.render(e)},_onObjectAdded:function(e){this.stateful&&e.setupState(),e.setCoords(),e.canvas=this,this.fire("object:added",{target:e}),e.fire("added")},_onObjectRemoved:function(e){this.fire("object:removed",{target:e}),e.fire("removed")},getObjects:function(){return this._objects},clearContext:function(e){return e.clearRect(0,0,this.width,this.height),this},getContext:function(){return this.contextContainer},clear:function(){return this._objects.length=0,this.discardActiveGroup&&this.discardActiveGroup(),this.discardActiveObject&&this.discardActiveObject(),this.clearContext(this.contextContainer),this.contextTop&&this.clearContext(this.contextTop),this.fire("canvas:cleared"),this.renderAll(),this},renderAll:function(e){var t=this[e===!0&&this.interactive?"contextTop":"contextContainer"];this.contextTop&&this.selection&&!this._groupSelector&&this.clearContext(this.contextTop),e||this.clearContext(t),this.fire("before:render"),this.clipTo&&fabric.util.clipContext(this,t),this.backgroundColor&&(t.fillStyle=this.backgroundColor.toLive?this.backgroundColor.toLive(t):this.backgroundColor,t.fillRect(this.backgroundColor.offsetX||0,this.backgroundColor.offsetY||0,this.width,this.height)),typeof this.backgroundImage=="object"&&this._drawBackroundImage(t);var n=this.getActiveGroup();for(var r=0,i=this._objects.length;r','\n'),t.push("