diff --git a/HEADER.js b/HEADER.js index a4d7239e..6f2c4652 100644 --- a/HEADER.js +++ b/HEADER.js @@ -18,14 +18,12 @@ else { /** * True when in environment that supports touch events - * @property isTouchSupported * @type boolean */ fabric.isTouchSupported = "ontouchstart" in fabric.document.documentElement; /** * True when in environment that's probably Node.js - * @property isLikelyNode * @type boolean */ fabric.isLikelyNode = typeof Buffer !== 'undefined' && typeof window === 'undefined'; diff --git a/dist/all.js b/dist/all.js index 7d656049..1759c992 100644 --- a/dist/all.js +++ b/dist/all.js @@ -19,14 +19,12 @@ else { /** * True when in environment that supports touch events - * @property isTouchSupported * @type boolean */ fabric.isTouchSupported = "ontouchstart" in fabric.document.documentElement; /** * True when in environment that's probably Node.js - * @property isLikelyNode * @type boolean */ fabric.isLikelyNode = typeof Buffer !== 'undefined' && typeof window === 'undefined'; @@ -1751,14 +1749,12 @@ if (!JSON) { }()); /** * Wrapper around `console.log` (when available) - * @method log * @param {Any} values Values to log */ fabric.log = function() { }; /** * Wrapper around `console.warn` (when available) - * @method warn * @param {Any} Values to log as a warning */ fabric.warn = function() { }; @@ -1776,19 +1772,17 @@ if (typeof console !== 'undefined') { } } -/** - * @namespace - */ -fabric.Observable = { +(function(){ /** * Observes specified event - * @method observe - * @depracated Since 0.8.34. Use `on` instead. + * @deprecated `observe` deprecated since 0.8.34 (use `on` instead) + * @memberOf fabric.Observable + * @alias on * @param {String} eventName * @param {Function} handler */ - observe: function(eventName, handler) { + function observe(eventName, handler) { if (!this.__eventListeners) { this.__eventListeners = { }; } @@ -1804,16 +1798,17 @@ fabric.Observable = { } this.__eventListeners[eventName].push(handler); } - }, + } /** * Stops event observing for a particular event handler - * @method stopObserving - * @depracated Since 0.8.34. Use `off` instead. + * @deprecated `stopObserving` deprecated since 0.8.34 (use `off` instead) + * @memberOf fabric.Observable + * @alias off * @param {String} eventName * @param {Function} handler */ - stopObserving: function(eventName, handler) { + function stopObserving(eventName, handler) { if (!this.__eventListeners) { this.__eventListeners = { }; } @@ -1825,16 +1820,17 @@ fabric.Observable = { this.__eventListeners[eventName].length = 0; } } - }, + } /** * Fires event with an optional options object - * @deprecated since 1.0.7 - * @method fire + * @deprecated `fire` deprecated since 1.0.7 (use `trigger` instead) + * @memberOf fabric.Observable + * @alias trigger * @param {String} eventName * @param {Object} [options] */ - fire: function(eventName, options) { + function fire(eventName, options) { if (!this.__eventListeners) { this.__eventListeners = { }; } @@ -1845,39 +1841,31 @@ fabric.Observable = { listenersForEvent[i](options || { }); } } -}; + + /** + * @namespace fabric.Observable + */ + fabric.Observable = { + observe: observe, + stopObserving: stopObserving, + fire: fire, + + on: observe, + off: stopObserving, + trigger: fire + }; +})(); /** - * Alias for observe - * @method observe - * @type function - */ -fabric.Observable.on = fabric.Observable.observe; - -/** - * Alias for stopObserving - * @method off - * @type function - */ -fabric.Observable.off = fabric.Observable.stopObserving; - -/** - * Alias for fire - * @method trigger - * @type function - */ -fabric.Observable.trigger = fabric.Observable.fire; -/** - * @namespace + * @namespace fabric.Collection */ fabric.Collection = { /** * Adds objects to collection, then renders canvas (if `renderOnAddition` is not `false`) * Objects should be instances of (or inherit from) fabric.Object - * @method add * @param [...] Zero or more fabric instances - * @chainable + * @return {Self} thisArg */ add: function () { this._objects.push.apply(this._objects, arguments); @@ -1891,11 +1879,10 @@ fabric.Collection = { /** * Inserts an object into collection at specified index and renders canvas * An object should be an instance of (or inherit from) fabric.Object - * @method insertAt * @param object {Object} Object to insert * @param index {Number} index to insert object at * @param nonSplicing {Boolean} when `true`, no splicing (shifting) of objects occurs - * @chainable + * @return {Self} thisArg */ insertAt: function (object, index, nonSplicing) { var objects = this.getObjects(); @@ -1912,10 +1899,8 @@ fabric.Collection = { /** * Removes an object from a group - * @method remove * @param {Object} object - * @return {fabric.Group} thisArg - * @chainable + * @return {Self} thisArg */ remove: function(object) { @@ -1934,7 +1919,6 @@ fabric.Collection = { /** * Executes given function for each object in this group - * @method forEachObject * @param {Function} callback * Callback invoked with current object as first argument, * index - as second and an array of all objects - as third. @@ -1943,7 +1927,7 @@ fabric.Collection = { * when no `context` argument is given * * @param {Object} context Context (aka thisObject) - * @chainable + * @return {Self} thisArg */ forEachObject: function(callback, context) { var objects = this.getObjects(), @@ -1956,9 +1940,8 @@ fabric.Collection = { /** * Returns object at specified index - * @method item * @param {Number} index - * @return {fabric.Object} + * @return {Self} thisArg */ item: function (index) { return this.getObjects()[index]; @@ -1966,7 +1949,6 @@ fabric.Collection = { /** * Returns true if collection contains no objects - * @method isEmpty * @return {Boolean} true if collection is empty */ isEmpty: function () { @@ -1983,7 +1965,6 @@ fabric.Collection = { /** * Returns true if collection contains an object - * @method contains * @param {Object} object Object to check against * @return {Boolean} `true` if collection contains an object */ @@ -1993,7 +1974,6 @@ fabric.Collection = { /** * Returns number representation of a collection complexity - * @method complexity * @return {Number} complexity */ complexity: function () { @@ -2005,9 +1985,7 @@ fabric.Collection = { /** * Makes all of the collection objects grayscale (i.e. calling `toGrayscale` on them) - * @method toGrayscale - * @return {fabric.Group} thisArg - * @chainable + * @return {Self} thisArg */ toGrayscale: function() { return this.forEachObject(function(obj) { @@ -2015,13 +1993,14 @@ fabric.Collection = { }); } }; + (function() { var sqrt = Math.sqrt, atan2 = Math.atan2; /** - * @namespace Various utilities + * @namespace fabric.util */ fabric.util = { }; @@ -2030,7 +2009,6 @@ fabric.Collection = { * Presence of value (and its position in an array) is determined via `Array.prototype.indexOf` * @static * @memberOf fabric.util - * @method removeFromArray * @param {Array} array * @param {Any} value * @return {Array} original array @@ -2046,7 +2024,6 @@ fabric.Collection = { /** * Returns random number between 2 specified ones. * @static - * @method getRandomInt * @memberOf fabric.util * @param {Number} min lower limit * @param {Number} max upper limit @@ -2061,7 +2038,6 @@ fabric.Collection = { /** * Transforms degrees to radians. * @static - * @method degreesToRadians * @memberOf fabric.util * @param {Number} degrees value in degrees * @return {Number} value in radians @@ -2073,7 +2049,6 @@ fabric.Collection = { /** * Transforms radians to degrees. * @static - * @method radiansToDegrees * @memberOf fabric.util * @param {Number} radians value in radians * @return {Number} value in degrees @@ -2085,7 +2060,6 @@ fabric.Collection = { /** * Rotates `point` around `origin` with `radians` * @static - * @method rotatePoint * @memberOf fabric.util * @param {fabric.Point} The point to rotate * @param {fabric.Point} The origin of the rotation @@ -2107,7 +2081,6 @@ fabric.Collection = { /** * A wrapper around Number#toFixed, which contrary to native method returns number, not string. * @static - * @method toFixed * @memberOf fabric.util * @param {Number | String} number number to operate on * @param {Number} fractionDigits number of fraction digits to "leave" @@ -2120,7 +2093,6 @@ fabric.Collection = { /** * Function which always returns `false`. * @static - * @method falseFunction * @memberOf fabric.util * @return {Boolean} */ @@ -2130,7 +2102,6 @@ fabric.Collection = { /** * Changes value from one to another within certain period of time, invoking callbacks as value is being changed. - * @method animate * @memberOf fabric.util * @param {Object} [options] Animation options * @param {Function} [options.onChange] Callback; invoked on every value change @@ -2179,7 +2150,6 @@ fabric.Collection = { }; /** * requestAnimationFrame polyfill based on http://paulirish.com/2011/requestanimationframe-for-smart-animating/ - * @method requestAnimFrame * @memberOf fabric.util * @param {Function} callback Callback to invoke * @param {DOMElement} element optional Element to associate with animation @@ -2190,7 +2160,6 @@ fabric.Collection = { /** * Loads image element from given url and passes it to a callback - * @method loadImage * @memberOf fabric.util * @param {String} url URL representing an image * @param {Function} callback Callback; invoked with loaded image @@ -2215,7 +2184,6 @@ fabric.Collection = { * Creates corresponding fabric instances from their object representations * @static * @memberOf fabric.util - * @method enlivenObjects * @param {Array} objects Objects to enliven * @param {Function} callback Callback to invoke when all objects are created */ @@ -2261,7 +2229,6 @@ fabric.Collection = { * Groups SVG elements (usually those retrieved from SVG document) * @static * @memberOf fabric.util - * @method groupSVGElements * @param {Array} elements SVG elements to group * @param {Object} [options] Options object * @return {fabric.Object|fabric.PathGroup} @@ -2302,7 +2269,6 @@ fabric.Collection = { * Populates an object with properties of another object * @static * @memberOf fabric.util - * @method populateWithProperties * @param {Object} source Source object * @param {Object} destination Destination object * @return {Array} properties Propertie names to include @@ -2321,7 +2287,6 @@ fabric.Collection = { * This method is used to draw dashed line around selection area. * See dotted stroke in canvas * - * @method drawDashedLine * @param ctx {Canvas} context * @param x {Number} start x coordinate * @param y {Number} start y coordinate @@ -2360,7 +2325,6 @@ fabric.Collection = { * Creates canvas element and initializes it via excanvas if necessary * @static * @memberOf fabric.util - * @method createCanvasElement * @param {CanvasElement} [canvasEl] optional canvas element to initialize; when not given, element is created implicitly * @return {CanvasElement} initialized canvas element */ @@ -2376,7 +2340,6 @@ fabric.Collection = { * Creates accessors (getXXX, setXXX) for a "class", based on "stateProperties" array * @static * @memberOf fabric.util - * @method createAccessors * @param {Object} klass "Class" to create accessors for */ function createAccessors(klass) { @@ -2404,7 +2367,10 @@ fabric.Collection = { } /** - * @method clipContext + * @static + * @memberOf fabric.util + * @param {fabric.Object} receiver Object implementing `clipTo` method + * @param {CanvasRenderingContext2D} ctx Context to clip */ function clipContext(receiver, ctx) { ctx.save(); @@ -2417,7 +2383,6 @@ fabric.Collection = { * Multiply matrix A by matrix B to nest transformations * @static * @memberOf fabric.util - * @method multiplyTransformMatrices * @param {Array} matrixA First transformMatrix * @param {Array} matrixB Second transformMatrix * @return {Array} The product of the two transform matrices @@ -2487,9 +2452,9 @@ fabric.Collection = { if (!Array.prototype.indexOf) { /** * Finds index of an element in an array - * @method indexOf * @param {Any} searchElement * @param {Number} [fromIndex] + * @return {Number} */ Array.prototype.indexOf = function (searchElement /*, fromIndex */ ) { if (this === void 0 || this === null) { @@ -2525,9 +2490,9 @@ fabric.Collection = { if (!Array.prototype.forEach) { /** * Iterates an array, invoking callback for each element - * @method forEach * @param {Function} fn Callback to invoke for each element * @param {Object} [context] Context to invoke callback in + * @return {Array} */ Array.prototype.forEach = function(fn, context) { for (var i = 0, len = this.length >>> 0; i < len; i++) { @@ -2541,9 +2506,9 @@ fabric.Collection = { if (!Array.prototype.map) { /** * Returns a result of iterating over an array, invoking callback for each element - * @method map * @param {Function} fn Callback to invoke for each element * @param {Object} [context] Context to invoke callback in + * @return {Array} */ Array.prototype.map = function(fn, context) { var result = [ ]; @@ -2559,9 +2524,9 @@ fabric.Collection = { if (!Array.prototype.every) { /** * Returns true if a callback returns truthy value for all elements in an array - * @method every * @param {Function} fn Callback to invoke for each element * @param {Object} [context] Context to invoke callback in + * @return {Boolean} */ Array.prototype.every = function(fn, context) { for (var i = 0, len = this.length >>> 0; i < len; i++) { @@ -2576,9 +2541,9 @@ fabric.Collection = { if (!Array.prototype.some) { /** * Returns true if a callback returns truthy value for at least one element in an array - * @method every * @param {Function} fn Callback to invoke for each element * @param {Object} [context] Context to invoke callback in + * @return {Boolean} */ Array.prototype.some = function(fn, context) { for (var i = 0, len = this.length >>> 0; i < len; i++) { @@ -2593,9 +2558,9 @@ fabric.Collection = { if (!Array.prototype.filter) { /** * Returns the result of iterating over elements in an array - * @method filter * @param {Function} fn Callback to invoke for each element * @param {Object} [context] Context to invoke callback in + * @return {Array} */ Array.prototype.filter = function(fn, context) { var result = [ ], val; @@ -2614,9 +2579,9 @@ fabric.Collection = { if (!Array.prototype.reduce) { /** * Returns "folded" (reduced) result of iterating over elements in an array - * @method filter * @param {Function} fn Callback to invoke for each element * @param {Object} [context] Context to invoke callback in + * @return {Any} */ Array.prototype.reduce = function(fn /*, initial*/) { var len = this.length >>> 0, @@ -2650,10 +2615,10 @@ fabric.Collection = { /** * Invokes method on all items in a given array - * @method invoke * @memberOf fabric.util.array * @param {Array} array Array to iterate over * @param {String} method Name of a method to invoke + * @return {Array} */ function invoke(array, method) { var args = slice.call(arguments, 2), result = [ ]; @@ -2665,10 +2630,10 @@ fabric.Collection = { /** * Finds maximum value in array (not necessarily "first" one) - * @method max * @memberOf fabric.util.array * @param {Array} array Array to iterate over * @param {String} byProperty + * @return {Any} */ function max(array, byProperty) { if (!array || array.length === 0) return undefined; @@ -2694,10 +2659,10 @@ fabric.Collection = { /** * Finds minimum value in array (not necessarily "first" one) - * @method min * @memberOf fabric.util.array * @param {Array} array Array to iterate over * @param {String} byProperty + * @return {Any} */ function min(array, byProperty) { if (!array || array.length === 0) return undefined; @@ -2723,7 +2688,7 @@ fabric.Collection = { } /** - * @namespace Array utilities + * @namespace fabric.util.array */ fabric.util.array = { invoke: invoke, @@ -2732,14 +2697,15 @@ fabric.Collection = { }; })(); + (function(){ /** * Copies all enumerable properties of one object to another * @memberOf fabric.util.object - * @method extend * @param {Object} destination Where to copy to * @param {Object} source Where to copy from + * @return {Object} */ function extend(destination, source) { // JScript DontEnum bug is not taken care of @@ -2751,27 +2717,28 @@ fabric.Collection = { /** * Creates an empty object and copies all enumerable properties of another object to it - * @method clone * @memberOf fabric.util.object * @param {Object} object Object to clone + * @return {Object} */ function clone(object) { return extend({ }, object); } - /** @namespace Object utilities */ + /** @namespace fabric.util.object */ fabric.util.object = { extend: extend, clone: clone }; })(); + (function() { if (!String.prototype.trim) { /** * Trims a string (removing whitespace from the beginning and the end) - * @method trim + * @function external:String#trim * @see String#trim on MDN */ String.prototype.trim = function () { @@ -2783,7 +2750,6 @@ if (!String.prototype.trim) { /** * Camelizes a string * @memberOf fabric.util.string - * @method camelize * @param {String} string String to camelize * @return {String} Camelized version of a string */ @@ -2796,7 +2762,6 @@ function camelize(string) { /** * Capitalizes a string * @memberOf fabric.util.string - * @method capitalize * @param {String} string String to capitalize * @return {String} Capitalized version of a string */ @@ -2807,7 +2772,6 @@ function capitalize(string) { /** * Escapes XML in a string * @memberOf fabric.util.string - * @method escapeXml * @param {String} string String to escape * @return {String} Escaped version of a string */ @@ -2819,7 +2783,10 @@ function escapeXml(string) { .replace(/>/g, '>'); } -/** @namespace String utilities */ +/** + * String utilities + * @namespace fabric.util.string + */ fabric.util.string = { camelize: camelize, capitalize: capitalize, @@ -2921,7 +2888,6 @@ fabric.util.string = { /** * Helper for creation of "classes". Note that pr - * @method createClass * @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) @@ -2959,6 +2925,7 @@ fabric.util.string = { fabric.util.createClass = createClass; })(); + (function () { /* EVENT HANDLING */ @@ -3130,7 +3097,6 @@ fabric.util.string = { /** * Cross-browser wrapper for getting event's coordinates - * @method getPointer * @memberOf fabric.util * @param {Event} event * @param {HTMLCanvasElement} upperCanvasEl <canvas> element on which object selection is drawn @@ -3207,7 +3173,6 @@ fabric.util.string = { /** * Cross-browser wrapper for setting element's style - * @method setStyle * @memberOf fabric.util * @param {HTMLElement} element * @param {Object} styles @@ -3274,13 +3239,13 @@ fabric.util.string = { fabric.util.setStyle = setStyle; })(); + (function() { var _slice = Array.prototype.slice; /** * Takes id and returns an element with that id (if one exists in a document) - * @method getById * @memberOf fabric.util * @param {String|HTMLElement} id * @return {HTMLElement|null} @@ -3291,7 +3256,6 @@ fabric.util.string = { /** * Converts an array-like object (e.g. arguments or NodeList) to an array - * @method toArray * @memberOf fabric.util * @param {Object} arrayLike * @return {Array} @@ -3318,7 +3282,6 @@ fabric.util.string = { /** * Creates specified element with specified attributes - * @method makeElement * @memberOf fabric.util * @param {String} tagName Type of an element to create * @param {Object} [attributes] Attributes to set on an element @@ -3342,7 +3305,6 @@ fabric.util.string = { /** * Adds class to an element - * @method addClass * @memberOf fabric.util * @param {HTMLElement} element Element to add class to * @param {String} className Class to add to an element @@ -3355,7 +3317,6 @@ fabric.util.string = { /** * Wraps element with another element - * @method wrapElement * @memberOf fabric.util * @param {HTMLElement} element Element to wrap * @param {HTMLElement|String} wrapper Element to wrap with @@ -3375,7 +3336,6 @@ fabric.util.string = { /** * Returns offset for a given element - * @method getElementOffset * @function * @memberOf fabric.util * @param {HTMLElement} element Element to get offset for @@ -3395,7 +3355,6 @@ fabric.util.string = { /** * Returns position of a given element - * @method getElementPosition * @function * @memberOf fabric.util * @param {HTMLElement} element Element to get offset for @@ -3431,7 +3390,6 @@ fabric.util.string = { /** * Makes element unselectable - * @method makeElementUnselectable * @memberOf fabric.util * @param {HTMLElement} element Element to make unselectable * @return {HTMLElement} Element that was passed in @@ -3451,7 +3409,6 @@ fabric.util.string = { /** * Makes element selectable - * @method makeElementSelectable * @memberOf fabric.util * @param {HTMLElement} element Element to make selectable * @return {HTMLElement} Element that was passed in @@ -3477,7 +3434,6 @@ fabric.util.string = { /** * Inserts a script element with a given url into a document; invokes callback, when that script is finished loading - * @method getScript * @memberOf fabric.util * @param {String} url URL of a script to load * @param {Function} callback Callback to execute when script is finished loading @@ -3519,6 +3475,7 @@ fabric.util.string = { fabric.util.getElementPosition = getElementPosition; })(); + (function(){ function addParamToUrl(url, param) { @@ -3547,7 +3504,6 @@ fabric.util.string = { /** * Cross-browser abstraction for sending XMLHttpRequest - * @method request * @memberOf fabric.util * @param {String} url URL to send XMLHttpRequest to * @param {Object} [options] Options object @@ -3591,11 +3547,11 @@ fabric.util.string = { fabric.util.request = request; })(); + (function() { /** * Quadratic easing in - * @method easeInQuad * @memberOf fabric.util.ease */ function easeInQuad(t, b, c, d) { @@ -3604,7 +3560,6 @@ fabric.util.string = { /** * Quadratic easing out - * @method easeOutQuad * @memberOf fabric.util.ease */ function easeOutQuad(t, b, c, d) { @@ -3613,7 +3568,6 @@ fabric.util.string = { /** * Quadratic easing in and out - * @method easeInOutQuad * @memberOf fabric.util.ease */ function easeInOutQuad(t, b, c, d) { @@ -3624,7 +3578,6 @@ fabric.util.string = { /** * Cubic easing in - * @method easeInCubic * @memberOf fabric.util.ease */ function easeInCubic(t, b, c, d) { @@ -3633,7 +3586,6 @@ fabric.util.string = { /** * Cubic easing out - * @method easeOutCubic * @memberOf fabric.util.ease */ function easeOutCubic(t, b, c, d) { @@ -3642,7 +3594,6 @@ fabric.util.string = { /** * Cubic easing in and out - * @method easeInOutCubic * @memberOf fabric.util.ease */ function easeInOutCubic(t, b, c, d) { @@ -3653,7 +3604,6 @@ fabric.util.string = { /** * Quartic easing in - * @method easeInQuart * @memberOf fabric.util.ease */ function easeInQuart(t, b, c, d) { @@ -3662,7 +3612,6 @@ fabric.util.string = { /** * Quartic easing out - * @method easeOutQuart * @memberOf fabric.util.ease */ function easeOutQuart(t, b, c, d) { @@ -3671,7 +3620,6 @@ fabric.util.string = { /** * Quartic easing in and out - * @method easeInOutQuart * @memberOf fabric.util.ease */ function easeInOutQuart(t, b, c, d) { @@ -3682,7 +3630,6 @@ fabric.util.string = { /** * Quintic easing in - * @method easeInQuint * @memberOf fabric.util.ease */ function easeInQuint(t, b, c, d) { @@ -3691,7 +3638,6 @@ fabric.util.string = { /** * Quintic easing out - * @method easeOutQuint * @memberOf fabric.util.ease */ function easeOutQuint(t, b, c, d) { @@ -3700,7 +3646,6 @@ fabric.util.string = { /** * Quintic easing in and out - * @method easeInOutQuint * @memberOf fabric.util.ease */ function easeInOutQuint(t, b, c, d) { @@ -3711,7 +3656,6 @@ fabric.util.string = { /** * Sinusoidal easing in - * @method easeInSine * @memberOf fabric.util.ease */ function easeInSine(t, b, c, d) { @@ -3720,7 +3664,6 @@ fabric.util.string = { /** * Sinusoidal easing out - * @method easeOutSine * @memberOf fabric.util.ease */ function easeOutSine(t, b, c, d) { @@ -3729,7 +3672,6 @@ fabric.util.string = { /** * Sinusoidal easing in and out - * @method easeInOutSine * @memberOf fabric.util.ease */ function easeInOutSine(t, b, c, d) { @@ -3738,7 +3680,6 @@ fabric.util.string = { /** * Exponential easing in - * @method easeInExpo * @memberOf fabric.util.ease */ function easeInExpo(t, b, c, d) { @@ -3747,7 +3688,6 @@ fabric.util.string = { /** * Exponential easing out - * @method easeOutExpo * @memberOf fabric.util.ease */ function easeOutExpo(t, b, c, d) { @@ -3756,7 +3696,6 @@ fabric.util.string = { /** * Exponential easing in and out - * @method easeInOutExpo * @memberOf fabric.util.ease */ function easeInOutExpo(t, b, c, d) { @@ -3769,7 +3708,6 @@ fabric.util.string = { /** * Circular easing in - * @method easeInCirc * @memberOf fabric.util.ease */ function easeInCirc(t, b, c, d) { @@ -3778,7 +3716,6 @@ fabric.util.string = { /** * Circular easing out - * @method easeOutCirc * @memberOf fabric.util.ease */ function easeOutCirc(t, b, c, d) { @@ -3787,7 +3724,6 @@ fabric.util.string = { /** * Circular easing in and out - * @method easeInOutCirc * @memberOf fabric.util.ease */ function easeInOutCirc(t, b, c, d) { @@ -3798,7 +3734,6 @@ fabric.util.string = { /** * Elastic easing in - * @method easeInElastic * @memberOf fabric.util.ease */ function easeInElastic(t, b, c, d) { @@ -3814,7 +3749,6 @@ fabric.util.string = { /** * Elastic easing out - * @method easeOutElastic * @memberOf fabric.util.ease */ function easeOutElastic(t, b, c, d) { @@ -3830,7 +3764,6 @@ fabric.util.string = { /** * Elastic easing in and out - * @method easeInOutElastic * @memberOf fabric.util.ease */ function easeInOutElastic(t, b, c, d) { @@ -3847,7 +3780,6 @@ fabric.util.string = { /** * Backwards easing in - * @method easeInBack * @memberOf fabric.util.ease */ function easeInBack(t, b, c, d, s) { @@ -3857,7 +3789,6 @@ fabric.util.string = { /** * Backwards easing out - * @method easeOutBack * @memberOf fabric.util.ease */ function easeOutBack(t, b, c, d, s) { @@ -3867,7 +3798,6 @@ fabric.util.string = { /** * Backwards easing in and out - * @method easeInOutBack * @memberOf fabric.util.ease */ function easeInOutBack(t, b, c, d, s) { @@ -3879,7 +3809,6 @@ fabric.util.string = { /** * Bouncing easing in - * @method easeInBounce * @memberOf fabric.util.ease */ function easeInBounce(t, b, c, d) { @@ -3888,7 +3817,6 @@ fabric.util.string = { /** * Bouncing easing out - * @method easeOutBounce * @memberOf fabric.util.ease */ function easeOutBounce(t, b, c, d) { @@ -3905,7 +3833,6 @@ fabric.util.string = { /** * Bouncing easing in and out - * @method easeInOutBounce * @memberOf fabric.util.ease */ function easeInOutBounce(t, b, c, d) { @@ -3914,6 +3841,7 @@ fabric.util.string = { } /** + * Easing functions * See Easing Equations by Robert Penner * @namespace fabric.util.ease */ @@ -3951,6 +3879,7 @@ fabric.util.string = { }; }()); + (function(global) { "use strict"; @@ -3996,7 +3925,6 @@ fabric.util.string = { * Parses parent "g" nodes recursively upwards. * @static * @memberOf fabric - * @method parseAttributes * @param {DOMElement} element Element to parse * @param {Array} attributes Array of attributes to parse * @return {Object} object containing parsed attributes' names/values @@ -4053,7 +3981,6 @@ fabric.util.string = { * @static * @function * @memberOf fabric - * @method parseTransformAttribute * @param attributeValue {String} string containing attribute value * @return {Array} array of 6 elements representing transformation matrix */ @@ -4198,7 +4125,6 @@ fabric.util.string = { * Parses "points" attribute, returning an array of values * @static * @memberOf fabric - * @method parsePointsAttribute * @param points {String} points attribute string * @return {Array} array of points */ @@ -4242,7 +4168,6 @@ fabric.util.string = { * Parses "style" attribute, retuning an object with values * @static * @memberOf fabric - * @method parseStyleAttribute * @param {SVGElement} element Element to parse * @return {Object} Objects with values parsed from style attribute of an element */ @@ -4296,7 +4221,6 @@ fabric.util.string = { * Transforms an array of svg elements to corresponding fabric.* instances * @static * @memberOf fabric - * @method parseElements * @param {Array} elements Array of elements to parse * @param {Function} callback Being passed an array of fabric instances (transformed from SVG elements) * @param {Object} [options] Options object @@ -4351,7 +4275,6 @@ fabric.util.string = { * @static * @function * @memberOf fabric - * @method getCSSRules * @param {SVGDocument} doc SVG document to parse * @return {Object} CSS rules of this document */ @@ -4422,7 +4345,6 @@ fabric.util.string = { * @static * @function * @memberOf fabric - * @method parseSVGDocument * @param {SVGDocument} doc SVG document to parse * @param {Function} callback Callback to call when parsing is finished; It's being passed an array of elements (parsed from a document). * @param {Function} [reviver] Method for further parsing of SVG elements, called after each fabric object created. @@ -4517,15 +4439,13 @@ fabric.util.string = { }; })(); - /** + /** * Used for caching SVG documents (loaded via `fabric.Canvas#loadSVGFromURL`) - * @property * @namespace */ var svgCache = { /** - * @method has * @param {String} name * @param {Function} callback */ @@ -4534,7 +4454,6 @@ fabric.util.string = { }, /** - * @method get * @param {String} url * @param {Function} callback */ @@ -4543,7 +4462,6 @@ fabric.util.string = { }, /** - * @method set * @param {String} url * @param {Object} object */ @@ -4554,7 +4472,6 @@ fabric.util.string = { /** * Takes url corresponding to an SVG document, and parses it into a set of fabric objects. Note that SVG is fetched via XMLHttpRequest, so it needs to conform to SOP (Same Origin Policy) - * @method loadSVGFromURL * @memberof fabric * @param {String} url * @param {Function} callback @@ -4601,8 +4518,8 @@ fabric.util.string = { } /** - * @method _enlivenCachedObject - */ + * @private + */ function _enlivenCachedObject(cachedObject) { var objects = cachedObject.objects, @@ -4617,7 +4534,6 @@ fabric.util.string = { /** * Takes string corresponding to an SVG document, and parses it into a set of fabric objects - * @method loadSVGFromString * @memberof fabric * @param {String} string * @param {Function} callback @@ -4646,7 +4562,6 @@ fabric.util.string = { /** * Creates markup containing SVG font faces - * @method createSVGFontFacesMarkup * @param {Array} objects Array of fabric objects * @return {String} */ @@ -4679,7 +4594,6 @@ fabric.util.string = { /** * Creates markup containing SVG referenced elements like patterns, gradients etc. - * @method createSVGRefElementsMarkup * @param {fabric.Canvas} canvas instance of fabric.Canvas * @return {String} */ @@ -4774,11 +4688,10 @@ fabric.util.string = { * @class Gradient * @memberOf fabric */ - fabric.Gradient = fabric.util.createClass(/** @scope fabric.Gradient.prototype */ { + fabric.Gradient = fabric.util.createClass(/** @lends fabric.Gradient.prototype */ { /** * Constructor - * @method initialize * @param {Object} [options] Options object with type, coords, gradientUnits and colorStops * @return {fabric.Gradient} thisArg */ @@ -4809,7 +4722,6 @@ fabric.util.string = { /** * Adds another colorStop - * @method add * @param {Object} colorStop Object with offset and color * @return {fabric.Gradient} thisArg */ @@ -4823,7 +4735,6 @@ fabric.util.string = { /** * Returns object representation of a gradient - * @method toObject * @return {Object} */ toObject: function() { @@ -4837,7 +4748,6 @@ fabric.util.string = { /** * Returns an instance of CanvasGradient - * @method toLive * @param ctx * @return {CanvasGradient} */ @@ -4871,7 +4781,6 @@ fabric.util.string = { /** * Returns SVG representation of an gradient - * @method toSVG * @param {Object} object Object to create a gradient for * @param {Boolean} normalize Whether coords should be normalized * @return {String} SVG representation of an gradient (linear/radial) @@ -4941,7 +4850,6 @@ fabric.util.string = { /** * Returns {@link fabric.Gradient} instance from an SVG element - * @method fromElement * @static * @memberof fabric.Gradient * @see http://www.w3.org/TR/SVG/pservers.html#LinearGradientElement @@ -5023,7 +4931,6 @@ fabric.util.string = { /** * Returns {@link fabric.Gradient} instance from its object representation - * @method forObject * @static * @param {Object} obj * @param {Object} [options] Options object @@ -5038,7 +4945,6 @@ fabric.util.string = { /** * @private - * @method _convertPercentUnitsToValues */ function _convertPercentUnitsToValues(object, options) { for (var prop in options) { @@ -5063,7 +4969,6 @@ fabric.util.string = { /** * @private - * @method _convertValuesToPercentUnits */ function _convertValuesToPercentUnits(object, options) { for (var prop in options) { @@ -5089,7 +4994,6 @@ fabric.util.string = { * @static * @function * @memberOf fabric - * @method getGradientDefs * @param {SVGDocument} doc SVG document to parse * @return {Object} Gradient definitions; key corresponds to element id, value -- to gradient definition element */ @@ -5117,37 +5021,34 @@ fabric.util.string = { fabric.getGradientDefs = getGradientDefs; })(); + /** * Pattern class * @class Pattern * @memberOf fabric */ -fabric.Pattern = fabric.util.createClass(/** @scope fabric.Pattern.prototype */ { +fabric.Pattern = fabric.util.createClass(/** @lends fabric.Pattern.prototype */ { /** * Repeat property of a pattern (one of repeat, repeat-x, repeat-y) - * @property * @type String */ repeat: 'repeat', /** * Pattern horizontal offset from object's left/top corner - * @property * @type Number */ offsetX: 0, /** * Pattern vertical offset from object's left/top corner - * @property * @type Number */ offsetY: 0, /** * Constructor - * @method initialize * @param {Object} [options] * @return {fabric.Pattern} thisArg */ @@ -5172,7 +5073,6 @@ fabric.Pattern = fabric.util.createClass(/** @scope fabric.Pattern.prototype */ /** * Returns object representation of a pattern - * @method toObject * @return {Object} */ toObject: function() { @@ -5199,7 +5099,6 @@ fabric.Pattern = fabric.util.createClass(/** @scope fabric.Pattern.prototype */ /** * Returns an instance of CanvasPattern - * @method toLive * @param ctx * @return {CanvasPattern} */ @@ -5214,46 +5113,40 @@ fabric.Pattern = fabric.util.createClass(/** @scope fabric.Pattern.prototype */ * @class Shadow * @memberOf fabric */ -fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { +fabric.Shadow = fabric.util.createClass(/** @lends fabric.Shadow.prototype */ { /** * Shadow color - * @property * @type String */ color: 'rgb(0,0,0)', /** * Shadow blur - * @property * @type Number */ blur: 0, /** * Shadow horizontal offset - * @property * @type Number */ offsetX: 0, /** * Shadow vertical offset - * @property * @type Number */ offsetY: 0, /** * Whether the shadow should affect stroke operations - * @property * @type Boolean */ affectStroke: false, /** * Constructor - * @method initialize * @param [options] Options object with any of color, blur, offsetX, offsetX properties * @return {fabric.Shadow} thisArg */ @@ -5265,7 +5158,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * Returns object representation of a shadow - * @method toObject * @return {Object} */ toObject: function() { @@ -5279,13 +5171,13 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * Returns SVG representation of a shadow - * @method toSVG * @return {String} */ toSVG: function() { } }); + (function(global) { "use strict"; @@ -5316,13 +5208,12 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { } } - Point.prototype = /** @scope fabric.Point.prototype */ { + Point.prototype = /** @lends fabric.Point.prototype */ { constructor: Point, /** * Constructor - * @method init * @param {Number} x left offset * @param {Number} y top offset */ @@ -5333,7 +5224,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * Adds another point to this one and returns another one - * @method add * @param {fabric.Point} that * @return {fabric.Point} new Point instance with added values */ @@ -5343,7 +5233,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * Adds another point to this one - * @method addEquals * @param {fabric.Point} that * @return {fabric.Point} thisArg */ @@ -5355,7 +5244,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * Adds value to this point and returns a new one - * @method scalarAdd * @param {Number} scalar * @return {fabric.Point} new Point with added value */ @@ -5365,7 +5253,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * Adds value to this point - * @method scalarAddEquals * @param {Number} scalar * @param {fabric.Point} thisArg */ @@ -5377,7 +5264,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * Subtracts another point from this point and returns a new one - * @method subtract * @param {fabric.Point} that * @return {fabric.Point} new Point object with subtracted values */ @@ -5387,7 +5273,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * Subtracts another point from this point - * @method subtractEquals * @param {fabric.Point} that * @return {fabric.Point} thisArg */ @@ -5399,7 +5284,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * Subtracts value from this point and returns a new one - * @method scalarSubtract * @param {Number} scalar * @return {fabric.Point} */ @@ -5409,7 +5293,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * Subtracts value from this point - * @method scalarSubtractEquals * @param {Number} scalar * @return {fabric.Point} thisArg */ @@ -5421,7 +5304,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * Miltiplies this point by a value and returns a new one - * @method multiply * @param {Number} scalar * @return {fabric.Point} */ @@ -5431,7 +5313,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * Miltiplies this point by a value - * @method multiplyEquals * @param {Number} scalar * @return {fabric.Point} thisArg */ @@ -5443,7 +5324,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * Divides this point by a value and returns a new one - * @method divide * @param {Number} scalar * @return {fabric.Point} */ @@ -5453,7 +5333,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * Divides this point by a value - * @method divideEquals * @param {Number} scalar * @return {fabric.Point} thisArg */ @@ -5465,7 +5344,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * Returns true if this point is equal to another one - * @method eq * @param {fabric.Point} that * @return {Boolean} */ @@ -5475,7 +5353,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * Returns true if this point is less than another one - * @method lt * @param {fabric.Point} that * @return {Boolean} */ @@ -5485,7 +5362,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * Returns true if this point is less than or equal to another one - * @method lte * @param {fabric.Point} that * @return {Boolean} */ @@ -5496,7 +5372,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * Returns true if this point is greater another one - * @method gt * @param {fabric.Point} that * @return {Boolean} */ @@ -5506,7 +5381,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * Returns true if this point is greater than or equal to another one - * @method gte * @param {fabric.Point} that * @return {Boolean} */ @@ -5516,7 +5390,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * Returns new point which is the result of linear interpolation with this one and another one - * @method lerp * @param {fabric.Point} that * @param {Number} t * @return {fabric.Point} @@ -5527,7 +5400,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * Returns distance from this point and another one - * @method distanceFrom * @param {fabric.Point} that * @return {Number} */ @@ -5539,7 +5411,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * Returns the point between this point and another one - * @method midPointFrom * @param {fabric.Point} that * @return {fabric.Point} */ @@ -5549,7 +5420,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * Returns a new point which is the min of this and another one - * @method min * @param {fabric.Point} that * @return {fabric.Point} */ @@ -5559,7 +5429,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * Returns a new point which is the max of this and another one - * @method max * @param {fabric.Point} that * @return {fabric.Point} */ @@ -5569,7 +5438,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * Returns string representation of this point - * @method toString * @return {String} */ toString: function () { @@ -5578,7 +5446,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * Sets x/y of this point - * @method setXY * @param {Number} x * @return {Number} y */ @@ -5589,7 +5456,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * Sets x/y of this point from another point - * @method setFromPoint * @param {fabric.Point} that */ setFromPoint: function (that) { @@ -5599,7 +5465,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * Swaps x/y of this point and another point - * @method setFromPoint * @param {fabric.Point} that */ swap: function (that) { @@ -5640,11 +5505,10 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { fabric.Intersection = Intersection; - fabric.Intersection.prototype = /** @scope fabric.Intersection.prototype */ { + fabric.Intersection.prototype = /** @lends fabric.Intersection.prototype */ { /** * Constructor - * @method init * @param {String} status */ init: function (status) { @@ -5654,7 +5518,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * Appends a point to intersection - * @method appendPoint * @param {fabric.Point} point */ appendPoint: function (point) { @@ -5663,7 +5526,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * Appends points to intersection - * @method appendPoints * @param {Array} points */ appendPoints: function (points) { @@ -5674,7 +5536,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * Checks if one line intersects another * @static - * @method intersectLineLine * @param {fabric.Point} a1 * @param {fabric.Point} a2 * @param {fabric.Point} b1 @@ -5710,7 +5571,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * Checks if line intersects polygon - * @method intersectLinePolygon * @static * @param {fabric.Point} a1 * @param {fabric.Point} a2 @@ -5736,7 +5596,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * Checks if polygon intersects another polygon - * @method intersectPolygonPolygon * @static * @param {Array} points1 * @param {Array} points2 @@ -5761,7 +5620,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * Checks if polygon intersects rectangle - * @method intersectPolygonRectangle * @static * @param {Array} points @@ -5791,7 +5649,8 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { return result; }; -})(typeof exports !== 'undefined' ? exports : this); +})(typeof exports !== 'undefined' ? exports : this); + (function(global) { "use strict"; @@ -5824,11 +5683,10 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { fabric.Color = Color; - fabric.Color.prototype = /** @scope fabric.Color.prototype */ { + fabric.Color.prototype = /** @lends fabric.Color.prototype */ { /** * @private - * @method _tryParsingColor */ _tryParsingColor: function(color) { var source; @@ -5849,7 +5707,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * Returns source of this color (where source is an array representation; ex: [200, 200, 100, 1]) - * @method getSource * @return {Array} */ getSource: function() { @@ -5858,7 +5715,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * Sets source of this color (where source is an array representation; ex: [200, 200, 100, 1]) - * @method setSource * @param {Array} source */ setSource: function(source) { @@ -5867,7 +5723,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * Returns color represenation in RGB format - * @method toRgb * @return {String} ex: rgb(0-255,0-255,0-255) */ toRgb: function() { @@ -5877,7 +5732,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * Returns color represenation in RGBA format - * @method toRgba * @return {String} ex: rgba(0-255,0-255,0-255,0-1) */ toRgba: function() { @@ -5887,7 +5741,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * Returns color represenation in HEX format - * @method toHex * @return {String} ex: FF5555 */ toHex: function() { @@ -5907,7 +5760,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * Gets value of alpha channel for this color - * @method getAlpha * @return {Number} 0-1 */ getAlpha: function() { @@ -5916,7 +5768,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * Sets value of alpha channel for this color - * @method setAlpha * @param {Number} 0-1 * @return {fabric.Color} thisArg */ @@ -5929,7 +5780,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * Transforms color to its grayscale representation - * @method toGrayscale * @return {fabric.Color} thisArg */ toGrayscale: function() { @@ -5942,7 +5792,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * Transforms color to its black and white representation - * @method toGrayscale * @return {fabric.Color} thisArg */ toBlackWhite: function(threshold) { @@ -5959,7 +5808,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * Overlays color with another color - * @method overlayWith * @param {String|fabric.Color} otherColor * @return {fabric.Color} thisArg */ @@ -6024,7 +5872,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * Returns new color object, when given a color in RGB format - * @method fromRgb * @param {String} color ex: rgb(0-255,0-255,0-255) * @return {fabric.Color} */ @@ -6034,7 +5881,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * Returns array represenatation (ex: [100, 100, 200, 1]) of a color that's in RGB or RGBA format - * @method sourceFromRgb * @param {String} color ex: rgb(0-255,0-255,0-255) * @return {Array} source */ @@ -6054,7 +5900,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { * Returns new color object, when given a color in RGBA format * @static * @function - * @method fromRgba * @param {String} color * @return {fabric.Color} */ @@ -6063,7 +5908,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * Returns new color object, when given a color in HEX format * @static - * @method fromHex * @return {fabric.Color} */ fabric.Color.fromHex = function(color) { @@ -6073,7 +5917,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * Returns array represenatation (ex: [100, 100, 200, 1]) of a color that's in HEX format * @static - * @method sourceFromHex * @param {String} color ex: FF5555 * @return {Array} source */ @@ -6097,7 +5940,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * Returns new color object, when given color in array representation (ex: [200, 100, 100, 0.5]) * @static - * @method fromSource * @return {fabric.Color} */ fabric.Color.fromSource = function(source) { @@ -6107,6 +5949,7 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { }; })(typeof exports !== 'undefined' ? exports : this); + (function () { "use strict"; @@ -6128,8 +5971,13 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { * Static canvas class * @class fabric.StaticCanvas * @constructor + * * @param {HTMLElement | String} el <canvas> element to initialize instance on * @param {Object} [options] Options object + * + * @borrows fabric.Observable.observe as fabric.StaticCanvas#observe + * @borrows fabric.Observable.stopObserving as fabric.StaticCanvas#stopObserving + * @borrows fabric.Observable.fire as fabric.StaticCanvas#fire */ fabric.StaticCanvas = function (el, options) { options || (options = { }); @@ -6141,26 +5989,23 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { extend(fabric.StaticCanvas.prototype, fabric.Observable); extend(fabric.StaticCanvas.prototype, fabric.Collection); - extend(fabric.StaticCanvas.prototype, /** @scope fabric.StaticCanvas.prototype */ { + extend(fabric.StaticCanvas.prototype, /** @lends fabric.StaticCanvas.prototype */ { /** * Background color of canvas instance - * @property * @type String */ backgroundColor: '', /** * Background image of canvas instance - * Should be set via `setBackgroundImage` - * @property + * Should be set via {@link fabric.StaticCanvas#setBackgroundImage} * @type String */ backgroundImage: '', /** * Opacity of the background image of the canvas instance - * @property * @type Float */ backgroundImageOpacity: 1.0, @@ -6168,43 +6013,37 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * Indicates whether the background image should be stretched to fit the * dimensions of the canvas instance. - * @property * @type Boolean */ backgroundImageStretch: true, /** * Overlay image of canvas instance - * Should be set via `setOverlayImage` - * @property + * Should be set via {@link fabric.StaticCanvas#setOverlayImage} * @type String */ overlayImage: '', /** * Left offset of overlay image (if present) - * @property * @type Number */ overlayImageLeft: 0, /** * Top offset of overlay image (if present) - * @property * @type Number */ overlayImageTop: 0, /** * Indicates whether toObject/toDatalessObject should include default values - * @property * @type Boolean */ includeDefaultValues: true, /** * Indicates whether objects' state should be saved - * @property * @type Boolean */ stateful: true, @@ -6213,29 +6052,25 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { * Indicates whether {@link fabric.Canvas.prototype.add} should also re-render canvas. * Disabling this option could give a great performance boost when adding a lot of objects to canvas at once * (followed by a manual rendering after addition) - * @property * @type Boolean */ renderOnAddition: true, /** * Function that determines clipping of entire canvas area - * Being passed context as first argument. See clipping canvas area in https://github.com/kangax/fabric.js/wiki/FAQ - * @property + * Being passed context as first argument. See clipping canvas area in {@link https://github.com/kangax/fabric.js/wiki/FAQ} * @type Function */ clipTo: null, /** * Indicates whether object controls (borders/controls) are rendered above overlay image - * @property * @type Boolean */ controlsAboveOverlay: false, /** * Callback; invoked right before object is about to be scaled/rotated - * @method onBeforeScaleRotate * @param {fabric.Object} target Object that's about to be scaled/rotated */ onBeforeScaleRotate: function () { @@ -6243,7 +6078,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { }, /** - * @method _initStatic * @private */ _initStatic: function(el, options) { @@ -6267,7 +6101,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * Calculates canvas element offset relative to the document * This method is also attached as "resize" event handler of window - * @method calcOffset * @return {fabric.Canvas} instance * @chainable */ @@ -6278,7 +6111,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * Sets overlay image for this canvas - * @method setOverlayImage * @param {String} url url of an image to set overlay to * @param {Function} callback callback to invoke when image is loaded and set as an overlay * @param {Object} [options] optional options to set for the overlay image @@ -6302,7 +6134,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * Sets background image for this canvas - * @method setBackgroundImage * @param {String} url url of an image to set background to * @param {Function} callback callback to invoke when image is loaded and set as background * @param {Object} [options] optional options to set for the background image @@ -6326,7 +6157,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * Sets background color for this canvas - * @method setBackgroundColor * @param {String|fabric.Pattern} Color of pattern to set background color to * @param {Function} callback callback to invoke when background color is set * @return {fabric.Canvas} thisArg @@ -6353,7 +6183,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * @private - * @method _createCanvasElement */ _createCanvasElement: function() { var element = fabric.document.createElement('canvas'); @@ -6368,7 +6197,7 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { }, /** - * @method _initCanvasElement + * @private * @param {HTMLElement} element */ _initCanvasElement: function(element) { @@ -6380,7 +6209,7 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { }, /** - * @method _initOptions + * @private * @param {Object} [options] */ _initOptions: function (options) { @@ -6399,7 +6228,7 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * Creates a bottom canvas - * @method _createLowerCanvas + * @private */ _createLowerCanvas: function (canvasEl) { this.lowerCanvasEl = fabric.util.getById(canvasEl) || this._createCanvasElement(); @@ -6416,7 +6245,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * Returns canvas width (in px) - * @method getWidth * @return {Number} */ getWidth: function () { @@ -6425,7 +6253,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * Returns canvas height (in px) - * @method getHeight * @return {Number} */ getHeight: function () { @@ -6434,7 +6261,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * Sets width of this canvas instance - * @method setWidth * @param {Number} width value to set width to * @return {fabric.Canvas} instance * @chainable true @@ -6445,7 +6271,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * Sets height of this canvas instance - * @method setHeight * @param {Number} height value to set height to * @return {fabric.Canvas} instance * @chainable true @@ -6456,7 +6281,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * Sets dimensions (width, height) of this canvas instance - * @method setDimensions * @param {Object} dimensions * @return {fabric.Canvas} thisArg * @chainable @@ -6471,7 +6295,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * Helper for setting width/height * @private - * @method _setDimensions * @param {String} prop property (width|height) * @param {Number} value value to set property to * @return {fabric.Canvas} instance @@ -6504,7 +6327,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * Returns <canvas> element corresponding to this instance - * @method getElement * @return {HTMLCanvasElement} */ getElement: function () { @@ -6513,7 +6335,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * Returns currently selected object, if any - * @method getActiveObject * @return {fabric.Object} */ getActiveObject: function() { @@ -6522,7 +6343,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * Returns currently selected group of object, if any - * @method getActiveGroup * @return {fabric.Group} */ getActiveGroup: function() { @@ -6552,7 +6372,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * @private - * @method _initObject */ _onObjectAdded: function(obj) { this.stateful && obj.setupState(); @@ -6563,7 +6382,7 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { }, /** - * @method private + * @private */ _onObjectRemoved: function(obj) { this.fire('object:removed', { target: obj }); @@ -6572,7 +6391,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * Returns an array of objects this instance has - * @method getObjects * @return {Array} */ getObjects: function () { @@ -6581,7 +6399,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * Clears specified context of canvas element - * @method clearContext * @param context {Object} ctx context to clear * @return {fabric.Canvas} thisArg * @chainable @@ -6593,7 +6410,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * Returns context of canvas where objects are drawn - * @method getContext * @return {CanvasRenderingContext2D} */ getContext: function () { @@ -6602,7 +6418,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * Clears all contexts (background, main, top) of an instance - * @method clear * @return {fabric.Canvas} thisArg * @chainable */ @@ -6625,7 +6440,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * Renders both the top canvas and the secondary container canvas. - * @method renderAll * @param allOnTop {Boolean} optional Whether we want to force all images to be rendered on the top canvas * @return {fabric.Canvas} instance * @chainable @@ -6704,7 +6518,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * @private - * @method _drawBackroundImage */ _drawBackroundImage: function(canvasToDrawOn) { canvasToDrawOn.save(); @@ -6722,7 +6535,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * Method to render only the top canvas. * Also used to render the group selection box. - * @method renderTop * @return {fabric.Canvas} thisArg * @chainable */ @@ -6753,7 +6565,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * Draws objects' controls (borders/controls) - * @method drawControls * @param {Object} ctx context to render controls on */ drawControls: function(ctx) { @@ -6780,7 +6591,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * Exports canvas element to a dataurl image. - * @method toDataURL * @param {Object} options * * `format` the format of the output image. Either "jpeg" or "png". @@ -6805,7 +6615,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { }, /** - * @method _toDataURL * @private */ __toDataURL: function(format, quality) { @@ -6821,7 +6630,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { }, /** - * @method _toDataURLWithMultiplier * @private */ __toDataURLWithMultiplier: function(format, quality, multiplier) { @@ -6874,7 +6682,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * Exports canvas element to a dataurl image (allowing to change image size via multiplier). * @deprecated since 1.0.13 - * @method toDataURLWithMultiplier * @param {String} format (png|jpeg) * @param {Number} multiplier * @param {Number} quality (0..1) @@ -6890,7 +6697,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * @private - * @method _tempRemoveBordersControlsFromGroup */ _tempRemoveBordersControlsFromGroup: function(group) { group.origHasControls = group.hasControls; @@ -6907,7 +6713,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * @private - * @method _restoreBordersControlsOnGroup */ _restoreBordersControlsOnGroup: function(group) { group.hideControls = group.origHideControls; @@ -6922,7 +6727,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * Returns coordinates of a center of canvas. * Returned value is an object with top and left properties - * @method getCenter * @return {Object} object with "top" and "left" number values */ getCenter: function () { @@ -6934,7 +6738,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * Centers object horizontally. - * @method centerObjectH * @param {fabric.Object} object Object to center * @return {fabric.Canvas} thisArg */ @@ -6946,7 +6749,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * Centers object vertically. - * @method centerObjectH * @param {fabric.Object} object Object to center * @return {fabric.Canvas} thisArg * @chainable @@ -6959,7 +6761,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * Centers object vertically and horizontally. - * @method centerObject * @param {fabric.Object} object Object to center * @return {fabric.Canvas} thisArg * @chainable @@ -6970,7 +6771,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * Returs dataless JSON representation of canvas - * @method toDatalessJSON * @param {Array} propertiesToInclude * @return {String} json string */ @@ -6980,7 +6780,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * Returns object representation of canvas - * @method toObject * @param {Array} propertiesToInclude * @return {Object} object representation of an instance */ @@ -6990,7 +6789,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * Returns dataless object representation of canvas - * @method toDatalessObject * @param {Array} propertiesToInclude * @return {Object} object representation of an instance */ @@ -7000,7 +6798,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * @private - * @method _toObjectMethod */ _toObjectMethod: function (methodName, propertiesToInclude) { var data = { @@ -7038,7 +6835,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * Returns SVG representation of canvas * @function - * @method toSVG * @param {Object} [options] Options for SVG output (suppressPreamble: true/false (if true xml tag is not included), * viewBox: {x, y, width, height} to define the svg output viewBox) * @return {String} @@ -7111,7 +6907,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * Removes an object from canvas and returns it - * @method remove * @param object {Object} Object to remove * @return {Object} removed object */ @@ -7128,7 +6923,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * Moves an object to the bottom of the stack of drawn objects - * @method sendToBack * @param object {fabric.Object} Object to send to back * @return {fabric.Canvas} thisArg * @chainable @@ -7141,7 +6935,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * Moves an object to the top of the stack of drawn objects - * @method bringToFront * @param object {fabric.Object} Object to send * @return {fabric.Canvas} thisArg * @chainable @@ -7154,7 +6947,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * Moves an object one level down in stack of drawn objects - * @method sendBackwards * @param object {fabric.Object} Object to send * @return {fabric.Canvas} thisArg * @chainable @@ -7186,7 +6978,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * Moves an object one level up in stack of drawn objects - * @method bringForward * @param object {fabric.Object} Object to send * @return {fabric.Canvas} thisArg * @chainable @@ -7220,7 +7011,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * Moves an object to specified level in stack of drawn objects - * @method moveTo * @param object {fabric.Object} Object to send * @param {Number} index Position to move to * @return {fabric.Canvas} thisArg @@ -7234,7 +7024,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * Clears a canvas element and removes all event handlers. - * @method dispose * @return {fabric.Canvas} thisArg * @chainable */ @@ -7260,7 +7049,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * @private - * @method _resizeImageToFit * @param {HTMLImageElement} imgEl */ _resizeImageToFit: function (imgEl) { @@ -7277,7 +7065,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * Returns a string representation of an instance - * @method toString * @return {String} string representation of an instance */ fabric.StaticCanvas.prototype.toString = function () { // Assign explicitly since `extend` doesn't take care of DontEnum bug yet @@ -7285,11 +7072,10 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { '{ objects: ' + this.getObjects().length + ' }>'; }; - extend(fabric.StaticCanvas, /** @scope fabric.StaticCanvas */ { + extend(fabric.StaticCanvas, /** @lends fabric.StaticCanvas */ { /** * @static - * @property EMPTY_JSON * @type String */ EMPTY_JSON: '{"objects": [], "background": "white"}', @@ -7297,7 +7083,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * Takes <canvas> element and transforms its data in such way that it becomes grayscale * @static - * @method toGrayscale * @param {HTMLCanvasElement} canvasEl */ toGrayscale: function (canvasEl) { @@ -7327,7 +7112,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { * Provides a way to check support of some of the canvas methods * (either those of HTMLCanvasElement itself, or rendering context) * - * @method supports * @param methodName {String} Method to check support for; * Could be one of "getImageData", "toDataURL" or "toDataURLWithQuality" * @return {Boolean | null} `true` if method is supported (or at least exists), @@ -7370,7 +7154,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * Returs JSON representation of canvas * @function - * @method toJSON * @param {Array} propertiesToInclude * @return {String} json string */ @@ -7382,53 +7165,46 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { * BaseBrush class * @class fabric.BaseBrush */ -fabric.BaseBrush = fabric.util.createClass({ +fabric.BaseBrush = fabric.util.createClass(/** @lends fabric.BaseBrush.prototype */ { /** * Color of a brush - * @property * @type String */ color: 'rgb(0, 0, 0)', /** * Width of a brush - * @property * @type Number */ width: 1, /** * Shadow blur of a brush - * @property * @type Number */ shadowBlur: 0, /** * Shadow color of a brush - * @property * @type String */ shadowColor: '', /** * Shadow offset x of a brush - * @property * @type Number */ shadowOffsetX: 0, /** * Shadow offset y of a brush - * @property * @type Number */ shadowOffsetY: 0, /** * Sets brush styles - * @method setBrushStyles */ setBrushStyles: function() { var ctx = this.canvas.contextTop; @@ -7440,7 +7216,6 @@ fabric.BaseBrush = fabric.util.createClass({ /** * Sets brush shadow styles - * @method setShadowStyles */ setShadowStyles: function() { var ctx = this.canvas.contextTop; @@ -7451,6 +7226,7 @@ fabric.BaseBrush = fabric.util.createClass({ ctx.shadowOffsetY = this.shadowOffsetY; } }); + (function() { var utilMin = fabric.util.array.min, @@ -7461,11 +7237,10 @@ fabric.BaseBrush = fabric.util.createClass({ * @class fabric.PencilBrush * @extends fabric.BaseBrush */ - fabric.PencilBrush = fabric.util.createClass( fabric.BaseBrush, /** @scope fabric.PencilBrush.prototype */ { + fabric.PencilBrush = fabric.util.createClass( fabric.BaseBrush, /** @lends fabric.PencilBrush.prototype */ { /** * Constructor - * @method initialize * @param {fabric.Canvas} canvas * @return {fabric.PencilBrush} Instance of a pencil brush */ @@ -7475,7 +7250,7 @@ fabric.BaseBrush = fabric.util.createClass({ }, /** - * @method onMouseDown + * Inovoked on mouse down * @param {Object} pointer */ onMouseDown: function(pointer) { @@ -7486,7 +7261,7 @@ fabric.BaseBrush = fabric.util.createClass({ }, /** - * @method onMouseMove + * Inovoked on mouse move * @param {Object} pointer */ onMouseMove: function(pointer) { @@ -7498,14 +7273,13 @@ fabric.BaseBrush = fabric.util.createClass({ }, /** - * @method onMouseUp + * Invoked on mouse up */ onMouseUp: function() { this._finalizeAndAddPath(); }, /** - * @method _prepareForDrawing * @param {Object} pointer */ _prepareForDrawing: function(pointer) { @@ -7520,7 +7294,6 @@ fabric.BaseBrush = fabric.util.createClass({ /** * @private - * @method _addPoint * @param {fabric.Point} point */ _addPoint: function(point) { @@ -7532,7 +7305,6 @@ fabric.BaseBrush = fabric.util.createClass({ * style. * * @private - * @method _reset * */ _reset: function() { @@ -7544,7 +7316,6 @@ fabric.BaseBrush = fabric.util.createClass({ /** * @private - * @method _captureDrawingPath * * @param point {pointer} (fabric.util.pointer) actual mouse position * related to the canvas. @@ -7558,7 +7329,6 @@ fabric.BaseBrush = fabric.util.createClass({ * Draw a smooth path on the topCanvas using quadraticCurveTo * * @private - * @method _render */ _render: function() { var ctx = this.canvas.contextTop; @@ -7589,7 +7359,6 @@ fabric.BaseBrush = fabric.util.createClass({ * Return an SVG path based on our captured points and their bounding box * * @private - * @method _getSVGPathData */ _getSVGPathData: function() { this.box = this.getPathBoundingBox(this._points); @@ -7599,7 +7368,6 @@ fabric.BaseBrush = fabric.util.createClass({ /** * Returns bounding box of a path based on given points - * @method getPathBoundingBox * @param {Array} points * @return {Object} object with minx, miny, maxx, maxy */ @@ -7636,7 +7404,6 @@ fabric.BaseBrush = fabric.util.createClass({ /** * Converts points to SVG path - * @method convertPointsToSVGPath * @param {Array} points Array of points * @return {String} SVG path */ @@ -7663,7 +7430,6 @@ fabric.BaseBrush = fabric.util.createClass({ /** * Creates fabric.Path object to add on canvas - * @method createPath * @param {String} pathData Path data * @return {fabric.Path} path to add on canvas */ @@ -7687,7 +7453,6 @@ fabric.BaseBrush = fabric.util.createClass({ * we use the points captured to create an new fabric path object * and add it to the fabric canvas. * - * @method _finalizeAndAddPath */ _finalizeAndAddPath: function() { var ctx = this.canvas.contextTop; @@ -7728,18 +7493,16 @@ fabric.BaseBrush = fabric.util.createClass({ * CircleBrush class * @class fabric.CircleBrush */ -fabric.CircleBrush = fabric.util.createClass( fabric.BaseBrush, /** @scope fabric.CircleBrush.prototype */ { +fabric.CircleBrush = fabric.util.createClass( fabric.BaseBrush, /** @lends fabric.CircleBrush.prototype */ { /** * Width of a brush - * @property * @type Number */ width: 10, /** * Constructor - * @method initialize * @param {fabric.Canvas} canvas * @return {fabric.CircleBrush} Instance of a circle brush */ @@ -7749,7 +7512,7 @@ fabric.CircleBrush = fabric.util.createClass( fabric.BaseBrush, /** @scope fabri }, /** - * @method onMouseDown + * Invoked on mouse down * @param {Object} pointer */ onMouseDown: function() { @@ -7759,7 +7522,7 @@ fabric.CircleBrush = fabric.util.createClass( fabric.BaseBrush, /** @scope fabri }, /** - * @method onMouseMove + * Invoked on mouse move * @param {Object} pointer */ onMouseMove: function(pointer) { @@ -7774,7 +7537,7 @@ fabric.CircleBrush = fabric.util.createClass( fabric.BaseBrush, /** @scope fabri }, /** - * @method onMouseUp + * Invoked on mouse up */ onMouseUp: function() { var originalRenderOnAddition = this.canvas.renderOnAddition; @@ -7802,7 +7565,6 @@ fabric.CircleBrush = fabric.util.createClass( fabric.BaseBrush, /** @scope fabri }, /** - * @method addPoint * @param {Object} pointer * @return {fabric.Point} Just added pointer point */ @@ -7824,50 +7586,45 @@ fabric.CircleBrush = fabric.util.createClass( fabric.BaseBrush, /** @scope fabri return pointerPoint; } }); + /** * SprayBrush class * @class fabric.SprayBrush */ -fabric.SprayBrush = fabric.util.createClass( fabric.BaseBrush, /** @scope fabric.SprayBrush.prototype */ { +fabric.SprayBrush = fabric.util.createClass( fabric.BaseBrush, /** @lends fabric.SprayBrush.prototype */ { /** * Width of a spray - * @property * @type Number */ width: 10, /** * Density of a spray (number of dots per chunk) - * @property * @type Number */ density: 20, /** * Width of spray dots - * @property * @type Number */ dotWidth: 1, /** * Width variance of spray dots - * @property * @type Number */ dotWidthVariance: 1, /** * Whether opacity of a dot should be random - * @property * @type Boolean */ randomOpacity: false, /** * Constructor - * @method initialize * @param {fabric.Canvas} canvas * @return {fabric.SprayBrush} Instance of a spray brush */ @@ -7877,7 +7634,7 @@ fabric.SprayBrush = fabric.util.createClass( fabric.BaseBrush, /** @scope fabric }, /** - * @method onMouseDown + * Invoked on mouse down * @param {Object} pointer */ onMouseDown: function(pointer) { @@ -7890,7 +7647,7 @@ fabric.SprayBrush = fabric.util.createClass( fabric.BaseBrush, /** @scope fabric }, /** - * @method onMouseMove + * Invoked on mouse move * @param {Object} pointer */ onMouseMove: function(pointer) { @@ -7899,7 +7656,7 @@ fabric.SprayBrush = fabric.util.createClass( fabric.BaseBrush, /** @scope fabric }, /** - * @method onMouseUp + * Invoked on mouse up */ onMouseUp: function() { var originalRenderOnAddition = this.canvas.renderOnAddition; @@ -7934,7 +7691,7 @@ fabric.SprayBrush = fabric.util.createClass( fabric.BaseBrush, /** @scope fabric }, /** - * @method render + * Renders brush */ render: function() { var ctx = this.canvas.contextTop; @@ -7952,7 +7709,6 @@ fabric.SprayBrush = fabric.util.createClass( fabric.BaseBrush, /** @scope fabric }, /** - * @method addSprayChunk * @param {Object} pointer */ addSprayChunk: function(pointer) { @@ -7987,12 +7743,13 @@ fabric.SprayBrush = fabric.util.createClass( fabric.BaseBrush, /** @scope fabric this.sprayChunks.push(this.sprayChunkPoints); } }); + /** * PatternBrush class * @class fabric.PatternBrush * @extends fabric.BaseBrush */ -fabric.PatternBrush = fabric.util.createClass(fabric.PencilBrush, /** @scope fabric.PatternBrush.prototype */ { +fabric.PatternBrush = fabric.util.createClass(fabric.PencilBrush, /** @lends fabric.PatternBrush.prototype */ { getPatternSrc: function() { @@ -8020,7 +7777,6 @@ fabric.PatternBrush = fabric.util.createClass(fabric.PencilBrush, /** @scope fab /** * Creates "pattern" instance property - * @method getPattern */ getPattern: function() { return this.canvas.contextTop.createPattern(this.source || this.getPatternSrc(), 'repeat'); @@ -8028,7 +7784,6 @@ fabric.PatternBrush = fabric.util.createClass(fabric.PencilBrush, /** @scope fab /** * Sets brush styles - * @method setBrushStyles */ setBrushStyles: function() { this.callSuper('setBrushStyles'); @@ -8037,7 +7792,6 @@ fabric.PatternBrush = fabric.util.createClass(fabric.PencilBrush, /** @scope fab /** * Creates path - * @method createPath */ createPath: function(pathData) { var path = this.callSuper('createPath', pathData); @@ -8047,6 +7801,7 @@ fabric.PatternBrush = fabric.util.createClass(fabric.PencilBrush, /** @scope fab return path; } }); + (function() { var extend = fabric.util.object.extend, @@ -8082,39 +7837,34 @@ fabric.PatternBrush = fabric.util.createClass(fabric.PencilBrush, /** @scope fab ProtoProxy.prototype = fabric.StaticCanvas.prototype; fabric.Canvas.prototype = new ProtoProxy(); - var InteractiveMethods = /** @scope fabric.Canvas.prototype */ { + var InteractiveMethods = /** @lends fabric.Canvas.prototype */ { /** * When true, objects can be transformed by one side (unproportionally) - * @property * @type Boolean */ uniScaleTransform: false, /** * When true, objects use center point as the origin of transformation - * @property * @type Boolean */ centerTransform: false, /** * Indicates that canvas is interactive. This property should not be changed. - * @property * @type Boolean */ interactive: true, /** * Indicates whether group selection should be enabled - * @property * @type Boolean */ selection: true, /** * Color of selection - * @property * @type String */ selectionColor: 'rgba(100, 100, 255, 0.3)', // blue @@ -8122,83 +7872,71 @@ fabric.PatternBrush = fabric.util.createClass(fabric.PencilBrush, /** @scope fab /** * Default dash array pattern * If not empty the selection border is dashed - * @property * @type Array */ selectionDashArray: [ ], /** * Color of the border of selection (usually slightly darker than color of selection itself) - * @property * @type String */ selectionBorderColor: 'rgba(255, 255, 255, 0.3)', /** * Width of a line used in object/group selection - * @property * @type Number */ selectionLineWidth: 1, /** * Default cursor value used when hovering over an object on canvas - * @property * @type String */ hoverCursor: 'move', /** * Default cursor value used when moving an object on canvas - * @property * @type String */ moveCursor: 'move', /** * Default cursor value used for the entire canvas - * @property * @type String */ defaultCursor: 'default', /** * Cursor value used during free drawing - * @property * @type String */ freeDrawingCursor: 'crosshair', /** * Cursor value used for rotation point - * @property * @type String */ rotationCursor: 'crosshair', /** * Default element class that's given to wrapper (div) element of canvas - * @property * @type String */ containerClass: 'canvas-container', /** * When true, object detection happens on per-pixel basis rather than on per-bounding-box - * @property * @type Boolean */ perPixelTargetFind: false, /** * Number of pixels around target pixel to tolerate (consider active) during object detection - * @property * @type Number */ targetFindTolerance: 0, /** - * @method _initInteractive * @private */ _initInteractive: function() { @@ -8215,7 +7953,7 @@ fabric.PatternBrush = fabric.util.createClass(fabric.PencilBrush, /** @scope fab /** * Resets the current transform to its original values and chooses the type of resizing based on the event - * @method _resetCurrentTransform + * @private * @param e {Event} Event object fired on mousemove */ _resetCurrentTransform: function(e) { @@ -8255,7 +7993,6 @@ fabric.PatternBrush = fabric.util.createClass(fabric.PencilBrush, /** @scope fab /** * Applies one implementation of 'point inside polygon' algorithm - * @method containsPoint * @param e { Event } event object * @param target { fabric.Object } object to test against * @return {Boolean} true if point contains within area of given object @@ -8283,7 +8020,6 @@ fabric.PatternBrush = fabric.util.createClass(fabric.PencilBrush, /** @scope fab /** * @private - * @method _normalizePointer */ _normalizePointer: function (object, pointer) { @@ -8306,7 +8042,6 @@ fabric.PatternBrush = fabric.util.createClass(fabric.PencilBrush, /** @scope fab /** * @private - * @method _isTargetTransparent */ _isTargetTransparent: function (target, x, y) { var cacheContext = this.contextCache; @@ -8353,7 +8088,6 @@ fabric.PatternBrush = fabric.util.createClass(fabric.PencilBrush, /** @scope fab /** * @private - * @method _shouldClearSelection */ _shouldClearSelection: function (e, target) { var activeGroup = this.getActiveGroup(); @@ -8365,14 +8099,13 @@ fabric.PatternBrush = fabric.util.createClass(fabric.PencilBrush, /** @scope fab !activeGroup.contains(target) && activeGroup !== target && !e.shiftKey) || ( - target && + target && !target.selectable) ); }, /** * @private - * @method _setupCurrentTransform */ _setupCurrentTransform: function (e, target) { if (!target) return; @@ -8446,7 +8179,7 @@ fabric.PatternBrush = fabric.util.createClass(fabric.PencilBrush, /** @scope fab }, /** - * @method _shouldHandleGroupLogic + * @private * @param e {Event} * @param target {fabric.Object} * @return {Boolean} @@ -8460,7 +8193,6 @@ fabric.PatternBrush = fabric.util.createClass(fabric.PencilBrush, /** @scope fab /** * @private - * @method _handleGroupLogic */ _handleGroupLogic: function (e, target) { if (target === this.getActiveGroup()) { @@ -8511,7 +8243,7 @@ fabric.PatternBrush = fabric.util.createClass(fabric.PencilBrush, /** @scope fab /** * Translates object by "setting" its left/top - * @method _translateObject + * @private * @param x {Number} pointer's x coordinate * @param y {Number} pointer's y coordinate */ @@ -8528,7 +8260,7 @@ fabric.PatternBrush = fabric.util.createClass(fabric.PencilBrush, /** @scope fab /** * Scales object by invoking its scaleX/scaleY methods - * @method _scaleObject + * @private * @param x {Number} pointer's x coordinate * @param y {Number} pointer's y coordinate * @param by {String} Either 'x' or 'y' - specifies dimension constraint by which to scale an object. @@ -8625,7 +8357,7 @@ fabric.PatternBrush = fabric.util.createClass(fabric.PencilBrush, /** @scope fab /** * Rotates object by invoking its rotate method - * @method _rotateObject + * @private * @param x {Number} pointer's x coordinate * @param y {Number} pointer's y coordinate */ @@ -8643,16 +8375,15 @@ fabric.PatternBrush = fabric.util.createClass(fabric.PencilBrush, /** @scope fab }, /** - * @method _setCursor + * @private */ _setCursor: function (value) { this.upperCanvasEl.style.cursor = value; }, /** - * @private - * @method _resetObjectTransform: - */ + * @private + */ _resetObjectTransform: function (target) { target.scaleX = 1; target.scaleY = 1; @@ -8660,7 +8391,6 @@ fabric.PatternBrush = fabric.util.createClass(fabric.PencilBrush, /** @scope fab }, /** - * @method _drawSelection * @private */ _drawSelection: function () { @@ -8711,7 +8441,6 @@ fabric.PatternBrush = fabric.util.createClass(fabric.PencilBrush, /** @scope fab /** * @private - * @method _findSelectedObjects */ _findSelectedObjects: function (e) { var group = [ ], @@ -8754,7 +8483,6 @@ fabric.PatternBrush = fabric.util.createClass(fabric.PencilBrush, /** @scope fab /** * Method that determines what object we are clicking on - * @method findTarget * @param {Event} e mouse event * @param {Boolean} skipGroup when true, group is skipped and only objects are traversed through */ @@ -8809,7 +8537,6 @@ fabric.PatternBrush = fabric.util.createClass(fabric.PencilBrush, /** @scope fab /** * Returns pointer coordinates relative to canvas. - * @method getPointer * @param {Event} e * @return {Object} object with "x" and "y" number values */ @@ -8823,7 +8550,6 @@ fabric.PatternBrush = fabric.util.createClass(fabric.PencilBrush, /** @scope fab /** * @private - * @method _createUpperCanvas * @param {HTMLElement|String} canvasEl Canvas element * @throws {CANVAS_INIT_ERROR} If canvas can not be initialized */ @@ -8839,7 +8565,6 @@ fabric.PatternBrush = fabric.util.createClass(fabric.PencilBrush, /** @scope fab /** * @private - * @method _createCacheCanvas */ _createCacheCanvas: function () { this.cacheCanvasEl = this._createCanvasElement(); @@ -8850,7 +8575,6 @@ fabric.PatternBrush = fabric.util.createClass(fabric.PencilBrush, /** @scope fab /** * @private - * @method _initWrapperElement * @param {Number} width * @param {Number} height */ @@ -8868,7 +8592,6 @@ fabric.PatternBrush = fabric.util.createClass(fabric.PencilBrush, /** @scope fab /** * @private - * @method _applyCanvasStyle * @param {Element} element */ _applyCanvasStyle: function (element) { @@ -8889,7 +8612,6 @@ fabric.PatternBrush = fabric.util.createClass(fabric.PencilBrush, /** @scope fab /** * Returns context of canvas where object selection is drawn - * @method getSelectionContext * @return {CanvasRenderingContext2D} */ getSelectionContext: function() { @@ -8898,7 +8620,6 @@ fabric.PatternBrush = fabric.util.createClass(fabric.PencilBrush, /** @scope fab /** * Returns <canvas> element on which object selection is drawn - * @method getSelectionElement * @return {HTMLCanvasElement} */ getSelectionElement: function () { @@ -8907,7 +8628,6 @@ fabric.PatternBrush = fabric.util.createClass(fabric.PencilBrush, /** @scope fab /** * Sets given object as the only active object on canvas - * @method setActiveObject * @param object {fabric.Object} Object to set as an active one * @return {fabric.Canvas} thisArg * @chainable @@ -8928,7 +8648,6 @@ fabric.PatternBrush = fabric.util.createClass(fabric.PencilBrush, /** @scope fab /** * Returns currently active object - * @method getActiveObject * @return {fabric.Object} active object */ getActiveObject: function () { @@ -8937,7 +8656,6 @@ fabric.PatternBrush = fabric.util.createClass(fabric.PencilBrush, /** @scope fab /** * Discards currently active object - * @method discardActiveObject * @return {fabric.Canvas} thisArg * @chainable */ @@ -8951,7 +8669,6 @@ fabric.PatternBrush = fabric.util.createClass(fabric.PencilBrush, /** @scope fab /** * Sets active group to a speicified one - * @method setActiveGroup * @param {fabric.Group} group Group to set as a current one * @return {fabric.Canvas} thisArg * @chainable @@ -8967,7 +8684,6 @@ fabric.PatternBrush = fabric.util.createClass(fabric.PencilBrush, /** @scope fab /** * Returns currently active group - * @method getActiveGroup * @return {fabric.Group} Current group */ getActiveGroup: function () { @@ -8976,7 +8692,6 @@ fabric.PatternBrush = fabric.util.createClass(fabric.PencilBrush, /** @scope fab /** * Removes currently active group - * @method discardActiveGroup * @return {fabric.Canvas} thisArg */ discardActiveGroup: function () { @@ -8989,7 +8704,6 @@ fabric.PatternBrush = fabric.util.createClass(fabric.PencilBrush, /** @scope fab /** * Deactivates all objects on canvas, removing any active group or object - * @method deactivateAll * @return {fabric.Canvas} thisArg */ deactivateAll: function () { @@ -9006,7 +8720,6 @@ fabric.PatternBrush = fabric.util.createClass(fabric.PencilBrush, /** @scope fab /** * Deactivates all objects and dispatches appropriate events - * @method deactivateAllWithDispatch * @return {fabric.Canvas} thisArg */ deactivateAllWithDispatch: function () { @@ -9034,6 +8747,7 @@ fabric.PatternBrush = fabric.util.createClass(fabric.PencilBrush, /** @scope fab } if (fabric.isTouchSupported) { + /** @ignore */ fabric.Canvas.prototype._setCursorFromEvent = function() { }; } @@ -9062,13 +8776,11 @@ fabric.PatternBrush = fabric.util.createClass(fabric.PencilBrush, /** @scope fab removeListener = fabric.util.removeListener, getPointer = fabric.util.getPointer; - fabric.util.object.extend(fabric.Canvas.prototype, /** @scope fabric.Canvas.prototype */ { + fabric.util.object.extend(fabric.Canvas.prototype, /** @lends fabric.Canvas.prototype */ { /** - * Adds mouse listeners to canvas - * @method _initEvents + * Adds mouse listeners to canvas * @private - * See configuration documentation for more details. */ _initEvents: function () { var _this = this; @@ -9099,7 +8811,6 @@ fabric.PatternBrush = fabric.util.createClass(fabric.PencilBrush, /** @scope fab }, /** - * @method _onMouseDown * @private */ _onMouseDown: function (e) { @@ -9116,7 +8827,6 @@ fabric.PatternBrush = fabric.util.createClass(fabric.PencilBrush, /** @scope fab }, /** - * @method _onMouseUp * @private */ _onMouseUp: function (e) { @@ -9133,7 +8843,6 @@ fabric.PatternBrush = fabric.util.createClass(fabric.PencilBrush, /** @scope fab }, /** - * @method _onMouseMove * @private */ _onMouseMove: function (e) { @@ -9142,7 +8851,6 @@ fabric.PatternBrush = fabric.util.createClass(fabric.PencilBrush, /** @scope fab }, /** - * @method _onResize * @private */ _onResize: function () { @@ -9153,9 +8861,8 @@ fabric.PatternBrush = fabric.util.createClass(fabric.PencilBrush, /** @scope fab * Method that defines the actions when mouse is released on canvas. * The method resets the currentTransform parameters, store the image corner * position in the image object and render the canvas on top. - * @method __onMouseUp + * @private * @param {Event} e Event object fired on mouseup - * */ __onMouseUp: function (e) { @@ -9233,9 +8940,8 @@ fabric.PatternBrush = fabric.util.createClass(fabric.PencilBrush, /** @scope fab * The method inits the currentTransform parameters and renders all the * canvas so the current image can be placed on the top canvas and the rest * in on the container one. - * @method __onMouseDown + * @private * @param e {Event} Event object fired on mousedown - * */ __onMouseDown: function (e) { @@ -9312,9 +9018,8 @@ fabric.PatternBrush = fabric.util.createClass(fabric.PencilBrush, /** @scope fab * an image or neither of them (only hovering). A group selection is also possible and would cancel * all any other type of action. * In case of an image transformation only the top canvas will be rendered. - * @method __onMouseMove + * @private * @param e {Event} Event object fired on mousemove - * */ __onMouseMove: function (e) { @@ -9441,7 +9146,6 @@ fabric.PatternBrush = fabric.util.createClass(fabric.PencilBrush, /** @scope fab /** * Sets the cursor depending on where the canvas is being hovered. * Note: very buggy in Opera - * @method _setCursorFromEvent * @param e {Event} Event object * @param target {Object} Object that the mouse is hovering, if so. */ @@ -9479,7 +9183,7 @@ fabric.PatternBrush = fabric.util.createClass(fabric.PencilBrush, /** @scope fab }); })(); -fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.StaticCanvas.prototype */ { +fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @lends fabric.StaticCanvas.prototype */ { /** * Animation duration (in ms) for fx* methods @@ -9489,7 +9193,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Centers object horizontally with animation. - * @method fxCenterObjectH * @param {fabric.Object} object Object to center * @param {Object} [callbacks] Callbacks object with optional "onComplete" and/or "onChange" properties * @return {fabric.Canvas} thisArg @@ -9523,7 +9226,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Centers object vertically with animation. - * @method fxCenterObjectV * @param {fabric.Object} object Object to center * @param {Object} [callbacks] Callbacks object with optional "onComplete" and/or "onChange" properties * @return {fabric.Canvas} thisArg @@ -9557,7 +9259,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Same as `fabric.Canvas#remove` but animated - * @method fxRemove * @param {fabric.Object} object Object to remove * @param {Function} callback Callback, invoked on effect completion * @return {fabric.Canvas} thisArg @@ -9592,12 +9293,12 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati return this; } }); -fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.StaticCanvas.prototype */ { + +fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @lends fabric.StaticCanvas.prototype */ { /** * Populates canvas with data from the specified dataless JSON * JSON format must conform to the one of `fabric.Canvas#toDatalessJSON` - * @method loadFromDatalessJSON * @param {String|Object} json JSON string or object * @param {Function} callback Callback, invoked when json is parsed * and corresponding objects (e.g: fabric.Image) @@ -9615,7 +9316,7 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati : json; if (!serialized) return; - + if (!serialized.objects) { serialized.objects = []; } @@ -9629,7 +9330,7 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati }, /** - * @method _enlivenDatalessObjects + * @private * @param {Array} objects * @param {Function} callback */ @@ -9743,7 +9444,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Populates canvas with data from the specified JSON * JSON format must conform to the one of `fabric.Canvas#toJSON` - * @method loadFromJSON * @param {String|Object} json JSON string or object * @param {Function} callback Callback, invoked when json is parsed * and corresponding objects (e.g: fabric.Image) @@ -9773,7 +9473,7 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati backgroundPatternLoaded, backgroundImageLoaded, overlayImageLoaded; - + var cbIfLoaded = function () { callback && backgroundImageLoaded && overlayImageLoaded && backgroundPatternLoaded && callback(); }; @@ -9830,7 +9530,7 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati }, /** - * @method _enlivenObjects + * @private * @param {Array} objects * @param {Function} callback */ @@ -9846,7 +9546,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * @private - * @method _toDataURL * @param {String} format * @param {Function} callback */ @@ -9858,7 +9557,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * @private - * @method _toDataURLWithMultiplier * @param {String} format * @param {Number} multiplier * @param {Function} callback @@ -9871,7 +9569,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Clones canvas instance - * @method clone * @param {Object} [callback] Receives cloned instance as a first argument */ clone: function (callback) { @@ -9887,7 +9584,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati * Clones canvas instance without cloning existing data. * This essentially copies canvas dimensions, clipping properties, etc. * but leaves data empty (so that you can populate it with your own) - * @method cloneWithoutData * @param {Object} [callback] Receives cloned instance as a first argument */ cloneWithoutData: function(callback) { @@ -9911,6 +9607,7 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati } } }); + (function(global) { "use strict"; @@ -9938,315 +9635,271 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Root object class from which all 2d shape classes inherit from - * @class Object + * @class fabric.Object * @memberOf fabric */ - fabric.Object = fabric.util.createClass(/** @scope fabric.Object.prototype */ { + fabric.Object = fabric.util.createClass(/** @lends fabric.Object.prototype */ { /** * Type of an object (rect, circle, path, etc.) - * @property * @type String */ type: 'object', /** * Horizontal origin of transformation of an object (one of "left", "right", "center") - * @property * @type String */ originX: 'center', /** * Vertical origin of transformation of an object (one of "top", "bottom", "center") - * @property * @type String */ originY: 'center', /** * Top position of an object. Note that by default it's relative to object center. You can change this by setting originY={top/center/bottom} - * @property * @type Number */ top: 0, /** * Left position of an object. Note that by default it's relative to object center. You can change this by setting originX={left/center/right} - * @property * @type Number */ left: 0, /** * Object width - * @property * @type Number */ width: 0, /** * Object height - * @property * @type Number */ height: 0, /** * Object scale factor (horizontal) - * @property * @type Number */ scaleX: 1, /** * Object scale factor (vertical) - * @property * @type Number */ scaleY: 1, /** * When true, an object is rendered as flipped horizontally - * @property * @type Boolean */ flipX: false, /** * When true, an object is rendered as flipped vertically - * @property * @type Boolean */ flipY: false, /** * Opacity of an object - * @property * @type Number */ opacity: 1, /** * Angle of rotation of an object (in degrees) - * @property * @type Number */ angle: 0, /** * Size of object's corners (in pixels) - * @property * @type Number */ cornerSize: 12, /** * When true, object's corners are rendered as transparent inside (i.e. stroke instead of fill) - * @property * @type Boolean */ transparentCorners: true, /** * Padding between object and its borders (in pixels) - * @property * @type Number */ padding: 0, /** * Border color of an object (when it's active) - * @property * @type String */ borderColor: 'rgba(102,153,255,0.75)', /** * Corner color of an object (when it's active) - * @property * @type String */ cornerColor: 'rgba(102,153,255,0.5)', /** * Color of object's fill - * @property * @type String */ fill: 'rgb(0,0,0)', /** * Fill rule used to fill an object - * @property * @type String */ fillRule: 'source-over', /** * Overlay fill (takes precedence over fill value) - * @property * @type String */ overlayFill: null, /** * When `true`, an object is rendered via stroke and this property specifies its color - * @property * @type String */ stroke: null, /** * Width of a stroke used to render this object - * @property * @type Number */ strokeWidth: 1, /** * Array specifying dash pattern of an object's stroke - * @property * @type Array */ strokeDashArray: null, /** * Shadow object representing shadow of this shape - * @property * @type fabric.Shadow */ shadow: null, /** * Border opacity when object is active and moving - * @property * @type Number */ borderOpacityWhenMoving: 0.4, /** * Border scale factor - * @property * @type Number */ borderScaleFactor: 1, /** * Transform matrix (similar to SVG's transform matrix) - * @property * @type Array */ transformMatrix: null, /** * Minimum allowed scale value of an object - * @property * @type Number */ minScaleLimit: 0.01, /** * When set to `false`, an object can not be selected for modification (using either point-click-based or group-based selection) - * @property * @type Boolean */ selectable: true, /** * When set to `false`, an object is not rendered on canvas - * @property * @type Boolean */ visible: true, /** * When set to `false`, object's controls are not displayed and can not be used to manipulate object - * @property * @type Boolean */ hasControls: true, /** * When set to `false`, object's borders are not rendered - * @property * @type Boolean */ hasBorders: true, /** * When set to `false`, object's rotating point will not be visible or selectable - * @property * @type Boolean */ hasRotatingPoint: true, /** * Offset for object's rotating point (when enabled via `hasRotatingPoint`) - * @property * @type Number */ rotatingPointOffset: 40, /** * When set to `true`, objects are "found" on canvas on per-pixel basis rather than according to bounding box - * @property * @type Boolean */ perPixelTargetFind: false, /** * When `false`, default object's values are not included in its serialization - * @property * @type Boolean */ includeDefaultValues: true, /** * Function that determines clipping of an object (context is passed as a first argument) - * @property * @type Function */ clipTo: null, /** * When `true`, object horizontal movement is locked - * @property * @type Boolean */ lockMovementX: false, /** * When `true`, object vertical movement is locked - * @property * @type Boolean */ lockMovementY: false, /** * When `true`, object rotation is locked - * @property * @type Boolean */ lockRotation: false, /** * When `true`, object horizontal scaling is locked - * @property * @type Boolean */ lockScalingX: false, /** * When `true`, object vertical scaling is locked - * @property * @type Boolean */ lockScalingY: false, /** * When `true`, object non-uniform scaling is locked - * @property * @type Boolean */ lockUniScaling: false, @@ -10254,7 +9907,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * List of properties to consider when checking if state of an object is changed (fabric.Object#hasStateChanged); * as well as for history (undo/redo) purposes - * @property * @type Array */ stateProperties: ( @@ -10266,7 +9918,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Constructor - * @method initialize * @param {Object} [options] Options object */ initialize: function(options) { @@ -10277,7 +9928,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * @private - * @method _initGradient */ _initGradient: function(options) { if (options.fill && options.fill.colorStops && !(options.fill instanceof fabric.Gradient)) { @@ -10287,7 +9937,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * @private - * @method _initPattern */ _initPattern: function(options) { if (options.fill && options.fill.source && !(options.fill instanceof fabric.Pattern)) { @@ -10300,7 +9949,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * @private - * @method _initShadow */ _initShadow: function(options) { if (options.shadow && !(options.shadow instanceof fabric.Shadow)) { @@ -10310,7 +9958,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Sets object's properties from options - * @method setOptions * @param {Object} [options] */ setOptions: function(options) { @@ -10324,7 +9971,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Transforms context when rendering an object - * @method transform * @param {CanvasRenderingContext2D} ctx Context */ transform: function(ctx) { @@ -10341,7 +9987,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Returns an object representation of an instance - * @method toObject * @param {Array} propertiesToInclude * @return {Object} object representation of an instance */ @@ -10388,7 +10033,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Returns (dataless) object representation of an instance - * @method toDatalessObject * @param {Array} [propertiesToInclude] * @return {Object} object representation of an instance */ @@ -10399,7 +10043,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Returns styles-string for svg-export - * @method getSvgStyles * @return {String} */ getSvgStyles: function() { @@ -10415,7 +10058,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Returns transform-string for svg-export - * @method getSvgTransform * @return {String} */ getSvgTransform: function() { @@ -10450,7 +10092,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * @private - * @method _removeDefaultValues */ _removeDefaultValues: function(object) { var defaultOptions = fabric.Object.prototype.options; @@ -10474,7 +10115,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Basic getter - * @method get * @param {String} property * @return {Any} value of a property */ @@ -10484,7 +10124,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Sets property to a given value. When changing position/dimension -related properties (left, top, scale, angle, etc.) `set` does not update position of object's borders/controls. If you need to update those, call `setCoords()`. - * @method set * @param {String} name * @param {Object|Function} value (if function, the value is passed into it and its return value is used as a new one) * @return {fabric.Object} thisArg @@ -10509,7 +10148,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * @private - * @method _set * @param key * @param value */ @@ -10538,7 +10176,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Toggles specified property from `true` to `false` or from `false` to `true` - * @method toggle * @param {String} property property to toggle * @return {fabric.Object} thisArg * @chainable @@ -10553,7 +10190,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Sets sourcePath of an object - * @method setSourcePath * @param {String} value * @return {fabric.Object} thisArg * @chainable @@ -10565,7 +10201,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Renders an object on a specified context - * @method render * @param {CanvasRenderingContext2D} ctx context to render on * @param {Boolean} [noTransform] When true, context is not transformed */ @@ -10623,7 +10258,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * @private - * @method _setShadow */ _setShadow: function(ctx) { if (!this.shadow) return; @@ -10636,7 +10270,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * @private - * @method _removeShadow */ _removeShadow: function(ctx) { ctx.shadowColor = ''; @@ -10645,7 +10278,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * @private - * @method _renderFill */ _renderFill: function(ctx) { if (!this.fill) return; @@ -10664,7 +10296,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Clones an instance - * @method clone * @param {Function} callback Callback is invoked with a clone as a first argument * @param {Array} propertiesToInclude * @return {fabric.Object} clone of an instance @@ -10678,7 +10309,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Creates an instance of fabric.Image out of an object - * @method cloneAsImage * @param callback {Function} callback, invoked with an instance as a first argument * @return {fabric.Object} thisArg * @chainable @@ -10712,7 +10342,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Converts an object into a data-url-like string - * @method toDataURL * @param callback {Function} callback that recieves resulting data-url string */ toDataURL: function(callback) { @@ -10752,7 +10381,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Returns true if object state (one of its state properties) was changed - * @method hasStateChanged * @return {Boolean} true if instance' state has changed */ hasStateChanged: function() { @@ -10763,7 +10391,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Saves state of an object - * @method saveState * @param {Object} [options] Object with additional `stateProperties` array to include when saving state * @return {fabric.Object} thisArg * @chainable @@ -10784,7 +10411,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Setups state of an object - * @method setupState */ setupState: function() { this.originalState = { }; @@ -10793,7 +10419,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Returns true if specified type is identical to the type of an instance - * @method isType * @param type {String} type to check against * @return {Boolean} */ @@ -10803,7 +10428,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Makes object's color grayscale - * @method toGrayscale * @return {fabric.Object} thisArg */ toGrayscale: function() { @@ -10816,7 +10440,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Returns complexity of an instance - * @method complexity * @return {Number} complexity */ complexity: function() { @@ -10825,9 +10448,8 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Returns a JSON representation of an instance - * @method toJSON * @param {Array} propertiesToInclude Any properties that you might want to additionally include in the output - * @return {String} json + * @return {Object} JSON */ toJSON: function(propertiesToInclude) { // delegate, not alias @@ -10836,7 +10458,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Sets gradient (fill or stroke) of an object - * @method setGradient * @param {String} property Property name 'stroke' or 'fill' * @param {Object} [options] Options object */ @@ -10868,7 +10489,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Sets pattern fill of an object - * @method setPatternFill * @param {Object} [options] Options object * @return {fabric.Object} thisArg * @chainable @@ -10879,7 +10499,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Sets shadow of an object - * @method setShadow * @param {Object} [options] Options object * @return {fabric.Object} thisArg * @chainable @@ -10890,7 +10509,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Animates object's properties - * @method animate * @param {String|Object} property to animate (if string) or properties to animate (if object) * @param {Number|Object} value to animate property to (if string was given first) or options object * @return {fabric.Object} thisArg @@ -10927,7 +10545,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * @private - * @method _animate * @param {String} property * @param {String} to * @param {Object} [options] @@ -10991,7 +10608,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Centers object horizontally on canvas to which it was added last - * @method centerH * @return {fabric.Object} thisArg */ centerH: function () { @@ -11001,7 +10617,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Centers object vertically on canvas to which it was added last - * @method centerV * @return {fabric.Object} thisArg * @chainable */ @@ -11012,7 +10627,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Centers object vertically and horizontally on canvas to which is was added last - * @method center * @return {fabric.Object} thisArg * @chainable */ @@ -11022,7 +10636,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Removes object from canvas to which it was added last - * @method remove * @return {fabric.Object} thisArg * @chainable */ @@ -11032,7 +10645,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Moves an object to the bottom of the stack of drawn objects - * @method sendToBack * @return {fabric.Object} thisArg * @chainable */ @@ -11048,7 +10660,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Moves an object to the top of the stack of drawn objects - * @method bringToFront * @return {fabric.Object} thisArg * @chainable */ @@ -11064,7 +10675,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Moves an object one level down in stack of drawn objects - * @method sendBackwards * @return {fabric.Object} thisArg * @chainable */ @@ -11080,7 +10690,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Moves an object one level up in stack of drawn objects - * @method bringForward * @return {fabric.Object} thisArg * @chainable */ @@ -11096,7 +10705,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Moves an object to specified level in stack of drawn objects - * @method moveTo * @param {Number} index New position of object * @return {fabric.Object} thisArg * @chainable @@ -11142,11 +10750,10 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati var degreesToRadians = fabric.util.degreesToRadians; - fabric.util.object.extend(fabric.Object.prototype, /** @scope fabric.Object.prototype */ { + fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prototype */ { /** * Translates the coordinates from origin to center coordinates (based on the object's dimensions) - * @method translateToCenterPoint * @param {fabric.Point} point The point which corresponds to the originX and originY params * @param {string} enum('left', 'center', 'right') Horizontal origin * @param {string} enum('top', 'center', 'bottom') Vertical origin @@ -11175,7 +10782,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Translates the coordinates from center to origin coordinates (based on the object's dimensions) - * @method translateToOriginPoint * @param {fabric.Point} point The point which corresponds to center of the object * @param {string} enum('left', 'center', 'right') Horizontal origin * @param {string} enum('top', 'center', 'bottom') Vertical origin @@ -11204,7 +10810,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Returns the real center coordinates of the object - * @method getCenterPoint * @return {fabric.Point} */ getCenterPoint: function() { @@ -11214,7 +10819,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Returns the coordinates of the object based on center coordinates - * @method getOriginPoint * @param {fabric.Point} point The point which corresponds to the originX and originY params * @return {fabric.Point} */ @@ -11224,7 +10828,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Returns the coordinates of the object as if it has a different origin - * @method getPointByOrigin * @param {string} enum('left', 'center', 'right') Horizontal origin * @param {string} enum('top', 'center', 'bottom') Vertical origin * @return {fabric.Point} @@ -11237,7 +10840,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Returns the point in local coordinates - * @method toLocalPoint * @param {fabric.Point} The point relative to the global coordinate system * @return {fabric.Point} */ @@ -11276,7 +10878,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Returns the point in global coordinates - * @method toGlobalPoint * @param {fabric.Point} The point relative to the local coordinate system * @return {fabric.Point} */ @@ -11286,7 +10887,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Sets the position of the object taking into consideration the object's origin - * @method setPositionByOrigin * @param {fabric.Point} point The new position of the object * @param {string} enum('left', 'center', 'right') Horizontal origin * @param {string} enum('top', 'center', 'bottom') Vertical origin @@ -11301,7 +10901,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati }, /** - * @method adjustPosition * @param {String} to One of left, center, right */ adjustPosition: function(to) { @@ -11345,15 +10944,15 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati }); })(); + (function() { var degreesToRadians = fabric.util.degreesToRadians; - fabric.util.object.extend(fabric.Object.prototype, /** @scope fabric.Object.prototype */ { + fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prototype */ { /** * Returns true if object intersects with an area formed by 2 points - * @method intersectsWithRect * @param {Object} selectionTL * @param {Object} selectionBR * @return {Boolean} @@ -11375,7 +10974,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Returns true if object intersects with another object - * @method intersectsWithObject * @param {Object} other Object to test * @return {Boolean} */ @@ -11402,7 +11000,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Returns true if object is fully contained within area of another object - * @method isContainedWithinObject * @param {Object} other Object to test * @return {Boolean} */ @@ -11412,7 +11009,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Returns true if object is fully contained within area formed by 2 points - * @method isContainedWithinRect * @param {Object} selectionTL * @param {Object} selectionBR * @return {Boolean} @@ -11432,7 +11028,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Returns width of an object's bounding rectangle * @deprecated since 1.0.4 - * @method getBoundingRectWidth * @return {Number} width value */ getBoundingRectWidth: function() { @@ -11442,7 +11037,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Returns height of an object's bounding rectangle * @deprecated since 1.0.4 - * @method getBoundingRectHeight * @return {Number} height value */ getBoundingRectHeight: function() { @@ -11451,7 +11045,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Returns coordinates of object's bounding rectangle (left, top, width, height) - * @method getBoundingRect * @return {Object} Object with left, top, width, height properties */ getBoundingRect: function() { @@ -11477,7 +11070,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Returns width of an object - * @method getWidth * @return {Number} width value */ getWidth: function() { @@ -11486,7 +11078,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Returns height of an object - * @method getHeight * @return {Number} height value */ getHeight: function() { @@ -11496,7 +11087,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Makes sure the scale is valid and modifies it if necessary * @private - * @method _constrainScale * @param {Number} value * @return {Number} */ @@ -11513,7 +11103,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Scales an object (equally by x and y) - * @method scale * @param value {Number} scale factor * @return {fabric.Object} thisArg * @chainable @@ -11535,7 +11124,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Scales an object to a given width, with respect to bounding box (scaling by x/y equally) - * @method scaleToWidth * @param value {Number} new width value * @return {fabric.Object} thisArg * @chainable @@ -11548,7 +11136,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Scales an object to a given height, with respect to bounding box (scaling by x/y equally) - * @method scaleToHeight * @param value {Number} new height value * @return {fabric.Object} thisArg * @chainable @@ -11561,7 +11148,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Sets corner position coordinates based on current angle, width and height - * @method setCoords * @return {fabric.Object} thisArg * @chainable */ @@ -11653,16 +11239,16 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati } }); })(); + (function(){ var getPointer = fabric.util.getPointer, degreesToRadians = fabric.util.degreesToRadians; - fabric.util.object.extend(fabric.Object.prototype, /** @scope fabric.Object.prototype */ { + fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prototype */ { /** * Determines which one of the four corners has been clicked - * @method _findTargetCorner * @private * @param e {Event} event object * @param offset {Object} canvas offset @@ -11715,7 +11301,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Helper method to determine how many cross points are between the 4 image edges * and the horizontal line determined by the position of our mouse when clicked on canvas - * @method _findCrossPoints * @private * @param ex {Number} x coordinate of the mouse * @param ey {Number} y coordinate of the mouse @@ -11765,7 +11350,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Method that returns an object with the image lines in it given the coordinates of the corners - * @method _getImageLines * @private * @param oCoords {Object} coordinates of the image corners */ @@ -11793,7 +11377,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Sets the coordinates of the draggable boxes in the corners of * the image used to scale/rotate it. - * @method _setCornerCoords * @private */ _setCornerCoords: function() { @@ -11981,7 +11564,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati * Draws borders of an object's bounding box. * Requires public properties: width, height * Requires public options: padding, borderColor - * @method drawBorders * @param {CanvasRenderingContext2D} ctx Context to draw on * @return {fabric.Object} thisArg * @chainable @@ -12038,7 +11620,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati * Draws corners of an object's bounding box. * Requires public properties: width, height, scaleX, scaleY * Requires public options: cornerSize, padding - * @method drawControls * @param {CanvasRenderingContext2D} ctx Context to draw on * @return {fabric.Object} thisArg * @chainable @@ -12168,18 +11749,16 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati * @class Line * @extends fabric.Object */ - fabric.Line = fabric.util.createClass(fabric.Object, /** @scope fabric.Line.prototype */ { + fabric.Line = fabric.util.createClass(fabric.Object, /** @lends fabric.Line.prototype */ { /** * Type of an object - * @property * @type String */ type: 'line', /** * Constructor - * @method initialize * @param {Array} [points] Array of points * @param {Object} [options] Options object * @return {fabric.Line} thisArg @@ -12203,7 +11782,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * @private - * @method _setWidthHeight * @param {Object} [options] Options */ _setWidthHeight: function(options) { @@ -12218,7 +11796,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * @private - * @method _set * @param {String} key * @param {Any} value */ @@ -12232,7 +11809,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * @private - * @method _render * @param {CanvasRenderingContext2D} ctx Context to render on */ _render: function(ctx) { @@ -12263,7 +11839,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Returns complexity of an instance - * @method complexity * @return {Number} complexity */ complexity: function() { @@ -12287,7 +11862,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Returns SVG representation of an instance - * @method toSVG * @return {String} svg representation of an instance */ toSVG: function() { @@ -12321,7 +11895,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Returns fabric.Line instance from an SVG element * @static - * @method fabric.Line.fromElement * @param {SVGElement} element Element to parse * @param {Object} [options] Options object * @return {fabric.Line} instance of fabric.Line @@ -12340,7 +11913,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Returns fabric.Line instance from an object representation * @static - * @method fabric.Line.fromObject * @param {Object} object Object to create an instance from * @return {fabric.Line} instance of fabric.Line */ @@ -12369,18 +11941,16 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati * @class Circle * @extends fabric.Object */ - fabric.Circle = fabric.util.createClass(fabric.Object, /** @scope fabric.Circle.prototype */ { + fabric.Circle = fabric.util.createClass(fabric.Object, /** @lends fabric.Circle.prototype */ { /** * Type of an object - * @property * @type String */ type: 'circle', /** * Constructor - * @method initialize * @param {Object} [options] Options object * @return {fabric.Circle} thisArg */ @@ -12396,7 +11966,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Returns object representation of an instance - * @method toObject * @param {Array} propertiesToInclude * @return {Object} object representation of an instance */ @@ -12408,7 +11977,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Returns svg representation of an instance - * @method toSVG * @return {String} svg representation of an instance */ toSVG: function() { @@ -12435,7 +12003,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * @private - * @method _render * @param ctx {CanvasRenderingContext2D} context to render on */ _render: function(ctx, noTransform) { @@ -12453,7 +12020,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Returns horizontal radius of an object (according to how an object is scaled) - * @method getRadiusX * @return {Number} */ getRadiusX: function() { @@ -12462,7 +12028,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Returns vertical radius of an object (according to how an object is scaled) - * @method getRadiusY * @return {Number} */ getRadiusY: function() { @@ -12471,7 +12036,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Sets radius of an object (and updates width accordingly) - * @method setRadius * @return {Number} */ setRadius: function(value) { @@ -12481,7 +12045,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Returns complexity of an instance - * @method complexity * @return {Number} complexity of this instance */ complexity: function() { @@ -12499,11 +12062,10 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Returns {@link fabric.Circle} instance from an SVG element * @static - * @method fabric.Circle.fromElement * @param {SVGElement} element Element to parse * @param {Object} [options] Options object * @throws {Error} If value of `r` attribute is missing or invalid - * @return {Object} Instance of fabric.Circle + * @return {fabric.Circle} Instance of fabric.Circle */ fabric.Circle.fromElement = function(element, options) { options || (options = { }); @@ -12535,7 +12097,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Returns {@link fabric.Circle} instance from an object representation * @static - * @method fabric.Circle.fromObject * @param {Object} object Object to create an instance from * @return {Object} Instance of fabric.Circle */ @@ -12561,18 +12122,16 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati * @class Triangle * @extends fabric.Object */ - fabric.Triangle = fabric.util.createClass(fabric.Object, /** @scope fabric.Triangle.prototype */ { + fabric.Triangle = fabric.util.createClass(fabric.Object, /** @lends fabric.Triangle.prototype */ { /** * Type of an object - * @property * @type String */ type: 'triangle', /** * Constructor - * @method initialize * @param {Object} [options] Options object * @return {Object} thisArg */ @@ -12587,7 +12146,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * @private - * @method _render * @param ctx {CanvasRenderingContext2D} Context to render on */ _render: function(ctx) { @@ -12609,7 +12167,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Returns complexity of an instance - * @method complexity * @return {Number} complexity of this instance */ complexity: function() { @@ -12618,7 +12175,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Returns SVG representation of an instance - * @method toSVG * @return {String} svg representation of an instance */ toSVG: function() { @@ -12654,7 +12210,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Returns fabric.Triangle instance from an object representation * @static - * @method Canvas.Trangle.fromObject * @param object {Object} object to create an instance from * @return {Object} instance of Canvas.Triangle */ @@ -12682,32 +12237,28 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati * @class Ellipse * @extends fabric.Object */ - fabric.Ellipse = fabric.util.createClass(fabric.Object, /** @scope fabric.Ellipse.prototype */ { + fabric.Ellipse = fabric.util.createClass(fabric.Object, /** @lends fabric.Ellipse.prototype */ { /** * Type of an object - * @property * @type String */ type: 'ellipse', /** * Horizontal radius - * @property * @type Number */ rx: 0, /** * Vertical radius - * @property * @type Number */ ry: 0, /** * Constructor - * @method initialize * @param {Object} [options] Options object * @return {fabric.Ellipse} thisArg */ @@ -12725,7 +12276,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Returns object representation of an instance - * @method toObject * @param {Array} propertiesToInclude * @return {Object} object representation of an instance */ @@ -12738,7 +12288,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Returns svg representation of an instance - * @method toSVG * @return {String} svg representation of an instance */ toSVG: function() { @@ -12765,7 +12314,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Renders this instance on a given context - * @method render * @param ctx {CanvasRenderingContext2D} context to render on * @param noTransform {Boolean} context is not transformed when set to true */ @@ -12777,7 +12325,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * @private - * @method _render * @param ctx {CanvasRenderingContext2D} context to render on */ _render: function(ctx, noTransform) { @@ -12799,7 +12346,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Returns complexity of an instance - * @method complexity * @return {Number} complexity */ complexity: function() { @@ -12817,7 +12363,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Returns {@link fabric.Ellipse} instance from an SVG element * @static - * @method fabric.Ellipse.fromElement * @param {SVGElement} element Element to parse * @param {Object} [options] Options object * @return {fabric.Ellipse} @@ -12847,7 +12392,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Returns {@link fabric.Ellipse} instance from an object representation * @static - * @method fabric.Ellipse.fromObject * @param {Object} object Object to create an instance from * @return {fabric.Ellipse} */ @@ -12874,39 +12418,34 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati * @class Rect * @extends fabric.Object */ - fabric.Rect = fabric.util.createClass(fabric.Object, /** @scope fabric.Rect.prototype */ { + fabric.Rect = fabric.util.createClass(fabric.Object, /** @lends fabric.Rect.prototype */ { /** * Type of an object - * @property * @type String */ type: 'rect', /** * Horizontal border radius - * @property * @type Number */ rx: 0, /** * Vertical border radius - * @property * @type Number */ ry: 0, /** * Used to specify dash pattern for stroke on this object - * @property * @type Array */ strokeDashArray: null, /** * Constructor - * @method initialize * @param {Object} [options] Options object * @return {Object} thisArg */ @@ -12925,7 +12464,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati * Creates `stateProperties` list on an instance, and adds `fabric.Rect` -specific ones to it * (such as "rx", "ry", etc.) * @private - * @method _initStateProperties */ _initStateProperties: function() { this.stateProperties = this.stateProperties.concat(['rx', 'ry']); @@ -12934,7 +12472,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Initializes rx/ry attributes * @private - * @method _initRxRy */ _initRxRy: function() { if (this.rx && !this.ry) { @@ -12947,7 +12484,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * @private - * @method _render * @param ctx {CanvasRenderingContext2D} context to render on */ _render: function(ctx) { @@ -12997,7 +12533,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * @private - * @method _renderDashedStroke */ _renderDashedStroke: function(ctx) { @@ -13057,9 +12592,8 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati }, /** - * @method _normalizeLeftTopProperties - * @private * Since coordinate system differs from that of SVG + * @private */ _normalizeLeftTopProperties: function(parsedAttributes) { if ('left' in parsedAttributes) { @@ -13075,7 +12609,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Returns complexity of an instance - * @method complexity * @return {Number} complexity */ complexity: function() { @@ -13084,7 +12617,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Returns object representation of an instance - * @method toObject * @param {Array} propertiesToInclude * @return {Object} object representation of an instance */ @@ -13097,7 +12629,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Returns svg representation of an instance - * @method toSVG * @return {String} svg representation of an instance */ toSVG: function() { @@ -13142,7 +12673,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Returns {@link fabric.Rect} instance from an SVG element * @static - * @method fabric.Rect.fromElement * @param {SVGElement} element Element to parse * @param {Object} [options] Options object * @return {fabric.Rect} Instance of fabric.Rect @@ -13164,7 +12694,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Returns {@link fabric.Rect} instance from an object representation * @static - * @method fabric.Rect.fromObject * @param object {Object} object to create an instance from * @return {Object} instance of fabric.Rect */ @@ -13191,18 +12720,16 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati * @class Polyline * @extends fabric.Object */ - fabric.Polyline = fabric.util.createClass(fabric.Object, /** @scope fabric.Polyline.prototype */ { + fabric.Polyline = fabric.util.createClass(fabric.Object, /** @lends fabric.Polyline.prototype */ { /** * Type of an object - * @property * @type String */ type: 'polyline', /** * Constructor - * @method initialize * @param {Array} points array of points * @param {Object} [options] Options object * @param {Boolean} Whether points offsetting should be skipped @@ -13217,7 +12744,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * @private - * @method _calcDimensions */ _calcDimensions: function(skipOffset) { return fabric.Polygon.prototype._calcDimensions.call(this, skipOffset); @@ -13225,7 +12751,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Returns object representation of an instance - * @method toObject * @param {Array} propertiesToInclude * @return {Object} object representation of an instance */ @@ -13235,7 +12760,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Returns SVG representation of an instance - * @method toSVG * @return {String} svg representation of an instance */ toSVG: function() { @@ -13266,7 +12790,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * @private - * @method _render * @param {CanvasRenderingContext2D} ctx Context to render on */ _render: function(ctx) { @@ -13286,7 +12809,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Returns complexity of an instance - * @method complexity * @return {Number} complexity */ complexity: function() { @@ -13304,7 +12826,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Returns fabric.Polyline instance from an SVG element * @static - * @method fabric.Polyline.fromElement * @param {SVGElement} element Element to parse * @param {Object} [options] Options object * @return {Object} instance of fabric.Polyline @@ -13330,7 +12851,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Returns fabric.Polyline instance from an object representation * @static - * @method fabric.Polyline.fromObject * @param {Object} [object] Object to create an instance from * @return {fabric.Polyline} */ @@ -13361,18 +12881,16 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati * @class Polygon * @extends fabric.Object */ - fabric.Polygon = fabric.util.createClass(fabric.Object, /** @scope fabric.Polygon.prototype */ { + fabric.Polygon = fabric.util.createClass(fabric.Object, /** @lends fabric.Polygon.prototype */ { /** * Type of an object - * @property * @type String */ type: 'polygon', /** * Constructor - * @method initialize * @param {Array} points Array of points * @param {Object} [options] Options object * @param {Boolean} Whether points offsetting should be skipped @@ -13387,7 +12905,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * @private - * @method _calcDimensions */ _calcDimensions: function(skipOffset) { @@ -13417,7 +12934,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Returns object representation of an instance - * @method toObject * @param {Array} propertiesToInclude * @return {Object} object representation of an instance */ @@ -13429,7 +12945,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Returns svg representation of an instance - * @method toSVG * @return {String} svg representation of an instance */ toSVG: function() { @@ -13460,7 +12975,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * @private - * @method _render * @param ctx {CanvasRenderingContext2D} context to render on */ _render: function(ctx) { @@ -13481,7 +12995,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Returns complexity of an instance - * @method complexity * @return {Number} complexity of this instance */ complexity: function() { @@ -13499,7 +13012,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Returns {@link fabric.Polygon} instance from an SVG element * @static - * @method fabric.Polygon.fromElement * @param {SVGElement} element Element to parse * @param {Object} [options] Options object * @return {fabric.Polygon} @@ -13525,7 +13037,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Returns fabric.Polygon instance from an object representation * @static - * @method fabric.Polygon.fromObject * @param {Object} object Object to create an instance from * @return {fabric.Polygon} */ @@ -13696,18 +13207,16 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati * @class Path * @extends fabric.Object */ - fabric.Path = fabric.util.createClass(fabric.Object, /** @scope fabric.Path.prototype */ { + fabric.Path = fabric.util.createClass(fabric.Object, /** @lends fabric.Path.prototype */ { /** * Type of an object - * @property * @type String */ type: 'path', /** * Constructor - * @method initialize * @param {Array|String} path Path data (sequence of coordinates and corresponding "command" tokens) * @param {Object} [options] Options object */ @@ -13741,7 +13250,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * @private - * @method _initializePath */ _initializePath: function (options) { var isWidthSet = 'width' in options, @@ -13771,7 +13279,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * @private - * @method _calculatePathOffset */ _calculatePathOffset: function (positionSet) { return { @@ -13782,7 +13289,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * @private - * @method _render */ _render: function(ctx) { var current, // current instruction @@ -14064,7 +13570,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Renders path on a specified context - * @method render * @param {CanvasRenderingContext2D} ctx context to render path on * @param {Boolean} [noTransform] When true, context is not transformed */ @@ -14126,7 +13631,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Returns string representation of an instance - * @method toString * @return {String} string representation of an instance */ toString: function() { @@ -14136,7 +13640,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Returns object representation of an instance - * @method toObject * @param {Array} propertiesToInclude * @return {Object} object representation of an instance */ @@ -14155,7 +13658,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Returns dataless object representation of an instance - * @method toDatalessObject * @param {Array} propertiesToInclude * @return {Object} object representation of an instance */ @@ -14170,7 +13672,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Returns svg representation of an instance - * @method toSVG * @return {String} svg representation of an instance */ toSVG: function() { @@ -14205,7 +13706,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Returns number representation of an instance complexity - * @method complexity * @return {Number} complexity */ complexity: function() { @@ -14214,7 +13714,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * @private - * @method _parsePath */ _parsePath: function() { var result = [ ], @@ -14251,7 +13750,7 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati }, /** - * @method _parseDimensions + * @private */ _parseDimensions: function() { var aX = [], @@ -14325,7 +13824,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Creates an instance of fabric.Path from an object * @static - * @method fabric.Path.fromObject * @return {fabric.Path} Instance of fabric.Path */ fabric.Path.fromObject = function(object) { @@ -14342,7 +13840,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Creates an instance of fabric.Path from an SVG element * @static - * @method fabric.Path.fromElement * @param {SVGElement} element to parse * @param {Object} [options] Options object * @return {fabric.Path} Instance of fabric.Path @@ -14375,25 +13872,22 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati * @class PathGroup * @extends fabric.Path */ - fabric.PathGroup = fabric.util.createClass(fabric.Path, /** @scope fabric.PathGroup.prototype */ { + fabric.PathGroup = fabric.util.createClass(fabric.Path, /** @lends fabric.PathGroup.prototype */ { /** * Type of an object - * @property * @type String */ type: 'path-group', /** * Fill value - * @property * @type String */ fill: '', /** * Constructor - * @method initialize * @param {Array} paths * @param {Object} [options] Options object * @return {fabric.PathGroup} thisArg @@ -14417,7 +13911,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Renders this group on a specified context - * @method render * @param {CanvasRenderingContext2D} ctx Context to render this instance on */ render: function(ctx) { @@ -14450,7 +13943,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Sets certain property to a certain value - * @method _set * @param {String} prop * @param {Any} value * @return {fabric.PathGroup} thisArg @@ -14469,7 +13961,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Returns object representation of this path group - * @method toObject * @param {Array} [propertiesToInclude] * @return {Object} object representation of an instance */ @@ -14482,7 +13973,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Returns dataless object representation of this path group - * @method toDatalessObject * @param {Array} [propertiesToInclude] * @return {Object} dataless object representation of an instance */ @@ -14496,7 +13986,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Returns svg representation of an instance - * @method toSVG * @return {String} svg representation of an instance */ toSVG: function() { @@ -14518,7 +14007,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Returns a string representation of this path group - * @method toString * @return {String} string representation of an object */ toString: function() { @@ -14528,7 +14016,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Returns true if all paths in this group are of same color - * @method isSameColor * @return {Boolean} true if all paths are of the same color (`fill`) */ isSameColor: function() { @@ -14540,7 +14027,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Returns number representation of object's complexity - * @method complexity * @return {Number} complexity */ complexity: function() { @@ -14551,7 +14037,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Makes path group grayscale - * @method toGrayscale * @return {fabric.PathGroup} thisArg */ toGrayscale: function() { @@ -14564,7 +14049,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Returns all paths in this path group - * @method getObjects * @return {Array} array of path objects included in this path group */ getObjects: function() { @@ -14574,7 +14058,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * @private - * @method instantiatePaths */ function instantiatePaths(paths) { for (var i = 0, len = paths.length; i < len; i++) { @@ -14589,7 +14072,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Creates fabric.PathGroup instance from an object representation * @static - * @method fabric.PathGroup.fromObject * @param {Object} object * @return {fabric.PathGroup} */ @@ -14599,6 +14081,7 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati }; })(typeof exports !== 'undefined' ? exports : this); + (function(global){ "use strict"; @@ -14630,18 +14113,16 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati * @class Group * @extends fabric.Object */ - fabric.Group = fabric.util.createClass(fabric.Object, fabric.Collection, /** @scope fabric.Group.prototype */ { + fabric.Group = fabric.util.createClass(fabric.Object, fabric.Collection, /** @lends fabric.Group.prototype */ { /** * Type of an object - * @property * @type String */ type: 'group', /** * Constructor - * @method initialized * @param {Object} objects Group objects * @param {Object} [options] Options object * @return {Object} thisArg @@ -14671,7 +14152,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * @private - * @method _updateObjectsCoords */ _updateObjectsCoords: function() { var groupDeltaX = this.left, @@ -14698,7 +14178,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Returns string represenation of a group - * @method toString * @return {String} */ toString: function() { @@ -14707,7 +14186,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Returns an array of all objects in this group - * @method getObjects * @return {Array} group objects */ getObjects: function() { @@ -14716,7 +14194,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Adds an object to a group; Then recalculates group's dimension, position. - * @method addWithUpdate * @param {Object} object * @return {fabric.Group} thisArg * @chainable @@ -14734,7 +14211,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Removes an object from a group; Then recalculates group's dimension, position. - * @method removeWithUpdate * @param {Object} object * @return {fabric.Group} thisArg * @chainable @@ -14802,7 +14278,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Returns object representation of an instance - * @method toObject * @param {Array} propertiesToInclude * @return {Object} object representation of an instance */ @@ -14814,7 +14289,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Renders instance on a given context - * @method render * @param {CanvasRenderingContext2D} ctx context to render instance on * @param {Boolean} [noTransform] When true, context is not transformed */ @@ -14860,7 +14334,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Retores original state of each of group objects (original state is that which was before group was created). * @private - * @method _restoreObjectsState * @return {fabric.Group} thisArg * @chainable */ @@ -14872,7 +14345,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Restores original state of a specified object in group * @private - * @method _restoreObjectState * @param {fabric.Object} object * @return {fabric.Group} thisArg */ @@ -14904,7 +14376,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Destroys a group (restoring state of its objects) - * @method destroy * @return {fabric.Group} thisArg * @chainable */ @@ -14926,7 +14397,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Checks whether this group was moved (since `saveCoords` was called last) - * @method hasMoved * @return {Boolean} true if an object was moved (since fabric.Group#saveCoords was called) */ hasMoved: function() { @@ -14936,7 +14406,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Sets coordinates of all group objects - * @method setObjectsCoords * @return {fabric.Group} thisArg * @chainable */ @@ -14949,7 +14418,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * @private - * @method _setOpacityIfSame */ _setOpacityIfSame: function() { var objects = this.getObjects(), @@ -14966,7 +14434,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * @private - * @method _calcBounds */ _calcBounds: function() { var aX = [], @@ -15001,7 +14468,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Checks if point is contained within the group - * @method containsPoint * @param {fabric.Point} point point with `x` and `y` properties * @return {Boolean} true if point is contained within group */ @@ -15020,7 +14486,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Returns svg representation of an instance - * @method toSVG * @return {String} svg representation of an instance */ toSVG: function() { @@ -15037,7 +14502,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Returns requested property - * @method get * @param {String} prop Property to get * @return {Any} */ @@ -15067,7 +14531,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Returns {@link fabric.Group} instance from an object representation * @static - * @method fabric.Group.fromObject * @param {Object} object Object to create a group from * @param {Object} [options] Options object * @return {fabric.Group} An instance of fabric.Group @@ -15108,11 +14571,10 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati * @class Image * @extends fabric.Object */ - fabric.Image = fabric.util.createClass(fabric.Object, /** @scope fabric.Image.prototype */ { + fabric.Image = fabric.util.createClass(fabric.Object, /** @lends fabric.Image.prototype */ { /** * Type of an object - * @property * @type String */ type: 'image', @@ -15141,7 +14603,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Returns image element which this instance if based on - * @method getElement * @return {HTMLImageElement} image element */ getElement: function() { @@ -15150,7 +14611,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Sets image element for this instance to a specified one - * @method setElement * @param {HTMLImageElement} element * @return {fabric.Image} thisArg * @chainable @@ -15163,7 +14623,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Returns original size of an image - * @method getOriginalSize * @return {Object} object with "width" and "height" properties */ getOriginalSize: function() { @@ -15176,7 +14635,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Renders image on a specified context - * @method render * @param {CanvasRenderingContext2D} ctx Context to render on * @param {Boolean} [noTransform] When true, context is not transformed */ @@ -15230,7 +14688,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Returns object representation of an instance - * @method toObject * @param {Array} propertiesToInclude * @return {Object} propertiesToInclude Object representation of an instance */ @@ -15243,7 +14700,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Returns SVG representation of an instance - * @method toSVG * @return {String} svg representation of an instance */ toSVG: function() { @@ -15261,7 +14717,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Returns source of an image - * @method getSrc * @return {String} Source of an image */ getSrc: function() { @@ -15270,7 +14725,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Returns string representation of an instance - * @method toString * @return {String} String representation of an instance */ toString: function() { @@ -15279,7 +14733,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Returns a clone of an instance - * @method clone * @param {Function} callback Callback is invoked with a clone as a first argument * @param {Array} propertiesToInclude */ @@ -15346,7 +14799,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * @private - * @method _render * @param ctx */ _render: function(ctx) { @@ -15361,7 +14813,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * @private - * @method _resetWidthHeight */ _resetWidthHeight: function() { var element = this.getElement(); @@ -15374,7 +14825,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati * The Image class's initialization method. This method is automatically * called by the constructor. * @private - * @method _initElement * @param {HTMLImageElement|String} el The element representing the image */ _initElement: function(element) { @@ -15384,7 +14834,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * @private - * @method _initConfig * @param {Object} [options] Options object */ _initConfig: function(options) { @@ -15395,7 +14844,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * @private - * @method _initFilters * @param {Object} object Object with filters property */ _initFilters: function(object) { @@ -15408,7 +14856,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * @private - * @method _setWidthHeight * @param {Object} [options] Object with width/height properties */ _setWidthHeight: function(options) { @@ -15423,7 +14870,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Returns complexity of an instance - * @method complexity * @return {Number} complexity */ complexity: function() { @@ -15441,14 +14887,12 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Alias for getSrc * @static - * @method getSvgSrc */ fabric.Image.prototype.getSvgSrc = fabric.Image.prototype.getSrc; /** * Creates an instance of fabric.Image from its object representation * @static - * @method fromObject * @param {Object} object * @param {Function} [callback] Callback to invoke when an image instance is created */ @@ -15484,7 +14928,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Creates an instance of fabric.Image from an URL string * @static - * @method fromURL * @param {String} url URL to create an image from * @param {Function} [callback] Callback to invoke when image is created (newly created image is passed as a first argument) * @param {Object} [imgOptions] Options object @@ -15505,7 +14948,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Returns {@link fabric.Image} instance from an SVG element * @static - * @method fabric.Image.fromElement * @param {SVGElement} element Element to parse * @param {Function} callback Callback to execute when fabric.Image object is created * @param {Object} [options] Options object @@ -15527,11 +14969,10 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati })(typeof exports !== 'undefined' ? exports : this); -fabric.util.object.extend(fabric.Object.prototype, /** @scope fabric.Object.prototype */ { +fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prototype */ { /** * @private - * @method _getAngleValueForStraighten * @return {Number} angle value */ _getAngleValueForStraighten: function() { @@ -15544,7 +14985,6 @@ fabric.util.object.extend(fabric.Object.prototype, /** @scope fabric.Object.prot /** * Straightens an object (rotating it from current angle to one of 0, 90, 180, 270, etc. depending on which is closer) - * @method straighten * @return {fabric.Object} thisArg * @chainable */ @@ -15555,7 +14995,6 @@ fabric.util.object.extend(fabric.Object.prototype, /** @scope fabric.Object.prot /** * Same as {@link fabric.Object.prototype.straghten} but with animation - * @method fxStraighten * @param {Object} callbacks * - onComplete: invoked on completion * - onChange: invoked on every step of animation @@ -15592,11 +15031,10 @@ fabric.util.object.extend(fabric.Object.prototype, /** @scope fabric.Object.prot } }); -fabric.util.object.extend(fabric.StaticCanvas.prototype, { +fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @lends fabric.StaticCanvas.prototype */ { /** * Straightens object, then rerenders canvas - * @method straightenObject * @param {fabric.Object} object Object to straighten * @return {fabric.Canvas} thisArg * @chainable @@ -15609,7 +15047,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, { /** * Same as {@link fabric.Canvas.prototype.straightenObject}, but animated - * @method fxStraightenObject * @param {fabric.Object} object Object to straighten * @return {fabric.Canvas} thisArg * @chainable @@ -15621,8 +15058,10 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, { return this; } }); + /** - * @namespace Image filters + * @namespace fabric.Image.filters + * @memberOf fabric.Image */ fabric.Image.filters = { }; @@ -15631,7 +15070,7 @@ fabric.Image.filters = { }; * @class fabric.Image.filters.Grayscale * @memberOf fabric.Image.filters */ -fabric.Image.filters.Grayscale = fabric.util.createClass( /** @scope fabric.Image.filters.Grayscale.prototype */ { +fabric.Image.filters.Grayscale = fabric.util.createClass( /** @lends fabric.Image.filters.Grayscale.prototype */ { /** * Filter type @@ -15641,7 +15080,6 @@ fabric.Image.filters.Grayscale = fabric.util.createClass( /** @scope fabric.Imag /** * Applies filter to canvas element - * @method applyTo * @memberOf fabric.Image.filters.Grayscale.prototype * @param {Object} canvasEl Canvas element to apply filter to */ @@ -15670,8 +15108,7 @@ fabric.Image.filters.Grayscale = fabric.util.createClass( /** @scope fabric.Imag /** * Returns json representation of filter - * @method toJSON - * @return {String} json representation of filter + * @return {Object} JSON representation of filter */ toJSON: function() { return { type: this.type }; @@ -15681,7 +15118,6 @@ fabric.Image.filters.Grayscale = fabric.util.createClass( /** @scope fabric.Imag /** * Returns filter instance from an object representation * @static - * @method fabric.Image.filters.Grayscale.fromObject * @return {fabric.Image.filters.Grayscale} */ fabric.Image.filters.Grayscale.fromObject = function() { @@ -15693,7 +15129,7 @@ fabric.Image.filters.Grayscale.fromObject = function() { * @class fabric.Image.filters.RemoveWhite * @memberOf fabric.Image.filters */ -fabric.Image.filters.RemoveWhite = fabric.util.createClass( /** @scope fabric.Image.filters.RemoveWhite.prototype */ { +fabric.Image.filters.RemoveWhite = fabric.util.createClass( /** @lends fabric.Image.filters.RemoveWhite.prototype */ { /** * Filter type @@ -15714,7 +15150,6 @@ fabric.Image.filters.RemoveWhite = fabric.util.createClass( /** @scope fabric.Im /** * Applies filter to canvas element - * @method applyTo * @param {Object} canvasEl Canvas element to apply filter to */ applyTo: function(canvasEl) { @@ -15749,8 +15184,7 @@ fabric.Image.filters.RemoveWhite = fabric.util.createClass( /** @scope fabric.Im /** * Returns json representation of filter - * @method toJSON - * @return {String} json representation of filter + * @return {Object} JSON representation of filter */ toJSON: function() { return { @@ -15764,7 +15198,6 @@ fabric.Image.filters.RemoveWhite = fabric.util.createClass( /** @scope fabric.Im /** * Returns filter instance from an object representation * @static - * @method fabric.Image.filters.RemoveWhite.fromObject * @return {fabric.Image.filters.RemoveWhite} */ fabric.Image.filters.RemoveWhite.fromObject = function(object) { @@ -15776,7 +15209,7 @@ fabric.Image.filters.RemoveWhite.fromObject = function(object) { * @class fabric.Image.filters.Invert * @memberOf fabric.Image.filters */ -fabric.Image.filters.Invert = fabric.util.createClass( /** @scope fabric.Image.filters.Invert.prototype */ { +fabric.Image.filters.Invert = fabric.util.createClass( /** @lends fabric.Image.filters.Invert.prototype */ { /** * Filter type @@ -15786,7 +15219,6 @@ fabric.Image.filters.Invert = fabric.util.createClass( /** @scope fabric.Image.f /** * Applies filter to canvas element - * @method applyTo * @memberOf fabric.Image.filters.Invert.prototype * @param {Object} canvasEl Canvas element to apply filter to */ @@ -15807,7 +15239,6 @@ fabric.Image.filters.Invert = fabric.util.createClass( /** @scope fabric.Image.f /** * Returns json representation of filter - * @method toJSON * @return {String} json representation of filter */ toJSON: function() { @@ -15818,7 +15249,6 @@ fabric.Image.filters.Invert = fabric.util.createClass( /** @scope fabric.Image.f /** * Returns filter instance from an object representation * @static - * @method fabric.Image.filters.Invert.fromObject * @return {fabric.Image.filters.Invert} */ fabric.Image.filters.Invert.fromObject = function() { @@ -15830,7 +15260,7 @@ fabric.Image.filters.Invert.fromObject = function() { * @class fabric.Image.filters.Sepia * @memberOf fabric.Image.filters */ -fabric.Image.filters.Sepia = fabric.util.createClass( /** @scope fabric.Image.filters.Sepia.prototype */ { +fabric.Image.filters.Sepia = fabric.util.createClass( /** @lends fabric.Image.filters.Sepia.prototype */ { /** * Filter type @@ -15840,7 +15270,6 @@ fabric.Image.filters.Sepia = fabric.util.createClass( /** @scope fabric.Image.fi /** * Applies filter to canvas element - * @method applyTo * @memberOf fabric.Image.filters.Sepia.prototype * @param {Object} canvasEl Canvas element to apply filter to */ @@ -15862,7 +15291,6 @@ fabric.Image.filters.Sepia = fabric.util.createClass( /** @scope fabric.Image.fi /** * Returns json representation of filter - * @method toJSON * @return {String} json representation of filter */ toJSON: function() { @@ -15873,7 +15301,6 @@ fabric.Image.filters.Sepia = fabric.util.createClass( /** @scope fabric.Image.fi /** * Returns filter instance from an object representation * @static - * @method fabric.Image.filters.Sepia.fromObject * @return {fabric.Image.filters.Sepia} */ fabric.Image.filters.Sepia.fromObject = function() { @@ -15885,7 +15312,7 @@ fabric.Image.filters.Sepia.fromObject = function() { * @class fabric.Image.filters.Sepia2 * @memberOf fabric.Image.filters */ -fabric.Image.filters.Sepia2 = fabric.util.createClass( /** @scope fabric.Image.filters.Sepia2.prototype */ { +fabric.Image.filters.Sepia2 = fabric.util.createClass( /** @lends fabric.Image.filters.Sepia2.prototype */ { /** * Filter type @@ -15895,7 +15322,6 @@ fabric.Image.filters.Sepia2 = fabric.util.createClass( /** @scope fabric.Image.f /** * Applies filter to canvas element - * @method applyTo * @memberOf fabric.Image.filters.Sepia.prototype * @param {Object} canvasEl Canvas element to apply filter to */ @@ -15921,7 +15347,6 @@ fabric.Image.filters.Sepia2 = fabric.util.createClass( /** @scope fabric.Image.f /** * Returns json representation of filter - * @method toJSON * @return {String} json representation of filter */ toJSON: function() { @@ -15932,7 +15357,6 @@ fabric.Image.filters.Sepia2 = fabric.util.createClass( /** @scope fabric.Image.f /** * Returns filter instance from an object representation * @static - * @method fabric.Image.filters.Sepia2.fromObject * @return {fabric.Image.filters.Sepia2} */ fabric.Image.filters.Sepia2.fromObject = function() { @@ -15944,7 +15368,7 @@ fabric.Image.filters.Sepia2.fromObject = function() { * @class fabric.Image.filters.Brightness * @memberOf fabric.Image.filters */ -fabric.Image.filters.Brightness = fabric.util.createClass( /** @scope fabric.Image.filters.Brightness.prototype */ { +fabric.Image.filters.Brightness = fabric.util.createClass( /** @lends fabric.Image.filters.Brightness.prototype */ { /** * Filter type @@ -15964,7 +15388,6 @@ fabric.Image.filters.Brightness = fabric.util.createClass( /** @scope fabric.Ima /** * Applies filter to canvas element - * @method applyTo * @param {Object} canvasEl Canvas element to apply filter to */ applyTo: function(canvasEl) { @@ -15984,7 +15407,6 @@ fabric.Image.filters.Brightness = fabric.util.createClass( /** @scope fabric.Ima /** * Returns json representation of filter - * @method toJSON * @return {String} json representation of filter */ toJSON: function() { @@ -15998,7 +15420,6 @@ fabric.Image.filters.Brightness = fabric.util.createClass( /** @scope fabric.Ima /** * Returns filter instance from an object representation * @static - * @method fabric.Image.filters.Brightness.fromObject * @return {fabric.Image.filters.Brightness} */ fabric.Image.filters.Brightness.fromObject = function(object) { @@ -16010,7 +15431,7 @@ fabric.Image.filters.Brightness.fromObject = function(object) { * @class fabric.Image.filters.Noise * @memberOf fabric.Image.filters */ -fabric.Image.filters.Noise = fabric.util.createClass( /** @scope fabric.Image.filters.Noise.prototype */ { +fabric.Image.filters.Noise = fabric.util.createClass( /** @lends fabric.Image.filters.Noise.prototype */ { /** * Filter type @@ -16030,7 +15451,6 @@ fabric.Image.filters.Noise = fabric.util.createClass( /** @scope fabric.Image.fi /** * Applies filter to canvas element - * @method applyTo * @param {Object} canvasEl Canvas element to apply filter to */ applyTo: function(canvasEl) { @@ -16053,7 +15473,6 @@ fabric.Image.filters.Noise = fabric.util.createClass( /** @scope fabric.Image.fi /** * Returns json representation of filter - * @method toJSON * @return {String} json representation of filter */ toJSON: function() { @@ -16067,7 +15486,6 @@ fabric.Image.filters.Noise = fabric.util.createClass( /** @scope fabric.Image.fi /** * Returns filter instance from an object representation * @static - * @method fabric.Image.filters.Noise.fromObject * @return {fabric.Image.filters.Noise} */ fabric.Image.filters.Noise.fromObject = function(object) { @@ -16079,7 +15497,7 @@ fabric.Image.filters.Noise.fromObject = function(object) { * @class fabric.Image.filters.GradientTransparency * @memberOf fabric.Image.filters */ -fabric.Image.filters.GradientTransparency = fabric.util.createClass( /** @scope fabric.Image.filters.GradientTransparency.prototype */ { +fabric.Image.filters.GradientTransparency = fabric.util.createClass( /** @lends fabric.Image.filters.GradientTransparency.prototype */ { /** * Filter type @@ -16099,7 +15517,6 @@ fabric.Image.filters.GradientTransparency = fabric.util.createClass( /** @scope /** * Applies filter to canvas element - * @method applyTo * @param {Object} canvasEl Canvas element to apply filter to */ applyTo: function(canvasEl) { @@ -16118,7 +15535,6 @@ fabric.Image.filters.GradientTransparency = fabric.util.createClass( /** @scope /** * Returns json representation of filter - * @method toJSON * @return {String} json representation of filter */ toJSON: function() { @@ -16132,7 +15548,6 @@ fabric.Image.filters.GradientTransparency = fabric.util.createClass( /** @scope /** * Returns filter instance from an object representation * @static - * @method fabric.Image.filters.GradientTransparency.fromObject * @return {fabric.Image.filters.GradientTransparency} */ fabric.Image.filters.GradientTransparency.fromObject = function(object) { @@ -16144,7 +15559,7 @@ fabric.Image.filters.GradientTransparency.fromObject = function(object) { * @class fabric.Image.filters.Tint * @memberOf fabric.Image.filters */ -fabric.Image.filters.Tint = fabric.util.createClass( /** @scope fabric.Image.filters.Tint.prototype */ { +fabric.Image.filters.Tint = fabric.util.createClass( /** @lends fabric.Image.filters.Tint.prototype */ { /** * Filter type @@ -16164,7 +15579,6 @@ fabric.Image.filters.Tint = fabric.util.createClass( /** @scope fabric.Image.fil /** * Applies filter to canvas element - * @method applyTo * @param {Object} canvasEl Canvas element to apply filter to */ applyTo: function(canvasEl) { @@ -16196,7 +15610,6 @@ fabric.Image.filters.Tint = fabric.util.createClass( /** @scope fabric.Image.fil /** * Returns json representation of filter - * @method toJSON * @return {String} json representation of filter */ toJSON: function() { @@ -16210,7 +15623,6 @@ fabric.Image.filters.Tint = fabric.util.createClass( /** @scope fabric.Image.fil /** * Returns filter instance from an object representation * @static - * @method fabric.Image.filters.Tint.fromObject * @return {fabric.Image.filters.Tint} */ fabric.Image.filters.Tint.fromObject = function(object) { @@ -16222,7 +15634,7 @@ fabric.Image.filters.Tint.fromObject = function(object) { * @class fabric.Image.filters.Convolute * @memberOf fabric.Image.filters */ -fabric.Image.filters.Convolute = fabric.util.createClass(/** @scope fabric.Image.filters.Convolute.prototype */ { +fabric.Image.filters.Convolute = fabric.util.createClass(/** @lends fabric.Image.filters.Convolute.prototype */ { /** * Filter type @@ -16249,7 +15661,6 @@ fabric.Image.filters.Convolute = fabric.util.createClass(/** @scope fabric.Image /** * @private - * @method _createImageData */ _createImageData: function(w, h) { return this.tmpCtx.createImageData(w, h); @@ -16257,7 +15668,6 @@ fabric.Image.filters.Convolute = fabric.util.createClass(/** @scope fabric.Image /** * Applies filter to canvas element - * @method applyTo * @param {Object} canvasEl Canvas element to apply filter to */ applyTo: function(canvasEl) { @@ -16315,7 +15725,6 @@ fabric.Image.filters.Convolute = fabric.util.createClass(/** @scope fabric.Image /** * Returns json representation of filter - * @method toJSON * @return {String} json representation of filter */ toJSON: function() { @@ -16329,7 +15738,6 @@ fabric.Image.filters.Convolute = fabric.util.createClass(/** @scope fabric.Image /** * Returns filter instance from an object representation * @static - * @method fabric.Image.filters.Convolute.fromObject * @return {fabric.Image.filters.Convolute} */ fabric.Image.filters.Convolute.fromObject = function(object) { @@ -16341,7 +15749,7 @@ fabric.Image.filters.Convolute.fromObject = function(object) { * @class fabric.Image.filters.Pixelate * @memberOf fabric.Image.filters */ -fabric.Image.filters.Pixelate = fabric.util.createClass(/** @scope fabric.Image.filters.Pixelate.prototype */ { +fabric.Image.filters.Pixelate = fabric.util.createClass(/** @lends fabric.Image.filters.Pixelate.prototype */ { /** * Filter type @@ -16361,7 +15769,6 @@ fabric.Image.filters.Pixelate = fabric.util.createClass(/** @scope fabric.Image. /** * Applies filter to canvas element - * @method applyTo * @param {Object} canvasEl Canvas element to apply filter to */ applyTo: function(canvasEl) { @@ -16410,7 +15817,6 @@ fabric.Image.filters.Pixelate = fabric.util.createClass(/** @scope fabric.Image. /** * Returns json representation of filter - * @method toJSON * @return {String} json representation of filter */ toJSON: function() { @@ -16424,12 +15830,12 @@ fabric.Image.filters.Pixelate = fabric.util.createClass(/** @scope fabric.Image. /** * Returns filter instance from an object representation * @static - * @method fabric.Image.filters.Pixelate.fromObject * @return {fabric.Image.filters.Pixelate} */ fabric.Image.filters.Pixelate.fromObject = function(object) { return new fabric.Image.filters.Pixelate(object); }; + (function(global) { "use strict"; @@ -16484,105 +15890,90 @@ fabric.Image.filters.Pixelate.fromObject = function(object) { /** * Font size (in pixels) - * @property * @type Number */ fontSize: 40, /** * Font weight (e.g. bold, normal, 400, 600, 800) - * @property * @type Number */ fontWeight: 'normal', /** * Font family - * @property * @type String */ fontFamily: 'Times New Roman', /** * Text decoration (e.g. underline, overline) - * @property * @type String */ textDecoration: '', /** * Text shadow - * @property * @type String | null */ textShadow: '', /** * Text alignment. Possible values: "left", "center", or "right". - * @property * @type String */ textAlign: 'left', /** * Font style (e.g. italic) - * @property * @type String */ fontStyle: '', /** * Line height - * @property * @type Number */ lineHeight: 1.3, /** * Stroke style. When specified, text is rendered with stroke - * @property * @type String */ stroke: '', /** * Stroke width - * @property * @type Number */ strokeWidth: 1, /** * Background color of an entire text box - * @property * @type String */ backgroundColor: '', /** * Background color of text lines - * @property * @type String */ textBackgroundColor: '', /** * URL of a font file, when using Cufon - * @property * @type String | null */ path: null, /** * Type of an object - * @property * @type String */ type: 'text', /** * Indicates whether canvas native text methods should be used to render text (otherwise, Cufon is used) - * @property * @type Boolean */ useNative: true, @@ -16590,7 +15981,6 @@ fabric.Image.filters.Pixelate.fromObject = function(object) { /** * List of properties to consider when checking if state of an object is changed (fabric.Object#hasStateChanged) * as well as for history (undo/redo) purposes - * @property * @type Array */ stateProperties: stateProperties, @@ -16606,7 +15996,9 @@ fabric.Image.filters.Pixelate.fromObject = function(object) { options = options || { }; this.text = text; + this.__skipDimension = true; this.setOptions(options); + this.__skipDimension = false; this._initDimensions(); this.setCoords(); }, @@ -16617,10 +16009,9 @@ fabric.Image.filters.Pixelate.fromObject = function(object) { * @method _initDimensions */ _initDimensions: function() { - if (!this._ctxForDimensions) { - this._ctxForDimensions = fabric.util.createCanvasElement().getContext('2d'); - } - this._render(this._ctxForDimensions); + if (this.__skipDimension) return; + var canvasEl = fabric.util.createCanvasElement(); + this._render(canvasEl.getContext('2d')); }, /** @@ -16714,7 +16105,13 @@ fabric.Image.filters.Pixelate.fromObject = function(object) { */ _renderViaNative: function(ctx) { - this.transform(ctx); + if (this.originX === 'left') { + ctx.translate(this.left, this.top); + } + else { + this.transform(ctx); + } + this._setTextStyles(ctx); var textLines = this.text.split(/\r?\n/); @@ -16882,6 +16279,14 @@ fabric.Image.filters.Pixelate.fromObject = function(object) { } }, + _getLeftOffset: function() { + return this.originX === 'left' ? 0 : -this.width / 2; + }, + + _getTopOffset: function() { + return this.originY === 'top' ? 0 : -this.height / 2; + }, + /** * @private * @method _renderTextFill @@ -16893,8 +16298,8 @@ fabric.Image.filters.Pixelate.fromObject = function(object) { 'fillText', ctx, textLines[i], - -this.width / 2, - (-this.height / 2) + (i * this.fontSize * this.lineHeight) + this.fontSize + this._getLeftOffset(), + this._getTopOffset() + (i * this.fontSize * this.lineHeight) + this.fontSize ); } }, @@ -16911,8 +16316,8 @@ fabric.Image.filters.Pixelate.fromObject = function(object) { 'strokeText', ctx, textLines[i], - -this.width / 2, - (-this.height / 2) + (i * this.fontSize * this.lineHeight) + this.fontSize + this._getLeftOffset(), + this._getTopOffset() + (i * this.fontSize * this.lineHeight) + this.fontSize ); } ctx.closePath(); @@ -16938,8 +16343,8 @@ fabric.Image.filters.Pixelate.fromObject = function(object) { ctx.fillStyle = this.backgroundColor; ctx.fillRect( - (-this.width / 2), - (-this.height / 2), + this._getLeftOffset(), + this._getTopOffset(), this.width, this.height ); @@ -16965,8 +16370,8 @@ fabric.Image.filters.Pixelate.fromObject = function(object) { var lineLeftOffset = this._getLineLeftOffset(lineWidth); ctx.fillRect( - (-this.width / 2) + lineLeftOffset, - (-this.height / 2) + (i * this.fontSize * this.lineHeight), + this._getLeftOffset() + lineLeftOffset, + this._getTopOffset() + (i * this.fontSize * this.lineHeight), lineWidth, this.fontSize * this.lineHeight ); @@ -17008,7 +16413,7 @@ fabric.Image.filters.Pixelate.fromObject = function(object) { */ _renderTextDecoration: function(ctx, textLines) { - var halfOfVerticalBox = this._getTextHeight(ctx, textLines) / 2; + var halfOfVerticalBox = this.originY === 'top' ? 0 : this._getTextHeight(ctx, textLines) / 2; var _this = this; /** @ignore */ @@ -17019,7 +16424,7 @@ fabric.Image.filters.Pixelate.fromObject = function(object) { var lineLeftOffset = _this._getLineLeftOffset(lineWidth); ctx.fillRect( - (-_this.width / 2) + lineLeftOffset, + _this._getLeftOffset() + lineLeftOffset, (offset + (i * _this.fontSize * _this.lineHeight)) - halfOfVerticalBox, lineWidth, 1); @@ -17513,7 +16918,6 @@ fabric.Image.filters.Pixelate.fromObject = function(object) { /** * Only available when running fabric on node.js - * @method createCanvasForNode * @param width Canvas width * @param height Canvas height * @return {Object} wrapped canvas instance diff --git a/dist/all.min.js b/dist/all.min.js index 529f36a0..a43ca7a2 100644 --- a/dist/all.min.js +++ b/dist/all.min.js @@ -1,6 +1,6 @@ -/* build: `node build.js modules=ALL exclude=gestures` *//*! Fabric.js Copyright 2008-2013, Printio (Juriy Zaytsev, Maxim Chernyak) */var fabric=fabric||{version:"1.1.8"};typeof exports!="undefined"&&(exports.fabric=fabric),typeof document!="undefined"&&typeof window!="undefined"?(fabric.document=document,fabric.window=window):(fabric.document=require("jsdom").jsdom(""),fabric.window=fabric.document.createWindow()),fabric.isTouchSupported="ontouchstart"in fabric.document.documentElement,fabric.isLikelyNode=typeof Buffer!="undefined"&&typeof window=="undefined";var Cufon=function(){function r(e){var t=this.face=e.face;this.glyphs=e.glyphs,this.w=e.w,this.baseSize=parseInt(t["units-per-em"],10),this.family=t["font-family"].toLowerCase(),this.weight=t["font-weight"],this.style=t["font-style"]||"normal",this.viewBox=function(){var e=t.bbox.split(/\s+/),n={minX:parseInt(e[0],10),minY:parseInt(e[1],10),maxX:parseInt(e[2],10),maxY:parseInt(e[3],10)};return n.width=n.maxX-n.minX,n.height=n.maxY-n.minY,n.toString=function(){return[this.minX,this.minY,this.width,this.height].join(" ")},n}(),this.ascent=-parseInt(t.ascent,10),this.descent=-parseInt(t.descent,10),this.height=-this.ascent+this.descent}function i(){var e={},t={oblique:"italic",italic:"oblique"};this.add=function(t){(e[t.style]||(e[t.style]={}))[t.weight]=t},this.get=function(n,r){var i=e[n]||e[t[n]]||e.normal||e.italic||e.oblique;if(!i)return null;r={normal:400,bold:700}[r]||parseInt(r,10);if(i[r])return i[r];var s={1:1,99:0}[r%100],o=[],u,a;s===undefined&&(s=r>400),r==500&&(r=400);for(var f in i){f=parseInt(f,10);if(!u||fa)a=f;o.push(f)}return ra&&(r=a),o.sort(function(e,t){return(s?e>r&&t>r?et:et:e=i.length+e?r():setTimeout(arguments.callee,10)}),function(t){e?t():n.push(t)}}(),supports:function(e,t){var n=fabric.document.createElement("span").style;return n[e]===undefined?!1:(n[e]=t,n[e]===t)},textAlign:function(e,t,n,r){return t.get("textAlign")=="right"?n>0&&(e=" "+e):nk&&(k=N),A.push(N),N=0;continue}var O=t.glyphs[T[b]]||t.missingGlyph;if(!O)continue;N+=C=Number(O.w||t.w)+h}A.push(N),N=Math.max(k,N);var M=[];for(var b=A.length;b--;)M[b]=N-A[b];if(C===null)return null;d+=l.width-C,m+=l.minX;var _,D;if(f)_=u,D=u.firstChild;else{_=fabric.document.createElement("span"),_.className="cufon cufon-canvas",_.alt=n,D=fabric.document.createElement("canvas"),_.appendChild(D);if(i.printable){var P=fabric.document.createElement("span");P.className="cufon-alt",P.appendChild(fabric.document.createTextNode(n)),_.appendChild(P)}}var H=_.style,B=D.style||{},j=c.convert(l.height-p+v),F=Math.ceil(j),I=F/j;D.width=Math.ceil(c.convert(N+d-m)*I),D.height=F,p+=l.minY,B.top=Math.round(c.convert(p-t.ascent))+"px",B.left=Math.round(c.convert(m))+"px";var q=Math.ceil(c.convert(N*I)),R=q+"px",U=c.convert(t.height),z=(i.lineHeight-1)*c.convert(-t.ascent/5)*(L-1);Cufon.textOptions.width=q,Cufon.textOptions.height=U*L+z,Cufon.textOptions.lines=L,Cufon.textOptions.totalLineHeight=z,e?(H.width=R,H.height=U+"px"):(H.paddingLeft=R,H.paddingBottom=U-1+"px");var W=Cufon.textOptions.context||D.getContext("2d"),X=F/l.height;Cufon.textOptions.fontAscent=t.ascent*X,Cufon.textOptions.boundaries=null;for(var V=Cufon.textOptions.shadowOffsets,b=y.length;b--;)V[b]=[y[b][0]*X,y[b][1]*X];W.save(),W.scale(X,X),W.translate(-m-1/X*D.width/2+(Cufon.fonts[t.family].offsetLeft||0),-p-Cufon.textOptions.height/X/2+(Cufon.fonts[t.family].offsetTop||0)),W.lineWidth=t.face["underline-thickness"],W.save();var J=Cufon.getTextDecoration(i),K=i.fontStyle==="italic";W.save(),Q();if(g)for(var b=0,w=g.length;b.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}}'),function(e,t,i,s,o,u,a){var f=t===null;f&&(t=o.alt);var l=e.viewBox,c=i.computedFontSize||(i.computedFontSize=new Cufon.CSS.Size(n(u,i.get("fontSize"))+"px",e.baseSize)),h=i.computedLSpacing;h==undefined&&(h=i.get("letterSpacing"),i.computedLSpacing=h=h=="normal"?0:~~c.convertFrom(r(u,h)));var p,d;if(f)p=o,d=o.firstChild;else{p=fabric.document.createElement("span"),p.className="cufon cufon-vml",p.alt=t,d=fabric.document.createElement("span"),d.className="cufon-vml-canvas",p.appendChild(d);if(s.printable){var v=fabric.document.createElement("span");v.className="cufon-alt",v.appendChild(fabric.document.createTextNode(t)),p.appendChild(v)}a||p.appendChild(fabric.document.createElement("cvml:shape"))}var m=p.style,g=d.style,y=c.convert(l.height),b=Math.ceil(y),w=b/y,E=l.minX,S=l.minY;g.height=b,g.top=Math.round(c.convert(S-e.ascent)),g.left=Math.round(c.convert(E)),m.height=c.convert(e.height)+"px";var x=Cufon.getTextDecoration(s),T=i.get("color"),N=Cufon.CSS.textTransform(t,i).split(""),C=0,k=0,L=null,A,O,M=s.textShadow;for(var _=0,D=0,P=N.length;_-1},complexity:function(){return this.getObjects().reduce(function(e,t){return e+=t.complexity?t.complexity():0,e},0)},toGrayscale:function(){return this.forEachObject(function(e){e.toGrayscale()})}},function(){function n(e,t){var n=e.indexOf(t);return n!==-1&&e.splice(n,1),e}function r(e,t){return Math.floor(Math.random()*(t-e+1))+e}function s(e){return e*i}function o(e){return e/i}function u(e,t,n){var r=Math.sin(n),i=Math.cos(n);e.subtractEquals(t);var s=e.x*i-e.y*r,o=e.x*r+e.y*i;return(new fabric.Point(s,o)).addEquals(t)}function a(e,t){return parseFloat(Number(e).toFixed(t))}function f(){return!1}function l(e){e||(e={});var t=+(new Date),n=e.duration||500,r=t+n,i,s=e.onChange||function(){},o=e.abort||function(){return!1},u=e.easing||function(e,t,n,r){return-n*Math.cos(e/r*(Math.PI/2))+n+t},a="startValue"in e?e.startValue:0,f="endValue"in e?e.endValue:100,l=e.byValue||f-a;e.onStart&&e.onStart(),function c(){i=+(new Date);var f=i>r?n:i-t;s(u(f,a,l,n));if(i>r||o()){e.onComplete&&e.onComplete();return}h(c)}()}function p(e,t,n){if(e){var r=new Image;r.onload=function(){t&&t.call(n,r),r=r.onload=null},r.src=e}else t&&t.call(n,e)}function d(e,t){function n(e){return fabric[fabric.util.string.camelize(fabric.util.string.capitalize(e))]}function r(){++s===o&&t&&t(i)}var i=[],s=0,o=e.length;e.forEach(function(e,t){if(!e.type)return;var s=n(e.type);s.async?s.fromObject(e,function(e,n){n||(i[t]=e),r()}):(i[t]=s.fromObject(e),r())})}function v(e,t,n){var r;return e.length>1?r=new fabric.PathGroup(e,t):r=e[0],typeof n!="undefined"&&r.setSourcePath(n),r}function m(e,t,n){if(n&&Object.prototype.toString.call(n)==="[object Array]")for(var r=0,i=n.length;rr)r+=u[p++%h],r>l&&(r=l),n[d?"lineTo":"moveTo"](r,0),d=!d;n.restore()}function y(e){return e||(e=fabric.document.createElement("canvas")),!e.getContext&&typeof G_vmlCanvasManager!="undefined"&&G_vmlCanvasManager.initElement(e),e}function b(e){var t=e.prototype;for(var n=t.stateProperties.length;n--;){var r=t.stateProperties[n],i=r.charAt(0).toUpperCase()+r.slice(1),s="set"+i,o="get"+i;t[o]||(t[o]=function(e){return new Function('return this.get("'+e+'")')}(r)),t[s]||(t[s]=function(e){return new Function("value",'return this.set("'+e+'", value)')}(r))}}function w(e,t){t.save(),t.beginPath(),e.clipTo(t),t.clip()}function E(e,t){var n=[[e[0],e[2],e[4]],[e[1],e[3],e[5]],[0,0,1]],r=[[t[0],t[2],t[4]],[t[1],t[3],t[5]],[0,0,1]],i=[];for(var s=0;s<3;s++){i[s]=[];for(var o=0;o<3;o++){var u=0;for(var a=0;a<3;a++)u+=n[s][a]*r[a][o];i[s][o]=u}}return[i[0][0],i[1][0],i[0][1],i[1][1],i[0][2],i[1][2]]}var e=Math.sqrt,t=Math.atan2;fabric.util={};var i=Math.PI/180,c=fabric.window.requestAnimationFrame||fabric.window.webkitRequestAnimationFrame||fabric.window.mozRequestAnimationFrame||fabric.window.oRequestAnimationFrame||fabric.window.msRequestAnimationFrame||function(e){fabric.window.setTimeout(e,1e3/60)},h=function(){return c.apply(fabric.window,arguments)};fabric.util.removeFromArray=n,fabric.util.degreesToRadians=s,fabric.util.radiansToDegrees=o,fabric.util.rotatePoint=u,fabric.util.toFixed=a,fabric.util.getRandomInt=r,fabric.util.falseFunction=f,fabric.util.animate=l,fabric.util.requestAnimFrame=h,fabric.util.loadImage=p,fabric.util.enlivenObjects=d,fabric.util.groupSVGElements=v,fabric.util.populateWithProperties=m,fabric.util.drawDashedLine=g,fabric.util.createCanvasElement=y,fabric.util.createAccessors=b,fabric.util.clipContext=w,fabric.util.multiplyTransformMatrices=E}(),function(){function t(t,n){var r=e.call(arguments,2),i=[];for(var s=0,o=t.length;s=r&&(r=e[n][t]);else while(n--)e[n]>=r&&(r=e[n]);return r}function r(e,t){if(!e||e.length===0)return undefined;var n=e.length-1,r=t?e[n][t]:e[n];if(t)while(n--)e[n][t]>>0;if(n===0)return-1;var r=0;arguments.length>0&&(r=Number(arguments[1]),r!==r?r=0:r!==0&&r!==Number.POSITIVE_INFINITY&&r!==Number.NEGATIVE_INFINITY&&(r=(r>0||-1)*Math.floor(Math.abs(r))));if(r>=n)return-1;var i=r>=0?r:Math.max(n-Math.abs(r),0);for(;i>>0;n>>0;r>>0;n>>0;n>>0;i>>0,n=0,r;if(arguments.length>1)r=arguments[1];else do{if(n in this){r=this[n++];break}if(++n>=t)throw new TypeError}while(!0);for(;n/g,">")}String.prototype.trim||(String.prototype.trim=function(){return this.replace(/^[\s\xA0]+/,"").replace(/[\s\xA0]+$/,"")}),fabric.util.string={camelize:e,capitalize:t,escapeXml:n}}(),function(){var e=Array.prototype.slice,t=Function.prototype.apply,n=function(){};Function.prototype.bind||(Function.prototype.bind=function(r){var i=this,s=e.call(arguments,1),o;return s.length?o=function(){return t.call(i,this instanceof n?this:r,s.concat(e.call(arguments)))}:o=function(){return t.call(i,this instanceof n?this:r,arguments)},n.prototype=this.prototype,o.prototype=new n,o})}(),function(){function i(){}function s(t){var n=this.constructor.superclass.prototype[t];return arguments.length>1?n.apply(this,e.call(arguments,1)):n.call(this)}function o(){function u(){this.initialize.apply(this,arguments)}var n=null,o=e.call(arguments,0);typeof o[0]=="function"&&(n=o.shift()),u.superclass=n,u.subclasses=[],n&&(i.prototype=n.prototype,u.prototype=new i,n.subclasses.push(u));for(var a=0,f=o.length;a-1?e.prototype[i]=function(e){return function(){var n=this.constructor.superclass;this.constructor.superclass=r;var i=t[e].apply(this,arguments);this.constructor.superclass=n;if(e!=="initialize")return i}}(i):e.prototype[i]=t[i],n&&(t.toString!==Object.prototype.toString&&(e.prototype.toString=t.toString),t.valueOf!==Object.prototype.valueOf&&(e.prototype.valueOf=t.valueOf))};fabric.util.createClass=o}(),function(){function e(e){var t=Array.prototype.slice.call(arguments,1),n,r,i=t.length;for(r=0;r-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=0,n=0;do t+=e.offsetTop||0,n+=e.offsetLeft||0,e=e.offsetParent;while(e);return{left:n,top:t}}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});var f;fabric.document.defaultView&&fabric.document.defaultView.getComputedStyle?f=function(e){return fabric.document.defaultView.getComputedStyle(e,null).position}:f=function(e){var t=e.style.position;return!t&&e.currentStyle&&(t=e.currentStyle.position),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.type="text/javascript",r.setAttribute("runat","server"),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.getElementPosition=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,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){v.set(e,{objects:t.util.array.invoke(r,"toObject"),options:i}),n(r,i)},r)}e=e.replace(/^\n\s*/,"").trim(),v.has(e,function(r){r?v.get(e,function(e){var t=g(e);n(t.objects,t.options)}):new t.util.request(e,{method:"get",onComplete:i})})}function g(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 y(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 b(e){var t="";for(var n=0,r=e.length;n',"",""].join("")),t}function w(e){var t="";return e.backgroundColor&&e.backgroundColor.source&&(t=['',''].join("")),t}var t=e.fabric||(e.fabric={}),n=t.util.object.extend,r=t.util.string.capitalize,i=t.util.object.clone,s=t.util.multiplyTransformMatrices,o={cx:"left",x:"left",cy:"top",y:"top",r:"radius","fill-opacity":"opacity","fill-rule":"fillRule","stroke-width":"strokeWidth",transform:"transformMatrix","text-decoration":"textDecoration","font-size":"fontSize","font-weight":"fontWeight","font-style":"fontStyle","font-family":"fontFamily"};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;c']:this.type==="radial"&&(i=["']);for(var s=0;s');return i.push(this.type==="linear"?"":""),i.join("")}}),fabric.util.object.extend(fabric.Gradient,{fromElement:function(n,r){var i=n.getElementsByTagName("stop"),s=n.nodeName==="linearGradient"?"linear":"radial",o=n.getAttribute("gradientUnits")||"objectBoundingBox",u=[],a={};s==="linear"?a={x1:n.getAttribute("x1")||0,y1:n.getAttribute("y1")||0,x2:n.getAttribute("x2")||"100%",y2:n.getAttribute("y2")||0}:s==="radial"&&(a={x1:n.getAttribute("fx")||n.getAttribute("cx")||"50%",y1:n.getAttribute("fy")||n.getAttribute("cy")||"50%",r1:0,x2:n.getAttribute("cx")||"50%",y2:n.getAttribute("cy")||"50%",r2:n.getAttribute("r")||"50%"});for(var f=i.length;f--;)u.push(e(i[f]));return t(r,a),new fabric.Gradient({type:s,coords:a,gradientUnits:o,colorStops:u})},forObject:function(e,n){return n||(n={}),t(e,n),new fabric.Gradient(n)}}),fabric.getGradientDefs=r}(),fabric.Pattern=fabric.util.createClass({repeat:"repeat",offsetX:0,offsetY:0,initialize:function(e){e||(e={}),e.source&&(this.source=typeof e.source=="string"?new Function(e.source):e.source),e.repeat&&(this.repeat=e.repeat),e.offsetX&&(this.offsetX=e.offsetX),e.offsetY&&(this.offsetY=e.offsetY)},toObject:function(){var e;return typeof this.source=="function"?e=String(this.source).match(/function\s+\w*\s*\(.*\)\s+\{([\s\S]*)\}/)[1]:typeof this.source.src=="string"&&(e=this.source.src),{source:e,repeat:this.repeat,offsetX:this.offsetX,offsetY:this.offsetY}},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]},toObject:function(){return{color:this.color,blur:this.blur,offsetX:this.offsetX,offsetY:this.offsetY}},toSVG:function(){}}),function(e){"use strict";function n(e,t){arguments.length>0&&this.init(e,t)}var t=e.fabric||(e.fabric={});if(t.Point){t.warn("fabric.Point is already defined");return}t.Point=n,n.prototype={constructor:n,init:function(e,t){this.x=e,this.y=t},add:function(e){return new n(this.x+e.x,this.y+e.y)},addEquals:function(e){return this.x+=e.x,this.y+=e.y,this},scalarAdd:function(e){return new n(this.x+e,this.y+e)},scalarAddEquals:function(e){return this.x+=e,this.y+=e,this},subtract:function(e){return new n(this.x-e.x,this.y-e.y)},subtractEquals:function(e){return this.x-=e.x,this.y-=e.y,this},scalarSubtract:function(e){return new n(this.x-e,this.y-e)},scalarSubtractEquals:function(e){return this.x-=e,this.y-=e,this},multiply:function(e){return new n(this.x*e,this.y*e)},multiplyEquals:function(e){return this.x*=e,this.y*=e,this},divide:function(e){return new n(this.x/e,this.y/e)},divideEquals:function(e){return this.x/=e,this.y/=e,this},eq:function(e){return this.x===e.x&&this.y===e.y},lt:function(e){return this.xe.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){arguments.length>0&&this.init(e)}var t=e.fabric||(e.fabric={});if(t.Intersection){t.warn("fabric.Intersection is already defined");return}t.Intersection=n,t.Intersection.prototype={init:function(e){this.status=e,this.points=[]},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("No Intersection")}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("No Intersection"),s=r.length;for(var o=0;o0&&(i.status="Intersection"),i},t.Intersection.intersectPolygonPolygon=function(e,t){var r=new n("No Intersection"),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("No Intersection");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])}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&&this.setSource(t)},getSource:function(){return this._source},setSource:function(e){this._source=e},toRgb:function(){var e=this.getSource();return"rgb("+e[0]+","+e[1]+","+e[2]+")"},toRgba:function(){var e=this.getSource();return"rgba("+e[0]+","+e[1]+","+e[2]+","+e[3]+")"},toHex:function(){var e=this.getSource(),t=e[0].toString(16);t=t.length===1?"0"+t:t;var n=e[1].toString(16);n=n.length===1?"0"+n:n;var r=e[2].toString(16);return r=r.length===1?"0"+r:r,t.toUpperCase()+n.toUpperCase()+r.toUpperCase()},getAlpha:function(){return this.getSource()[3]},setAlpha:function(e){var t=this.getSource();return t[3]=e,this.setSource(t),this},toGrayscale:function(){var e=this.getSource(),t=parseInt((e[0]*.3+e[1]*.59+e[2]*.11).toFixed(0),10),n=e[3];return this.setSource([t,t,t,n]),this},toBlackWhite:function(e){var t=this.getSource(),n=(t[0]*.3+t[1]*.59+t[2]*.11).toFixed(0),r=t[3];return e=e||127,n=Number(n)',''),t.push("',"Created with Fabric.js ",fabric.version,"","",fabric.createSVGFontFacesMarkup(this.getObjects()),fabric.createSVGRefElementsMarkup(this),""),this.backgroundColor&&this.backgroundColor.source&&t.push('"),this.backgroundImage&&t.push(''),this.overlayImage&&t.push('');for(var n=0,r=this.getObjects(),i=r.length;n"),t.join("")},remove:function(e){return this.getActiveObject()===e&&(this.fire("before:selection:cleared",{target:e}),this.discardActiveObject(),this.fire("selection:cleared")),fabric.Collection.remove.call(this,e)},sendToBack:function(e){return n(this._objects,e),this._objects.unshift(e),this.renderAll&&this.renderAll()},bringToFront:function(e){return n(this._objects,e),this._objects.push(e),this.renderAll&&this.renderAll()},sendBackwards:function(e){var t=this._objects.indexOf(e),r=t;if(t!==0){for(var i=t-1;i>=0;--i){var s=e.intersectsWithObject(this._objects[i])||e.isContainedWithinObject(this._objects[i])||this._objects[i].isContainedWithinObject(e);if(s){r=i;break}}n(this._objects,e),this._objects.splice(r,0,e)}return this.renderAll&&this.renderAll()},bringForward:function(e){var t=this.getObjects(),r=t.indexOf(e),i=r;if(r!==t.length-1){for(var s=r+1,o=this._objects.length;s"},e(fabric.StaticCanvas,{EMPTY_JSON:'{"objects": [], "background": "white"}',toGrayscale:function(e){var t=e.getContext("2d"),n=t.getImageData(0,0,e.width,e.height),r=n.data,i=n.width,s=n.height,o,u,a,f;for(a=0;a0&&(t>this.targetFindTolerance?t-=this.targetFindTolerance:t=0,n>this.targetFindTolerance?n-=this.targetFindTolerance:n=0);var o=!0,u=r.getImageData(t,n,this.targetFindTolerance*2||1,this.targetFindTolerance*2||1);for(var a=3;a0?0:-n),t.ey-(r>0?0:-r),i,o),e.lineWidth=this.selectionLineWidth,e.strokeStyle=this.selectionBorderColor;if(this.selectionDashArray.length>1){var u=t.ex+a-(n>0?0:i),f=t.ey+a-(r>0?0:o);e.beginPath(),fabric.util.drawDashedLine(e,u,f,u+i,f,this.selectionDashArray),fabric.util.drawDashedLine(e,u,f+o-1,u+i,f+o-1,this.selectionDashArray),fabric.util.drawDashedLine(e,u,f,u,f+o,this.selectionDashArray),fabric.util.drawDashedLine(e,u+i-1,f,u+i-1,f+o,this.selectionDashArray),e.closePath(),e.stroke()}else e.strokeRect(t.ex+a-(n>0?0:i),t.ey+a-(r>0?0:o),i,o)},_findSelectedObjects:function(e){var t=[],n=this._groupSelector.ex,r=this._groupSelector.ey,i=n+this._groupSelector.left,s=r+this._groupSelector.top,a,f=new fabric.Point(o(n,i),o(r,s)),l=new fabric.Point(u(n,i),u(r,s));for(var c=0,h=this._objects.length;c1&&(t=new fabric.Group(t),this.setActiveGroup(t),t.saveCoords(),this.fire("selection:created",{target:t})),this.renderAll()},findTarget:function(e,t){var n,r=this.getPointer(e);if(this.controlsAboveOverlay&&this.lastRenderedObjectWithControlsAboveOverlay&&this.lastRenderedObjectWithControlsAboveOverlay.visible&&this.containsPoint(e,this.lastRenderedObjectWithControlsAboveOverlay)&&this.lastRenderedObjectWithControlsAboveOverlay._findTargetCorner(e,this._offset))return n=this.lastRenderedObjectWithControlsAboveOverlay,n;var i=this.getActiveGroup();if(i&&!t&&this.containsPoint(e,i))return n=i,n;var s=[];for(var o=this._objects.length;o--;)if(this._objects[o]&&this._objects[o].visible&&this.containsPoint(e,this._objects[o])){if(!this.perPixelTargetFind&&!this._objects[o].perPixelTargetFind){n=this._objects[o],this.relatedTarget=n;break}s[s.length]=this._objects[o]}for(var u=0,a=s.length;u"},get:function(e){return this[e]},set:function(e,t){if(typeof e=="object")for(var n in e)this._set(n,e[n]);else typeof t=="function"?this._set(e,t(this.get(e))):this._set(e,t);return this},_set:function(e,t){var n=e==="scaleX"||e==="scaleY";n&&(t=this._constrainScale(t));if(e==="scaleX"&&t<0)this.flipX=!this.flipX,t*=-1;else if(e==="scaleY"&&t<0)this.flipY=!this.flipY,t*=-1;else if(e==="width"||e==="height")this.minScaleLimit=r(Math.min(.1,1/Math.max(this.width,this.height)),2);return this[e]=t,this},toggle:function(e){var t=this.get(e);return typeof t=="boolean"&&this.set(e,!t),this},setSourcePath:function(e){return this.sourcePath=e,this},render:function(e,n){if(this.width===0||this.height===0||!this.visible)return;e.save();var r=this.transformMatrix;r&&!this.group&&e.setTransform(r[0],r[1],r[2],r[3],r[4],r[5]),n||this.transform(e);if(this.stroke||this.strokeDashArray)e.lineWidth=this.strokeWidth,this.stroke&&this.stroke.toLive?e.strokeStyle=this.stroke.toLive(e):e.strokeStyle=this.stroke;this.overlayFill?e.fillStyle=this.overlayFill:this.fill&&(e.fillStyle=this.fill.toLive?this.fill.toLive(e):this.fill),r&&this.group&&(e.translate(-this.group.width/2,-this.group.height/2),e.transform(r[0],r[1],r[2],r[3],r[4],r[5])),this._setShadow(e),this.clipTo&&t.util.clipContext(this,e),this._render(e,n),this.clipTo&&e.restore(),this._removeShadow(e),this.active&&!n&&(this.drawBorders(e),this.drawControls(e)),e.restore()},_setShadow:function(e){if(!this.shadow)return;e.shadowColor=this.shadow.color,e.shadowBlur=this.shadow.blur,e.shadowOffsetX=this.shadow.offsetX,e.shadowOffsetY=this.shadow.offsetY},_removeShadow:function(e){e.shadowColor="",e.shadowBlur=e.shadowOffsetX=e.shadowOffsetY=0},_renderFill:function(e){if(!this.fill)return;this.fill.toLive&&(e.save(),e.translate(-this.width/2+this.fill.offsetX,-this.height/2+this.fill.offsetY)),e.fill(),this.fill.toLive&&e.restore()},clone:function(e,n){return this.constructor.fromObject?this.constructor.fromObject(this.toObject(n),e):new t.Object(this.toObject(n))},cloneAsImage:function(e){if(t.Image){var n=new o;n.onload=function(){e&&e(new t.Image(n),r),n=n.onload=null};var r={angle:this.getAngle(),flipX:this.getFlipX(),flipY:this.getFlipY()};this.set({angle:0,flipX:!1,flipY:!1}),this.toDataURL(function(e){n.src=e})}return this},toDataURL:function(e){function i(t){t.left=n.width/2,t.top=n.height/2,t.set("active",!1),r.add(t);var i=r.toDataURL();r.dispose(),r=t=null,e&&e(i)}var n=t.util.createCanvasElement();n.width=this.getBoundingRectWidth(),n.height=this.getBoundingRectHeight(),t.util.wrapElement(n,"div");var r=new t.Canvas(n);r.backgroundColor="transparent",r.renderAll(),this.constructor.async?this.clone(i):i(this.clone())},hasStateChanged:function(){return this.stateProperties.some(function(e){return this[e]!==this.originalState[e]},this)},saveState:function(e){return this.stateProperties.forEach(function(e){this.originalState[e]=this.get(e)},this),e&&e.stateProperties&&e.stateProperties.forEach(function(e){this.originalState[e]=this.get(e)},this),this},setupState:function(){this.originalState={},this.saveState()},isType:function(e){return this.type===e},toGrayscale:function(){var e=this.get("fill");return e&&this.set("overlayFill",(new t.Color(e)).toGrayscale().toRgb()),this},complexity:function(){return 0},toJSON:function(e){return this.toObject(e)},setGradient:function(e,n){n||(n={});var r={colorStops:[]};r.type=n.type||(n.r1||n.r2?"radial":"linear"),r.coords={x1:n.x1,y1:n.y1,x2:n.x2,y2:n.y2};if(n.r1||n.r2)r.coords.r1=n.r1,r.coords.r2=n.r2;for(var i in n.colorStops){var s=new t.Color(n.colorStops[i]);r.colorStops.push({offset:i,color:s.toRgb(),opacity:s.getAlpha()})}this.set(e,t.Gradient.forObject(this,r))},setPatternFill:function(e){return this.set("fill",new t.Pattern(e))},setShadow:function(e){return this.set("shadow",new t.Shadow(e))},animate:function(){if(arguments[0]&&typeof arguments[0]=="object"){var e=[],t,n;for(t in arguments[0])e.push(t);for(var r=0,i=e.length;re.x&&i.xe.y&&s.y1?this.strokeWidth:0,n=this.padding,r=e(this.angle);this.currentWidth=(this.width+t)*this.scaleX+n*2,this.currentHeight=(this.height+t)*this.scaleY+n*2,this.currentWidth<0&&(this.currentWidth=Math.abs(this.currentWidth));var i=Math.sqrt(Math.pow(this.currentWidth/2,2)+Math.pow(this.currentHeight/2,2)),s=Math.atan(this.currentHeight/this.currentWidth),o=Math.cos(s+r)*i,u=Math.sin(s+r)*i,a=Math.sin(r),f=Math.cos(r),l=this.getCenterPoint(),c={x:l.x-o,y:l.y-u},h={x:c.x+this.currentWidth*f,y:c.y+this.currentWidth*a},p={x:h.x-this.currentHeight*a,y:h.y+this.currentHeight*f},d={x:c.x-this.currentHeight*a,y:c.y+this.currentHeight*f},v={x:c.x-this.currentHeight/2*a,y:c.y+this.currentHeight/2*f},m={x:c.x+this.currentWidth/2*f,y:c.y+this.currentWidth/2*a},g={x:h.x-this.currentHeight/2*a,y:h.y+this.currentHeight/2*f},y={x:d.x+this.currentWidth/2*f,y:d.y+this.currentWidth/2*a},b={x:c.x+this.currentWidth/2*f,y:c.y+this.currentWidth/2*a};return this.oCoords={tl:c,tr:h,br:p,bl:d,ml:v,mt:m,mr:g,mb:y,mtr:b},this._setCornerCoords(),this}})}(),function(){var e=fabric.util.getPointer,t=fabric.util.degreesToRadians;fabric.util.object.extend(fabric.Object.prototype,{_findTargetCorner:function(t,n){if(!this.hasControls||!this.active)return!1;var r=e(t,this.canvas.upperCanvasEl),i=r.x-n.left,s=r.y-n.top,o,u;for(var a in this.oCoords){if(a==="mtr"&&!this.hasRotatingPoint)continue;if(!(!this.get("lockUniScaling")||a!=="mt"&&a!=="mr"&&a!=="mb"&&a!=="ml"))continue;u=this._getImageLines(this.oCoords[a].corner,a),o=this._findCrossPoints(i,s,u);if(o%2===1&&o!==0)return this.__corner=a,a}return!1},_findCrossPoints:function(e,t,n){var r,i,s,o,u,a,f=0,l;for(var c in n){l=n[c];if(l.o.y=t&&l.d.y>=t)continue;l.o.x===l.d.x&&l.o.x>=e?(u=l.o.x,a=t):(r=0,i=(l.d.y-l.o.y)/(l.d.x-l.o.x),s=t-r*e,o=l.o.y-i*l.o.x,u=-(s-o)/(r-i),a=s+r*u),u>=e&&(f+=1);if(f===2)break}return f},_getImageLines:function(e){return{topline:{o:e.tl,d:e.tr},rightline:{o:e.tr,d:e.br},bottomline:{o:e.br,d:e.bl},leftline:{o:e.bl,d:e.tl}}},_setCornerCoords:function(){var e=this.oCoords,n=t(this.angle),r=t(45-this.angle),i=Math.sqrt(2*Math.pow(this.cornerSize,2))/2,s=i*Math.cos(r),o=i*Math.sin(r),u=Math.sin(n),a=Math.cos(n);e.tl.corner={tl:{x:e.tl.x-o,y:e.tl.y-s},tr:{x:e.tl.x+s,y:e.tl.y-o},bl:{x:e.tl.x-s,y:e.tl.y+o},br:{x:e.tl.x+o,y:e.tl.y+s}},e.tr.corner={tl:{x:e.tr.x-o,y:e.tr.y-s},tr:{x:e.tr.x+s,y:e.tr.y-o},br:{x:e.tr.x+o,y:e.tr.y+s},bl:{x:e.tr.x-s,y:e.tr.y+o}},e.bl.corner={tl:{x:e.bl.x-o,y:e.bl.y-s},bl:{x:e.bl.x-s,y:e.bl.y+o},br:{x:e.bl.x+o,y:e.bl.y+s},tr:{x:e.bl.x+s,y:e.bl.y-o}},e.br.corner={tr:{x:e.br.x+s,y:e.br.y-o},bl:{x:e.br.x-s,y:e.br.y+o},br:{x:e.br.x+o,y:e.br.y+s},tl:{x:e.br.x-o,y:e.br.y-s}},e.ml.corner={tl:{x:e.ml.x-o,y:e.ml.y-s},tr:{x:e.ml.x+s,y:e.ml.y-o},bl:{x:e.ml.x-s,y:e.ml.y+o},br:{x:e.ml.x+o,y:e.ml.y+s}},e.mt.corner={tl:{x:e.mt.x-o,y:e.mt.y-s},tr:{x:e.mt.x+s,y:e.mt.y-o},bl:{x:e.mt.x-s,y:e.mt.y+o},br:{x:e.mt.x+o,y:e.mt.y+s}},e.mr.corner={tl:{x:e.mr.x-o,y:e.mr.y-s},tr:{x:e.mr.x+s,y:e.mr.y-o},bl:{x:e.mr.x-s,y:e.mr.y+o},br:{x:e.mr.x+o,y:e.mr.y+s}},e.mb.corner={tl:{x:e.mb.x-o,y:e.mb.y-s},tr:{x:e.mb.x+s,y:e.mb.y-o},bl:{x:e.mb.x-s,y:e.mb.y+o},br:{x:e.mb.x+o,y:e.mb.y+s}},e.mtr.corner={tl:{x:e.mtr.x-o+u*this.rotatingPointOffset,y:e.mtr.y-s-a*this.rotatingPointOffset},tr:{x:e.mtr.x+s+u*this.rotatingPointOffset,y:e.mtr.y-o-a*this.rotatingPointOffset},bl:{x:e.mtr.x-s+u*this.rotatingPointOffset,y:e.mtr.y+o-a*this.rotatingPointOffset},br:{x:e.mtr.x+o+u*this.rotatingPointOffset,y:e.mtr.y+s-a*this.rotatingPointOffset}}},drawBorders:function(e){if(!this.hasBorders)return this;var t=this.padding,n=t*2,r=this.strokeWidth>1?this.strokeWidth:0;e.save(),e.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1,e.strokeStyle=this.borderColor;var i=1/this._constrainScale(this.scaleX),s=1/this._constrainScale(this.scaleY);e.lineWidth=1/this.borderScaleFactor,e.scale(i,s);var o=this.getWidth(),u=this.getHeight();e.strokeRect(~~(-(o/2)-t-r/2*this.scaleX)+.5,~~(-(u/2)-t-r/2*this.scaleY)+.5,~~(o+n+r*this.scaleX),~~(u+n+r*this.scaleY));if(this.hasRotatingPoint&&!this.get("lockRotation")&&this.hasControls){var a=(this.flipY?u+r*this.scaleY+t*2:-u-r*this.scaleY-t*2)/2;e.beginPath(),e.moveTo(0,a),e.lineTo(0,a+(this.flipY?this.rotatingPointOffset:-this.rotatingPointOffset)),e.closePath(),e.stroke()}return e.restore(),this},drawControls:function(e){if(!this.hasControls)return this;var t=this.cornerSize,n=t/2,r=this.strokeWidth/2,i=-(this.width/2),s=-(this.height/2),o,u,a=t/this.scaleX,f=t/this.scaleY,l=this.padding/this.scaleX,c=this.padding/this.scaleY,h=n/this.scaleY,p=n/this.scaleX,d=(n-t)/this.scaleX,v=(n-t)/this.scaleY,m=this.height,g=this.width,y=this.transparentCorners?"strokeRect":"fillRect",b=typeof G_vmlCanvasManager!="undefined";return e.save(),e.lineWidth=1/Math.max(this.scaleX,this.scaleY),e.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1,e.strokeStyle=e.fillStyle=this.cornerColor,o=i-p-r-l,u=s-h-r-c,b||e.clearRect(o,u,a,f),e[y](o,u,a,f),o=i+g-p+r+l,u=s-h-r-c,b||e.clearRect(o,u,a,f),e[y](o,u,a,f),o=i-p-r-l,u=s+m+v+r+c,b||e.clearRect(o,u,a,f),e[y](o,u,a,f),o=i+g+d+r+l,u=s+m+v+r+c,b||e.clearRect(o,u,a,f),e[y](o,u,a,f),this.get("lockUniScaling")||(o=i+g/2-p,u=s-h-r-c,b||e.clearRect(o,u,a,f),e[y](o,u,a,f),o=i+g/2-p,u=s+m+v+r+c,b||e.clearRect(o,u,a,f),e[y](o,u,a,f),o=i+g+d+r+l,u=s+m/2-h,b||e.clearRect(o,u,a,f),e[y](o,u,a,f),o=i-p-r-l,u=s+m/2-h,b||e.clearRect(o,u,a,f),e[y](o,u,a,f)),this.hasRotatingPoint&&(o=i+g/2-p,u=this.flipY?s+m+this.rotatingPointOffset/this.scaleY-f/2+r+c:s-this.rotatingPointOffset/this.scaleY-f/2-r-c,b||e.clearRect(o,u,a,f),e[y](o,u,a,f)),e.restore(),this}})}(),function(e){"use strict";var t=e.fabric||(e.fabric={}),n=t.util.object.extend,r={x1:1,x2:1,y1:1,y2:1};if(t.Line){t.warn("fabric.Line is already defined");return}t.Line=t.util.createClass(t.Object,{type:"line",initialize:function(e,t){t=t||{},e||(e=[0,0,0,0]),this.callSuper("initialize",t),this.set("x1",e[0]),this.set("y1",e[1]),this.set("x2",e[2]),this.set("y2",e[3]),this._setWidthHeight(t)},_setWidthHeight:function(e){e||(e={}),this.set("width",this.x2-this.x1||1),this.set("height",this.y2-this.y1||1),this.set("left","left"in e?e.left:this.x1+this.width/2),this.set("top","top"in e?e.top:this.y1+this.height/2)},_set:function(e,t){return this[e]=t,e in r&&this._setWidthHeight(),this},_render:function(e){e.beginPath();var t=this.group&&this.group.type!=="group";t&&!this.transformMatrix?e.translate(-this.group.width/2+this.left,-this.group.height/2+this.top):e.translate(this.left,this.top),e.moveTo(this.width===1?0:-this.width/2,this.height===1?0:-this.height/2),e.lineTo(this.width===1?0:this.width/2,this.height===1?0:this.height/2),e.lineWidth=this.strokeWidth;var n=e.strokeStyle;e.strokeStyle=this.stroke||e.fillStyle,e.stroke(),e.strokeStyle=n},complexity:function(){return 1},toObject:function(e){return n(this.callSuper("toObject",e),{x1:this.get("x1"),y1:this.get("y1"),x2:this.get("x2"),y2:this.get("y2")})},toSVG:function(){var e=[];return this.stroke&&this.stroke.toLive&&e.push(this.stroke.toSVG(this,!0)),e.push("'),e.join("")}}),t.Line.ATTRIBUTE_NAMES="x1 y1 x2 y2 stroke stroke-width transform".split(" "),t.Line.fromElement=function(e,r){var i=t.parseAttributes(e,t.Line.ATTRIBUTE_NAMES),s=[i.x1||0,i.y1||0,i.x2||0,i.y2||0];return new t.Line(s,n(i,r))},t.Line.fromObject=function(e){var n=[e.x1,e.y1,e.x2,e.y2];return new t.Line(n,e)}}(typeof exports!="undefined"?exports:this),function(e){"use strict";function i(e){return"radius"in e&&e.radius>0}var t=e.fabric||(e.fabric={}),n=Math.PI*2,r=t.util.object.extend;if(t.Circle){t.warn("fabric.Circle is already defined.");return}t.Circle=t.util.createClass(t.Object,{type:"circle",initialize:function(e){e=e||{},this.set("radius",e.radius||0),this.callSuper("initialize",e);var t=this.get("radius")*2;this.set("width",t).set("height",t)},toObject:function(e){return r(this.callSuper("toObject",e),{radius:this.get("radius")})},toSVG:function(){var e=[];return this.fill&&this.fill.toLive&&e.push(this.fill.toSVG(this,!1)),this.stroke&&this.stroke.toLive&&e.push(this.stroke.toSVG(this,!1)),e.push("'),e.join("")},_render:function(e,t){e.beginPath(),e.globalAlpha=this.group?e.globalAlpha*this.opacity:this.opacity,e.arc(t?this.left:0,t?this.top:0,this.radius,0,n,!1),e.closePath(),this._renderFill(e),this._removeShadow(e),this.stroke&&e.stroke()},getRadiusX:function(){return this.get("radius")*this.get("scaleX")},getRadiusY:function(){return this.get("radius")*this.get("scaleY")},setRadius:function(e){this.radius=e,this.set("width",e*2).set("height",e*2)},complexity:function(){return 1}}),t.Circle.ATTRIBUTE_NAMES="cx cy r fill fill-opacity opacity stroke stroke-width transform".split(" "),t.Circle.fromElement=function(e,n){n||(n={});var s=t.parseAttributes(e,t.Circle.ATTRIBUTE_NAMES);if(!i(s))throw new Error("value of `r` attribute is required and can not be negative");"left"in s&&(s.left-=n.width/2||0),"top"in s&&(s.top-=n.height/2||0);var o=new t.Circle(r(s,n));return o.cx=parseFloat(e.getAttribute("cx"))||0,o.cy=parseFloat(e.getAttribute("cy"))||0,o},t.Circle.fromObject=function(e){return new t.Circle(e)}}(typeof exports!="undefined"?exports:this),function(e){"use strict";var t=e.fabric||(e.fabric={});if(t.Triangle){t.warn("fabric.Triangle is already defined");return}t.Triangle=t.util.createClass(t.Object,{type:"triangle",initialize:function(e){e=e||{},this.callSuper("initialize",e),this.set("width",e.width||100).set("height",e.height||100)},_render:function(e){var t=this.width/2,n=this.height/2;e.beginPath(),e.moveTo(-t,n),e.lineTo(0,-n),e.lineTo(t,n),e.closePath(),this._renderFill(e),this.stroke&&e.stroke()},complexity:function(){return 1},toSVG:function(){var e=[],t=this.width/2,n=this.height/2,r=[-t+" "+n,"0 "+ -n,t+" "+n].join(",");return this.fill&&this.fill.toLive&&e.push(this.fill.toSVG(this,!0)),this.stroke&&this.stroke.toLive&&e.push(this.stroke.toSVG(this,!0)),e.push("'),e.join("")}}),t.Triangle.fromObject=function(e){return new t.Triangle(e)}}(typeof exports!="undefined"?exports:this),function(e){"use strict";var t=e.fabric||(e.fabric={}),n=Math.PI*2,r=t.util.object.extend;if(t.Ellipse){t.warn("fabric.Ellipse is already defined.");return}t.Ellipse=t.util.createClass(t.Object,{type:"ellipse",rx:0,ry:0,initialize:function(e){e=e||{},this.callSuper("initialize",e),this.set("rx",e.rx||0),this.set("ry",e.ry||0),this.set("width",this.get("rx")*2),this.set("height",this.get("ry")*2)},toObject:function(e){return r(this.callSuper("toObject",e),{rx:this.get("rx"),ry:this.get("ry")})},toSVG:function(){var e=[];return this.fill&&this.fill.toLive&&e.push(this.fill.toSVG(this,!1)),this.stroke&&this.stroke.toLive&&e.push(this.stroke.toSVG(this,!1)),e.push("'),e.join("")},render:function(e,t){if(this.rx===0||this.ry===0)return;return this.callSuper("render",e,t)},_render:function(e,t){e.beginPath(),e.save(),e.globalAlpha=this.group?e.globalAlpha*this.opacity:this.opacity,this.transformMatrix&&this.group&&e.translate(this.cx,this.cy),e.transform(1,0,0,this.ry/this.rx,0,0),e.arc(t?this.left:0,t?this.top:0,this.rx,0,n,!1),this.stroke&&e.stroke(),this._removeShadow(e),this._renderFill(e),e.restore()},complexity:function(){return 1}}),t.Ellipse.ATTRIBUTE_NAMES="cx cy rx ry fill fill-opacity opacity stroke stroke-width transform".split(" "),t.Ellipse.fromElement=function(e,n){n||(n={});var i=t.parseAttributes(e,t.Ellipse.ATTRIBUTE_NAMES),s=i.left,o=i.top;"left"in i&&(i.left-=n.width/2||0),"top"in i&&(i.top-=n.height/2||0);var u=new t.Ellipse(r(i,n));return u.cx=s||0,u.cy=o||0,u},t.Ellipse.fromObject=function(e){return new t.Ellipse(e)}}(typeof exports!="undefined"?exports:this),function(e){"use strict";function r(e){return e.left=e.left||0,e.top=e.top||0,e}var t=e.fabric||(e.fabric={}),n=t.util.object.extend;if(t.Rect){console.warn("fabric.Rect is already defined");return}t.Rect=t.util.createClass(t.Object,{type:"rect",rx:0,ry:0,strokeDashArray:null,initialize:function(e){e=e||{},this._initStateProperties(),this.callSuper("initialize",e),this._initRxRy(),this.x=0,this.y=0},_initStateProperties:function(){this.stateProperties=this.stateProperties.concat(["rx","ry"])},_initRxRy:function(){this.rx&&!this.ry?this.ry=this.rx:this.ry&&!this.rx&&(this.rx=this.ry)},_render:function(e){var t=this.rx||0,n=this.ry||0,r=-this.width/2,i=-this.height/2,s=this.width,o=this.height,u=this.group&&this.group.type!=="group";e.beginPath(),e.globalAlpha=u?e.globalAlpha*this.opacity:this.opacity,this.transformMatrix&&u&&e.translate(this.width/2+this.x,this.height/2+this.y),!this.transformMatrix&&u&&e.translate(-this.group.width/2+this.width/2+this.x,-this.group.height/2+this.height/2+this.y),e.moveTo(r+t,i),e.lineTo(r+s-t,i),e.quadraticCurveTo(r+s,i,r+s,i+n,r+s,i+n),e.lineTo(r+s,i+o-n),e.quadraticCurveTo(r+s,i+o,r+s-t,i+o,r+s-t,i+o),e.lineTo(r+t,i+o),e.quadraticCurveTo(r,i+o,r,i+o-n,r,i+o-n),e.lineTo(r,i+n),e.quadraticCurveTo(r,i,r+t,i,r+t,i),e.closePath(),this._renderFill(e),this._removeShadow(e),this.strokeDashArray?this._renderDashedStroke(e):this.stroke&&e.stroke()},_renderDashedStroke:function(e){function u(u,a){var f=0,l=0,c=(a?i.height:i.width)+s*2;while(fc&&(l=f-c),u?n+=h*u-(l*u||0):r+=h*a-(l*a||0),e[1&t?"moveTo":"lineTo"](n,r),t>=o&&(t=0)}}1&this.strokeDashArray.length&&this.strokeDashArray.push.apply(this.strokeDashArray,this.strokeDashArray);var t=0,n=-this.width/2,r=-this.height/2,i=this,s=this.padding,o=this.strokeDashArray.length;e.save(),e.beginPath(),u(1,0),u(0,1),u(-1,0),u(0,-1),e.stroke(),e.closePath(),e.restore()},_normalizeLeftTopProperties:function(e){return"left"in e&&this.set("left",e.left+this.getWidth()/2),this.set("x",e.left||0),"top"in e&&this.set("top",e.top+this.getHeight()/2),this.set("y",e.top||0),this},complexity:function(){return 1},toObject:function(e){return n(this.callSuper("toObject",e),{rx:this.get("rx")||0,ry:this.get("ry")||0})},toSVG:function(){var e=[];return this.fill&&this.fill.toLive&&e.push(this.fill.toSVG(this,!1)),this.stroke&&this.stroke.toLive&&e.push(this.stroke.toSVG(this,!1)),e.push("'),e.join("")}}),t.Rect.ATTRIBUTE_NAMES="x y width height rx ry fill fill-opacity opacity stroke stroke-width transform".split(" "),t.Rect.fromElement=function(e,i){if(!e)return null;var s=t.parseAttributes(e,t.Rect.ATTRIBUTE_NAMES);s=r(s);var o=new t.Rect(n(i?t.util.object.clone(i):{},s));return o._normalizeLeftTopProperties(s),o},t.Rect.fromObject=function(e){return new t.Rect(e)}}(typeof exports!="undefined"?exports:this),function(e){"use strict";var t=e.fabric||(e.fabric={}),n=t.util.toFixed;if(t.Polyline){t.warn("fabric.Polyline is already defined");return}t.Polyline=t.util.createClass(t.Object,{type:"polyline",initialize:function(e,t,n){t=t||{},this.set("points",e),this.callSuper("initialize",t),this._calcDimensions(n)},_calcDimensions:function(e){return t.Polygon.prototype._calcDimensions.call(this,e)},toObject:function(e){return t.Polygon.prototype.toObject.call(this,e)},toSVG:function(){var e=[],t=[];for(var r=0 -,i=this.points.length;r'),t.join("")},_render:function(e){var t;e.beginPath(),e.moveTo(this.points[0].x,this.points[0].y);for(var n=0,r=this.points.length;n'),t.join("")},_render:function(e){var t;e.beginPath(),e.moveTo(this.points[0].x,this.points[0].y);for(var n=0,r=this.points.length;n1&&(g=Math.sqrt(g),n*=g,i*=g);var y=d/n,b=p/n,w=-p/i,E=d/i,S=y*l+b*c,x=w*l+E*c,T=y*e+b*t,N=w*e+E*t,C=(T-S)*(T-S)+(N-x)*(N-x),k=1/C-.25;k<0&&(k=0);var L=Math.sqrt(k);a===u&&(L=-L);var A=.5*(S+T)-L*(N-x),O=.5*(x+N)+L*(T-S),M=Math.atan2(x-O,S-A),_=Math.atan2(N-O,T-A),D=_-M;D<0&&a===1?D+=2*Math.PI:D>0&&a===0&&(D-=2*Math.PI);var P=Math.ceil(Math.abs(D/(Math.PI*.5+.001))),H=[];for(var B=0;B"},toObject:function(e){var t=h(this.callSuper("toObject",e),{path:this.path});return this.sourcePath&&(t.sourcePath=this.sourcePath),this.transformMatrix&&(t.transformMatrix=this.transformMatrix),t},toDatalessObject:function(e){var t=this.toObject(e);return this.sourcePath&&(t.path=this.sourcePath),delete t.sourcePath,t},toSVG:function(){var e=[],t=[];for(var n=0,r=this.path.length;n',"",""),t.join("")},complexity:function(){return this.path.length},_parsePath:function(){var e=[],n,r,i;for(var s=0,o,u=this.path.length;sc)for(var h=1,p=o.length;h"];for(var n=0,r=e.length;n"),t.join("")},toString:function(){return"#"},isSameColor:function(){var e=this.getObjects()[0].get("fill");return this.getObjects().every(function(t){return t.get("fill")===e})},complexity:function(){return this.paths.reduce(function(e,t){return e+(t&&t.complexity?t.complexity():0)},0)},toGrayscale:function(){var e=this.paths.length;while(e--)this.paths[e].toGrayscale();return this},getObjects:function(){return this.paths}}),t.PathGroup.fromObject=function(e){var n=u(e.paths);return new t.PathGroup(n,e)}}(typeof exports!="undefined"?exports:this),function(e){"use strict";var t=e.fabric||(e.fabric={}),n=t.util.object.extend,r=t.util.array.min,i=t.util.array.max,s=t.util.array.invoke;if(t.Group)return;var o={lockMovementX:!0,lockMovementY:!0,lockRotation:!0,lockScalingX:!0,lockScalingY:!0,lockUniScaling:!0};t.Group=t.util.createClass(t.Object,t.Collection,{type:"group",initialize:function(e,t){t=t||{},this._objects=e||[];for(var r=this._objects.length;r--;)this._objects[r].group=this;this.originalState={},this.callSuper("initialize"),this._calcBounds(),this._updateObjectsCoords(),t&&n(this,t),this._setOpacityIfSame(),this.setCoords(!0),this.saveCoords()},_updateObjectsCoords:function(){var e=this.left,t=this.top;this.forEachObject(function(n){var r=n.get("left"),i=n.get("top");n.set("originalLeft",r),n.set("originalTop",i),n.set("left",r-e),n.set("top",i-t),n.setCoords(),n.__origHasControls=n.hasControls,n.hasControls=!1},this)},toString:function(){return"#"},getObjects:function(){return this._objects},addWithUpdate:function(e){return this._restoreObjectsState(),this._objects.push(e),e.group=this,this.forEachObject(function(e){e.set("active",!0),e.group=this},this),this._calcBounds(),this._updateObjectsCoords(),this},removeWithUpdate:function(e){return this._restoreObjectsState(),this.forEachObject(function(e){e.set("active",!0),e.group=this},this),this.remove(e),this._calcBounds(),this._updateObjectsCoords(),this},_onObjectAdded:function(e){e.group=this},_onObjectRemoved:function(e){delete e.group,e.set("active",!1)},delegatedProperties:{fill:!0,opacity:!0,fontFamily:!0,fontWeight:!0,fontSize:!0,fontStyle:!0,lineHeight:!0,textDecoration:!0,textShadow:!0,textAlign:!0,backgroundColor:!0},_set:function(e,t){if(e in this.delegatedProperties){var n=this._objects.length;this[e]=t;while(n--)this._objects[n].set(e,t)}else this[e]=t},toObject:function(e){return n(this.callSuper("toObject",e),{objects:s(this._objects,"toObject",e)})},render:function(e,n){if(!this.visible)return;e.save(),this.transform(e);var r=Math.max(this.scaleX,this.scaleY);this.clipTo&&t.util.clipContext(this,e);for(var i=0,s=this._objects.length;ie.x&&i-ne.y},toSVG:function(){var e=[];for(var t=this._objects.length;t--;)e.push(this._objects[t].toSVG());return''+e.join("")+""},get:function(e){if(e in o){if(this[e])return this[e];for(var t=0,n=this._objects.length;t'+'"+""},getSrc:function(){return this.getElement().src||this.getElement()._src},toString:function(){return'#'},clone:function(e,t){this.constructor.fromObject(this.toObject(t),e)},applyFilters:function(e){if(this.filters.length===0){this.setElement(this._originalImage),e&&e();return}var t=typeof Buffer!="undefined"&&typeof window=="undefined",n=this._originalImage,r=fabric.util.createCanvasElement(),i=t?new(require("canvas").Image):fabric.document.createElement("img"),s=this;r.width=n.width,r.height=n.height,r.getContext("2d").drawImage(n,0,0,n.width,n.height),this.filters.forEach(function(e){e&&e.applyTo(r)}),i.onload=function(){s._element=i,e&&e(),i.onload=r=n=null},i.width=n.width,i.height=n.height;if(t){var o=r.toDataURL("image/png").substring(22);i.src=new Buffer(o,"base64"),s._element=i,e&&e()}else i.src=r.toDataURL("image/png");return this},_render:function(e){e.drawImage(this._element,-this.width/2,-this.height/2,this.width,this.height)},_resetWidthHeight:function(){var e=this.getElement();this.set("width",e.width),this.set("height",e.height)},_initElement:function(e){this.setElement(fabric.util.getById(e)),fabric.util.addClass(this.getElement(),fabric.Image.CSS_CANVAS)},_initConfig:function(e){e||(e={}),this.setOptions(e),this._setWidthHeight(e)},_initFilters:function(e){e.filters&&e.filters.length&&(this.filters=e.filters.map(function(e){return e&&fabric.Image.filters[e.type].fromObject(e)}))},_setWidthHeight:function(e){this.width="width"in e?e.width:this.getElement().width||0,this.height="height"in e?e.height:this.getElement().height||0},complexity:function(){return 1}}),fabric.Image.CSS_CANVAS="canvas-img",fabric.Image.prototype.getSvgSrc=fabric.Image.prototype.getSrc,fabric.Image.fromObject=function(e,t){var n=fabric.document.createElement("img"),r=e.src;e.width&&(n.width=e.width),e.height&&(n.height=e.height),n.onload=function(){fabric.Image.prototype._initFilters.call(e,e);var r=new fabric.Image(n,e);t&&t(r),n=n.onload=n.onerror=null},n.onerror=function(){fabric.log("Error loading "+n.src),t&&t(null,!0),n=n.onload=n.onerror=null},n.src=r},fabric.Image.fromURL=function(e,t,n){fabric.util.loadImage(e,function(e){t(new fabric.Image(e,n))})},fabric.Image.ATTRIBUTE_NAMES="x y width height fill fill-opacity opacity stroke stroke-width transform xlink:href".split(" "),fabric.Image.fromElement=function(e,n,r){var i=fabric.parseAttributes(e,fabric.Image.ATTRIBUTE_NAMES);fabric.Image.fromURL(i["xlink:href"],n,t(r?fabric.util.object.clone(r):{},i))},fabric.Image.async=!0}(typeof exports!="undefined"?exports:this),fabric.util.object.extend(fabric.Object.prototype,{_getAngleValueForStraighten:function(){var e=this.getAngle()%360;return e>0?Math.round((e-1)/90)*90:Math.round(e/90)*90},straighten:function(){return this.setAngle(this._getAngleValueForStraighten()),this},fxStraighten:function(e){e=e||{};var t=function(){},n=e.onComplete||t,r=e.onChange||t,i=this;return fabric.util.animate({startValue:this.get("angle"),endValue:this._getAngleValueForStraighten(),duration:this.FX_DURATION,onChange:function(e){i.setAngle(e),r()},onComplete:function(){i.setCoords(),n()},onStart:function(){i.set("active",!1)}}),this}}),fabric.util.object.extend(fabric.StaticCanvas.prototype,{straightenObject:function(e){return e.straighten(),this.renderAll(),this},fxStraightenObject:function(e){return e.fxStraighten({onChange:this.renderAll.bind(this)}),this}}),fabric.Image.filters={},fabric.Image.filters.Grayscale=fabric.util.createClass({type:"Grayscale",applyTo:function(e){var t=e.getContext("2d"),n=t.getImageData(0,0,e.width,e.height),r=n.data,i=n.width,s=n.height,o,u,a,f;for(a=0;ao&&f>o&&l>o&&u(a-f)0&&(r[s]=a,r[s+1]=f,r[s+2]=l);t.putImageData(n,0,0)},toJSON:function(){return{type:this.type,color:this.color}}}),fabric.Image.filters.Tint.fromObject=function(e){return new fabric.Image.filters.Tint(e)},fabric.Image.filters.Convolute=fabric.util.createClass({type:"Convolute",initialize:function(e){e||(e={}),this.opaque=e.opaque,this.matrix=e.matrix||[0,0,0,0,1,0,0,0,0];var t=fabric.util.createCanvasElement();this.tmpCtx=t.getContext("2d")},_createImageData:function(e,t){return this.tmpCtx.createImageData(e,t)},applyTo:function(e){var t=this.matrix,n=e.getContext("2d"),r=n.getImageData(0,0,e.width,e.height),i=Math.round(Math.sqrt(t.length)),s=Math.floor(i/2),o=r.data,u=r.width,a=r.height,f=u,l=a,c=this._createImageData(f,l),h=c.data,p=this.opaque?1:0;for(var d=0;d=0&&N=0&&C'},_render:function(e){var t=this.group&&this.group.type!=="group";t&&!this.transformMatrix?e.translate(-this.group.width/2+this.left,-this.group.height/2+this.top):t&&this.transformMatrix&&e.translate(-this.group.width/2,-this.group.height/2),typeof Cufon=="undefined"||this.useNative===!0?this._renderViaNative(e):this._renderViaCufon(e)},_renderViaCufon:function(e){var t=Cufon.textOptions||(Cufon.textOptions={});t.left=this.left,t.top=this.top,t.context=e,t.color=this.fill;var n=this._initDummyElementForCufon();this.transform(e),Cufon.replaceElement(n,{engine:"canvas",separate:"none",fontFamily:this.fontFamily,fontWeight:this.fontWeight,textDecoration:this.textDecoration,textShadow:this.textShadow,textAlign:this.textAlign,fontStyle:this.fontStyle,lineHeight:this.lineHeight,stroke:this.stroke,strokeWidth:this.strokeWidth,backgroundColor:this.backgroundColor,textBackgroundColor:this.textBackgroundColor}),this.width=t.width,this.height=t.height,this._totalLineHeight=t.totalLineHeight,this._fontAscent=t.fontAscent,this._boundaries=t.boundaries,this._shadowOffsets=t.shadowOffsets,this._shadows=t.shadows||[],n=null,this.setCoords()},_renderViaNative:function(e){this.transform(e),this._setTextStyles(e);var n=this.text.split(/\r?\n/);this.width=this._getTextWidth(e,n),this.height=this._getTextHeight(e,n),this._renderTextBackground(e,n),this.textAlign!=="left"&&this.textAlign!=="justify"&&(e.save(),e.translate(this.textAlign==="center"?this.width/2:this.width,0)),this._setTextShadow(e),this.clipTo&&t.util.clipContext(this,e),this._renderTextFill(e,n),this._renderTextStroke(e,n),this.clipTo&&e.restore(),this.textShadow&&e.restore(),this.textAlign!=="left"&&this.textAlign!=="justify"&&e.restore(),this._renderTextDecoration(e,n),this._setBoundaries(e,n),this._totalLineHeight=0,this.setCoords()},_setBoundaries:function(e,t){this._boundaries=[];for(var n=0,r=t.length;nn&&(n=s)}return n},_setTextShadow:function(e){if(this.textShadow){var t=/\s+(-?\d+)(?:px)?\s+(-?\d+)(?:px)?\s+(\d+)(?:px)?\s*/,n=this.textShadow,r=t.exec(this.textShadow),i=n.replace(t,"");e.save(),e.shadowColor=i,e.shadowOffsetX=parseInt(r[1],10),e.shadowOffsetY=parseInt(r[2],10),e.shadowBlur=parseInt(r[3],10),this._shadows=[{blur:e.shadowBlur,color:e.shadowColor,offX:e.shadowOffsetX,offY:e.shadowOffsetY}],this._shadowOffsets=[[parseInt(e.shadowOffsetX,10),parseInt(e.shadowOffsetY,10)]]}},_drawTextLine:function(e,t,n,r,i){if(this.textAlign!=="justify"){t[e](n,r,i);return}var s=t.measureText(n).width,o=this -.width;if(o>s){var u=n.split(/\s+/),a=t.measureText(n.replace(/\s+/g,"")).width,f=o-a,l=u.length-1,c=f/l,h=0;for(var p=0,d=u.length;p-1&&i(this.fontSize),this.textDecoration.indexOf("line-through")>-1&&i(this.fontSize/2),this.textDecoration.indexOf("overline")>-1&&i(0)},_getFontDeclaration:function(){return[t.isLikelyNode?this.fontWeight:this.fontStyle,t.isLikelyNode?this.fontStyle:this.fontWeight,this.fontSize+"px",t.isLikelyNode?'"'+this.fontFamily+'"':this.fontFamily].join(" ")},_initDummyElementForCufon:function(){var e=t.document.createElement("pre"),n=t.document.createElement("div");return n.appendChild(e),typeof G_vmlCanvasManager=="undefined"?e.innerHTML=this.text:e.innerText=this.text.replace(/\r?\n/gi,"\r"),e.style.fontSize=this.fontSize+"px",e.style.letterSpacing="normal",e},render:function(e,t){if(!this.visible)return;e.save(),this._render(e),!t&&this.active&&(this.drawBorders(e),this.drawControls(e)),e.restore()},toObject:function(e){return n(this.callSuper("toObject",e),{text:this.text,fontSize:this.fontSize,fontWeight:this.fontWeight,fontFamily:this.fontFamily,fontStyle:this.fontStyle,lineHeight:this.lineHeight,textDecoration:this.textDecoration,textShadow:this.textShadow,textAlign:this.textAlign,path:this.path,stroke:this.stroke,strokeWidth:this.strokeWidth,backgroundColor:this.backgroundColor,textBackgroundColor:this.textBackgroundColor,useNative:this.useNative})},toSVG:function(){var e=this.text.split(/\r?\n/),t=this.useNative?this.fontSize*this.lineHeight:-this._fontAscent-this._fontAscent/5*this.lineHeight,n=-(this.width/2),r=this.useNative?this.fontSize-1:this.height/2-e.length*this.fontSize-this._totalLineHeight,s=this._getSVGTextAndBg(t,n,e),o=this._getSVGShadows(t,e);return r+=this._fontAscent?this._fontAscent/5*this.lineHeight:0,['',s.textBgRects.join(""),"',o.join(""),s.textSpans.join(""),"",""].join("")},_getSVGShadows:function(e,n){var r=[],s,o,u,a,f=1;if(!this._shadows||!this._boundaries)return r;for(s=0,u=this._shadows.length;s",t.util.string.escapeXml(n[o]),""),f=1}else f++;return r},_getSVGTextAndBg:function(e,n,r){var s=[],o=[],u,a,f,l=1;this.backgroundColor&&this._boundaries&&o.push("');for(u=0,f=r.length;u",t.util.string.escapeXml(r[u]),""),l=1):l++;if(!this.textBackgroundColor||!this._boundaries)continue;o.push("')}return{textSpans:s,textBgRects:o}},_getFillAttributes:function(e){var n=e&&typeof e=="string"?new t.Color(e):"";return!n||!n.getSource()||n.getAlpha()===1?'fill="'+e+'"':'opacity="'+n.getAlpha()+'" fill="'+n.setAlpha(1).toRgb()+'"'},setColor:function(e){return this.set("fill",e),this},getText:function(){return this.text},_set:function(e,t){e==="fontFamily"&&this.path&&(this.path=this.path.replace(/(.*?)([^\/]*)(\.font\.js)/,"$1"+t+"$3")),this.callSuper("_set",e,t),e in s&&(this._initDimensions(),this.setCoords())}}),t.Text.ATTRIBUTE_NAMES="x y fill fill-opacity opacity stroke stroke-width transform font-family font-style font-weight font-size text-decoration".split(" "),t.Text.fromObject=function(e){return new t.Text(e.text,r(e))},t.Text.fromElement=function(e,n){if(!e)return null;var r=t.parseAttributes(e,t.Text.ATTRIBUTE_NAMES);n=t.util.object.extend(n?t.util.object.clone(n):{},r);var i=new t.Text(e.textContent,n);return i.set({left:i.getLeft()+i.getWidth()/2,top:i.getTop()-i.getHeight()/2}),i},t.util.createAccessors(t.Text)}(typeof exports!="undefined"?exports:this),function(){function request(e,t,n){var r=URL.parse(e);r.port||(r.port=r.protocol.indexOf("https:")===0?443:80);var i=r.port===443?HTTPS:HTTP,s=i.request({hostname:r.hostname,port:r.port,path:r.pathname,method:"GET"},function(e){var r="";t&&e.setEncoding(t),e.on("end",function(){n(r)}),e.on("data",function(t){e.statusCode===200&&(r+=t)})});s.on("error",function(e){e.errno===process.ECONNREFUSED?fabric.log("ECONNREFUSED: connection refused to "+r.hostname+":"+r.port):fabric.log(e.message)}),s.end()}function request_fs(e,t){var n=require("fs"),r=n.createReadStream(e),i="";r.on("data",function(e){i+=e}),r.on("end",function(){t(i)})}if(typeof document!="undefined"&&typeof window!="undefined")return;var DOMParser=(new require("xmldom")).DOMParser,URL=require("url"),HTTP=require("http"),HTTPS=require("https"),Canvas=require("canvas"),Image=require("canvas").Image;fabric.util.loadImage=function(e,t,n){var r=function(r){i.src=new Buffer(r,"binary"),i._src=e,t&&t.call(n,i)},i=new Image;e&&e.indexOf("data")===0?(i.src=i._src=e,t&&t.call(n,i)):e&&e.indexOf("http")!==0?request_fs(e,r):e&&request(e,"binary",r)},fabric.loadSVGFromURL=function(e,t){e=e.replace(/^\n\s*/,"").replace(/\?.*$/,"").trim(),e.indexOf("http")!==0?request_fs(e,function(e){fabric.loadSVGFromString(e,t)}):request(e,"",function(e){fabric.loadSVGFromString(e,t)})},fabric.loadSVGFromString=function(e,t){var n=(new DOMParser).parseFromString(e);fabric.parseSVGDocument(n.documentElement,function(e,n){t(e,n)})},fabric.util.getScript=function(url,callback){request(url,"",function(body){eval(body),callback&&callback()})},fabric.Image.fromObject=function(e,t){fabric.util.loadImage(e.src,function(n){var r=new fabric.Image(n);r._initConfig(e),r._initFilters(e),t(r)})},fabric.createCanvasForNode=function(e,t){var n=fabric.document.createElement("canvas"),r=new Canvas(e||600,t||600);n.style={},n.width=r.width,n.height=r.height;var i=fabric.Canvas||fabric.StaticCanvas,s=new i(n);return s.contextContainer=r.getContext("2d"),s.nodeCanvas=r,s.Font=Canvas.Font,s},fabric.StaticCanvas.prototype.createPNGStream=function(){return this.nodeCanvas.createPNGStream()},fabric.StaticCanvas.prototype.createJPEGStream=function(e){return this.nodeCanvas.createJPEGStream(e)};var origSetWidth=fabric.StaticCanvas.prototype.setWidth;fabric.StaticCanvas.prototype.setWidth=function(e){return origSetWidth.call(this,e),this.nodeCanvas.width=e,this},fabric.Canvas&&(fabric.Canvas.prototype.setWidth=fabric.StaticCanvas.prototype.setWidth);var origSetHeight=fabric.StaticCanvas.prototype.setHeight;fabric.StaticCanvas.prototype.setHeight=function(e){return origSetHeight.call(this,e),this.nodeCanvas.height=e,this},fabric.Canvas&&(fabric.Canvas.prototype.setHeight=fabric.StaticCanvas.prototype.setHeight)}(); \ No newline at end of file +/* build: `node build.js modules=ALL exclude=gestures` *//*! Fabric.js Copyright 2008-2013, Printio (Juriy Zaytsev, Maxim Chernyak) */var fabric=fabric||{version:"1.1.8"};typeof exports!="undefined"&&(exports.fabric=fabric),typeof document!="undefined"&&typeof window!="undefined"?(fabric.document=document,fabric.window=window):(fabric.document=require("jsdom").jsdom(""),fabric.window=fabric.document.createWindow()),fabric.isTouchSupported="ontouchstart"in fabric.document.documentElement,fabric.isLikelyNode=typeof Buffer!="undefined"&&typeof window=="undefined";var Cufon=function(){function r(e){var t=this.face=e.face;this.glyphs=e.glyphs,this.w=e.w,this.baseSize=parseInt(t["units-per-em"],10),this.family=t["font-family"].toLowerCase(),this.weight=t["font-weight"],this.style=t["font-style"]||"normal",this.viewBox=function(){var e=t.bbox.split(/\s+/),n={minX:parseInt(e[0],10),minY:parseInt(e[1],10),maxX:parseInt(e[2],10),maxY:parseInt(e[3],10)};return n.width=n.maxX-n.minX,n.height=n.maxY-n.minY,n.toString=function(){return[this.minX,this.minY,this.width,this.height].join(" ")},n}(),this.ascent=-parseInt(t.ascent,10),this.descent=-parseInt(t.descent,10),this.height=-this.ascent+this.descent}function i(){var e={},t={oblique:"italic",italic:"oblique"};this.add=function(t){(e[t.style]||(e[t.style]={}))[t.weight]=t},this.get=function(n,r){var i=e[n]||e[t[n]]||e.normal||e.italic||e.oblique;if(!i)return null;r={normal:400,bold:700}[r]||parseInt(r,10);if(i[r])return i[r];var s={1:1,99:0}[r%100],o=[],u,a;s===undefined&&(s=r>400),r==500&&(r=400);for(var f in i){f=parseInt(f,10);if(!u||fa)a=f;o.push(f)}return ra&&(r=a),o.sort(function(e,t){return(s?e>r&&t>r?et:et:e=i.length+e?r():setTimeout(arguments.callee,10)}),function(t){e?t():n.push(t)}}(),supports:function(e,t){var n=fabric.document.createElement("span").style;return n[e]===undefined?!1:(n[e]=t,n[e]===t)},textAlign:function(e,t,n,r){return t.get("textAlign")=="right"?n>0&&(e=" "+e):nk&&(k=N),A.push(N),N=0;continue}var O=t.glyphs[T[b]]||t.missingGlyph;if(!O)continue;N+=C=Number(O.w||t.w)+h}A.push(N),N=Math.max(k,N);var M=[];for(var b=A.length;b--;)M[b]=N-A[b];if(C===null)return null;d+=l.width-C,m+=l.minX;var _,D;if(f)_=u,D=u.firstChild;else{_=fabric.document.createElement("span"),_.className="cufon cufon-canvas",_.alt=n,D=fabric.document.createElement("canvas"),_.appendChild(D);if(i.printable){var P=fabric.document.createElement("span");P.className="cufon-alt",P.appendChild(fabric.document.createTextNode(n)),_.appendChild(P)}}var H=_.style,B=D.style||{},j=c.convert(l.height-p+v),F=Math.ceil(j),I=F/j;D.width=Math.ceil(c.convert(N+d-m)*I),D.height=F,p+=l.minY,B.top=Math.round(c.convert(p-t.ascent))+"px",B.left=Math.round(c.convert(m))+"px";var q=Math.ceil(c.convert(N*I)),R=q+"px",U=c.convert(t.height),z=(i.lineHeight-1)*c.convert(-t.ascent/5)*(L-1);Cufon.textOptions.width=q,Cufon.textOptions.height=U*L+z,Cufon.textOptions.lines=L,Cufon.textOptions.totalLineHeight=z,e?(H.width=R,H.height=U+"px"):(H.paddingLeft=R,H.paddingBottom=U-1+"px");var W=Cufon.textOptions.context||D.getContext("2d"),X=F/l.height;Cufon.textOptions.fontAscent=t.ascent*X,Cufon.textOptions.boundaries=null;for(var V=Cufon.textOptions.shadowOffsets,b=y.length;b--;)V[b]=[y[b][0]*X,y[b][1]*X];W.save(),W.scale(X,X),W.translate(-m-1/X*D.width/2+(Cufon.fonts[t.family].offsetLeft||0),-p-Cufon.textOptions.height/X/2+(Cufon.fonts[t.family].offsetTop||0)),W.lineWidth=t.face["underline-thickness"],W.save();var J=Cufon.getTextDecoration(i),K=i.fontStyle==="italic";W.save(),Q();if(g)for(var b=0,w=g.length;b.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}}'),function(e,t,i,s,o,u,a){var f=t===null;f&&(t=o.alt);var l=e.viewBox,c=i.computedFontSize||(i.computedFontSize=new Cufon.CSS.Size(n(u,i.get("fontSize"))+"px",e.baseSize)),h=i.computedLSpacing;h==undefined&&(h=i.get("letterSpacing"),i.computedLSpacing=h=h=="normal"?0:~~c.convertFrom(r(u,h)));var p,d;if(f)p=o,d=o.firstChild;else{p=fabric.document.createElement("span"),p.className="cufon cufon-vml",p.alt=t,d=fabric.document.createElement("span"),d.className="cufon-vml-canvas",p.appendChild(d);if(s.printable){var v=fabric.document.createElement("span");v.className="cufon-alt",v.appendChild(fabric.document.createTextNode(t)),p.appendChild(v)}a||p.appendChild(fabric.document.createElement("cvml:shape"))}var m=p.style,g=d.style,y=c.convert(l.height),b=Math.ceil(y),w=b/y,E=l.minX,S=l.minY;g.height=b,g.top=Math.round(c.convert(S-e.ascent)),g.left=Math.round(c.convert(E)),m.height=c.convert(e.height)+"px";var x=Cufon.getTextDecoration(s),T=i.get("color"),N=Cufon.CSS.textTransform(t,i).split(""),C=0,k=0,L=null,A,O,M=s.textShadow;for(var _=0,D=0,P=N.length;_-1},complexity:function(){return this.getObjects().reduce(function(e,t){return e+=t.complexity?t.complexity():0,e},0)},toGrayscale:function(){return this.forEachObject(function(e){e.toGrayscale()})}},function(){function n(e,t){var n=e.indexOf(t);return n!==-1&&e.splice(n,1),e}function r(e,t){return Math.floor(Math.random()*(t-e+1))+e}function s(e){return e*i}function o(e){return e/i}function u(e,t,n){var r=Math.sin(n),i=Math.cos(n);e.subtractEquals(t);var s=e.x*i-e.y*r,o=e.x*r+e.y*i;return(new fabric.Point(s,o)).addEquals(t)}function a(e,t){return parseFloat(Number(e).toFixed(t))}function f(){return!1}function l(e){e||(e={});var t=+(new Date),n=e.duration||500,r=t+n,i,s=e.onChange||function(){},o=e.abort||function(){return!1},u=e.easing||function(e,t,n,r){return-n*Math.cos(e/r*(Math.PI/2))+n+t},a="startValue"in e?e.startValue:0,f="endValue"in e?e.endValue:100,l=e.byValue||f-a;e.onStart&&e.onStart(),function c(){i=+(new Date);var f=i>r?n:i-t;s(u(f,a,l,n));if(i>r||o()){e.onComplete&&e.onComplete();return}h(c)}()}function p(e,t,n){if(e){var r=new Image;r.onload=function(){t&&t.call(n,r),r=r.onload=null},r.src=e}else t&&t.call(n,e)}function d(e,t){function n(e){return fabric[fabric.util.string.camelize(fabric.util.string.capitalize(e))]}function r(){++s===o&&t&&t(i)}var i=[],s=0,o=e.length;e.forEach(function(e,t){if(!e.type)return;var s=n(e.type);s.async?s.fromObject(e,function(e,n){n||(i[t]=e),r()}):(i[t]=s.fromObject(e),r())})}function v(e,t,n){var r;return e.length>1?r=new fabric.PathGroup(e,t):r=e[0],typeof n!="undefined"&&r.setSourcePath(n),r}function m(e,t,n){if(n&&Object.prototype.toString.call(n)==="[object Array]")for(var r=0,i=n.length;rr)r+=u[p++%h],r>l&&(r=l),n[d?"lineTo":"moveTo"](r,0),d=!d;n.restore()}function y(e){return e||(e=fabric.document.createElement("canvas")),!e.getContext&&typeof G_vmlCanvasManager!="undefined"&&G_vmlCanvasManager.initElement(e),e}function b(e){var t=e.prototype;for(var n=t.stateProperties.length;n--;){var r=t.stateProperties[n],i=r.charAt(0).toUpperCase()+r.slice(1),s="set"+i,o="get"+i;t[o]||(t[o]=function(e){return new Function('return this.get("'+e+'")')}(r)),t[s]||(t[s]=function(e){return new Function("value",'return this.set("'+e+'", value)')}(r))}}function w(e,t){t.save(),t.beginPath(),e.clipTo(t),t.clip()}function E(e,t){var n=[[e[0],e[2],e[4]],[e[1],e[3],e[5]],[0,0,1]],r=[[t[0],t[2],t[4]],[t[1],t[3],t[5]],[0,0,1]],i=[];for(var s=0;s<3;s++){i[s]=[];for(var o=0;o<3;o++){var u=0;for(var a=0;a<3;a++)u+=n[s][a]*r[a][o];i[s][o]=u}}return[i[0][0],i[1][0],i[0][1],i[1][1],i[0][2],i[1][2]]}var e=Math.sqrt,t=Math.atan2;fabric.util={};var i=Math.PI/180,c=fabric.window.requestAnimationFrame||fabric.window.webkitRequestAnimationFrame||fabric.window.mozRequestAnimationFrame||fabric.window.oRequestAnimationFrame||fabric.window.msRequestAnimationFrame||function(e){fabric.window.setTimeout(e,1e3/60)},h=function(){return c.apply(fabric.window,arguments)};fabric.util.removeFromArray=n,fabric.util.degreesToRadians=s,fabric.util.radiansToDegrees=o,fabric.util.rotatePoint=u,fabric.util.toFixed=a,fabric.util.getRandomInt=r,fabric.util.falseFunction=f,fabric.util.animate=l,fabric.util.requestAnimFrame=h,fabric.util.loadImage=p,fabric.util.enlivenObjects=d,fabric.util.groupSVGElements=v,fabric.util.populateWithProperties=m,fabric.util.drawDashedLine=g,fabric.util.createCanvasElement=y,fabric.util.createAccessors=b,fabric.util.clipContext=w,fabric.util.multiplyTransformMatrices=E}(),function(){function t(t,n){var r=e.call(arguments,2),i=[];for(var s=0,o=t.length;s=r&&(r=e[n][t]);else while(n--)e[n]>=r&&(r=e[n]);return r}function r(e,t){if(!e||e.length===0)return undefined;var n=e.length-1,r=t?e[n][t]:e[n];if(t)while(n--)e[n][t]>>0;if(n===0)return-1;var r=0;arguments.length>0&&(r=Number(arguments[1]),r!==r?r=0:r!==0&&r!==Number.POSITIVE_INFINITY&&r!==Number.NEGATIVE_INFINITY&&(r=(r>0||-1)*Math.floor(Math.abs(r))));if(r>=n)return-1;var i=r>=0?r:Math.max(n-Math.abs(r),0);for(;i>>0;n>>0;r>>0;n>>0;n>>0;i>>0,n=0,r;if(arguments.length>1)r=arguments[1];else do{if(n in this){r=this[n++];break}if(++n>=t)throw new TypeError}while(!0);for(;n/g,">")}String.prototype.trim||(String.prototype.trim=function(){return this.replace(/^[\s\xA0]+/,"").replace(/[\s\xA0]+$/,"")}),fabric.util.string={camelize:e,capitalize:t,escapeXml:n}}(),function(){var e=Array.prototype.slice,t=Function.prototype.apply,n=function(){};Function.prototype.bind||(Function.prototype.bind=function(r){var i=this,s=e.call(arguments,1),o;return s.length?o=function(){return t.call(i,this instanceof n?this:r,s.concat(e.call(arguments)))}:o=function(){return t.call(i,this instanceof n?this:r,arguments)},n.prototype=this.prototype,o.prototype=new n,o})}(),function(){function i(){}function s(t){var n=this.constructor.superclass.prototype[t];return arguments.length>1?n.apply(this,e.call(arguments,1)):n.call(this)}function o(){function u(){this.initialize.apply(this,arguments)}var n=null,o=e.call(arguments,0);typeof o[0]=="function"&&(n=o.shift()),u.superclass=n,u.subclasses=[],n&&(i.prototype=n.prototype,u.prototype=new i,n.subclasses.push(u));for(var a=0,f=o.length;a-1?e.prototype[i]=function(e){return function(){var n=this.constructor.superclass;this.constructor.superclass=r;var i=t[e].apply(this,arguments);this.constructor.superclass=n;if(e!=="initialize")return i}}(i):e.prototype[i]=t[i],n&&(t.toString!==Object.prototype.toString&&(e.prototype.toString=t.toString),t.valueOf!==Object.prototype.valueOf&&(e.prototype.valueOf=t.valueOf))};fabric.util.createClass=o}(),function(){function e(e){var t=Array.prototype.slice.call(arguments,1),n,r,i=t.length;for(r=0;r-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=0,n=0;do t+=e.offsetTop||0,n+=e.offsetLeft||0,e=e.offsetParent;while(e);return{left:n,top:t}}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});var f;fabric.document.defaultView&&fabric.document.defaultView.getComputedStyle?f=function(e){return fabric.document.defaultView.getComputedStyle(e,null).position}:f=function(e){var t=e.style.position;return!t&&e.currentStyle&&(t=e.currentStyle.position),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.type="text/javascript",r.setAttribute("runat","server"),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.getElementPosition=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,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){v.set(e,{objects:t.util.array.invoke(r,"toObject"),options:i}),n(r,i)},r)}e=e.replace(/^\n\s*/,"").trim(),v.has(e,function(r){r?v.get(e,function(e){var t=g(e);n(t.objects,t.options)}):new t.util.request(e,{method:"get",onComplete:i})})}function g(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 y(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 b(e){var t="";for(var n=0,r=e.length;n',"",""].join("")),t}function w(e){var t="";return e.backgroundColor&&e.backgroundColor.source&&(t=['',''].join("")),t}var t=e.fabric||(e.fabric={}),n=t.util.object.extend,r=t.util.string.capitalize,i=t.util.object.clone,s=t.util.multiplyTransformMatrices,o={cx:"left",x:"left",cy:"top",y:"top",r:"radius","fill-opacity":"opacity","fill-rule":"fillRule","stroke-width":"strokeWidth",transform:"transformMatrix","text-decoration":"textDecoration","font-size":"fontSize","font-weight":"fontWeight","font-style":"fontStyle","font-family":"fontFamily"};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;c']:this.type==="radial"&&(i=["']);for(var s=0;s');return i.push(this.type==="linear"?"":""),i.join("")}}),fabric.util.object.extend(fabric.Gradient,{fromElement:function(n,r){var i=n.getElementsByTagName("stop"),s=n.nodeName==="linearGradient"?"linear":"radial",o=n.getAttribute("gradientUnits")||"objectBoundingBox",u=[],a={};s==="linear"?a={x1:n.getAttribute("x1")||0,y1:n.getAttribute("y1")||0,x2:n.getAttribute("x2")||"100%",y2:n.getAttribute("y2")||0}:s==="radial"&&(a={x1:n.getAttribute("fx")||n.getAttribute("cx")||"50%",y1:n.getAttribute("fy")||n.getAttribute("cy")||"50%",r1:0,x2:n.getAttribute("cx")||"50%",y2:n.getAttribute("cy")||"50%",r2:n.getAttribute("r")||"50%"});for(var f=i.length;f--;)u.push(e(i[f]));return t(r,a),new fabric.Gradient({type:s,coords:a,gradientUnits:o,colorStops:u})},forObject:function(e,n){return n||(n={}),t(e,n),new fabric.Gradient(n)}}),fabric.getGradientDefs=r}(),fabric.Pattern=fabric.util.createClass({repeat:"repeat",offsetX:0,offsetY:0,initialize:function(e){e||(e={}),e.source&&(this.source=typeof e.source=="string"?new Function(e.source):e.source),e.repeat&&(this.repeat=e.repeat),e.offsetX&&(this.offsetX=e.offsetX),e.offsetY&&(this.offsetY=e.offsetY)},toObject:function(){var e;return typeof this.source=="function"?e=String(this.source).match(/function\s+\w*\s*\(.*\)\s+\{([\s\S]*)\}/)[1]:typeof this.source.src=="string"&&(e=this.source.src),{source:e,repeat:this.repeat,offsetX:this.offsetX,offsetY:this.offsetY}},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]},toObject:function(){return{color:this.color,blur:this.blur,offsetX:this.offsetX,offsetY:this.offsetY}},toSVG:function(){}}),function(e){"use strict";function n(e,t){arguments.length>0&&this.init(e,t)}var t=e.fabric||(e.fabric={});if(t.Point){t.warn("fabric.Point is already defined");return}t.Point=n,n.prototype={constructor:n,init:function(e,t){this.x=e,this.y=t},add:function(e){return new n(this.x+e.x,this.y+e.y)},addEquals:function(e){return this.x+=e.x,this.y+=e.y,this},scalarAdd:function(e){return new n(this.x+e,this.y+e)},scalarAddEquals:function(e){return this.x+=e,this.y+=e,this},subtract:function(e){return new n(this.x-e.x,this.y-e.y)},subtractEquals:function(e){return this.x-=e.x,this.y-=e.y,this},scalarSubtract:function(e){return new n(this.x-e,this.y-e)},scalarSubtractEquals:function(e){return this.x-=e,this.y-=e,this},multiply:function(e){return new n(this.x*e,this.y*e)},multiplyEquals:function(e){return this.x*=e,this.y*=e,this},divide:function(e){return new n(this.x/e,this.y/e)},divideEquals:function(e){return this.x/=e,this.y/=e,this},eq:function(e){return this.x===e.x&&this.y===e.y},lt:function(e){return this.xe.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){arguments.length>0&&this.init(e)}var t=e.fabric||(e.fabric={});if(t.Intersection){t.warn("fabric.Intersection is already defined");return}t.Intersection=n,t.Intersection.prototype={init:function(e){this.status=e,this.points=[]},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("No Intersection")}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("No Intersection"),s=r.length;for(var o=0;o0&&(i.status="Intersection"),i},t.Intersection.intersectPolygonPolygon=function(e,t){var r=new n("No Intersection"),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("No Intersection");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])}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&&this.setSource(t)},getSource:function(){return this._source},setSource:function(e){this._source=e},toRgb:function(){var e=this.getSource();return"rgb("+e[0]+","+e[1]+","+e[2]+")"},toRgba:function(){var e=this.getSource();return"rgba("+e[0]+","+e[1]+","+e[2]+","+e[3]+")"},toHex:function(){var e=this.getSource(),t=e[0].toString(16);t=t.length===1?"0"+t:t;var n=e[1].toString(16);n=n.length===1?"0"+n:n;var r=e[2].toString(16);return r=r.length===1?"0"+r:r,t.toUpperCase()+n.toUpperCase()+r.toUpperCase()},getAlpha:function(){return this.getSource()[3]},setAlpha:function(e){var t=this.getSource();return t[3]=e,this.setSource(t),this},toGrayscale:function(){var e=this.getSource(),t=parseInt((e[0]*.3+e[1]*.59+e[2]*.11).toFixed(0),10),n=e[3];return this.setSource([t,t,t,n]),this},toBlackWhite:function(e){var t=this.getSource(),n=(t[0]*.3+t[1]*.59+t[2]*.11).toFixed(0),r=t[3];return e=e||127,n=Number(n)',''),t.push("',"Created with Fabric.js ",fabric.version,"","",fabric.createSVGFontFacesMarkup(this.getObjects()),fabric.createSVGRefElementsMarkup(this),""),this.backgroundColor&&this.backgroundColor.source&&t.push('"),this.backgroundImage&&t.push(''),this.overlayImage&&t.push('');for(var n=0,r=this.getObjects(),i=r.length;n"),t.join("")},remove:function(e){return this.getActiveObject()===e&&(this.fire("before:selection:cleared",{target:e}),this.discardActiveObject(),this.fire("selection:cleared")),fabric.Collection.remove.call(this,e)},sendToBack:function(e){return n(this._objects,e),this._objects.unshift(e),this.renderAll&&this.renderAll()},bringToFront:function(e){return n(this._objects,e),this._objects.push(e),this.renderAll&&this.renderAll()},sendBackwards:function(e){var t=this._objects.indexOf(e),r=t;if(t!==0){for(var i=t-1;i>=0;--i){var s=e.intersectsWithObject(this._objects[i])||e.isContainedWithinObject(this._objects[i])||this._objects[i].isContainedWithinObject(e);if(s){r=i;break}}n(this._objects,e),this._objects.splice(r,0,e)}return this.renderAll&&this.renderAll()},bringForward:function(e){var t=this.getObjects(),r=t.indexOf(e),i=r;if(r!==t.length-1){for(var s=r+1,o=this._objects.length;s"},e(fabric.StaticCanvas,{EMPTY_JSON:'{"objects": [], "background": "white"}',toGrayscale:function(e){var t=e.getContext("2d"),n=t.getImageData(0,0,e.width,e.height),r=n.data,i=n.width,s=n.height,o,u,a,f;for(a=0;a0&&(t>this.targetFindTolerance?t-=this.targetFindTolerance:t=0,n>this.targetFindTolerance?n-=this.targetFindTolerance:n=0);var o=!0,u=r.getImageData(t,n,this.targetFindTolerance*2||1,this.targetFindTolerance*2||1);for(var a=3;a0?0:-n),t.ey-(r>0?0:-r),i,o),e.lineWidth=this.selectionLineWidth,e.strokeStyle=this.selectionBorderColor;if(this.selectionDashArray.length>1){var u=t.ex+a-(n>0?0:i),f=t.ey+a-(r>0?0:o);e.beginPath(),fabric.util.drawDashedLine(e,u,f,u+i,f,this.selectionDashArray),fabric.util.drawDashedLine(e,u,f+o-1,u+i,f+o-1,this.selectionDashArray),fabric.util.drawDashedLine(e,u,f,u,f+o,this.selectionDashArray),fabric.util.drawDashedLine(e,u+i-1,f,u+i-1,f+o,this.selectionDashArray),e.closePath(),e.stroke()}else e.strokeRect(t.ex+a-(n>0?0:i),t.ey+a-(r>0?0:o),i,o)},_findSelectedObjects:function(e){var t=[],n=this._groupSelector.ex,r=this._groupSelector.ey,i=n+this._groupSelector.left,s=r+this._groupSelector.top,a,f=new fabric.Point(o(n,i),o(r,s)),l=new fabric.Point(u(n,i),u(r,s));for(var c=0,h=this._objects.length;c1&&(t=new fabric.Group(t),this.setActiveGroup(t),t.saveCoords(),this.fire("selection:created",{target:t})),this.renderAll()},findTarget:function(e,t){var n,r=this.getPointer(e);if(this.controlsAboveOverlay&&this.lastRenderedObjectWithControlsAboveOverlay&&this.lastRenderedObjectWithControlsAboveOverlay.visible&&this.containsPoint(e,this.lastRenderedObjectWithControlsAboveOverlay)&&this.lastRenderedObjectWithControlsAboveOverlay._findTargetCorner(e,this._offset))return n=this.lastRenderedObjectWithControlsAboveOverlay,n;var i=this.getActiveGroup();if(i&&!t&&this.containsPoint(e,i))return n=i,n;var s=[];for(var o=this._objects.length;o--;)if(this._objects[o]&&this._objects[o].visible&&this.containsPoint(e,this._objects[o])){if(!this.perPixelTargetFind&&!this._objects[o].perPixelTargetFind){n=this._objects[o],this.relatedTarget=n;break}s[s.length]=this._objects[o]}for(var u=0,a=s.length;u"},get:function(e){return this[e]},set:function(e,t){if(typeof e=="object")for(var n in e)this._set(n,e[n]);else typeof t=="function"?this._set(e,t(this.get(e))):this._set(e,t);return this},_set:function(e,t){var n=e==="scaleX"||e==="scaleY";n&&(t=this._constrainScale(t));if(e==="scaleX"&&t<0)this.flipX=!this.flipX,t*=-1;else if(e==="scaleY"&&t<0)this.flipY=!this.flipY,t*=-1;else if(e==="width"||e==="height")this.minScaleLimit=r(Math.min(.1,1/Math.max(this.width,this.height)),2);return this[e]=t,this},toggle:function(e){var t=this.get(e);return typeof t=="boolean"&&this.set(e,!t),this},setSourcePath:function(e){return this.sourcePath=e,this},render:function(e,n){if(this.width===0||this.height===0||!this.visible)return;e.save();var r=this.transformMatrix;r&&!this.group&&e.setTransform(r[0],r[1],r[2],r[3],r[4],r[5]),n||this.transform(e);if(this.stroke||this.strokeDashArray)e.lineWidth=this.strokeWidth,this.stroke&&this.stroke.toLive?e.strokeStyle=this.stroke.toLive(e):e.strokeStyle=this.stroke;this.overlayFill?e.fillStyle=this.overlayFill:this.fill&&(e.fillStyle=this.fill.toLive?this.fill.toLive(e):this.fill),r&&this.group&&(e.translate(-this.group.width/2,-this.group.height/2),e.transform(r[0],r[1],r[2],r[3],r[4],r[5])),this._setShadow(e),this.clipTo&&t.util.clipContext(this,e),this._render(e,n),this.clipTo&&e.restore(),this._removeShadow(e),this.active&&!n&&(this.drawBorders(e),this.drawControls(e)),e.restore()},_setShadow:function(e){if(!this.shadow)return;e.shadowColor=this.shadow.color,e.shadowBlur=this.shadow.blur,e.shadowOffsetX=this.shadow.offsetX,e.shadowOffsetY=this.shadow.offsetY},_removeShadow:function(e){e.shadowColor="",e.shadowBlur=e.shadowOffsetX=e.shadowOffsetY=0},_renderFill:function(e){if(!this.fill)return;this.fill.toLive&&(e.save(),e.translate(-this.width/2+this.fill.offsetX,-this.height/2+this.fill.offsetY)),e.fill(),this.fill.toLive&&e.restore()},clone:function(e,n){return this.constructor.fromObject?this.constructor.fromObject(this.toObject(n),e):new t.Object(this.toObject(n))},cloneAsImage:function(e){if(t.Image){var n=new o;n.onload=function(){e&&e(new t.Image(n),r),n=n.onload=null};var r={angle:this.getAngle(),flipX:this.getFlipX(),flipY:this.getFlipY()};this.set({angle:0,flipX:!1,flipY:!1}),this.toDataURL(function(e){n.src=e})}return this},toDataURL:function(e){function i(t){t.left=n.width/2,t.top=n.height/2,t.set("active",!1),r.add(t);var i=r.toDataURL();r.dispose(),r=t=null,e&&e(i)}var n=t.util.createCanvasElement();n.width=this.getBoundingRectWidth(),n.height=this.getBoundingRectHeight(),t.util.wrapElement(n,"div");var r=new t.Canvas(n);r.backgroundColor="transparent",r.renderAll(),this.constructor.async?this.clone(i):i(this.clone())},hasStateChanged:function(){return this.stateProperties.some(function(e){return this[e]!==this.originalState[e]},this)},saveState:function(e){return this.stateProperties.forEach(function(e){this.originalState[e]=this.get(e)},this),e&&e.stateProperties&&e.stateProperties.forEach(function(e){this.originalState[e]=this.get(e)},this),this},setupState:function(){this.originalState={},this.saveState()},isType:function(e){return this.type===e},toGrayscale:function(){var e=this.get("fill");return e&&this.set("overlayFill",(new t.Color(e)).toGrayscale().toRgb()),this},complexity:function(){return 0},toJSON:function(e){return this.toObject(e)},setGradient:function(e,n){n||(n={});var r={colorStops:[]};r.type=n.type||(n.r1||n.r2?"radial":"linear"),r.coords={x1:n.x1,y1:n.y1,x2:n.x2,y2:n.y2};if(n.r1||n.r2)r.coords.r1=n.r1,r.coords.r2=n.r2;for(var i in n.colorStops){var s=new t.Color(n.colorStops[i]);r.colorStops.push({offset:i,color:s.toRgb(),opacity:s.getAlpha()})}this.set(e,t.Gradient.forObject(this,r))},setPatternFill:function(e){return this.set("fill",new t.Pattern(e))},setShadow:function(e){return this.set("shadow",new t.Shadow(e))},animate:function(){if(arguments[0]&&typeof arguments[0]=="object"){var e=[],t,n;for(t in arguments[0])e.push(t);for(var r=0,i=e.length;re.x&&i.xe.y&&s.y1?this.strokeWidth:0,n=this.padding,r=e(this.angle);this.currentWidth=(this.width+t)*this.scaleX+n*2,this.currentHeight=(this.height+t)*this.scaleY+n*2,this.currentWidth<0&&(this.currentWidth=Math.abs(this.currentWidth));var i=Math.sqrt(Math.pow(this.currentWidth/2,2)+Math.pow(this.currentHeight/2,2)),s=Math.atan(this.currentHeight/this.currentWidth),o=Math.cos(s+r)*i,u=Math.sin(s+r)*i,a=Math.sin(r),f=Math.cos(r),l=this.getCenterPoint(),c={x:l.x-o,y:l.y-u},h={x:c.x+this.currentWidth*f,y:c.y+this.currentWidth*a},p={x:h.x-this.currentHeight*a,y:h.y+this.currentHeight*f},d={x:c.x-this.currentHeight*a,y:c.y+this.currentHeight*f},v={x:c.x-this.currentHeight/2*a,y:c.y+this.currentHeight/2*f},m={x:c.x+this.currentWidth/2*f,y:c.y+this.currentWidth/2*a},g={x:h.x-this.currentHeight/2*a,y:h.y+this.currentHeight/2*f},y={x:d.x+this.currentWidth/2*f,y:d.y+this.currentWidth/2*a},b={x:c.x+this.currentWidth/2*f,y:c.y+this.currentWidth/2*a};return this.oCoords={tl:c,tr:h,br:p,bl:d,ml:v,mt:m,mr:g,mb:y,mtr:b},this._setCornerCoords(),this}})}(),function(){var e=fabric.util.getPointer,t=fabric.util.degreesToRadians;fabric.util.object.extend(fabric.Object.prototype,{_findTargetCorner:function(t,n){if(!this.hasControls||!this.active)return!1;var r=e(t,this.canvas.upperCanvasEl),i=r.x-n.left,s=r.y-n.top,o,u;for(var a in this.oCoords){if(a==="mtr"&&!this.hasRotatingPoint)continue;if(!(!this.get("lockUniScaling")||a!=="mt"&&a!=="mr"&&a!=="mb"&&a!=="ml"))continue;u=this._getImageLines(this.oCoords[a].corner,a),o=this._findCrossPoints(i,s,u);if(o%2===1&&o!==0)return this.__corner=a,a}return!1},_findCrossPoints:function(e,t,n){var r,i,s,o,u,a,f=0,l;for(var c in n){l=n[c];if(l.o.y=t&&l.d.y>=t)continue;l.o.x===l.d.x&&l.o.x>=e?(u=l.o.x,a=t):(r=0,i=(l.d.y-l.o.y)/(l.d.x-l.o.x),s=t-r*e,o=l.o.y-i*l.o.x,u=-(s-o)/(r-i),a=s+r*u),u>=e&&(f+=1);if(f===2)break}return f},_getImageLines:function(e){return{topline:{o:e.tl,d:e.tr},rightline:{o:e.tr,d:e.br},bottomline:{o:e.br,d:e.bl},leftline:{o:e.bl,d:e.tl}}},_setCornerCoords:function(){var e=this.oCoords,n=t(this.angle),r=t(45-this.angle),i=Math.sqrt(2*Math.pow(this.cornerSize,2))/2,s=i*Math.cos(r),o=i*Math.sin(r),u=Math.sin(n),a=Math.cos(n);e.tl.corner={tl:{x:e.tl.x-o,y:e.tl.y-s},tr:{x:e.tl.x+s,y:e.tl.y-o},bl:{x:e.tl.x-s,y:e.tl.y+o},br:{x:e.tl.x+o,y:e.tl.y+s}},e.tr.corner={tl:{x:e.tr.x-o,y:e.tr.y-s},tr:{x:e.tr.x+s,y:e.tr.y-o},br:{x:e.tr.x+o,y:e.tr.y+s},bl:{x:e.tr.x-s,y:e.tr.y+o}},e.bl.corner={tl:{x:e.bl.x-o,y:e.bl.y-s},bl:{x:e.bl.x-s,y:e.bl.y+o},br:{x:e.bl.x+o,y:e.bl.y+s},tr:{x:e.bl.x+s,y:e.bl.y-o}},e.br.corner={tr:{x:e.br.x+s,y:e.br.y-o},bl:{x:e.br.x-s,y:e.br.y+o},br:{x:e.br.x+o,y:e.br.y+s},tl:{x:e.br.x-o,y:e.br.y-s}},e.ml.corner={tl:{x:e.ml.x-o,y:e.ml.y-s},tr:{x:e.ml.x+s,y:e.ml.y-o},bl:{x:e.ml.x-s,y:e.ml.y+o},br:{x:e.ml.x+o,y:e.ml.y+s}},e.mt.corner={tl:{x:e.mt.x-o,y:e.mt.y-s},tr:{x:e.mt.x+s,y:e.mt.y-o},bl:{x:e.mt.x-s,y:e.mt.y+o},br:{x:e.mt.x+o,y:e.mt.y+s}},e.mr.corner={tl:{x:e.mr.x-o,y:e.mr.y-s},tr:{x:e.mr.x+s,y:e.mr.y-o},bl:{x:e.mr.x-s,y:e.mr.y+o},br:{x:e.mr.x+o,y:e.mr.y+s}},e.mb.corner={tl:{x:e.mb.x-o,y:e.mb.y-s},tr:{x:e.mb.x+s,y:e.mb.y-o},bl:{x:e.mb.x-s,y:e.mb.y+o},br:{x:e.mb.x+o,y:e.mb.y+s}},e.mtr.corner={tl:{x:e.mtr.x-o+u*this.rotatingPointOffset,y:e.mtr.y-s-a*this.rotatingPointOffset},tr:{x:e.mtr.x+s+u*this.rotatingPointOffset,y:e.mtr.y-o-a*this.rotatingPointOffset},bl:{x:e.mtr.x-s+u*this.rotatingPointOffset,y:e.mtr.y+o-a*this.rotatingPointOffset},br:{x:e.mtr.x+o+u*this.rotatingPointOffset,y:e.mtr.y+s-a*this.rotatingPointOffset}}},drawBorders:function(e){if(!this.hasBorders)return this;var t=this.padding,n=t*2,r=this.strokeWidth>1?this.strokeWidth:0;e.save(),e.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1,e.strokeStyle=this.borderColor;var i=1/this._constrainScale(this.scaleX),s=1/this._constrainScale(this.scaleY);e.lineWidth=1/this.borderScaleFactor,e.scale(i,s);var o=this.getWidth(),u=this.getHeight();e.strokeRect(~~(-(o/2)-t-r/2*this.scaleX)+.5,~~(-(u/2)-t-r/2*this.scaleY)+.5,~~(o+n+r*this.scaleX),~~(u+n+r*this.scaleY));if(this.hasRotatingPoint&&!this.get("lockRotation")&&this.hasControls){var a=(this.flipY?u+r*this.scaleY+t*2:-u-r*this.scaleY-t*2)/2;e.beginPath(),e.moveTo(0,a),e.lineTo(0,a+(this.flipY?this.rotatingPointOffset:-this.rotatingPointOffset)),e.closePath(),e.stroke()}return e.restore(),this},drawControls:function(e){if(!this.hasControls)return this;var t=this.cornerSize,n=t/2,r=this.strokeWidth/2,i=-(this.width/2),s=-(this.height/2),o,u,a=t/this.scaleX,f=t/this.scaleY,l=this.padding/this.scaleX,c=this.padding/this.scaleY,h=n/this.scaleY,p=n/this.scaleX,d=(n-t)/this.scaleX,v=(n-t)/this.scaleY,m=this.height,g=this.width,y=this.transparentCorners?"strokeRect":"fillRect",b=typeof G_vmlCanvasManager!="undefined";return e.save(),e.lineWidth=1/Math.max(this.scaleX,this.scaleY),e.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1,e.strokeStyle=e.fillStyle=this.cornerColor,o=i-p-r-l,u=s-h-r-c,b||e.clearRect(o,u,a,f),e[y](o,u,a,f),o=i+g-p+r+l,u=s-h-r-c,b||e.clearRect(o,u,a,f),e[y](o,u,a,f),o=i-p-r-l,u=s+m+v+r+c,b||e.clearRect(o,u,a,f),e[y](o,u,a,f),o=i+g+d+r+l,u=s+m+v+r+c,b||e.clearRect(o,u,a,f),e[y](o,u,a,f),this.get("lockUniScaling")||(o=i+g/2-p,u=s-h-r-c,b||e.clearRect(o,u,a,f),e[y](o,u,a,f),o=i+g/2-p,u=s+m+v+r+c,b||e.clearRect(o,u,a,f),e[y](o,u,a,f),o=i+g+d+r+l,u=s+m/2-h,b||e.clearRect(o,u,a,f),e[y](o,u,a,f),o=i-p-r-l,u=s+m/2-h,b||e.clearRect(o,u,a,f),e[y](o,u,a,f)),this.hasRotatingPoint&&(o=i+g/2-p,u=this.flipY?s+m+this.rotatingPointOffset/this.scaleY-f/2+r+c:s-this.rotatingPointOffset/this.scaleY-f/2-r-c,b||e.clearRect(o,u,a,f),e[y](o,u,a,f)),e.restore(),this}})}(),function(e){"use strict";var t=e.fabric||(e.fabric={}),n=t.util.object.extend,r={x1:1,x2:1,y1:1,y2:1};if(t.Line){t.warn("fabric.Line is already defined");return}t.Line=t.util.createClass(t.Object,{type:"line",initialize:function(e,t){t=t||{},e||(e=[0,0,0,0]),this.callSuper("initialize",t),this.set("x1",e[0]),this.set("y1",e[1]),this.set("x2",e[2]),this.set("y2",e[3]),this._setWidthHeight(t)},_setWidthHeight:function(e){e||(e={}),this.set("width",this.x2-this.x1||1),this.set("height",this.y2-this.y1||1),this.set("left","left"in e?e.left:this.x1+this.width/2),this.set("top","top"in e?e.top:this.y1+this.height/2)},_set:function(e,t){return this[e]=t,e in r&&this._setWidthHeight(),this},_render:function(e){e.beginPath();var t=this.group&&this.group.type!=="group";t&&!this.transformMatrix?e.translate(-this.group.width/2+this.left,-this.group.height/2+this.top):e.translate(this.left,this.top),e.moveTo(this.width===1?0:-this.width/2,this.height===1?0:-this.height/2),e.lineTo(this.width===1?0:this.width/2,this.height===1?0:this.height/2),e.lineWidth=this.strokeWidth;var n=e.strokeStyle;e.strokeStyle=this.stroke||e.fillStyle,e.stroke(),e.strokeStyle=n},complexity:function(){return 1},toObject:function(e){return n(this.callSuper("toObject",e),{x1:this.get("x1"),y1:this.get("y1"),x2:this.get("x2"),y2:this.get("y2")})},toSVG:function(){var e=[];return this.stroke&&this.stroke.toLive&&e.push(this.stroke.toSVG(this,!0)),e.push("'),e.join("")}}),t.Line.ATTRIBUTE_NAMES="x1 y1 x2 y2 stroke stroke-width transform".split(" "),t.Line.fromElement=function(e,r){var i=t.parseAttributes(e,t.Line.ATTRIBUTE_NAMES),s=[i.x1||0,i.y1||0,i.x2||0,i.y2||0];return new t.Line(s,n(i,r))},t.Line.fromObject=function(e){var n=[e.x1,e.y1,e.x2,e.y2];return new t.Line(n,e)}}(typeof exports!="undefined"?exports:this),function(e){"use strict";function i(e){return"radius"in e&&e.radius>0}var t=e.fabric||(e.fabric={}),n=Math.PI*2,r=t.util.object.extend;if(t.Circle){t.warn("fabric.Circle is already defined.");return}t.Circle=t.util.createClass(t.Object,{type:"circle",initialize:function(e){e=e||{},this.set("radius",e.radius||0),this.callSuper("initialize",e);var t=this.get("radius")*2;this.set("width",t).set("height",t)},toObject:function(e){return r(this.callSuper("toObject",e),{radius:this.get("radius")})},toSVG:function(){var e=[];return this.fill&&this.fill.toLive&&e.push(this.fill.toSVG(this,!1)),this.stroke&&this.stroke.toLive&&e.push(this.stroke.toSVG(this,!1)),e.push("'),e.join("")},_render:function(e,t){e.beginPath(),e.globalAlpha=this.group?e.globalAlpha*this.opacity:this.opacity,e.arc(t?this.left:0,t?this.top:0,this.radius,0,n,!1),e.closePath(),this._renderFill(e),this._removeShadow(e),this.stroke&&e.stroke()},getRadiusX:function(){return this.get("radius")*this.get("scaleX")},getRadiusY:function(){return this.get("radius")*this.get("scaleY")},setRadius:function(e){this.radius=e,this.set("width",e*2).set("height",e*2)},complexity:function(){return 1}}),t.Circle.ATTRIBUTE_NAMES="cx cy r fill fill-opacity opacity stroke stroke-width transform".split(" "),t.Circle.fromElement=function(e,n){n||(n={});var s=t.parseAttributes(e,t.Circle.ATTRIBUTE_NAMES);if(!i(s))throw new Error("value of `r` attribute is required and can not be negative");"left"in s&&(s.left-=n.width/2||0),"top"in s&&(s.top-=n.height/2||0);var o=new t.Circle(r(s,n));return o.cx=parseFloat(e.getAttribute("cx"))||0,o.cy=parseFloat(e.getAttribute("cy"))||0,o},t.Circle.fromObject=function(e){return new t.Circle(e)}}(typeof exports!="undefined"?exports:this),function(e){"use strict";var t=e.fabric||(e.fabric={});if(t.Triangle){t.warn("fabric.Triangle is already defined");return}t.Triangle=t.util.createClass(t.Object,{type:"triangle",initialize:function(e){e=e||{},this.callSuper("initialize",e),this.set("width",e.width||100).set("height",e.height||100)},_render:function(e){var t=this.width/2,n=this.height/2;e.beginPath(),e.moveTo(-t,n),e.lineTo(0,-n),e.lineTo(t,n),e.closePath(),this._renderFill(e),this.stroke&&e.stroke()},complexity:function(){return 1},toSVG:function(){var e=[],t=this.width/2,n=this.height/2,r=[-t+" "+n,"0 "+ -n,t+" "+n].join(",");return this.fill&&this.fill.toLive&&e.push(this.fill.toSVG(this,!0)),this.stroke&&this.stroke.toLive&&e.push(this.stroke.toSVG(this,!0)),e.push("'),e.join("")}}),t.Triangle.fromObject=function(e){return new t.Triangle(e)}}(typeof exports!="undefined"?exports:this),function(e){"use strict";var t=e.fabric||(e.fabric={}),n=Math.PI*2,r=t.util.object.extend;if(t.Ellipse){t.warn("fabric.Ellipse is already defined.");return}t.Ellipse=t.util.createClass(t.Object,{type:"ellipse",rx:0,ry:0,initialize:function(e){e=e||{},this.callSuper("initialize",e),this.set("rx",e.rx||0),this.set("ry",e.ry||0),this.set("width",this.get("rx")*2),this.set("height",this.get("ry")*2)},toObject:function(e){return r(this.callSuper("toObject",e),{rx:this.get("rx"),ry:this.get("ry")})},toSVG:function(){var e=[];return this.fill&&this.fill.toLive&&e.push(this.fill.toSVG(this,!1)),this.stroke&&this.stroke.toLive&&e.push(this.stroke.toSVG(this,!1)),e.push("'),e.join("")},render:function(e,t){if(this.rx===0||this.ry===0)return;return this.callSuper("render",e,t)},_render:function(e,t){e.beginPath(),e.save(),e.globalAlpha=this.group?e.globalAlpha*this.opacity:this.opacity,this.transformMatrix&&this.group&&e.translate(this.cx,this.cy),e.transform(1,0,0,this.ry/this.rx,0,0),e.arc(t?this.left:0,t?this.top:0,this.rx,0,n,!1),this.stroke&&e.stroke(),this._removeShadow(e),this._renderFill(e),e.restore()},complexity:function(){return 1}}),t.Ellipse.ATTRIBUTE_NAMES="cx cy rx ry fill fill-opacity opacity stroke stroke-width transform".split(" "),t.Ellipse.fromElement=function(e,n){n||(n={});var i=t.parseAttributes(e,t.Ellipse.ATTRIBUTE_NAMES),s=i.left,o=i.top;"left"in i&&(i.left-=n.width/2||0),"top"in i&&(i.top-=n.height/2||0);var u=new t.Ellipse(r(i,n));return u.cx=s||0,u.cy=o||0,u},t.Ellipse.fromObject=function(e){return new t.Ellipse(e)}}(typeof exports!="undefined"?exports:this),function(e){"use strict";function r(e){return e.left=e.left||0,e.top=e.top||0,e}var t=e.fabric||(e.fabric={}),n=t.util.object.extend;if(t.Rect){console.warn("fabric.Rect is already defined");return}t.Rect=t.util.createClass(t.Object,{type:"rect",rx:0,ry:0,strokeDashArray:null,initialize:function(e){e=e||{},this._initStateProperties(),this.callSuper("initialize",e),this._initRxRy(),this.x=0,this.y=0},_initStateProperties:function(){this.stateProperties=this.stateProperties.concat(["rx","ry"])},_initRxRy:function(){this.rx&&!this.ry?this.ry=this.rx:this.ry&&!this.rx&&(this.rx=this.ry)},_render:function(e){var t=this.rx||0,n=this.ry||0,r=-this.width/2,i=-this.height/2,s=this.width,o=this.height,u=this.group&&this.group.type!=="group";e.beginPath(),e.globalAlpha=u?e.globalAlpha*this.opacity:this.opacity,this.transformMatrix&&u&&e.translate(this.width/2+this.x,this.height/2+this.y),!this.transformMatrix&&u&&e.translate(-this.group.width/2+this.width/2+this.x,-this.group.height/2+this.height/2+this.y),e.moveTo(r+t,i),e.lineTo(r+s-t,i),e.quadraticCurveTo(r+s,i,r+s,i+n,r+s,i+n),e.lineTo(r+s,i+o-n),e.quadraticCurveTo(r+s,i+o,r+s-t,i+o,r+s-t,i+o),e.lineTo(r+t,i+o),e.quadraticCurveTo(r,i+o,r,i+o-n,r,i+o-n),e.lineTo(r,i+n),e.quadraticCurveTo(r,i,r+t,i,r+t,i),e.closePath(),this._renderFill(e),this._removeShadow(e),this.strokeDashArray?this._renderDashedStroke(e):this.stroke&&e.stroke()},_renderDashedStroke:function(e){function u(u,a){var f=0,l=0,c=(a?i.height:i.width)+s*2;while(fc&&(l=f-c),u?n+=h*u-(l*u||0):r+=h*a-(l*a||0),e[1&t?"moveTo":"lineTo"](n,r),t>=o&&(t=0)}}1&this.strokeDashArray.length&&this.strokeDashArray.push.apply(this.strokeDashArray,this.strokeDashArray);var t=0,n=-this.width/2,r=-this.height/2,i=this,s=this.padding,o=this.strokeDashArray.length;e.save(),e.beginPath(),u(1,0),u(0,1),u(-1,0),u(0,-1),e.stroke(),e.closePath(),e.restore()},_normalizeLeftTopProperties:function(e){return"left"in e&&this.set("left",e.left+this.getWidth()/2),this.set("x",e.left||0),"top"in e&&this.set("top",e.top+this.getHeight()/2),this.set("y",e.top||0),this},complexity:function(){return 1},toObject:function(e){return n(this.callSuper("toObject",e),{rx:this.get("rx")||0,ry:this.get("ry")||0})},toSVG:function(){var e=[];return this.fill&&this.fill.toLive&&e.push(this.fill.toSVG(this,!1)),this.stroke&&this.stroke.toLive&&e.push(this.stroke.toSVG(this,!1)),e.push("'),e.join("")}}),t.Rect.ATTRIBUTE_NAMES="x y width height rx ry fill fill-opacity opacity stroke stroke-width transform".split(" "),t.Rect.fromElement=function(e,i){if(!e)return null;var s=t.parseAttributes(e,t.Rect.ATTRIBUTE_NAMES);s=r(s);var o=new t.Rect(n(i?t.util.object.clone(i):{},s));return o._normalizeLeftTopProperties(s),o},t.Rect.fromObject=function(e){return new t.Rect(e)}}(typeof exports!="undefined"?exports:this),function(e){"use strict";var t=e.fabric||(e.fabric={}),n=t.util.toFixed;if(t.Polyline){t.warn("fabric.Polyline is already defined");return}t.Polyline=t.util.createClass(t.Object,{type:"polyline",initialize:function(e,t,n){t=t||{},this.set("points",e),this.callSuper("initialize",t),this._calcDimensions(n)},_calcDimensions:function(e){return t.Polygon.prototype._calcDimensions.call(this,e)},toObject:function(e){return t.Polygon.prototype.toObject.call(this,e)},toSVG:function(){var e=[],t=[];for(var r=0,i=this.points.length;r'),t.join("")},_render:function(e){var t;e.beginPath(),e.moveTo(this.points[0].x,this.points[0].y);for(var n=0,r=this.points.length;n'),t.join("")},_render:function(e){var t;e.beginPath(),e.moveTo(this.points[0].x,this.points[0].y);for(var n=0,r=this.points.length;n1&&(g=Math.sqrt(g),n*=g,i*=g);var y=d/n,b=p/n,w=-p/i,E=d/i,S=y*l+b*c,x=w*l+E*c,T=y*e+b*t,N=w*e+E*t,C=(T-S)*(T-S)+(N-x)*(N-x),k=1/C-.25;k<0&&(k=0);var L=Math.sqrt(k);a===u&&(L=-L);var A=.5*(S+T)-L*(N-x),O=.5*(x+N)+L*(T-S),M=Math.atan2(x-O,S-A),_=Math.atan2(N-O,T-A),D=_-M;D<0&&a===1?D+=2*Math.PI:D>0&&a===0&&(D-=2*Math.PI);var P=Math.ceil(Math.abs(D/(Math.PI*.5+.001))),H=[];for(var B=0;B"},toObject:function(e){var t=h(this.callSuper("toObject",e),{path:this.path});return this.sourcePath&&(t.sourcePath=this.sourcePath),this.transformMatrix&&(t.transformMatrix=this.transformMatrix),t},toDatalessObject:function(e){var t=this.toObject(e);return this.sourcePath&&(t.path=this.sourcePath),delete t.sourcePath,t},toSVG:function(){var e=[],t=[];for(var n=0,r=this.path.length;n',"",""),t.join("")},complexity:function(){return this.path.length},_parsePath:function(){var e=[],n,r,i;for(var s=0,o,u=this.path.length;sc)for(var h=1,p=o.length;h"];for(var n=0,r=e.length;n"),t.join("")},toString:function(){return"#"},isSameColor:function(){var e=this.getObjects()[0].get("fill");return this.getObjects().every(function(t){return t.get("fill")===e})},complexity:function(){return this.paths.reduce(function(e,t){return e+(t&&t.complexity?t.complexity():0)},0)},toGrayscale:function(){var e=this.paths.length;while(e--)this.paths[e].toGrayscale();return this},getObjects:function(){return this.paths}}),t.PathGroup.fromObject=function(e){var n=u(e.paths);return new t.PathGroup(n,e)}}(typeof exports!="undefined"?exports:this),function(e){"use strict";var t=e.fabric||(e.fabric={}),n=t.util.object.extend,r=t.util.array.min,i=t.util.array.max,s=t.util.array.invoke;if(t.Group)return;var o={lockMovementX:!0,lockMovementY:!0,lockRotation:!0,lockScalingX:!0,lockScalingY:!0,lockUniScaling:!0};t.Group=t.util.createClass(t.Object,t.Collection,{type:"group",initialize:function(e,t){t=t||{},this._objects=e||[];for(var r=this._objects.length;r--;)this._objects[r].group=this;this.originalState={},this.callSuper("initialize"),this._calcBounds(),this._updateObjectsCoords(),t&&n(this,t),this._setOpacityIfSame(),this.setCoords(!0),this.saveCoords()},_updateObjectsCoords:function(){var e=this.left,t=this.top;this.forEachObject(function(n){var r=n.get("left"),i=n.get("top");n.set("originalLeft",r),n.set("originalTop",i),n.set("left",r-e),n.set("top",i-t),n.setCoords(),n.__origHasControls=n.hasControls,n.hasControls=!1},this)},toString:function(){return"#"},getObjects:function(){return this._objects},addWithUpdate:function(e){return this._restoreObjectsState(),this._objects.push(e),e.group=this,this.forEachObject(function(e){e.set("active",!0),e.group=this},this),this._calcBounds(),this._updateObjectsCoords(),this},removeWithUpdate:function(e){return this._restoreObjectsState(),this.forEachObject(function(e){e.set("active",!0),e.group=this},this),this.remove(e),this._calcBounds(),this._updateObjectsCoords(),this},_onObjectAdded:function(e){e.group=this},_onObjectRemoved:function(e){delete e.group,e.set("active",!1)},delegatedProperties:{fill:!0,opacity:!0,fontFamily:!0,fontWeight:!0,fontSize:!0,fontStyle:!0,lineHeight:!0,textDecoration:!0,textShadow:!0,textAlign:!0,backgroundColor:!0},_set:function(e,t){if(e in this.delegatedProperties){var n=this._objects.length;this[e]=t;while(n--)this._objects[n].set(e,t)}else this[e]=t},toObject:function(e){return n(this.callSuper("toObject",e),{objects:s(this._objects,"toObject",e)})},render:function(e,n){if(!this.visible)return;e.save(),this.transform(e);var r=Math.max(this.scaleX,this.scaleY);this.clipTo&&t.util.clipContext(this,e);for(var i=0,s=this._objects.length;ie.x&&i-ne.y},toSVG:function(){var e=[];for(var t=this._objects.length;t--;)e.push(this._objects[t].toSVG());return''+e.join("")+""},get:function(e){if(e in o){if(this[e])return this[e];for(var t=0,n=this._objects.length;t'+'"+""},getSrc:function(){return this.getElement().src||this.getElement()._src},toString:function(){return'#'},clone:function(e,t){this.constructor.fromObject(this.toObject(t),e)},applyFilters:function(e){if(this.filters.length===0){this.setElement(this._originalImage),e&&e();return}var t=typeof Buffer!="undefined"&&typeof window=="undefined",n=this._originalImage,r=fabric.util.createCanvasElement(),i=t?new(require("canvas").Image):fabric.document.createElement("img"),s=this;r.width=n.width,r.height=n.height,r.getContext("2d").drawImage(n,0,0,n.width,n.height),this.filters.forEach(function(e){e&&e.applyTo(r)}),i.onload=function(){s._element=i,e&&e(),i.onload=r=n=null},i.width=n.width,i.height=n.height;if(t){var o=r.toDataURL("image/png").substring(22);i.src=new Buffer(o,"base64"),s._element=i,e&&e()}else i.src=r.toDataURL("image/png");return this},_render:function(e){e.drawImage(this._element,-this.width/2,-this.height/2,this.width,this.height)},_resetWidthHeight:function(){var e=this.getElement();this.set("width",e.width),this.set("height",e.height)},_initElement:function(e){this.setElement(fabric.util.getById(e)),fabric.util.addClass(this.getElement(),fabric.Image.CSS_CANVAS)},_initConfig:function(e){e||(e={}),this.setOptions(e),this._setWidthHeight(e)},_initFilters:function(e){e.filters&&e.filters.length&&(this.filters=e.filters.map(function(e){return e&&fabric.Image.filters[e.type].fromObject(e)}))},_setWidthHeight:function(e){this.width="width"in e?e.width:this.getElement().width||0,this.height="height"in e?e.height:this.getElement().height||0},complexity:function(){return 1}}),fabric.Image.CSS_CANVAS="canvas-img",fabric.Image.prototype.getSvgSrc=fabric.Image.prototype.getSrc,fabric.Image.fromObject=function(e,t){var n=fabric.document.createElement("img"),r=e.src;e.width&&(n.width=e.width),e.height&&(n.height=e.height),n.onload=function(){fabric.Image.prototype._initFilters.call(e,e);var r=new fabric.Image(n,e);t&&t(r),n=n.onload=n.onerror=null},n.onerror=function(){fabric.log("Error loading "+n.src),t&&t(null,!0),n=n.onload=n.onerror=null},n.src=r},fabric.Image.fromURL=function(e,t,n){fabric.util.loadImage(e,function(e){t(new fabric.Image(e,n))})},fabric.Image.ATTRIBUTE_NAMES="x y width height fill fill-opacity opacity stroke stroke-width transform xlink:href".split(" "),fabric.Image.fromElement=function(e,n,r){var i=fabric.parseAttributes(e,fabric.Image.ATTRIBUTE_NAMES);fabric.Image.fromURL(i["xlink:href"],n,t(r?fabric.util.object.clone(r):{},i))},fabric.Image.async=!0}(typeof exports!="undefined"?exports:this),fabric.util.object.extend(fabric.Object.prototype,{_getAngleValueForStraighten:function(){var e=this.getAngle()%360;return e>0?Math.round((e-1)/90)*90:Math.round(e/90)*90},straighten:function(){return this.setAngle(this._getAngleValueForStraighten()),this},fxStraighten:function(e){e=e||{};var t=function(){},n=e.onComplete||t,r=e.onChange||t,i=this;return fabric.util.animate({startValue:this.get("angle"),endValue:this._getAngleValueForStraighten(),duration:this.FX_DURATION,onChange:function(e){i.setAngle(e),r()},onComplete:function(){i.setCoords(),n()},onStart:function(){i.set("active",!1)}}),this}}),fabric.util.object.extend(fabric.StaticCanvas.prototype,{straightenObject:function(e){return e.straighten(),this.renderAll(),this},fxStraightenObject:function(e){return e.fxStraighten({onChange:this.renderAll.bind(this)}),this}}),fabric.Image.filters={},fabric.Image.filters.Grayscale=fabric.util.createClass({type:"Grayscale",applyTo:function(e){var t=e.getContext("2d"),n=t.getImageData(0,0,e.width,e.height),r=n.data,i=n.width,s=n.height,o,u,a,f;for(a=0;ao&&f>o&&l>o&&u(a-f)0&&(r[s]=a,r[s+1]=f,r[s+2]=l);t.putImageData(n,0,0)},toJSON:function(){return{type:this.type,color:this.color}}}),fabric.Image.filters.Tint.fromObject=function(e){return new fabric.Image.filters.Tint(e)},fabric.Image.filters.Convolute=fabric.util.createClass({type:"Convolute",initialize:function(e){e||(e={}),this.opaque=e.opaque,this.matrix=e.matrix||[0,0,0,0,1,0,0,0,0];var t=fabric.util.createCanvasElement();this.tmpCtx=t.getContext("2d")},_createImageData:function(e,t){return this.tmpCtx.createImageData(e,t)},applyTo:function(e){var t=this.matrix,n=e.getContext("2d"),r=n.getImageData(0,0,e.width,e.height),i=Math.round(Math.sqrt(t.length)),s=Math.floor(i/2),o=r.data,u=r.width,a=r.height,f=u,l=a,c=this._createImageData(f,l),h=c.data,p=this.opaque?1:0;for(var d=0;d=0&&N=0&&C'},_render:function(e){var t=this.group&&this.group.type!=="group";t&&!this.transformMatrix?e.translate(-this.group.width/2+this.left,-this.group.height/2+this.top):t&&this.transformMatrix&&e.translate(-this.group.width/2,-this.group.height/2),typeof Cufon=="undefined"||this.useNative===!0?this._renderViaNative(e):this._renderViaCufon(e)},_renderViaCufon:function(e){var t=Cufon.textOptions||(Cufon.textOptions={});t.left=this.left,t.top=this.top,t.context=e,t.color=this.fill;var n=this._initDummyElementForCufon();this.transform(e),Cufon.replaceElement(n,{engine:"canvas",separate:"none",fontFamily:this.fontFamily,fontWeight:this.fontWeight,textDecoration:this.textDecoration,textShadow:this.textShadow,textAlign:this.textAlign,fontStyle:this.fontStyle,lineHeight:this.lineHeight,stroke:this.stroke,strokeWidth:this.strokeWidth,backgroundColor:this.backgroundColor,textBackgroundColor:this.textBackgroundColor}),this.width=t.width,this.height=t.height,this._totalLineHeight=t.totalLineHeight,this._fontAscent=t.fontAscent,this._boundaries=t.boundaries,this._shadowOffsets=t.shadowOffsets,this._shadows=t.shadows||[],n=null,this.setCoords()},_renderViaNative:function(e){this.originX==="left"?e.translate(this.left,this.top):this.transform(e),this._setTextStyles(e);var n=this.text.split(/\r?\n/);this.width=this._getTextWidth(e,n),this.height=this._getTextHeight(e,n),this._renderTextBackground(e,n),this.textAlign!=="left"&&this.textAlign!=="justify"&&(e.save(),e.translate(this.textAlign==="center"?this.width/2:this.width,0)),this._setTextShadow(e),this.clipTo&&t.util.clipContext(this,e),this._renderTextFill(e,n),this._renderTextStroke(e,n),this.clipTo&&e.restore(),this.textShadow&&e.restore(),this.textAlign!=="left"&&this.textAlign!=="justify"&&e.restore(),this._renderTextDecoration(e,n),this._setBoundaries(e,n),this._totalLineHeight=0,this.setCoords()},_setBoundaries:function(e,t){this._boundaries=[];for(var n=0,r=t.length;nn&&(n=s)}return n},_setTextShadow:function(e){if(this.textShadow){var t=/\s+(-?\d+)(?:px)?\s+(-?\d+)(?:px)?\s+(\d+)(?:px)?\s*/,n=this.textShadow,r=t.exec(this.textShadow),i=n.replace(t,"");e.save(),e.shadowColor=i,e.shadowOffsetX=parseInt(r[1],10),e.shadowOffsetY=parseInt(r[2],10),e.shadowBlur=parseInt(r[3],10),this._shadows=[{blur:e.shadowBlur,color:e.shadowColor,offX:e.shadowOffsetX,offY:e.shadowOffsetY}],this._shadowOffsets=[[parseInt(e.shadowOffsetX,10),parseInt(e.shadowOffsetY,10)]]}},_drawTextLine:function(e,t,n,r,i){if(this.textAlign!=="justify"){t[e](n,r,i);return}var s=t.measureText(n).width,o=this.width;if(o>s){var u=n.split(/\s+/ +),a=t.measureText(n.replace(/\s+/g,"")).width,f=o-a,l=u.length-1,c=f/l,h=0;for(var p=0,d=u.length;p-1&&i(this.fontSize),this.textDecoration.indexOf("line-through")>-1&&i(this.fontSize/2),this.textDecoration.indexOf("overline")>-1&&i(0)},_getFontDeclaration:function(){return[t.isLikelyNode?this.fontWeight:this.fontStyle,t.isLikelyNode?this.fontStyle:this.fontWeight,this.fontSize+"px",t.isLikelyNode?'"'+this.fontFamily+'"':this.fontFamily].join(" ")},_initDummyElementForCufon:function(){var e=t.document.createElement("pre"),n=t.document.createElement("div");return n.appendChild(e),typeof G_vmlCanvasManager=="undefined"?e.innerHTML=this.text:e.innerText=this.text.replace(/\r?\n/gi,"\r"),e.style.fontSize=this.fontSize+"px",e.style.letterSpacing="normal",e},render:function(e,t){if(!this.visible)return;e.save(),this._render(e),!t&&this.active&&(this.drawBorders(e),this.drawControls(e)),e.restore()},toObject:function(e){return n(this.callSuper("toObject",e),{text:this.text,fontSize:this.fontSize,fontWeight:this.fontWeight,fontFamily:this.fontFamily,fontStyle:this.fontStyle,lineHeight:this.lineHeight,textDecoration:this.textDecoration,textShadow:this.textShadow,textAlign:this.textAlign,path:this.path,stroke:this.stroke,strokeWidth:this.strokeWidth,backgroundColor:this.backgroundColor,textBackgroundColor:this.textBackgroundColor,useNative:this.useNative})},toSVG:function(){var e=this.text.split(/\r?\n/),t=this.useNative?this.fontSize*this.lineHeight:-this._fontAscent-this._fontAscent/5*this.lineHeight,n=-(this.width/2),r=this.useNative?this.fontSize-1:this.height/2-e.length*this.fontSize-this._totalLineHeight,s=this._getSVGTextAndBg(t,n,e),o=this._getSVGShadows(t,e);return r+=this._fontAscent?this._fontAscent/5*this.lineHeight:0,['',s.textBgRects.join(""),"',o.join(""),s.textSpans.join(""),"",""].join("")},_getSVGShadows:function(e,n){var r=[],s,o,u,a,f=1;if(!this._shadows||!this._boundaries)return r;for(s=0,u=this._shadows.length;s",t.util.string.escapeXml(n[o]),""),f=1}else f++;return r},_getSVGTextAndBg:function(e,n,r){var s=[],o=[],u,a,f,l=1;this.backgroundColor&&this._boundaries&&o.push("');for(u=0,f=r.length;u",t.util.string.escapeXml(r[u]),""),l=1):l++;if(!this.textBackgroundColor||!this._boundaries)continue;o.push("')}return{textSpans:s,textBgRects:o}},_getFillAttributes:function(e){var n=e&&typeof e=="string"?new t.Color(e):"";return!n||!n.getSource()||n.getAlpha()===1?'fill="'+e+'"':'opacity="'+n.getAlpha()+'" fill="'+n.setAlpha(1).toRgb()+'"'},setColor:function(e){return this.set("fill",e),this},getText:function(){return this.text},_set:function(e,t){e==="fontFamily"&&this.path&&(this.path=this.path.replace(/(.*?)([^\/]*)(\.font\.js)/,"$1"+t+"$3")),this.callSuper("_set",e,t),e in s&&(this._initDimensions(),this.setCoords())}}),t.Text.ATTRIBUTE_NAMES="x y fill fill-opacity opacity stroke stroke-width transform font-family font-style font-weight font-size text-decoration".split(" "),t.Text.fromObject=function(e){return new t.Text(e.text,r(e))},t.Text.fromElement=function(e,n){if(!e)return null;var r=t.parseAttributes(e,t.Text.ATTRIBUTE_NAMES);n=t.util.object.extend(n?t.util.object.clone(n):{},r);var i=new t.Text(e.textContent,n);return i.set({left:i.getLeft()+i.getWidth()/2,top:i.getTop()-i.getHeight()/2}),i},t.util.createAccessors(t.Text)}(typeof exports!="undefined"?exports:this),function(){function request(e,t,n){var r=URL.parse(e);r.port||(r.port=r.protocol.indexOf("https:")===0?443:80);var i=r.port===443?HTTPS:HTTP,s=i.request({hostname:r.hostname,port:r.port,path:r.pathname,method:"GET"},function(e){var r="";t&&e.setEncoding(t),e.on("end",function(){n(r)}),e.on("data",function(t){e.statusCode===200&&(r+=t)})});s.on("error",function(e){e.errno===process.ECONNREFUSED?fabric.log("ECONNREFUSED: connection refused to "+r.hostname+":"+r.port):fabric.log(e.message)}),s.end()}function request_fs(e,t){var n=require("fs"),r=n.createReadStream(e),i="";r.on("data",function(e){i+=e}),r.on("end",function(){t(i)})}if(typeof document!="undefined"&&typeof window!="undefined")return;var DOMParser=(new require("xmldom")).DOMParser,URL=require("url"),HTTP=require("http"),HTTPS=require("https"),Canvas=require("canvas"),Image=require("canvas").Image;fabric.util.loadImage=function(e,t,n){var r=function(r){i.src=new Buffer(r,"binary"),i._src=e,t&&t.call(n,i)},i=new Image;e&&e.indexOf("data")===0?(i.src=i._src=e,t&&t.call(n,i)):e&&e.indexOf("http")!==0?request_fs(e,r):e&&request(e,"binary",r)},fabric.loadSVGFromURL=function(e,t){e=e.replace(/^\n\s*/,"").replace(/\?.*$/,"").trim(),e.indexOf("http")!==0?request_fs(e,function(e){fabric.loadSVGFromString(e,t)}):request(e,"",function(e){fabric.loadSVGFromString(e,t)})},fabric.loadSVGFromString=function(e,t){var n=(new DOMParser).parseFromString(e);fabric.parseSVGDocument(n.documentElement,function(e,n){t(e,n)})},fabric.util.getScript=function(url,callback){request(url,"",function(body){eval(body),callback&&callback()})},fabric.Image.fromObject=function(e,t){fabric.util.loadImage(e.src,function(n){var r=new fabric.Image(n);r._initConfig(e),r._initFilters(e),t(r)})},fabric.createCanvasForNode=function(e,t){var n=fabric.document.createElement("canvas"),r=new Canvas(e||600,t||600);n.style={},n.width=r.width,n.height=r.height;var i=fabric.Canvas||fabric.StaticCanvas,s=new i(n);return s.contextContainer=r.getContext("2d"),s.nodeCanvas=r,s.Font=Canvas.Font,s},fabric.StaticCanvas.prototype.createPNGStream=function(){return this.nodeCanvas.createPNGStream()},fabric.StaticCanvas.prototype.createJPEGStream=function(e){return this.nodeCanvas.createJPEGStream(e)};var origSetWidth=fabric.StaticCanvas.prototype.setWidth;fabric.StaticCanvas.prototype.setWidth=function(e){return origSetWidth.call(this,e),this.nodeCanvas.width=e,this},fabric.Canvas&&(fabric.Canvas.prototype.setWidth=fabric.StaticCanvas.prototype.setWidth);var origSetHeight=fabric.StaticCanvas.prototype.setHeight;fabric.StaticCanvas.prototype.setHeight=function(e){return origSetHeight.call(this,e),this.nodeCanvas.height=e,this},fabric.Canvas&&(fabric.Canvas.prototype.setHeight=fabric.StaticCanvas.prototype.setHeight)}(); \ No newline at end of file diff --git a/dist/all.min.js.gz b/dist/all.min.js.gz index 8178b8d8..3856675c 100644 Binary files a/dist/all.min.js.gz and b/dist/all.min.js.gz differ diff --git a/src/base_brush.class.js b/src/base_brush.class.js index 7b723515..0e992961 100644 --- a/src/base_brush.class.js +++ b/src/base_brush.class.js @@ -2,53 +2,46 @@ * BaseBrush class * @class fabric.BaseBrush */ -fabric.BaseBrush = fabric.util.createClass({ +fabric.BaseBrush = fabric.util.createClass(/** @lends fabric.BaseBrush.prototype */ { /** * Color of a brush - * @property * @type String */ color: 'rgb(0, 0, 0)', /** * Width of a brush - * @property * @type Number */ width: 1, /** * Shadow blur of a brush - * @property * @type Number */ shadowBlur: 0, /** * Shadow color of a brush - * @property * @type String */ shadowColor: '', /** * Shadow offset x of a brush - * @property * @type Number */ shadowOffsetX: 0, /** * Shadow offset y of a brush - * @property * @type Number */ shadowOffsetY: 0, /** * Sets brush styles - * @method setBrushStyles */ setBrushStyles: function() { var ctx = this.canvas.contextTop; @@ -60,7 +53,6 @@ fabric.BaseBrush = fabric.util.createClass({ /** * Sets brush shadow styles - * @method setShadowStyles */ setShadowStyles: function() { var ctx = this.canvas.contextTop; @@ -70,4 +62,4 @@ fabric.BaseBrush = fabric.util.createClass({ ctx.shadowOffsetX = this.shadowOffsetX; ctx.shadowOffsetY = this.shadowOffsetY; } -}); \ No newline at end of file +}); diff --git a/src/canvas.class.js b/src/canvas.class.js index 01c01054..4affefa7 100644 --- a/src/canvas.class.js +++ b/src/canvas.class.js @@ -33,39 +33,34 @@ ProtoProxy.prototype = fabric.StaticCanvas.prototype; fabric.Canvas.prototype = new ProtoProxy(); - var InteractiveMethods = /** @scope fabric.Canvas.prototype */ { + var InteractiveMethods = /** @lends fabric.Canvas.prototype */ { /** * When true, objects can be transformed by one side (unproportionally) - * @property * @type Boolean */ uniScaleTransform: false, /** * When true, objects use center point as the origin of transformation - * @property * @type Boolean */ centerTransform: false, /** * Indicates that canvas is interactive. This property should not be changed. - * @property * @type Boolean */ interactive: true, /** * Indicates whether group selection should be enabled - * @property * @type Boolean */ selection: true, /** * Color of selection - * @property * @type String */ selectionColor: 'rgba(100, 100, 255, 0.3)', // blue @@ -73,83 +68,71 @@ /** * Default dash array pattern * If not empty the selection border is dashed - * @property * @type Array */ selectionDashArray: [ ], /** * Color of the border of selection (usually slightly darker than color of selection itself) - * @property * @type String */ selectionBorderColor: 'rgba(255, 255, 255, 0.3)', /** * Width of a line used in object/group selection - * @property * @type Number */ selectionLineWidth: 1, /** * Default cursor value used when hovering over an object on canvas - * @property * @type String */ hoverCursor: 'move', /** * Default cursor value used when moving an object on canvas - * @property * @type String */ moveCursor: 'move', /** * Default cursor value used for the entire canvas - * @property * @type String */ defaultCursor: 'default', /** * Cursor value used during free drawing - * @property * @type String */ freeDrawingCursor: 'crosshair', /** * Cursor value used for rotation point - * @property * @type String */ rotationCursor: 'crosshair', /** * Default element class that's given to wrapper (div) element of canvas - * @property * @type String */ containerClass: 'canvas-container', /** * When true, object detection happens on per-pixel basis rather than on per-bounding-box - * @property * @type Boolean */ perPixelTargetFind: false, /** * Number of pixels around target pixel to tolerate (consider active) during object detection - * @property * @type Number */ targetFindTolerance: 0, /** - * @method _initInteractive * @private */ _initInteractive: function() { @@ -166,7 +149,7 @@ /** * Resets the current transform to its original values and chooses the type of resizing based on the event - * @method _resetCurrentTransform + * @private * @param e {Event} Event object fired on mousemove */ _resetCurrentTransform: function(e) { @@ -206,7 +189,6 @@ /** * Applies one implementation of 'point inside polygon' algorithm - * @method containsPoint * @param e { Event } event object * @param target { fabric.Object } object to test against * @return {Boolean} true if point contains within area of given object @@ -234,7 +216,6 @@ /** * @private - * @method _normalizePointer */ _normalizePointer: function (object, pointer) { @@ -257,7 +238,6 @@ /** * @private - * @method _isTargetTransparent */ _isTargetTransparent: function (target, x, y) { var cacheContext = this.contextCache; @@ -304,7 +284,6 @@ /** * @private - * @method _shouldClearSelection */ _shouldClearSelection: function (e, target) { var activeGroup = this.getActiveGroup(); @@ -316,14 +295,13 @@ !activeGroup.contains(target) && activeGroup !== target && !e.shiftKey) || ( - target && + target && !target.selectable) ); }, /** * @private - * @method _setupCurrentTransform */ _setupCurrentTransform: function (e, target) { if (!target) return; @@ -397,7 +375,7 @@ }, /** - * @method _shouldHandleGroupLogic + * @private * @param e {Event} * @param target {fabric.Object} * @return {Boolean} @@ -411,7 +389,6 @@ /** * @private - * @method _handleGroupLogic */ _handleGroupLogic: function (e, target) { if (target === this.getActiveGroup()) { @@ -462,7 +439,7 @@ /** * Translates object by "setting" its left/top - * @method _translateObject + * @private * @param x {Number} pointer's x coordinate * @param y {Number} pointer's y coordinate */ @@ -479,7 +456,7 @@ /** * Scales object by invoking its scaleX/scaleY methods - * @method _scaleObject + * @private * @param x {Number} pointer's x coordinate * @param y {Number} pointer's y coordinate * @param by {String} Either 'x' or 'y' - specifies dimension constraint by which to scale an object. @@ -576,7 +553,7 @@ /** * Rotates object by invoking its rotate method - * @method _rotateObject + * @private * @param x {Number} pointer's x coordinate * @param y {Number} pointer's y coordinate */ @@ -594,16 +571,15 @@ }, /** - * @method _setCursor + * @private */ _setCursor: function (value) { this.upperCanvasEl.style.cursor = value; }, /** - * @private - * @method _resetObjectTransform: - */ + * @private + */ _resetObjectTransform: function (target) { target.scaleX = 1; target.scaleY = 1; @@ -611,7 +587,6 @@ }, /** - * @method _drawSelection * @private */ _drawSelection: function () { @@ -662,7 +637,6 @@ /** * @private - * @method _findSelectedObjects */ _findSelectedObjects: function (e) { var group = [ ], @@ -705,7 +679,6 @@ /** * Method that determines what object we are clicking on - * @method findTarget * @param {Event} e mouse event * @param {Boolean} skipGroup when true, group is skipped and only objects are traversed through */ @@ -760,7 +733,6 @@ /** * Returns pointer coordinates relative to canvas. - * @method getPointer * @param {Event} e * @return {Object} object with "x" and "y" number values */ @@ -774,7 +746,6 @@ /** * @private - * @method _createUpperCanvas * @param {HTMLElement|String} canvasEl Canvas element * @throws {CANVAS_INIT_ERROR} If canvas can not be initialized */ @@ -790,7 +761,6 @@ /** * @private - * @method _createCacheCanvas */ _createCacheCanvas: function () { this.cacheCanvasEl = this._createCanvasElement(); @@ -801,7 +771,6 @@ /** * @private - * @method _initWrapperElement * @param {Number} width * @param {Number} height */ @@ -819,7 +788,6 @@ /** * @private - * @method _applyCanvasStyle * @param {Element} element */ _applyCanvasStyle: function (element) { @@ -840,7 +808,6 @@ /** * Returns context of canvas where object selection is drawn - * @method getSelectionContext * @return {CanvasRenderingContext2D} */ getSelectionContext: function() { @@ -849,7 +816,6 @@ /** * Returns <canvas> element on which object selection is drawn - * @method getSelectionElement * @return {HTMLCanvasElement} */ getSelectionElement: function () { @@ -858,7 +824,6 @@ /** * Sets given object as the only active object on canvas - * @method setActiveObject * @param object {fabric.Object} Object to set as an active one * @return {fabric.Canvas} thisArg * @chainable @@ -879,7 +844,6 @@ /** * Returns currently active object - * @method getActiveObject * @return {fabric.Object} active object */ getActiveObject: function () { @@ -888,7 +852,6 @@ /** * Discards currently active object - * @method discardActiveObject * @return {fabric.Canvas} thisArg * @chainable */ @@ -902,7 +865,6 @@ /** * Sets active group to a speicified one - * @method setActiveGroup * @param {fabric.Group} group Group to set as a current one * @return {fabric.Canvas} thisArg * @chainable @@ -918,7 +880,6 @@ /** * Returns currently active group - * @method getActiveGroup * @return {fabric.Group} Current group */ getActiveGroup: function () { @@ -927,7 +888,6 @@ /** * Removes currently active group - * @method discardActiveGroup * @return {fabric.Canvas} thisArg */ discardActiveGroup: function () { @@ -940,7 +900,6 @@ /** * Deactivates all objects on canvas, removing any active group or object - * @method deactivateAll * @return {fabric.Canvas} thisArg */ deactivateAll: function () { @@ -957,7 +916,6 @@ /** * Deactivates all objects and dispatches appropriate events - * @method deactivateAllWithDispatch * @return {fabric.Canvas} thisArg */ deactivateAllWithDispatch: function () { @@ -985,6 +943,7 @@ } if (fabric.isTouchSupported) { + /** @ignore */ fabric.Canvas.prototype._setCursorFromEvent = function() { }; } diff --git a/src/canvas_animation.mixin.js b/src/canvas_animation.mixin.js index 888b39c6..89a7e4fc 100644 --- a/src/canvas_animation.mixin.js +++ b/src/canvas_animation.mixin.js @@ -1,4 +1,4 @@ -fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.StaticCanvas.prototype */ { +fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @lends fabric.StaticCanvas.prototype */ { /** * Animation duration (in ms) for fx* methods @@ -8,7 +8,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Centers object horizontally with animation. - * @method fxCenterObjectH * @param {fabric.Object} object Object to center * @param {Object} [callbacks] Callbacks object with optional "onComplete" and/or "onChange" properties * @return {fabric.Canvas} thisArg @@ -42,7 +41,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Centers object vertically with animation. - * @method fxCenterObjectV * @param {fabric.Object} object Object to center * @param {Object} [callbacks] Callbacks object with optional "onComplete" and/or "onChange" properties * @return {fabric.Canvas} thisArg @@ -76,7 +74,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Same as `fabric.Canvas#remove` but animated - * @method fxRemove * @param {fabric.Object} object Object to remove * @param {Function} callback Callback, invoked on effect completion * @return {fabric.Canvas} thisArg @@ -110,4 +107,4 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati return this; } -}); \ No newline at end of file +}); diff --git a/src/canvas_events.mixin.js b/src/canvas_events.mixin.js index a0bc3eb2..94c1d83b 100644 --- a/src/canvas_events.mixin.js +++ b/src/canvas_events.mixin.js @@ -14,13 +14,11 @@ removeListener = fabric.util.removeListener, getPointer = fabric.util.getPointer; - fabric.util.object.extend(fabric.Canvas.prototype, /** @scope fabric.Canvas.prototype */ { + fabric.util.object.extend(fabric.Canvas.prototype, /** @lends fabric.Canvas.prototype */ { /** - * Adds mouse listeners to canvas - * @method _initEvents + * Adds mouse listeners to canvas * @private - * See configuration documentation for more details. */ _initEvents: function () { var _this = this; @@ -51,7 +49,6 @@ }, /** - * @method _onMouseDown * @private */ _onMouseDown: function (e) { @@ -68,7 +65,6 @@ }, /** - * @method _onMouseUp * @private */ _onMouseUp: function (e) { @@ -85,7 +81,6 @@ }, /** - * @method _onMouseMove * @private */ _onMouseMove: function (e) { @@ -94,7 +89,6 @@ }, /** - * @method _onResize * @private */ _onResize: function () { @@ -105,9 +99,8 @@ * Method that defines the actions when mouse is released on canvas. * The method resets the currentTransform parameters, store the image corner * position in the image object and render the canvas on top. - * @method __onMouseUp + * @private * @param {Event} e Event object fired on mouseup - * */ __onMouseUp: function (e) { @@ -185,9 +178,8 @@ * The method inits the currentTransform parameters and renders all the * canvas so the current image can be placed on the top canvas and the rest * in on the container one. - * @method __onMouseDown + * @private * @param e {Event} Event object fired on mousedown - * */ __onMouseDown: function (e) { @@ -264,9 +256,8 @@ * an image or neither of them (only hovering). A group selection is also possible and would cancel * all any other type of action. * In case of an image transformation only the top canvas will be rendered. - * @method __onMouseMove + * @private * @param e {Event} Event object fired on mousemove - * */ __onMouseMove: function (e) { @@ -393,7 +384,6 @@ /** * Sets the cursor depending on where the canvas is being hovered. * Note: very buggy in Opera - * @method _setCursorFromEvent * @param e {Event} Event object * @param target {Object} Object that the mouse is hovering, if so. */ diff --git a/src/canvas_gestures.mixin.js b/src/canvas_gestures.mixin.js index 08e020e8..2949a254 100644 --- a/src/canvas_gestures.mixin.js +++ b/src/canvas_gestures.mixin.js @@ -3,13 +3,12 @@ var degreesToRadians = fabric.util.degreesToRadians, radiansToDegrees = fabric.util.radiansToDegrees; - fabric.util.object.extend(fabric.Canvas.prototype, /** @scope fabric.Canvas.prototype */ { + fabric.util.object.extend(fabric.Canvas.prototype, /** @lends fabric.Canvas.prototype */ { /** * Method that defines actions when an Event.js gesture is detected on an object. Currently only supports * 2 finger gestures. * - * @method __onTransformGesture * @param e Event object by Event.js * @param self Event proxy object by Event.js */ @@ -73,4 +72,4 @@ t.target.angle = radiansToDegrees(degreesToRadians(curAngle) + t.theta); } }); -})(); \ No newline at end of file +})(); diff --git a/src/canvas_serialization.mixin.js b/src/canvas_serialization.mixin.js index 67f21965..0d2567c6 100644 --- a/src/canvas_serialization.mixin.js +++ b/src/canvas_serialization.mixin.js @@ -1,9 +1,8 @@ -fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.StaticCanvas.prototype */ { +fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @lends fabric.StaticCanvas.prototype */ { /** * Populates canvas with data from the specified dataless JSON * JSON format must conform to the one of `fabric.Canvas#toDatalessJSON` - * @method loadFromDatalessJSON * @param {String|Object} json JSON string or object * @param {Function} callback Callback, invoked when json is parsed * and corresponding objects (e.g: fabric.Image) @@ -21,7 +20,7 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati : json; if (!serialized) return; - + if (!serialized.objects) { serialized.objects = []; } @@ -35,7 +34,7 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati }, /** - * @method _enlivenDatalessObjects + * @private * @param {Array} objects * @param {Function} callback */ @@ -149,7 +148,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Populates canvas with data from the specified JSON * JSON format must conform to the one of `fabric.Canvas#toJSON` - * @method loadFromJSON * @param {String|Object} json JSON string or object * @param {Function} callback Callback, invoked when json is parsed * and corresponding objects (e.g: fabric.Image) @@ -179,7 +177,7 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati backgroundPatternLoaded, backgroundImageLoaded, overlayImageLoaded; - + var cbIfLoaded = function () { callback && backgroundImageLoaded && overlayImageLoaded && backgroundPatternLoaded && callback(); }; @@ -236,7 +234,7 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati }, /** - * @method _enlivenObjects + * @private * @param {Array} objects * @param {Function} callback */ @@ -252,7 +250,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * @private - * @method _toDataURL * @param {String} format * @param {Function} callback */ @@ -264,7 +261,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * @private - * @method _toDataURLWithMultiplier * @param {String} format * @param {Number} multiplier * @param {Function} callback @@ -277,7 +273,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati /** * Clones canvas instance - * @method clone * @param {Object} [callback] Receives cloned instance as a first argument */ clone: function (callback) { @@ -293,7 +288,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati * Clones canvas instance without cloning existing data. * This essentially copies canvas dimensions, clipping properties, etc. * but leaves data empty (so that you can populate it with your own) - * @method cloneWithoutData * @param {Object} [callback] Receives cloned instance as a first argument */ cloneWithoutData: function(callback) { @@ -316,4 +310,4 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati callback && callback(clone); } } -}); \ No newline at end of file +}); diff --git a/src/circle.class.js b/src/circle.class.js index 027423f6..9f788946 100644 --- a/src/circle.class.js +++ b/src/circle.class.js @@ -16,18 +16,16 @@ * @class Circle * @extends fabric.Object */ - fabric.Circle = fabric.util.createClass(fabric.Object, /** @scope fabric.Circle.prototype */ { + fabric.Circle = fabric.util.createClass(fabric.Object, /** @lends fabric.Circle.prototype */ { /** * Type of an object - * @property * @type String */ type: 'circle', /** * Constructor - * @method initialize * @param {Object} [options] Options object * @return {fabric.Circle} thisArg */ @@ -43,7 +41,6 @@ /** * Returns object representation of an instance - * @method toObject * @param {Array} propertiesToInclude * @return {Object} object representation of an instance */ @@ -55,7 +52,6 @@ /** * Returns svg representation of an instance - * @method toSVG * @return {String} svg representation of an instance */ toSVG: function() { @@ -82,7 +78,6 @@ /** * @private - * @method _render * @param ctx {CanvasRenderingContext2D} context to render on */ _render: function(ctx, noTransform) { @@ -100,7 +95,6 @@ /** * Returns horizontal radius of an object (according to how an object is scaled) - * @method getRadiusX * @return {Number} */ getRadiusX: function() { @@ -109,7 +103,6 @@ /** * Returns vertical radius of an object (according to how an object is scaled) - * @method getRadiusY * @return {Number} */ getRadiusY: function() { @@ -118,7 +111,6 @@ /** * Sets radius of an object (and updates width accordingly) - * @method setRadius * @return {Number} */ setRadius: function(value) { @@ -128,7 +120,6 @@ /** * Returns complexity of an instance - * @method complexity * @return {Number} complexity of this instance */ complexity: function() { @@ -146,11 +137,10 @@ /** * Returns {@link fabric.Circle} instance from an SVG element * @static - * @method fabric.Circle.fromElement * @param {SVGElement} element Element to parse * @param {Object} [options] Options object * @throws {Error} If value of `r` attribute is missing or invalid - * @return {Object} Instance of fabric.Circle + * @return {fabric.Circle} Instance of fabric.Circle */ fabric.Circle.fromElement = function(element, options) { options || (options = { }); @@ -182,7 +172,6 @@ /** * Returns {@link fabric.Circle} instance from an object representation * @static - * @method fabric.Circle.fromObject * @param {Object} object Object to create an instance from * @return {Object} Instance of fabric.Circle */ diff --git a/src/circle_brush.class.js b/src/circle_brush.class.js index 4862038c..9bdfb414 100644 --- a/src/circle_brush.class.js +++ b/src/circle_brush.class.js @@ -2,18 +2,16 @@ * CircleBrush class * @class fabric.CircleBrush */ -fabric.CircleBrush = fabric.util.createClass( fabric.BaseBrush, /** @scope fabric.CircleBrush.prototype */ { +fabric.CircleBrush = fabric.util.createClass( fabric.BaseBrush, /** @lends fabric.CircleBrush.prototype */ { /** * Width of a brush - * @property * @type Number */ width: 10, /** * Constructor - * @method initialize * @param {fabric.Canvas} canvas * @return {fabric.CircleBrush} Instance of a circle brush */ @@ -23,7 +21,7 @@ fabric.CircleBrush = fabric.util.createClass( fabric.BaseBrush, /** @scope fabri }, /** - * @method onMouseDown + * Invoked on mouse down * @param {Object} pointer */ onMouseDown: function() { @@ -33,7 +31,7 @@ fabric.CircleBrush = fabric.util.createClass( fabric.BaseBrush, /** @scope fabri }, /** - * @method onMouseMove + * Invoked on mouse move * @param {Object} pointer */ onMouseMove: function(pointer) { @@ -48,7 +46,7 @@ fabric.CircleBrush = fabric.util.createClass( fabric.BaseBrush, /** @scope fabri }, /** - * @method onMouseUp + * Invoked on mouse up */ onMouseUp: function() { var originalRenderOnAddition = this.canvas.renderOnAddition; @@ -76,7 +74,6 @@ fabric.CircleBrush = fabric.util.createClass( fabric.BaseBrush, /** @scope fabri }, /** - * @method addPoint * @param {Object} pointer * @return {fabric.Point} Just added pointer point */ @@ -97,4 +94,4 @@ fabric.CircleBrush = fabric.util.createClass( fabric.BaseBrush, /** @scope fabri return pointerPoint; } -}); \ No newline at end of file +}); diff --git a/src/collection.mixin.js b/src/collection.mixin.js index 4ae53199..05321613 100644 --- a/src/collection.mixin.js +++ b/src/collection.mixin.js @@ -1,14 +1,13 @@ /** - * @namespace + * @namespace fabric.Collection */ fabric.Collection = { /** * Adds objects to collection, then renders canvas (if `renderOnAddition` is not `false`) * Objects should be instances of (or inherit from) fabric.Object - * @method add * @param [...] Zero or more fabric instances - * @chainable + * @return {Self} thisArg */ add: function () { this._objects.push.apply(this._objects, arguments); @@ -22,11 +21,10 @@ fabric.Collection = { /** * Inserts an object into collection at specified index and renders canvas * An object should be an instance of (or inherit from) fabric.Object - * @method insertAt * @param object {Object} Object to insert * @param index {Number} index to insert object at * @param nonSplicing {Boolean} when `true`, no splicing (shifting) of objects occurs - * @chainable + * @return {Self} thisArg */ insertAt: function (object, index, nonSplicing) { var objects = this.getObjects(); @@ -43,10 +41,8 @@ fabric.Collection = { /** * Removes an object from a group - * @method remove * @param {Object} object - * @return {fabric.Group} thisArg - * @chainable + * @return {Self} thisArg */ remove: function(object) { @@ -65,7 +61,6 @@ fabric.Collection = { /** * Executes given function for each object in this group - * @method forEachObject * @param {Function} callback * Callback invoked with current object as first argument, * index - as second and an array of all objects - as third. @@ -74,7 +69,7 @@ fabric.Collection = { * when no `context` argument is given * * @param {Object} context Context (aka thisObject) - * @chainable + * @return {Self} thisArg */ forEachObject: function(callback, context) { var objects = this.getObjects(), @@ -87,9 +82,8 @@ fabric.Collection = { /** * Returns object at specified index - * @method item * @param {Number} index - * @return {fabric.Object} + * @return {Self} thisArg */ item: function (index) { return this.getObjects()[index]; @@ -97,7 +91,6 @@ fabric.Collection = { /** * Returns true if collection contains no objects - * @method isEmpty * @return {Boolean} true if collection is empty */ isEmpty: function () { @@ -114,7 +107,6 @@ fabric.Collection = { /** * Returns true if collection contains an object - * @method contains * @param {Object} object Object to check against * @return {Boolean} `true` if collection contains an object */ @@ -124,7 +116,6 @@ fabric.Collection = { /** * Returns number representation of a collection complexity - * @method complexity * @return {Number} complexity */ complexity: function () { @@ -136,13 +127,11 @@ fabric.Collection = { /** * Makes all of the collection objects grayscale (i.e. calling `toGrayscale` on them) - * @method toGrayscale - * @return {fabric.Group} thisArg - * @chainable + * @return {Self} thisArg */ toGrayscale: function() { return this.forEachObject(function(obj) { obj.toGrayscale(); }); } -}; \ No newline at end of file +}; diff --git a/src/color.class.js b/src/color.class.js index 3794452f..f292a934 100644 --- a/src/color.class.js +++ b/src/color.class.js @@ -30,11 +30,10 @@ fabric.Color = Color; - fabric.Color.prototype = /** @scope fabric.Color.prototype */ { + fabric.Color.prototype = /** @lends fabric.Color.prototype */ { /** * @private - * @method _tryParsingColor */ _tryParsingColor: function(color) { var source; @@ -55,7 +54,6 @@ /** * Returns source of this color (where source is an array representation; ex: [200, 200, 100, 1]) - * @method getSource * @return {Array} */ getSource: function() { @@ -64,7 +62,6 @@ /** * Sets source of this color (where source is an array representation; ex: [200, 200, 100, 1]) - * @method setSource * @param {Array} source */ setSource: function(source) { @@ -73,7 +70,6 @@ /** * Returns color represenation in RGB format - * @method toRgb * @return {String} ex: rgb(0-255,0-255,0-255) */ toRgb: function() { @@ -83,7 +79,6 @@ /** * Returns color represenation in RGBA format - * @method toRgba * @return {String} ex: rgba(0-255,0-255,0-255,0-1) */ toRgba: function() { @@ -93,7 +88,6 @@ /** * Returns color represenation in HEX format - * @method toHex * @return {String} ex: FF5555 */ toHex: function() { @@ -113,7 +107,6 @@ /** * Gets value of alpha channel for this color - * @method getAlpha * @return {Number} 0-1 */ getAlpha: function() { @@ -122,7 +115,6 @@ /** * Sets value of alpha channel for this color - * @method setAlpha * @param {Number} 0-1 * @return {fabric.Color} thisArg */ @@ -135,7 +127,6 @@ /** * Transforms color to its grayscale representation - * @method toGrayscale * @return {fabric.Color} thisArg */ toGrayscale: function() { @@ -148,7 +139,6 @@ /** * Transforms color to its black and white representation - * @method toGrayscale * @return {fabric.Color} thisArg */ toBlackWhite: function(threshold) { @@ -165,7 +155,6 @@ /** * Overlays color with another color - * @method overlayWith * @param {String|fabric.Color} otherColor * @return {fabric.Color} thisArg */ @@ -230,7 +219,6 @@ /** * Returns new color object, when given a color in RGB format - * @method fromRgb * @param {String} color ex: rgb(0-255,0-255,0-255) * @return {fabric.Color} */ @@ -240,7 +228,6 @@ /** * Returns array represenatation (ex: [100, 100, 200, 1]) of a color that's in RGB or RGBA format - * @method sourceFromRgb * @param {String} color ex: rgb(0-255,0-255,0-255) * @return {Array} source */ @@ -260,7 +247,6 @@ * Returns new color object, when given a color in RGBA format * @static * @function - * @method fromRgba * @param {String} color * @return {fabric.Color} */ @@ -269,7 +255,6 @@ /** * Returns new color object, when given a color in HEX format * @static - * @method fromHex * @return {fabric.Color} */ fabric.Color.fromHex = function(color) { @@ -279,7 +264,6 @@ /** * Returns array represenatation (ex: [100, 100, 200, 1]) of a color that's in HEX format * @static - * @method sourceFromHex * @param {String} color ex: FF5555 * @return {Array} source */ @@ -303,7 +287,6 @@ /** * Returns new color object, when given color in array representation (ex: [200, 100, 100, 0.5]) * @static - * @method fromSource * @return {fabric.Color} */ fabric.Color.fromSource = function(source) { @@ -312,4 +295,4 @@ return oColor; }; -})(typeof exports !== 'undefined' ? exports : this); \ No newline at end of file +})(typeof exports !== 'undefined' ? exports : this); diff --git a/src/ellipse.class.js b/src/ellipse.class.js index 36012cd7..9e59ea0f 100644 --- a/src/ellipse.class.js +++ b/src/ellipse.class.js @@ -16,32 +16,28 @@ * @class Ellipse * @extends fabric.Object */ - fabric.Ellipse = fabric.util.createClass(fabric.Object, /** @scope fabric.Ellipse.prototype */ { + fabric.Ellipse = fabric.util.createClass(fabric.Object, /** @lends fabric.Ellipse.prototype */ { /** * Type of an object - * @property * @type String */ type: 'ellipse', /** * Horizontal radius - * @property * @type Number */ rx: 0, /** * Vertical radius - * @property * @type Number */ ry: 0, /** * Constructor - * @method initialize * @param {Object} [options] Options object * @return {fabric.Ellipse} thisArg */ @@ -59,7 +55,6 @@ /** * Returns object representation of an instance - * @method toObject * @param {Array} propertiesToInclude * @return {Object} object representation of an instance */ @@ -72,7 +67,6 @@ /** * Returns svg representation of an instance - * @method toSVG * @return {String} svg representation of an instance */ toSVG: function() { @@ -99,7 +93,6 @@ /** * Renders this instance on a given context - * @method render * @param ctx {CanvasRenderingContext2D} context to render on * @param noTransform {Boolean} context is not transformed when set to true */ @@ -111,7 +104,6 @@ /** * @private - * @method _render * @param ctx {CanvasRenderingContext2D} context to render on */ _render: function(ctx, noTransform) { @@ -133,7 +125,6 @@ /** * Returns complexity of an instance - * @method complexity * @return {Number} complexity */ complexity: function() { @@ -151,7 +142,6 @@ /** * Returns {@link fabric.Ellipse} instance from an SVG element * @static - * @method fabric.Ellipse.fromElement * @param {SVGElement} element Element to parse * @param {Object} [options] Options object * @return {fabric.Ellipse} @@ -181,7 +171,6 @@ /** * Returns {@link fabric.Ellipse} instance from an object representation * @static - * @method fabric.Ellipse.fromObject * @param {Object} object Object to create an instance from * @return {fabric.Ellipse} */ diff --git a/src/gradient.class.js b/src/gradient.class.js index 5e4450df..b2745e4d 100644 --- a/src/gradient.class.js +++ b/src/gradient.class.js @@ -52,11 +52,10 @@ * @class Gradient * @memberOf fabric */ - fabric.Gradient = fabric.util.createClass(/** @scope fabric.Gradient.prototype */ { + fabric.Gradient = fabric.util.createClass(/** @lends fabric.Gradient.prototype */ { /** * Constructor - * @method initialize * @param {Object} [options] Options object with type, coords, gradientUnits and colorStops * @return {fabric.Gradient} thisArg */ @@ -87,7 +86,6 @@ /** * Adds another colorStop - * @method add * @param {Object} colorStop Object with offset and color * @return {fabric.Gradient} thisArg */ @@ -101,7 +99,6 @@ /** * Returns object representation of a gradient - * @method toObject * @return {Object} */ toObject: function() { @@ -115,7 +112,6 @@ /** * Returns an instance of CanvasGradient - * @method toLive * @param ctx * @return {CanvasGradient} */ @@ -149,7 +145,6 @@ /** * Returns SVG representation of an gradient - * @method toSVG * @param {Object} object Object to create a gradient for * @param {Boolean} normalize Whether coords should be normalized * @return {String} SVG representation of an gradient (linear/radial) @@ -219,7 +214,6 @@ /** * Returns {@link fabric.Gradient} instance from an SVG element - * @method fromElement * @static * @memberof fabric.Gradient * @see http://www.w3.org/TR/SVG/pservers.html#LinearGradientElement @@ -301,7 +295,6 @@ /** * Returns {@link fabric.Gradient} instance from its object representation - * @method forObject * @static * @param {Object} obj * @param {Object} [options] Options object @@ -316,7 +309,6 @@ /** * @private - * @method _convertPercentUnitsToValues */ function _convertPercentUnitsToValues(object, options) { for (var prop in options) { @@ -341,7 +333,6 @@ /** * @private - * @method _convertValuesToPercentUnits */ function _convertValuesToPercentUnits(object, options) { for (var prop in options) { @@ -367,7 +358,6 @@ * @static * @function * @memberOf fabric - * @method getGradientDefs * @param {SVGDocument} doc SVG document to parse * @return {Object} Gradient definitions; key corresponds to element id, value -- to gradient definition element */ @@ -394,4 +384,4 @@ fabric.getGradientDefs = getGradientDefs; -})(); \ No newline at end of file +})(); diff --git a/src/group.class.js b/src/group.class.js index 3c99e890..cf286005 100644 --- a/src/group.class.js +++ b/src/group.class.js @@ -29,18 +29,16 @@ * @class Group * @extends fabric.Object */ - fabric.Group = fabric.util.createClass(fabric.Object, fabric.Collection, /** @scope fabric.Group.prototype */ { + fabric.Group = fabric.util.createClass(fabric.Object, fabric.Collection, /** @lends fabric.Group.prototype */ { /** * Type of an object - * @property * @type String */ type: 'group', /** * Constructor - * @method initialized * @param {Object} objects Group objects * @param {Object} [options] Options object * @return {Object} thisArg @@ -70,7 +68,6 @@ /** * @private - * @method _updateObjectsCoords */ _updateObjectsCoords: function() { var groupDeltaX = this.left, @@ -97,7 +94,6 @@ /** * Returns string represenation of a group - * @method toString * @return {String} */ toString: function() { @@ -106,7 +102,6 @@ /** * Returns an array of all objects in this group - * @method getObjects * @return {Array} group objects */ getObjects: function() { @@ -115,7 +110,6 @@ /** * Adds an object to a group; Then recalculates group's dimension, position. - * @method addWithUpdate * @param {Object} object * @return {fabric.Group} thisArg * @chainable @@ -133,7 +127,6 @@ /** * Removes an object from a group; Then recalculates group's dimension, position. - * @method removeWithUpdate * @param {Object} object * @return {fabric.Group} thisArg * @chainable @@ -201,7 +194,6 @@ /** * Returns object representation of an instance - * @method toObject * @param {Array} propertiesToInclude * @return {Object} object representation of an instance */ @@ -213,7 +205,6 @@ /** * Renders instance on a given context - * @method render * @param {CanvasRenderingContext2D} ctx context to render instance on * @param {Boolean} [noTransform] When true, context is not transformed */ @@ -259,7 +250,6 @@ /** * Retores original state of each of group objects (original state is that which was before group was created). * @private - * @method _restoreObjectsState * @return {fabric.Group} thisArg * @chainable */ @@ -271,7 +261,6 @@ /** * Restores original state of a specified object in group * @private - * @method _restoreObjectState * @param {fabric.Object} object * @return {fabric.Group} thisArg */ @@ -303,7 +292,6 @@ /** * Destroys a group (restoring state of its objects) - * @method destroy * @return {fabric.Group} thisArg * @chainable */ @@ -325,7 +313,6 @@ /** * Checks whether this group was moved (since `saveCoords` was called last) - * @method hasMoved * @return {Boolean} true if an object was moved (since fabric.Group#saveCoords was called) */ hasMoved: function() { @@ -335,7 +322,6 @@ /** * Sets coordinates of all group objects - * @method setObjectsCoords * @return {fabric.Group} thisArg * @chainable */ @@ -348,7 +334,6 @@ /** * @private - * @method _setOpacityIfSame */ _setOpacityIfSame: function() { var objects = this.getObjects(), @@ -365,7 +350,6 @@ /** * @private - * @method _calcBounds */ _calcBounds: function() { var aX = [], @@ -400,7 +384,6 @@ /** * Checks if point is contained within the group - * @method containsPoint * @param {fabric.Point} point point with `x` and `y` properties * @return {Boolean} true if point is contained within group */ @@ -419,7 +402,6 @@ /** * Returns svg representation of an instance - * @method toSVG * @return {String} svg representation of an instance */ toSVG: function() { @@ -436,7 +418,6 @@ /** * Returns requested property - * @method get * @param {String} prop Property to get * @return {Any} */ @@ -466,7 +447,6 @@ /** * Returns {@link fabric.Group} instance from an object representation * @static - * @method fabric.Group.fromObject * @param {Object} object Object to create a group from * @param {Object} [options] Options object * @return {fabric.Group} An instance of fabric.Group diff --git a/src/image.class.js b/src/image.class.js index 393d3f83..7364d738 100644 --- a/src/image.class.js +++ b/src/image.class.js @@ -18,11 +18,10 @@ * @class Image * @extends fabric.Object */ - fabric.Image = fabric.util.createClass(fabric.Object, /** @scope fabric.Image.prototype */ { + fabric.Image = fabric.util.createClass(fabric.Object, /** @lends fabric.Image.prototype */ { /** * Type of an object - * @property * @type String */ type: 'image', @@ -51,7 +50,6 @@ /** * Returns image element which this instance if based on - * @method getElement * @return {HTMLImageElement} image element */ getElement: function() { @@ -60,7 +58,6 @@ /** * Sets image element for this instance to a specified one - * @method setElement * @param {HTMLImageElement} element * @return {fabric.Image} thisArg * @chainable @@ -73,7 +70,6 @@ /** * Returns original size of an image - * @method getOriginalSize * @return {Object} object with "width" and "height" properties */ getOriginalSize: function() { @@ -86,7 +82,6 @@ /** * Renders image on a specified context - * @method render * @param {CanvasRenderingContext2D} ctx Context to render on * @param {Boolean} [noTransform] When true, context is not transformed */ @@ -140,7 +135,6 @@ /** * Returns object representation of an instance - * @method toObject * @param {Array} propertiesToInclude * @return {Object} propertiesToInclude Object representation of an instance */ @@ -153,7 +147,6 @@ /** * Returns SVG representation of an instance - * @method toSVG * @return {String} svg representation of an instance */ toSVG: function() { @@ -171,7 +164,6 @@ /** * Returns source of an image - * @method getSrc * @return {String} Source of an image */ getSrc: function() { @@ -180,7 +172,6 @@ /** * Returns string representation of an instance - * @method toString * @return {String} String representation of an instance */ toString: function() { @@ -189,7 +180,6 @@ /** * Returns a clone of an instance - * @method clone * @param {Function} callback Callback is invoked with a clone as a first argument * @param {Array} propertiesToInclude */ @@ -256,7 +246,6 @@ /** * @private - * @method _render * @param ctx */ _render: function(ctx) { @@ -271,7 +260,6 @@ /** * @private - * @method _resetWidthHeight */ _resetWidthHeight: function() { var element = this.getElement(); @@ -284,7 +272,6 @@ * The Image class's initialization method. This method is automatically * called by the constructor. * @private - * @method _initElement * @param {HTMLImageElement|String} el The element representing the image */ _initElement: function(element) { @@ -294,7 +281,6 @@ /** * @private - * @method _initConfig * @param {Object} [options] Options object */ _initConfig: function(options) { @@ -305,7 +291,6 @@ /** * @private - * @method _initFilters * @param {Object} object Object with filters property */ _initFilters: function(object) { @@ -318,7 +303,6 @@ /** * @private - * @method _setWidthHeight * @param {Object} [options] Object with width/height properties */ _setWidthHeight: function(options) { @@ -333,7 +317,6 @@ /** * Returns complexity of an instance - * @method complexity * @return {Number} complexity */ complexity: function() { @@ -351,14 +334,12 @@ /** * Alias for getSrc * @static - * @method getSvgSrc */ fabric.Image.prototype.getSvgSrc = fabric.Image.prototype.getSrc; /** * Creates an instance of fabric.Image from its object representation * @static - * @method fromObject * @param {Object} object * @param {Function} [callback] Callback to invoke when an image instance is created */ @@ -394,7 +375,6 @@ /** * Creates an instance of fabric.Image from an URL string * @static - * @method fromURL * @param {String} url URL to create an image from * @param {Function} [callback] Callback to invoke when image is created (newly created image is passed as a first argument) * @param {Object} [imgOptions] Options object @@ -415,7 +395,6 @@ /** * Returns {@link fabric.Image} instance from an SVG element * @static - * @method fabric.Image.fromElement * @param {SVGElement} element Element to parse * @param {Function} callback Callback to execute when fabric.Image object is created * @param {Object} [options] Options object diff --git a/src/image_filters.js b/src/image_filters.js index 7c161757..5084e6b9 100644 --- a/src/image_filters.js +++ b/src/image_filters.js @@ -1,5 +1,6 @@ /** - * @namespace Image filters + * @namespace fabric.Image.filters + * @memberOf fabric.Image */ fabric.Image.filters = { }; @@ -8,7 +9,7 @@ fabric.Image.filters = { }; * @class fabric.Image.filters.Grayscale * @memberOf fabric.Image.filters */ -fabric.Image.filters.Grayscale = fabric.util.createClass( /** @scope fabric.Image.filters.Grayscale.prototype */ { +fabric.Image.filters.Grayscale = fabric.util.createClass( /** @lends fabric.Image.filters.Grayscale.prototype */ { /** * Filter type @@ -18,7 +19,6 @@ fabric.Image.filters.Grayscale = fabric.util.createClass( /** @scope fabric.Imag /** * Applies filter to canvas element - * @method applyTo * @memberOf fabric.Image.filters.Grayscale.prototype * @param {Object} canvasEl Canvas element to apply filter to */ @@ -47,8 +47,7 @@ fabric.Image.filters.Grayscale = fabric.util.createClass( /** @scope fabric.Imag /** * Returns json representation of filter - * @method toJSON - * @return {String} json representation of filter + * @return {Object} JSON representation of filter */ toJSON: function() { return { type: this.type }; @@ -58,7 +57,6 @@ fabric.Image.filters.Grayscale = fabric.util.createClass( /** @scope fabric.Imag /** * Returns filter instance from an object representation * @static - * @method fabric.Image.filters.Grayscale.fromObject * @return {fabric.Image.filters.Grayscale} */ fabric.Image.filters.Grayscale.fromObject = function() { @@ -70,7 +68,7 @@ fabric.Image.filters.Grayscale.fromObject = function() { * @class fabric.Image.filters.RemoveWhite * @memberOf fabric.Image.filters */ -fabric.Image.filters.RemoveWhite = fabric.util.createClass( /** @scope fabric.Image.filters.RemoveWhite.prototype */ { +fabric.Image.filters.RemoveWhite = fabric.util.createClass( /** @lends fabric.Image.filters.RemoveWhite.prototype */ { /** * Filter type @@ -91,7 +89,6 @@ fabric.Image.filters.RemoveWhite = fabric.util.createClass( /** @scope fabric.Im /** * Applies filter to canvas element - * @method applyTo * @param {Object} canvasEl Canvas element to apply filter to */ applyTo: function(canvasEl) { @@ -126,8 +123,7 @@ fabric.Image.filters.RemoveWhite = fabric.util.createClass( /** @scope fabric.Im /** * Returns json representation of filter - * @method toJSON - * @return {String} json representation of filter + * @return {Object} JSON representation of filter */ toJSON: function() { return { @@ -141,7 +137,6 @@ fabric.Image.filters.RemoveWhite = fabric.util.createClass( /** @scope fabric.Im /** * Returns filter instance from an object representation * @static - * @method fabric.Image.filters.RemoveWhite.fromObject * @return {fabric.Image.filters.RemoveWhite} */ fabric.Image.filters.RemoveWhite.fromObject = function(object) { @@ -153,7 +148,7 @@ fabric.Image.filters.RemoveWhite.fromObject = function(object) { * @class fabric.Image.filters.Invert * @memberOf fabric.Image.filters */ -fabric.Image.filters.Invert = fabric.util.createClass( /** @scope fabric.Image.filters.Invert.prototype */ { +fabric.Image.filters.Invert = fabric.util.createClass( /** @lends fabric.Image.filters.Invert.prototype */ { /** * Filter type @@ -163,7 +158,6 @@ fabric.Image.filters.Invert = fabric.util.createClass( /** @scope fabric.Image.f /** * Applies filter to canvas element - * @method applyTo * @memberOf fabric.Image.filters.Invert.prototype * @param {Object} canvasEl Canvas element to apply filter to */ @@ -184,7 +178,6 @@ fabric.Image.filters.Invert = fabric.util.createClass( /** @scope fabric.Image.f /** * Returns json representation of filter - * @method toJSON * @return {String} json representation of filter */ toJSON: function() { @@ -195,7 +188,6 @@ fabric.Image.filters.Invert = fabric.util.createClass( /** @scope fabric.Image.f /** * Returns filter instance from an object representation * @static - * @method fabric.Image.filters.Invert.fromObject * @return {fabric.Image.filters.Invert} */ fabric.Image.filters.Invert.fromObject = function() { @@ -207,7 +199,7 @@ fabric.Image.filters.Invert.fromObject = function() { * @class fabric.Image.filters.Sepia * @memberOf fabric.Image.filters */ -fabric.Image.filters.Sepia = fabric.util.createClass( /** @scope fabric.Image.filters.Sepia.prototype */ { +fabric.Image.filters.Sepia = fabric.util.createClass( /** @lends fabric.Image.filters.Sepia.prototype */ { /** * Filter type @@ -217,7 +209,6 @@ fabric.Image.filters.Sepia = fabric.util.createClass( /** @scope fabric.Image.fi /** * Applies filter to canvas element - * @method applyTo * @memberOf fabric.Image.filters.Sepia.prototype * @param {Object} canvasEl Canvas element to apply filter to */ @@ -239,7 +230,6 @@ fabric.Image.filters.Sepia = fabric.util.createClass( /** @scope fabric.Image.fi /** * Returns json representation of filter - * @method toJSON * @return {String} json representation of filter */ toJSON: function() { @@ -250,7 +240,6 @@ fabric.Image.filters.Sepia = fabric.util.createClass( /** @scope fabric.Image.fi /** * Returns filter instance from an object representation * @static - * @method fabric.Image.filters.Sepia.fromObject * @return {fabric.Image.filters.Sepia} */ fabric.Image.filters.Sepia.fromObject = function() { @@ -262,7 +251,7 @@ fabric.Image.filters.Sepia.fromObject = function() { * @class fabric.Image.filters.Sepia2 * @memberOf fabric.Image.filters */ -fabric.Image.filters.Sepia2 = fabric.util.createClass( /** @scope fabric.Image.filters.Sepia2.prototype */ { +fabric.Image.filters.Sepia2 = fabric.util.createClass( /** @lends fabric.Image.filters.Sepia2.prototype */ { /** * Filter type @@ -272,7 +261,6 @@ fabric.Image.filters.Sepia2 = fabric.util.createClass( /** @scope fabric.Image.f /** * Applies filter to canvas element - * @method applyTo * @memberOf fabric.Image.filters.Sepia.prototype * @param {Object} canvasEl Canvas element to apply filter to */ @@ -298,7 +286,6 @@ fabric.Image.filters.Sepia2 = fabric.util.createClass( /** @scope fabric.Image.f /** * Returns json representation of filter - * @method toJSON * @return {String} json representation of filter */ toJSON: function() { @@ -309,7 +296,6 @@ fabric.Image.filters.Sepia2 = fabric.util.createClass( /** @scope fabric.Image.f /** * Returns filter instance from an object representation * @static - * @method fabric.Image.filters.Sepia2.fromObject * @return {fabric.Image.filters.Sepia2} */ fabric.Image.filters.Sepia2.fromObject = function() { @@ -321,7 +307,7 @@ fabric.Image.filters.Sepia2.fromObject = function() { * @class fabric.Image.filters.Brightness * @memberOf fabric.Image.filters */ -fabric.Image.filters.Brightness = fabric.util.createClass( /** @scope fabric.Image.filters.Brightness.prototype */ { +fabric.Image.filters.Brightness = fabric.util.createClass( /** @lends fabric.Image.filters.Brightness.prototype */ { /** * Filter type @@ -341,7 +327,6 @@ fabric.Image.filters.Brightness = fabric.util.createClass( /** @scope fabric.Ima /** * Applies filter to canvas element - * @method applyTo * @param {Object} canvasEl Canvas element to apply filter to */ applyTo: function(canvasEl) { @@ -361,7 +346,6 @@ fabric.Image.filters.Brightness = fabric.util.createClass( /** @scope fabric.Ima /** * Returns json representation of filter - * @method toJSON * @return {String} json representation of filter */ toJSON: function() { @@ -375,7 +359,6 @@ fabric.Image.filters.Brightness = fabric.util.createClass( /** @scope fabric.Ima /** * Returns filter instance from an object representation * @static - * @method fabric.Image.filters.Brightness.fromObject * @return {fabric.Image.filters.Brightness} */ fabric.Image.filters.Brightness.fromObject = function(object) { @@ -387,7 +370,7 @@ fabric.Image.filters.Brightness.fromObject = function(object) { * @class fabric.Image.filters.Noise * @memberOf fabric.Image.filters */ -fabric.Image.filters.Noise = fabric.util.createClass( /** @scope fabric.Image.filters.Noise.prototype */ { +fabric.Image.filters.Noise = fabric.util.createClass( /** @lends fabric.Image.filters.Noise.prototype */ { /** * Filter type @@ -407,7 +390,6 @@ fabric.Image.filters.Noise = fabric.util.createClass( /** @scope fabric.Image.fi /** * Applies filter to canvas element - * @method applyTo * @param {Object} canvasEl Canvas element to apply filter to */ applyTo: function(canvasEl) { @@ -430,7 +412,6 @@ fabric.Image.filters.Noise = fabric.util.createClass( /** @scope fabric.Image.fi /** * Returns json representation of filter - * @method toJSON * @return {String} json representation of filter */ toJSON: function() { @@ -444,7 +425,6 @@ fabric.Image.filters.Noise = fabric.util.createClass( /** @scope fabric.Image.fi /** * Returns filter instance from an object representation * @static - * @method fabric.Image.filters.Noise.fromObject * @return {fabric.Image.filters.Noise} */ fabric.Image.filters.Noise.fromObject = function(object) { @@ -456,7 +436,7 @@ fabric.Image.filters.Noise.fromObject = function(object) { * @class fabric.Image.filters.GradientTransparency * @memberOf fabric.Image.filters */ -fabric.Image.filters.GradientTransparency = fabric.util.createClass( /** @scope fabric.Image.filters.GradientTransparency.prototype */ { +fabric.Image.filters.GradientTransparency = fabric.util.createClass( /** @lends fabric.Image.filters.GradientTransparency.prototype */ { /** * Filter type @@ -476,7 +456,6 @@ fabric.Image.filters.GradientTransparency = fabric.util.createClass( /** @scope /** * Applies filter to canvas element - * @method applyTo * @param {Object} canvasEl Canvas element to apply filter to */ applyTo: function(canvasEl) { @@ -495,7 +474,6 @@ fabric.Image.filters.GradientTransparency = fabric.util.createClass( /** @scope /** * Returns json representation of filter - * @method toJSON * @return {String} json representation of filter */ toJSON: function() { @@ -509,7 +487,6 @@ fabric.Image.filters.GradientTransparency = fabric.util.createClass( /** @scope /** * Returns filter instance from an object representation * @static - * @method fabric.Image.filters.GradientTransparency.fromObject * @return {fabric.Image.filters.GradientTransparency} */ fabric.Image.filters.GradientTransparency.fromObject = function(object) { @@ -521,7 +498,7 @@ fabric.Image.filters.GradientTransparency.fromObject = function(object) { * @class fabric.Image.filters.Tint * @memberOf fabric.Image.filters */ -fabric.Image.filters.Tint = fabric.util.createClass( /** @scope fabric.Image.filters.Tint.prototype */ { +fabric.Image.filters.Tint = fabric.util.createClass( /** @lends fabric.Image.filters.Tint.prototype */ { /** * Filter type @@ -541,7 +518,6 @@ fabric.Image.filters.Tint = fabric.util.createClass( /** @scope fabric.Image.fil /** * Applies filter to canvas element - * @method applyTo * @param {Object} canvasEl Canvas element to apply filter to */ applyTo: function(canvasEl) { @@ -573,7 +549,6 @@ fabric.Image.filters.Tint = fabric.util.createClass( /** @scope fabric.Image.fil /** * Returns json representation of filter - * @method toJSON * @return {String} json representation of filter */ toJSON: function() { @@ -587,7 +562,6 @@ fabric.Image.filters.Tint = fabric.util.createClass( /** @scope fabric.Image.fil /** * Returns filter instance from an object representation * @static - * @method fabric.Image.filters.Tint.fromObject * @return {fabric.Image.filters.Tint} */ fabric.Image.filters.Tint.fromObject = function(object) { @@ -599,7 +573,7 @@ fabric.Image.filters.Tint.fromObject = function(object) { * @class fabric.Image.filters.Convolute * @memberOf fabric.Image.filters */ -fabric.Image.filters.Convolute = fabric.util.createClass(/** @scope fabric.Image.filters.Convolute.prototype */ { +fabric.Image.filters.Convolute = fabric.util.createClass(/** @lends fabric.Image.filters.Convolute.prototype */ { /** * Filter type @@ -626,7 +600,6 @@ fabric.Image.filters.Convolute = fabric.util.createClass(/** @scope fabric.Image /** * @private - * @method _createImageData */ _createImageData: function(w, h) { return this.tmpCtx.createImageData(w, h); @@ -634,7 +607,6 @@ fabric.Image.filters.Convolute = fabric.util.createClass(/** @scope fabric.Image /** * Applies filter to canvas element - * @method applyTo * @param {Object} canvasEl Canvas element to apply filter to */ applyTo: function(canvasEl) { @@ -692,7 +664,6 @@ fabric.Image.filters.Convolute = fabric.util.createClass(/** @scope fabric.Image /** * Returns json representation of filter - * @method toJSON * @return {String} json representation of filter */ toJSON: function() { @@ -706,7 +677,6 @@ fabric.Image.filters.Convolute = fabric.util.createClass(/** @scope fabric.Image /** * Returns filter instance from an object representation * @static - * @method fabric.Image.filters.Convolute.fromObject * @return {fabric.Image.filters.Convolute} */ fabric.Image.filters.Convolute.fromObject = function(object) { @@ -718,7 +688,7 @@ fabric.Image.filters.Convolute.fromObject = function(object) { * @class fabric.Image.filters.Pixelate * @memberOf fabric.Image.filters */ -fabric.Image.filters.Pixelate = fabric.util.createClass(/** @scope fabric.Image.filters.Pixelate.prototype */ { +fabric.Image.filters.Pixelate = fabric.util.createClass(/** @lends fabric.Image.filters.Pixelate.prototype */ { /** * Filter type @@ -738,7 +708,6 @@ fabric.Image.filters.Pixelate = fabric.util.createClass(/** @scope fabric.Image. /** * Applies filter to canvas element - * @method applyTo * @param {Object} canvasEl Canvas element to apply filter to */ applyTo: function(canvasEl) { @@ -787,7 +756,6 @@ fabric.Image.filters.Pixelate = fabric.util.createClass(/** @scope fabric.Image. /** * Returns json representation of filter - * @method toJSON * @return {String} json representation of filter */ toJSON: function() { @@ -801,9 +769,8 @@ fabric.Image.filters.Pixelate = fabric.util.createClass(/** @scope fabric.Image. /** * Returns filter instance from an object representation * @static - * @method fabric.Image.filters.Pixelate.fromObject * @return {fabric.Image.filters.Pixelate} */ fabric.Image.filters.Pixelate.fromObject = function(object) { return new fabric.Image.filters.Pixelate(object); -}; \ No newline at end of file +}; diff --git a/src/intersection.class.js b/src/intersection.class.js index d2ec1cd7..d1b7bc29 100644 --- a/src/intersection.class.js +++ b/src/intersection.class.js @@ -24,11 +24,10 @@ fabric.Intersection = Intersection; - fabric.Intersection.prototype = /** @scope fabric.Intersection.prototype */ { + fabric.Intersection.prototype = /** @lends fabric.Intersection.prototype */ { /** * Constructor - * @method init * @param {String} status */ init: function (status) { @@ -38,7 +37,6 @@ /** * Appends a point to intersection - * @method appendPoint * @param {fabric.Point} point */ appendPoint: function (point) { @@ -47,7 +45,6 @@ /** * Appends points to intersection - * @method appendPoints * @param {Array} points */ appendPoints: function (points) { @@ -58,7 +55,6 @@ /** * Checks if one line intersects another * @static - * @method intersectLineLine * @param {fabric.Point} a1 * @param {fabric.Point} a2 * @param {fabric.Point} b1 @@ -94,7 +90,6 @@ /** * Checks if line intersects polygon - * @method intersectLinePolygon * @static * @param {fabric.Point} a1 * @param {fabric.Point} a2 @@ -120,7 +115,6 @@ /** * Checks if polygon intersects another polygon - * @method intersectPolygonPolygon * @static * @param {Array} points1 * @param {Array} points2 @@ -145,7 +139,6 @@ /** * Checks if polygon intersects rectangle - * @method intersectPolygonRectangle * @static * @param {Array} points @@ -175,4 +168,4 @@ return result; }; -})(typeof exports !== 'undefined' ? exports : this); \ No newline at end of file +})(typeof exports !== 'undefined' ? exports : this); diff --git a/src/line.class.js b/src/line.class.js index 92390385..50aa6112 100644 --- a/src/line.class.js +++ b/src/line.class.js @@ -16,18 +16,16 @@ * @class Line * @extends fabric.Object */ - fabric.Line = fabric.util.createClass(fabric.Object, /** @scope fabric.Line.prototype */ { + fabric.Line = fabric.util.createClass(fabric.Object, /** @lends fabric.Line.prototype */ { /** * Type of an object - * @property * @type String */ type: 'line', /** * Constructor - * @method initialize * @param {Array} [points] Array of points * @param {Object} [options] Options object * @return {fabric.Line} thisArg @@ -51,7 +49,6 @@ /** * @private - * @method _setWidthHeight * @param {Object} [options] Options */ _setWidthHeight: function(options) { @@ -66,7 +63,6 @@ /** * @private - * @method _set * @param {String} key * @param {Any} value */ @@ -80,7 +76,6 @@ /** * @private - * @method _render * @param {CanvasRenderingContext2D} ctx Context to render on */ _render: function(ctx) { @@ -111,7 +106,6 @@ /** * Returns complexity of an instance - * @method complexity * @return {Number} complexity */ complexity: function() { @@ -135,7 +129,6 @@ /** * Returns SVG representation of an instance - * @method toSVG * @return {String} svg representation of an instance */ toSVG: function() { @@ -169,7 +162,6 @@ /** * Returns fabric.Line instance from an SVG element * @static - * @method fabric.Line.fromElement * @param {SVGElement} element Element to parse * @param {Object} [options] Options object * @return {fabric.Line} instance of fabric.Line @@ -188,7 +180,6 @@ /** * Returns fabric.Line instance from an object representation * @static - * @method fabric.Line.fromObject * @param {Object} object Object to create an instance from * @return {fabric.Line} instance of fabric.Line */ diff --git a/src/log.js b/src/log.js index 813fd68d..65c4bda2 100644 --- a/src/log.js +++ b/src/log.js @@ -1,13 +1,11 @@ /** * Wrapper around `console.log` (when available) - * @method log * @param {Any} values Values to log */ fabric.log = function() { }; /** * Wrapper around `console.warn` (when available) - * @method warn * @param {Any} Values to log as a warning */ fabric.warn = function() { }; diff --git a/src/node.js b/src/node.js index f02898d0..6e3f00e4 100644 --- a/src/node.js +++ b/src/node.js @@ -129,7 +129,6 @@ /** * Only available when running fabric on node.js - * @method createCanvasForNode * @param width Canvas width * @param height Canvas height * @return {Object} wrapped canvas instance diff --git a/src/object.class.js b/src/object.class.js index a8d01f2e..4700752d 100644 --- a/src/object.class.js +++ b/src/object.class.js @@ -25,315 +25,271 @@ /** * Root object class from which all 2d shape classes inherit from - * @class Object + * @class fabric.Object * @memberOf fabric */ - fabric.Object = fabric.util.createClass(/** @scope fabric.Object.prototype */ { + fabric.Object = fabric.util.createClass(/** @lends fabric.Object.prototype */ { /** * Type of an object (rect, circle, path, etc.) - * @property * @type String */ type: 'object', /** * Horizontal origin of transformation of an object (one of "left", "right", "center") - * @property * @type String */ originX: 'center', /** * Vertical origin of transformation of an object (one of "top", "bottom", "center") - * @property * @type String */ originY: 'center', /** * Top position of an object. Note that by default it's relative to object center. You can change this by setting originY={top/center/bottom} - * @property * @type Number */ top: 0, /** * Left position of an object. Note that by default it's relative to object center. You can change this by setting originX={left/center/right} - * @property * @type Number */ left: 0, /** * Object width - * @property * @type Number */ width: 0, /** * Object height - * @property * @type Number */ height: 0, /** * Object scale factor (horizontal) - * @property * @type Number */ scaleX: 1, /** * Object scale factor (vertical) - * @property * @type Number */ scaleY: 1, /** * When true, an object is rendered as flipped horizontally - * @property * @type Boolean */ flipX: false, /** * When true, an object is rendered as flipped vertically - * @property * @type Boolean */ flipY: false, /** * Opacity of an object - * @property * @type Number */ opacity: 1, /** * Angle of rotation of an object (in degrees) - * @property * @type Number */ angle: 0, /** * Size of object's corners (in pixels) - * @property * @type Number */ cornerSize: 12, /** * When true, object's corners are rendered as transparent inside (i.e. stroke instead of fill) - * @property * @type Boolean */ transparentCorners: true, /** * Padding between object and its borders (in pixels) - * @property * @type Number */ padding: 0, /** * Border color of an object (when it's active) - * @property * @type String */ borderColor: 'rgba(102,153,255,0.75)', /** * Corner color of an object (when it's active) - * @property * @type String */ cornerColor: 'rgba(102,153,255,0.5)', /** * Color of object's fill - * @property * @type String */ fill: 'rgb(0,0,0)', /** * Fill rule used to fill an object - * @property * @type String */ fillRule: 'source-over', /** * Overlay fill (takes precedence over fill value) - * @property * @type String */ overlayFill: null, /** * When `true`, an object is rendered via stroke and this property specifies its color - * @property * @type String */ stroke: null, /** * Width of a stroke used to render this object - * @property * @type Number */ strokeWidth: 1, /** * Array specifying dash pattern of an object's stroke - * @property * @type Array */ strokeDashArray: null, /** * Shadow object representing shadow of this shape - * @property * @type fabric.Shadow */ shadow: null, /** * Border opacity when object is active and moving - * @property * @type Number */ borderOpacityWhenMoving: 0.4, /** * Border scale factor - * @property * @type Number */ borderScaleFactor: 1, /** * Transform matrix (similar to SVG's transform matrix) - * @property * @type Array */ transformMatrix: null, /** * Minimum allowed scale value of an object - * @property * @type Number */ minScaleLimit: 0.01, /** * When set to `false`, an object can not be selected for modification (using either point-click-based or group-based selection) - * @property * @type Boolean */ selectable: true, /** * When set to `false`, an object is not rendered on canvas - * @property * @type Boolean */ visible: true, /** * When set to `false`, object's controls are not displayed and can not be used to manipulate object - * @property * @type Boolean */ hasControls: true, /** * When set to `false`, object's borders are not rendered - * @property * @type Boolean */ hasBorders: true, /** * When set to `false`, object's rotating point will not be visible or selectable - * @property * @type Boolean */ hasRotatingPoint: true, /** * Offset for object's rotating point (when enabled via `hasRotatingPoint`) - * @property * @type Number */ rotatingPointOffset: 40, /** * When set to `true`, objects are "found" on canvas on per-pixel basis rather than according to bounding box - * @property * @type Boolean */ perPixelTargetFind: false, /** * When `false`, default object's values are not included in its serialization - * @property * @type Boolean */ includeDefaultValues: true, /** * Function that determines clipping of an object (context is passed as a first argument) - * @property * @type Function */ clipTo: null, /** * When `true`, object horizontal movement is locked - * @property * @type Boolean */ lockMovementX: false, /** * When `true`, object vertical movement is locked - * @property * @type Boolean */ lockMovementY: false, /** * When `true`, object rotation is locked - * @property * @type Boolean */ lockRotation: false, /** * When `true`, object horizontal scaling is locked - * @property * @type Boolean */ lockScalingX: false, /** * When `true`, object vertical scaling is locked - * @property * @type Boolean */ lockScalingY: false, /** * When `true`, object non-uniform scaling is locked - * @property * @type Boolean */ lockUniScaling: false, @@ -341,7 +297,6 @@ /** * List of properties to consider when checking if state of an object is changed (fabric.Object#hasStateChanged); * as well as for history (undo/redo) purposes - * @property * @type Array */ stateProperties: ( @@ -353,7 +308,6 @@ /** * Constructor - * @method initialize * @param {Object} [options] Options object */ initialize: function(options) { @@ -364,7 +318,6 @@ /** * @private - * @method _initGradient */ _initGradient: function(options) { if (options.fill && options.fill.colorStops && !(options.fill instanceof fabric.Gradient)) { @@ -374,7 +327,6 @@ /** * @private - * @method _initPattern */ _initPattern: function(options) { if (options.fill && options.fill.source && !(options.fill instanceof fabric.Pattern)) { @@ -387,7 +339,6 @@ /** * @private - * @method _initShadow */ _initShadow: function(options) { if (options.shadow && !(options.shadow instanceof fabric.Shadow)) { @@ -397,7 +348,6 @@ /** * Sets object's properties from options - * @method setOptions * @param {Object} [options] */ setOptions: function(options) { @@ -411,7 +361,6 @@ /** * Transforms context when rendering an object - * @method transform * @param {CanvasRenderingContext2D} ctx Context */ transform: function(ctx) { @@ -428,7 +377,6 @@ /** * Returns an object representation of an instance - * @method toObject * @param {Array} propertiesToInclude * @return {Object} object representation of an instance */ @@ -475,7 +423,6 @@ /** * Returns (dataless) object representation of an instance - * @method toDatalessObject * @param {Array} [propertiesToInclude] * @return {Object} object representation of an instance */ @@ -486,7 +433,6 @@ /** * Returns styles-string for svg-export - * @method getSvgStyles * @return {String} */ getSvgStyles: function() { @@ -502,7 +448,6 @@ /** * Returns transform-string for svg-export - * @method getSvgTransform * @return {String} */ getSvgTransform: function() { @@ -537,7 +482,6 @@ /** * @private - * @method _removeDefaultValues */ _removeDefaultValues: function(object) { var defaultOptions = fabric.Object.prototype.options; @@ -561,7 +505,6 @@ /** * Basic getter - * @method get * @param {String} property * @return {Any} value of a property */ @@ -571,7 +514,6 @@ /** * Sets property to a given value. When changing position/dimension -related properties (left, top, scale, angle, etc.) `set` does not update position of object's borders/controls. If you need to update those, call `setCoords()`. - * @method set * @param {String} name * @param {Object|Function} value (if function, the value is passed into it and its return value is used as a new one) * @return {fabric.Object} thisArg @@ -596,7 +538,6 @@ /** * @private - * @method _set * @param key * @param value */ @@ -625,7 +566,6 @@ /** * Toggles specified property from `true` to `false` or from `false` to `true` - * @method toggle * @param {String} property property to toggle * @return {fabric.Object} thisArg * @chainable @@ -640,7 +580,6 @@ /** * Sets sourcePath of an object - * @method setSourcePath * @param {String} value * @return {fabric.Object} thisArg * @chainable @@ -652,7 +591,6 @@ /** * Renders an object on a specified context - * @method render * @param {CanvasRenderingContext2D} ctx context to render on * @param {Boolean} [noTransform] When true, context is not transformed */ @@ -710,7 +648,6 @@ /** * @private - * @method _setShadow */ _setShadow: function(ctx) { if (!this.shadow) return; @@ -723,7 +660,6 @@ /** * @private - * @method _removeShadow */ _removeShadow: function(ctx) { ctx.shadowColor = ''; @@ -732,7 +668,6 @@ /** * @private - * @method _renderFill */ _renderFill: function(ctx) { if (!this.fill) return; @@ -751,7 +686,6 @@ /** * Clones an instance - * @method clone * @param {Function} callback Callback is invoked with a clone as a first argument * @param {Array} propertiesToInclude * @return {fabric.Object} clone of an instance @@ -765,7 +699,6 @@ /** * Creates an instance of fabric.Image out of an object - * @method cloneAsImage * @param callback {Function} callback, invoked with an instance as a first argument * @return {fabric.Object} thisArg * @chainable @@ -799,7 +732,6 @@ /** * Converts an object into a data-url-like string - * @method toDataURL * @param callback {Function} callback that recieves resulting data-url string */ toDataURL: function(callback) { @@ -839,7 +771,6 @@ /** * Returns true if object state (one of its state properties) was changed - * @method hasStateChanged * @return {Boolean} true if instance' state has changed */ hasStateChanged: function() { @@ -850,7 +781,6 @@ /** * Saves state of an object - * @method saveState * @param {Object} [options] Object with additional `stateProperties` array to include when saving state * @return {fabric.Object} thisArg * @chainable @@ -871,7 +801,6 @@ /** * Setups state of an object - * @method setupState */ setupState: function() { this.originalState = { }; @@ -880,7 +809,6 @@ /** * Returns true if specified type is identical to the type of an instance - * @method isType * @param type {String} type to check against * @return {Boolean} */ @@ -890,7 +818,6 @@ /** * Makes object's color grayscale - * @method toGrayscale * @return {fabric.Object} thisArg */ toGrayscale: function() { @@ -903,7 +830,6 @@ /** * Returns complexity of an instance - * @method complexity * @return {Number} complexity */ complexity: function() { @@ -912,9 +838,8 @@ /** * Returns a JSON representation of an instance - * @method toJSON * @param {Array} propertiesToInclude Any properties that you might want to additionally include in the output - * @return {String} json + * @return {Object} JSON */ toJSON: function(propertiesToInclude) { // delegate, not alias @@ -923,7 +848,6 @@ /** * Sets gradient (fill or stroke) of an object - * @method setGradient * @param {String} property Property name 'stroke' or 'fill' * @param {Object} [options] Options object */ @@ -955,7 +879,6 @@ /** * Sets pattern fill of an object - * @method setPatternFill * @param {Object} [options] Options object * @return {fabric.Object} thisArg * @chainable @@ -966,7 +889,6 @@ /** * Sets shadow of an object - * @method setShadow * @param {Object} [options] Options object * @return {fabric.Object} thisArg * @chainable @@ -977,7 +899,6 @@ /** * Animates object's properties - * @method animate * @param {String|Object} property to animate (if string) or properties to animate (if object) * @param {Number|Object} value to animate property to (if string was given first) or options object * @return {fabric.Object} thisArg @@ -1014,7 +935,6 @@ /** * @private - * @method _animate * @param {String} property * @param {String} to * @param {Object} [options] @@ -1078,7 +998,6 @@ /** * Centers object horizontally on canvas to which it was added last - * @method centerH * @return {fabric.Object} thisArg */ centerH: function () { @@ -1088,7 +1007,6 @@ /** * Centers object vertically on canvas to which it was added last - * @method centerV * @return {fabric.Object} thisArg * @chainable */ @@ -1099,7 +1017,6 @@ /** * Centers object vertically and horizontally on canvas to which is was added last - * @method center * @return {fabric.Object} thisArg * @chainable */ @@ -1109,7 +1026,6 @@ /** * Removes object from canvas to which it was added last - * @method remove * @return {fabric.Object} thisArg * @chainable */ @@ -1119,7 +1035,6 @@ /** * Moves an object to the bottom of the stack of drawn objects - * @method sendToBack * @return {fabric.Object} thisArg * @chainable */ @@ -1135,7 +1050,6 @@ /** * Moves an object to the top of the stack of drawn objects - * @method bringToFront * @return {fabric.Object} thisArg * @chainable */ @@ -1151,7 +1065,6 @@ /** * Moves an object one level down in stack of drawn objects - * @method sendBackwards * @return {fabric.Object} thisArg * @chainable */ @@ -1167,7 +1080,6 @@ /** * Moves an object one level up in stack of drawn objects - * @method bringForward * @return {fabric.Object} thisArg * @chainable */ @@ -1183,7 +1095,6 @@ /** * Moves an object to specified level in stack of drawn objects - * @method moveTo * @param {Number} index New position of object * @return {fabric.Object} thisArg * @chainable diff --git a/src/object_geometry.mixin.js b/src/object_geometry.mixin.js index 25222b2e..1cad84d5 100644 --- a/src/object_geometry.mixin.js +++ b/src/object_geometry.mixin.js @@ -2,11 +2,10 @@ var degreesToRadians = fabric.util.degreesToRadians; - fabric.util.object.extend(fabric.Object.prototype, /** @scope fabric.Object.prototype */ { + fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prototype */ { /** * Returns true if object intersects with an area formed by 2 points - * @method intersectsWithRect * @param {Object} selectionTL * @param {Object} selectionBR * @return {Boolean} @@ -28,7 +27,6 @@ /** * Returns true if object intersects with another object - * @method intersectsWithObject * @param {Object} other Object to test * @return {Boolean} */ @@ -55,7 +53,6 @@ /** * Returns true if object is fully contained within area of another object - * @method isContainedWithinObject * @param {Object} other Object to test * @return {Boolean} */ @@ -65,7 +62,6 @@ /** * Returns true if object is fully contained within area formed by 2 points - * @method isContainedWithinRect * @param {Object} selectionTL * @param {Object} selectionBR * @return {Boolean} @@ -85,7 +81,6 @@ /** * Returns width of an object's bounding rectangle * @deprecated since 1.0.4 - * @method getBoundingRectWidth * @return {Number} width value */ getBoundingRectWidth: function() { @@ -95,7 +90,6 @@ /** * Returns height of an object's bounding rectangle * @deprecated since 1.0.4 - * @method getBoundingRectHeight * @return {Number} height value */ getBoundingRectHeight: function() { @@ -104,7 +98,6 @@ /** * Returns coordinates of object's bounding rectangle (left, top, width, height) - * @method getBoundingRect * @return {Object} Object with left, top, width, height properties */ getBoundingRect: function() { @@ -130,7 +123,6 @@ /** * Returns width of an object - * @method getWidth * @return {Number} width value */ getWidth: function() { @@ -139,7 +131,6 @@ /** * Returns height of an object - * @method getHeight * @return {Number} height value */ getHeight: function() { @@ -149,7 +140,6 @@ /** * Makes sure the scale is valid and modifies it if necessary * @private - * @method _constrainScale * @param {Number} value * @return {Number} */ @@ -166,7 +156,6 @@ /** * Scales an object (equally by x and y) - * @method scale * @param value {Number} scale factor * @return {fabric.Object} thisArg * @chainable @@ -188,7 +177,6 @@ /** * Scales an object to a given width, with respect to bounding box (scaling by x/y equally) - * @method scaleToWidth * @param value {Number} new width value * @return {fabric.Object} thisArg * @chainable @@ -201,7 +189,6 @@ /** * Scales an object to a given height, with respect to bounding box (scaling by x/y equally) - * @method scaleToHeight * @param value {Number} new height value * @return {fabric.Object} thisArg * @chainable @@ -214,7 +201,6 @@ /** * Sets corner position coordinates based on current angle, width and height - * @method setCoords * @return {fabric.Object} thisArg * @chainable */ @@ -305,4 +291,4 @@ return this; } }); -})(); \ No newline at end of file +})(); diff --git a/src/object_interactivity.mixin.js b/src/object_interactivity.mixin.js index 0e6d7aef..65d3a76d 100644 --- a/src/object_interactivity.mixin.js +++ b/src/object_interactivity.mixin.js @@ -3,11 +3,10 @@ var getPointer = fabric.util.getPointer, degreesToRadians = fabric.util.degreesToRadians; - fabric.util.object.extend(fabric.Object.prototype, /** @scope fabric.Object.prototype */ { + fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prototype */ { /** * Determines which one of the four corners has been clicked - * @method _findTargetCorner * @private * @param e {Event} event object * @param offset {Object} canvas offset @@ -60,7 +59,6 @@ /** * Helper method to determine how many cross points are between the 4 image edges * and the horizontal line determined by the position of our mouse when clicked on canvas - * @method _findCrossPoints * @private * @param ex {Number} x coordinate of the mouse * @param ey {Number} y coordinate of the mouse @@ -110,7 +108,6 @@ /** * Method that returns an object with the image lines in it given the coordinates of the corners - * @method _getImageLines * @private * @param oCoords {Object} coordinates of the image corners */ @@ -138,7 +135,6 @@ /** * Sets the coordinates of the draggable boxes in the corners of * the image used to scale/rotate it. - * @method _setCornerCoords * @private */ _setCornerCoords: function() { @@ -326,7 +322,6 @@ * Draws borders of an object's bounding box. * Requires public properties: width, height * Requires public options: padding, borderColor - * @method drawBorders * @param {CanvasRenderingContext2D} ctx Context to draw on * @return {fabric.Object} thisArg * @chainable @@ -383,7 +378,6 @@ * Draws corners of an object's bounding box. * Requires public properties: width, height, scaleX, scaleY * Requires public options: cornerSize, padding - * @method drawControls * @param {CanvasRenderingContext2D} ctx Context to draw on * @return {fabric.Object} thisArg * @chainable diff --git a/src/object_origin.mixin.js b/src/object_origin.mixin.js index 00981731..deab234f 100644 --- a/src/object_origin.mixin.js +++ b/src/object_origin.mixin.js @@ -2,11 +2,10 @@ var degreesToRadians = fabric.util.degreesToRadians; - fabric.util.object.extend(fabric.Object.prototype, /** @scope fabric.Object.prototype */ { + fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prototype */ { /** * Translates the coordinates from origin to center coordinates (based on the object's dimensions) - * @method translateToCenterPoint * @param {fabric.Point} point The point which corresponds to the originX and originY params * @param {string} enum('left', 'center', 'right') Horizontal origin * @param {string} enum('top', 'center', 'bottom') Vertical origin @@ -35,7 +34,6 @@ /** * Translates the coordinates from center to origin coordinates (based on the object's dimensions) - * @method translateToOriginPoint * @param {fabric.Point} point The point which corresponds to center of the object * @param {string} enum('left', 'center', 'right') Horizontal origin * @param {string} enum('top', 'center', 'bottom') Vertical origin @@ -64,7 +62,6 @@ /** * Returns the real center coordinates of the object - * @method getCenterPoint * @return {fabric.Point} */ getCenterPoint: function() { @@ -74,7 +71,6 @@ /** * Returns the coordinates of the object based on center coordinates - * @method getOriginPoint * @param {fabric.Point} point The point which corresponds to the originX and originY params * @return {fabric.Point} */ @@ -84,7 +80,6 @@ /** * Returns the coordinates of the object as if it has a different origin - * @method getPointByOrigin * @param {string} enum('left', 'center', 'right') Horizontal origin * @param {string} enum('top', 'center', 'bottom') Vertical origin * @return {fabric.Point} @@ -97,7 +92,6 @@ /** * Returns the point in local coordinates - * @method toLocalPoint * @param {fabric.Point} The point relative to the global coordinate system * @return {fabric.Point} */ @@ -136,7 +130,6 @@ /** * Returns the point in global coordinates - * @method toGlobalPoint * @param {fabric.Point} The point relative to the local coordinate system * @return {fabric.Point} */ @@ -146,7 +139,6 @@ /** * Sets the position of the object taking into consideration the object's origin - * @method setPositionByOrigin * @param {fabric.Point} point The new position of the object * @param {string} enum('left', 'center', 'right') Horizontal origin * @param {string} enum('top', 'center', 'bottom') Vertical origin @@ -161,7 +153,6 @@ }, /** - * @method adjustPosition * @param {String} to One of left, center, right */ adjustPosition: function(to) { @@ -204,4 +195,4 @@ } }); -})(); \ No newline at end of file +})(); diff --git a/src/object_straightening.mixin.js b/src/object_straightening.mixin.js index 8cd8aa28..7c572369 100644 --- a/src/object_straightening.mixin.js +++ b/src/object_straightening.mixin.js @@ -1,8 +1,7 @@ -fabric.util.object.extend(fabric.Object.prototype, /** @scope fabric.Object.prototype */ { +fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prototype */ { /** * @private - * @method _getAngleValueForStraighten * @return {Number} angle value */ _getAngleValueForStraighten: function() { @@ -15,7 +14,6 @@ fabric.util.object.extend(fabric.Object.prototype, /** @scope fabric.Object.prot /** * Straightens an object (rotating it from current angle to one of 0, 90, 180, 270, etc. depending on which is closer) - * @method straighten * @return {fabric.Object} thisArg * @chainable */ @@ -26,7 +24,6 @@ fabric.util.object.extend(fabric.Object.prototype, /** @scope fabric.Object.prot /** * Same as {@link fabric.Object.prototype.straghten} but with animation - * @method fxStraighten * @param {Object} callbacks * - onComplete: invoked on completion * - onChange: invoked on every step of animation @@ -63,11 +60,10 @@ fabric.util.object.extend(fabric.Object.prototype, /** @scope fabric.Object.prot } }); -fabric.util.object.extend(fabric.StaticCanvas.prototype, { +fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @lends fabric.StaticCanvas.prototype */ { /** * Straightens object, then rerenders canvas - * @method straightenObject * @param {fabric.Object} object Object to straighten * @return {fabric.Canvas} thisArg * @chainable @@ -80,7 +76,6 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, { /** * Same as {@link fabric.Canvas.prototype.straightenObject}, but animated - * @method fxStraightenObject * @param {fabric.Object} object Object to straighten * @return {fabric.Canvas} thisArg * @chainable @@ -91,4 +86,4 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, { }); return this; } -}); \ No newline at end of file +}); diff --git a/src/observable.mixin.js b/src/observable.mixin.js index 692024fa..84470715 100644 --- a/src/observable.mixin.js +++ b/src/observable.mixin.js @@ -1,16 +1,14 @@ -/** - * @namespace - */ -fabric.Observable = { +(function(){ /** * Observes specified event - * @method observe - * @depracated Since 0.8.34. Use `on` instead. + * @deprecated `observe` deprecated since 0.8.34 (use `on` instead) + * @memberOf fabric.Observable + * @alias on * @param {String} eventName * @param {Function} handler */ - observe: function(eventName, handler) { + function observe(eventName, handler) { if (!this.__eventListeners) { this.__eventListeners = { }; } @@ -26,16 +24,17 @@ fabric.Observable = { } this.__eventListeners[eventName].push(handler); } - }, + } /** * Stops event observing for a particular event handler - * @method stopObserving - * @depracated Since 0.8.34. Use `off` instead. + * @deprecated `stopObserving` deprecated since 0.8.34 (use `off` instead) + * @memberOf fabric.Observable + * @alias off * @param {String} eventName * @param {Function} handler */ - stopObserving: function(eventName, handler) { + function stopObserving(eventName, handler) { if (!this.__eventListeners) { this.__eventListeners = { }; } @@ -47,16 +46,17 @@ fabric.Observable = { this.__eventListeners[eventName].length = 0; } } - }, + } /** * Fires event with an optional options object - * @deprecated since 1.0.7 - * @method fire + * @deprecated `fire` deprecated since 1.0.7 (use `trigger` instead) + * @memberOf fabric.Observable + * @alias trigger * @param {String} eventName * @param {Object} [options] */ - fire: function(eventName, options) { + function fire(eventName, options) { if (!this.__eventListeners) { this.__eventListeners = { }; } @@ -67,25 +67,17 @@ fabric.Observable = { listenersForEvent[i](options || { }); } } -}; -/** - * Alias for observe - * @method observe - * @type function - */ -fabric.Observable.on = fabric.Observable.observe; + /** + * @namespace fabric.Observable + */ + fabric.Observable = { + observe: observe, + stopObserving: stopObserving, + fire: fire, -/** - * Alias for stopObserving - * @method off - * @type function - */ -fabric.Observable.off = fabric.Observable.stopObserving; - -/** - * Alias for fire - * @method trigger - * @type function - */ -fabric.Observable.trigger = fabric.Observable.fire; \ No newline at end of file + on: observe, + off: stopObserving, + trigger: fire + }; +})(); diff --git a/src/parser.js b/src/parser.js index 2d6c50d2..7a1c6ff9 100644 --- a/src/parser.js +++ b/src/parser.js @@ -43,7 +43,6 @@ * Parses parent "g" nodes recursively upwards. * @static * @memberOf fabric - * @method parseAttributes * @param {DOMElement} element Element to parse * @param {Array} attributes Array of attributes to parse * @return {Object} object containing parsed attributes' names/values @@ -100,7 +99,6 @@ * @static * @function * @memberOf fabric - * @method parseTransformAttribute * @param attributeValue {String} string containing attribute value * @return {Array} array of 6 elements representing transformation matrix */ @@ -245,7 +243,6 @@ * Parses "points" attribute, returning an array of values * @static * @memberOf fabric - * @method parsePointsAttribute * @param points {String} points attribute string * @return {Array} array of points */ @@ -289,7 +286,6 @@ * Parses "style" attribute, retuning an object with values * @static * @memberOf fabric - * @method parseStyleAttribute * @param {SVGElement} element Element to parse * @return {Object} Objects with values parsed from style attribute of an element */ @@ -343,7 +339,6 @@ * Transforms an array of svg elements to corresponding fabric.* instances * @static * @memberOf fabric - * @method parseElements * @param {Array} elements Array of elements to parse * @param {Function} callback Being passed an array of fabric instances (transformed from SVG elements) * @param {Object} [options] Options object @@ -398,7 +393,6 @@ * @static * @function * @memberOf fabric - * @method getCSSRules * @param {SVGDocument} doc SVG document to parse * @return {Object} CSS rules of this document */ @@ -469,7 +463,6 @@ * @static * @function * @memberOf fabric - * @method parseSVGDocument * @param {SVGDocument} doc SVG document to parse * @param {Function} callback Callback to call when parsing is finished; It's being passed an array of elements (parsed from a document). * @param {Function} [reviver] Method for further parsing of SVG elements, called after each fabric object created. @@ -564,15 +557,13 @@ }; })(); - /** + /** * Used for caching SVG documents (loaded via `fabric.Canvas#loadSVGFromURL`) - * @property * @namespace */ var svgCache = { /** - * @method has * @param {String} name * @param {Function} callback */ @@ -581,7 +572,6 @@ }, /** - * @method get * @param {String} url * @param {Function} callback */ @@ -590,7 +580,6 @@ }, /** - * @method set * @param {String} url * @param {Object} object */ @@ -601,7 +590,6 @@ /** * Takes url corresponding to an SVG document, and parses it into a set of fabric objects. Note that SVG is fetched via XMLHttpRequest, so it needs to conform to SOP (Same Origin Policy) - * @method loadSVGFromURL * @memberof fabric * @param {String} url * @param {Function} callback @@ -648,8 +636,8 @@ } /** - * @method _enlivenCachedObject - */ + * @private + */ function _enlivenCachedObject(cachedObject) { var objects = cachedObject.objects, @@ -664,7 +652,6 @@ /** * Takes string corresponding to an SVG document, and parses it into a set of fabric objects - * @method loadSVGFromString * @memberof fabric * @param {String} string * @param {Function} callback @@ -693,7 +680,6 @@ /** * Creates markup containing SVG font faces - * @method createSVGFontFacesMarkup * @param {Array} objects Array of fabric objects * @return {String} */ @@ -726,7 +712,6 @@ /** * Creates markup containing SVG referenced elements like patterns, gradients etc. - * @method createSVGRefElementsMarkup * @param {fabric.Canvas} canvas instance of fabric.Canvas * @return {String} */ diff --git a/src/path.class.js b/src/path.class.js index aa46259f..c8a3c754 100644 --- a/src/path.class.js +++ b/src/path.class.js @@ -159,18 +159,16 @@ * @class Path * @extends fabric.Object */ - fabric.Path = fabric.util.createClass(fabric.Object, /** @scope fabric.Path.prototype */ { + fabric.Path = fabric.util.createClass(fabric.Object, /** @lends fabric.Path.prototype */ { /** * Type of an object - * @property * @type String */ type: 'path', /** * Constructor - * @method initialize * @param {Array|String} path Path data (sequence of coordinates and corresponding "command" tokens) * @param {Object} [options] Options object */ @@ -204,7 +202,6 @@ /** * @private - * @method _initializePath */ _initializePath: function (options) { var isWidthSet = 'width' in options, @@ -234,7 +231,6 @@ /** * @private - * @method _calculatePathOffset */ _calculatePathOffset: function (positionSet) { return { @@ -245,7 +241,6 @@ /** * @private - * @method _render */ _render: function(ctx) { var current, // current instruction @@ -527,7 +522,6 @@ /** * Renders path on a specified context - * @method render * @param {CanvasRenderingContext2D} ctx context to render path on * @param {Boolean} [noTransform] When true, context is not transformed */ @@ -589,7 +583,6 @@ /** * Returns string representation of an instance - * @method toString * @return {String} string representation of an instance */ toString: function() { @@ -599,7 +592,6 @@ /** * Returns object representation of an instance - * @method toObject * @param {Array} propertiesToInclude * @return {Object} object representation of an instance */ @@ -618,7 +610,6 @@ /** * Returns dataless object representation of an instance - * @method toDatalessObject * @param {Array} propertiesToInclude * @return {Object} object representation of an instance */ @@ -633,7 +624,6 @@ /** * Returns svg representation of an instance - * @method toSVG * @return {String} svg representation of an instance */ toSVG: function() { @@ -668,7 +658,6 @@ /** * Returns number representation of an instance complexity - * @method complexity * @return {Number} complexity */ complexity: function() { @@ -677,7 +666,6 @@ /** * @private - * @method _parsePath */ _parsePath: function() { var result = [ ], @@ -714,7 +702,7 @@ }, /** - * @method _parseDimensions + * @private */ _parseDimensions: function() { var aX = [], @@ -788,7 +776,6 @@ /** * Creates an instance of fabric.Path from an object * @static - * @method fabric.Path.fromObject * @return {fabric.Path} Instance of fabric.Path */ fabric.Path.fromObject = function(object) { @@ -805,7 +792,6 @@ /** * Creates an instance of fabric.Path from an SVG element * @static - * @method fabric.Path.fromElement * @param {SVGElement} element to parse * @param {Object} [options] Options object * @return {fabric.Path} Instance of fabric.Path diff --git a/src/path_group.class.js b/src/path_group.class.js index ed88e51d..7bf50b73 100644 --- a/src/path_group.class.js +++ b/src/path_group.class.js @@ -19,25 +19,22 @@ * @class PathGroup * @extends fabric.Path */ - fabric.PathGroup = fabric.util.createClass(fabric.Path, /** @scope fabric.PathGroup.prototype */ { + fabric.PathGroup = fabric.util.createClass(fabric.Path, /** @lends fabric.PathGroup.prototype */ { /** * Type of an object - * @property * @type String */ type: 'path-group', /** * Fill value - * @property * @type String */ fill: '', /** * Constructor - * @method initialize * @param {Array} paths * @param {Object} [options] Options object * @return {fabric.PathGroup} thisArg @@ -61,7 +58,6 @@ /** * Renders this group on a specified context - * @method render * @param {CanvasRenderingContext2D} ctx Context to render this instance on */ render: function(ctx) { @@ -94,7 +90,6 @@ /** * Sets certain property to a certain value - * @method _set * @param {String} prop * @param {Any} value * @return {fabric.PathGroup} thisArg @@ -113,7 +108,6 @@ /** * Returns object representation of this path group - * @method toObject * @param {Array} [propertiesToInclude] * @return {Object} object representation of an instance */ @@ -126,7 +120,6 @@ /** * Returns dataless object representation of this path group - * @method toDatalessObject * @param {Array} [propertiesToInclude] * @return {Object} dataless object representation of an instance */ @@ -140,7 +133,6 @@ /** * Returns svg representation of an instance - * @method toSVG * @return {String} svg representation of an instance */ toSVG: function() { @@ -162,7 +154,6 @@ /** * Returns a string representation of this path group - * @method toString * @return {String} string representation of an object */ toString: function() { @@ -172,7 +163,6 @@ /** * Returns true if all paths in this group are of same color - * @method isSameColor * @return {Boolean} true if all paths are of the same color (`fill`) */ isSameColor: function() { @@ -184,7 +174,6 @@ /** * Returns number representation of object's complexity - * @method complexity * @return {Number} complexity */ complexity: function() { @@ -195,7 +184,6 @@ /** * Makes path group grayscale - * @method toGrayscale * @return {fabric.PathGroup} thisArg */ toGrayscale: function() { @@ -208,7 +196,6 @@ /** * Returns all paths in this path group - * @method getObjects * @return {Array} array of path objects included in this path group */ getObjects: function() { @@ -218,7 +205,6 @@ /** * @private - * @method instantiatePaths */ function instantiatePaths(paths) { for (var i = 0, len = paths.length; i < len; i++) { @@ -233,7 +219,6 @@ /** * Creates fabric.PathGroup instance from an object representation * @static - * @method fabric.PathGroup.fromObject * @param {Object} object * @return {fabric.PathGroup} */ @@ -242,4 +227,4 @@ return new fabric.PathGroup(paths, object); }; -})(typeof exports !== 'undefined' ? exports : this); \ No newline at end of file +})(typeof exports !== 'undefined' ? exports : this); diff --git a/src/pattern.class.js b/src/pattern.class.js index 064976ed..e2de0be9 100644 --- a/src/pattern.class.js +++ b/src/pattern.class.js @@ -3,32 +3,28 @@ * @class Pattern * @memberOf fabric */ -fabric.Pattern = fabric.util.createClass(/** @scope fabric.Pattern.prototype */ { +fabric.Pattern = fabric.util.createClass(/** @lends fabric.Pattern.prototype */ { /** * Repeat property of a pattern (one of repeat, repeat-x, repeat-y) - * @property * @type String */ repeat: 'repeat', /** * Pattern horizontal offset from object's left/top corner - * @property * @type Number */ offsetX: 0, /** * Pattern vertical offset from object's left/top corner - * @property * @type Number */ offsetY: 0, /** * Constructor - * @method initialize * @param {Object} [options] * @return {fabric.Pattern} thisArg */ @@ -53,7 +49,6 @@ fabric.Pattern = fabric.util.createClass(/** @scope fabric.Pattern.prototype */ /** * Returns object representation of a pattern - * @method toObject * @return {Object} */ toObject: function() { @@ -80,7 +75,6 @@ fabric.Pattern = fabric.util.createClass(/** @scope fabric.Pattern.prototype */ /** * Returns an instance of CanvasPattern - * @method toLive * @param ctx * @return {CanvasPattern} */ diff --git a/src/pattern_brush.class.js b/src/pattern_brush.class.js index 2b077799..b9f38edc 100644 --- a/src/pattern_brush.class.js +++ b/src/pattern_brush.class.js @@ -3,7 +3,7 @@ * @class fabric.PatternBrush * @extends fabric.BaseBrush */ -fabric.PatternBrush = fabric.util.createClass(fabric.PencilBrush, /** @scope fabric.PatternBrush.prototype */ { +fabric.PatternBrush = fabric.util.createClass(fabric.PencilBrush, /** @lends fabric.PatternBrush.prototype */ { getPatternSrc: function() { @@ -31,7 +31,6 @@ fabric.PatternBrush = fabric.util.createClass(fabric.PencilBrush, /** @scope fab /** * Creates "pattern" instance property - * @method getPattern */ getPattern: function() { return this.canvas.contextTop.createPattern(this.source || this.getPatternSrc(), 'repeat'); @@ -39,7 +38,6 @@ fabric.PatternBrush = fabric.util.createClass(fabric.PencilBrush, /** @scope fab /** * Sets brush styles - * @method setBrushStyles */ setBrushStyles: function() { this.callSuper('setBrushStyles'); @@ -48,7 +46,6 @@ fabric.PatternBrush = fabric.util.createClass(fabric.PencilBrush, /** @scope fab /** * Creates path - * @method createPath */ createPath: function(pathData) { var path = this.callSuper('createPath', pathData); @@ -57,4 +54,4 @@ fabric.PatternBrush = fabric.util.createClass(fabric.PencilBrush, /** @scope fab }); return path; } -}); \ No newline at end of file +}); diff --git a/src/pencil_brush.class.js b/src/pencil_brush.class.js index 3db4f0a0..df644a63 100644 --- a/src/pencil_brush.class.js +++ b/src/pencil_brush.class.js @@ -8,11 +8,10 @@ * @class fabric.PencilBrush * @extends fabric.BaseBrush */ - fabric.PencilBrush = fabric.util.createClass( fabric.BaseBrush, /** @scope fabric.PencilBrush.prototype */ { + fabric.PencilBrush = fabric.util.createClass( fabric.BaseBrush, /** @lends fabric.PencilBrush.prototype */ { /** * Constructor - * @method initialize * @param {fabric.Canvas} canvas * @return {fabric.PencilBrush} Instance of a pencil brush */ @@ -22,7 +21,7 @@ }, /** - * @method onMouseDown + * Inovoked on mouse down * @param {Object} pointer */ onMouseDown: function(pointer) { @@ -33,7 +32,7 @@ }, /** - * @method onMouseMove + * Inovoked on mouse move * @param {Object} pointer */ onMouseMove: function(pointer) { @@ -45,14 +44,13 @@ }, /** - * @method onMouseUp + * Invoked on mouse up */ onMouseUp: function() { this._finalizeAndAddPath(); }, /** - * @method _prepareForDrawing * @param {Object} pointer */ _prepareForDrawing: function(pointer) { @@ -67,7 +65,6 @@ /** * @private - * @method _addPoint * @param {fabric.Point} point */ _addPoint: function(point) { @@ -79,7 +76,6 @@ * style. * * @private - * @method _reset * */ _reset: function() { @@ -91,7 +87,6 @@ /** * @private - * @method _captureDrawingPath * * @param point {pointer} (fabric.util.pointer) actual mouse position * related to the canvas. @@ -105,7 +100,6 @@ * Draw a smooth path on the topCanvas using quadraticCurveTo * * @private - * @method _render */ _render: function() { var ctx = this.canvas.contextTop; @@ -136,7 +130,6 @@ * Return an SVG path based on our captured points and their bounding box * * @private - * @method _getSVGPathData */ _getSVGPathData: function() { this.box = this.getPathBoundingBox(this._points); @@ -146,7 +139,6 @@ /** * Returns bounding box of a path based on given points - * @method getPathBoundingBox * @param {Array} points * @return {Object} object with minx, miny, maxx, maxy */ @@ -183,7 +175,6 @@ /** * Converts points to SVG path - * @method convertPointsToSVGPath * @param {Array} points Array of points * @return {String} SVG path */ @@ -210,7 +201,6 @@ /** * Creates fabric.Path object to add on canvas - * @method createPath * @param {String} pathData Path data * @return {fabric.Path} path to add on canvas */ @@ -234,7 +224,6 @@ * we use the points captured to create an new fabric path object * and add it to the fabric canvas. * - * @method _finalizeAndAddPath */ _finalizeAndAddPath: function() { var ctx = this.canvas.contextTop; diff --git a/src/point.class.js b/src/point.class.js index 6fd88f38..fc3ce961 100644 --- a/src/point.class.js +++ b/src/point.class.js @@ -28,13 +28,12 @@ } } - Point.prototype = /** @scope fabric.Point.prototype */ { + Point.prototype = /** @lends fabric.Point.prototype */ { constructor: Point, /** * Constructor - * @method init * @param {Number} x left offset * @param {Number} y top offset */ @@ -45,7 +44,6 @@ /** * Adds another point to this one and returns another one - * @method add * @param {fabric.Point} that * @return {fabric.Point} new Point instance with added values */ @@ -55,7 +53,6 @@ /** * Adds another point to this one - * @method addEquals * @param {fabric.Point} that * @return {fabric.Point} thisArg */ @@ -67,7 +64,6 @@ /** * Adds value to this point and returns a new one - * @method scalarAdd * @param {Number} scalar * @return {fabric.Point} new Point with added value */ @@ -77,7 +73,6 @@ /** * Adds value to this point - * @method scalarAddEquals * @param {Number} scalar * @param {fabric.Point} thisArg */ @@ -89,7 +84,6 @@ /** * Subtracts another point from this point and returns a new one - * @method subtract * @param {fabric.Point} that * @return {fabric.Point} new Point object with subtracted values */ @@ -99,7 +93,6 @@ /** * Subtracts another point from this point - * @method subtractEquals * @param {fabric.Point} that * @return {fabric.Point} thisArg */ @@ -111,7 +104,6 @@ /** * Subtracts value from this point and returns a new one - * @method scalarSubtract * @param {Number} scalar * @return {fabric.Point} */ @@ -121,7 +113,6 @@ /** * Subtracts value from this point - * @method scalarSubtractEquals * @param {Number} scalar * @return {fabric.Point} thisArg */ @@ -133,7 +124,6 @@ /** * Miltiplies this point by a value and returns a new one - * @method multiply * @param {Number} scalar * @return {fabric.Point} */ @@ -143,7 +133,6 @@ /** * Miltiplies this point by a value - * @method multiplyEquals * @param {Number} scalar * @return {fabric.Point} thisArg */ @@ -155,7 +144,6 @@ /** * Divides this point by a value and returns a new one - * @method divide * @param {Number} scalar * @return {fabric.Point} */ @@ -165,7 +153,6 @@ /** * Divides this point by a value - * @method divideEquals * @param {Number} scalar * @return {fabric.Point} thisArg */ @@ -177,7 +164,6 @@ /** * Returns true if this point is equal to another one - * @method eq * @param {fabric.Point} that * @return {Boolean} */ @@ -187,7 +173,6 @@ /** * Returns true if this point is less than another one - * @method lt * @param {fabric.Point} that * @return {Boolean} */ @@ -197,7 +182,6 @@ /** * Returns true if this point is less than or equal to another one - * @method lte * @param {fabric.Point} that * @return {Boolean} */ @@ -208,7 +192,6 @@ /** * Returns true if this point is greater another one - * @method gt * @param {fabric.Point} that * @return {Boolean} */ @@ -218,7 +201,6 @@ /** * Returns true if this point is greater than or equal to another one - * @method gte * @param {fabric.Point} that * @return {Boolean} */ @@ -228,7 +210,6 @@ /** * Returns new point which is the result of linear interpolation with this one and another one - * @method lerp * @param {fabric.Point} that * @param {Number} t * @return {fabric.Point} @@ -239,7 +220,6 @@ /** * Returns distance from this point and another one - * @method distanceFrom * @param {fabric.Point} that * @return {Number} */ @@ -251,7 +231,6 @@ /** * Returns the point between this point and another one - * @method midPointFrom * @param {fabric.Point} that * @return {fabric.Point} */ @@ -261,7 +240,6 @@ /** * Returns a new point which is the min of this and another one - * @method min * @param {fabric.Point} that * @return {fabric.Point} */ @@ -271,7 +249,6 @@ /** * Returns a new point which is the max of this and another one - * @method max * @param {fabric.Point} that * @return {fabric.Point} */ @@ -281,7 +258,6 @@ /** * Returns string representation of this point - * @method toString * @return {String} */ toString: function () { @@ -290,7 +266,6 @@ /** * Sets x/y of this point - * @method setXY * @param {Number} x * @return {Number} y */ @@ -301,7 +276,6 @@ /** * Sets x/y of this point from another point - * @method setFromPoint * @param {fabric.Point} that */ setFromPoint: function (that) { @@ -311,7 +285,6 @@ /** * Swaps x/y of this point and another point - * @method setFromPoint * @param {fabric.Point} that */ swap: function (that) { diff --git a/src/polygon.class.js b/src/polygon.class.js index 69938553..0a3d2920 100644 --- a/src/polygon.class.js +++ b/src/polygon.class.js @@ -18,18 +18,16 @@ * @class Polygon * @extends fabric.Object */ - fabric.Polygon = fabric.util.createClass(fabric.Object, /** @scope fabric.Polygon.prototype */ { + fabric.Polygon = fabric.util.createClass(fabric.Object, /** @lends fabric.Polygon.prototype */ { /** * Type of an object - * @property * @type String */ type: 'polygon', /** * Constructor - * @method initialize * @param {Array} points Array of points * @param {Object} [options] Options object * @param {Boolean} Whether points offsetting should be skipped @@ -44,7 +42,6 @@ /** * @private - * @method _calcDimensions */ _calcDimensions: function(skipOffset) { @@ -74,7 +71,6 @@ /** * Returns object representation of an instance - * @method toObject * @param {Array} propertiesToInclude * @return {Object} object representation of an instance */ @@ -86,7 +82,6 @@ /** * Returns svg representation of an instance - * @method toSVG * @return {String} svg representation of an instance */ toSVG: function() { @@ -117,7 +112,6 @@ /** * @private - * @method _render * @param ctx {CanvasRenderingContext2D} context to render on */ _render: function(ctx) { @@ -138,7 +132,6 @@ /** * Returns complexity of an instance - * @method complexity * @return {Number} complexity of this instance */ complexity: function() { @@ -156,7 +149,6 @@ /** * Returns {@link fabric.Polygon} instance from an SVG element * @static - * @method fabric.Polygon.fromElement * @param {SVGElement} element Element to parse * @param {Object} [options] Options object * @return {fabric.Polygon} @@ -182,7 +174,6 @@ /** * Returns fabric.Polygon instance from an object representation * @static - * @method fabric.Polygon.fromObject * @param {Object} object Object to create an instance from * @return {fabric.Polygon} */ diff --git a/src/polyline.class.js b/src/polyline.class.js index f2b02840..f0a4a3c3 100644 --- a/src/polyline.class.js +++ b/src/polyline.class.js @@ -15,18 +15,16 @@ * @class Polyline * @extends fabric.Object */ - fabric.Polyline = fabric.util.createClass(fabric.Object, /** @scope fabric.Polyline.prototype */ { + fabric.Polyline = fabric.util.createClass(fabric.Object, /** @lends fabric.Polyline.prototype */ { /** * Type of an object - * @property * @type String */ type: 'polyline', /** * Constructor - * @method initialize * @param {Array} points array of points * @param {Object} [options] Options object * @param {Boolean} Whether points offsetting should be skipped @@ -41,7 +39,6 @@ /** * @private - * @method _calcDimensions */ _calcDimensions: function(skipOffset) { return fabric.Polygon.prototype._calcDimensions.call(this, skipOffset); @@ -49,7 +46,6 @@ /** * Returns object representation of an instance - * @method toObject * @param {Array} propertiesToInclude * @return {Object} object representation of an instance */ @@ -59,7 +55,6 @@ /** * Returns SVG representation of an instance - * @method toSVG * @return {String} svg representation of an instance */ toSVG: function() { @@ -90,7 +85,6 @@ /** * @private - * @method _render * @param {CanvasRenderingContext2D} ctx Context to render on */ _render: function(ctx) { @@ -110,7 +104,6 @@ /** * Returns complexity of an instance - * @method complexity * @return {Number} complexity */ complexity: function() { @@ -128,7 +121,6 @@ /** * Returns fabric.Polyline instance from an SVG element * @static - * @method fabric.Polyline.fromElement * @param {SVGElement} element Element to parse * @param {Object} [options] Options object * @return {Object} instance of fabric.Polyline @@ -154,7 +146,6 @@ /** * Returns fabric.Polyline instance from an object representation * @static - * @method fabric.Polyline.fromObject * @param {Object} [object] Object to create an instance from * @return {fabric.Polyline} */ diff --git a/src/rect.class.js b/src/rect.class.js index 299dbc5d..c46a312a 100644 --- a/src/rect.class.js +++ b/src/rect.class.js @@ -15,39 +15,34 @@ * @class Rect * @extends fabric.Object */ - fabric.Rect = fabric.util.createClass(fabric.Object, /** @scope fabric.Rect.prototype */ { + fabric.Rect = fabric.util.createClass(fabric.Object, /** @lends fabric.Rect.prototype */ { /** * Type of an object - * @property * @type String */ type: 'rect', /** * Horizontal border radius - * @property * @type Number */ rx: 0, /** * Vertical border radius - * @property * @type Number */ ry: 0, /** * Used to specify dash pattern for stroke on this object - * @property * @type Array */ strokeDashArray: null, /** * Constructor - * @method initialize * @param {Object} [options] Options object * @return {Object} thisArg */ @@ -66,7 +61,6 @@ * Creates `stateProperties` list on an instance, and adds `fabric.Rect` -specific ones to it * (such as "rx", "ry", etc.) * @private - * @method _initStateProperties */ _initStateProperties: function() { this.stateProperties = this.stateProperties.concat(['rx', 'ry']); @@ -75,7 +69,6 @@ /** * Initializes rx/ry attributes * @private - * @method _initRxRy */ _initRxRy: function() { if (this.rx && !this.ry) { @@ -88,7 +81,6 @@ /** * @private - * @method _render * @param ctx {CanvasRenderingContext2D} context to render on */ _render: function(ctx) { @@ -138,7 +130,6 @@ /** * @private - * @method _renderDashedStroke */ _renderDashedStroke: function(ctx) { @@ -198,9 +189,8 @@ }, /** - * @method _normalizeLeftTopProperties - * @private * Since coordinate system differs from that of SVG + * @private */ _normalizeLeftTopProperties: function(parsedAttributes) { if ('left' in parsedAttributes) { @@ -216,7 +206,6 @@ /** * Returns complexity of an instance - * @method complexity * @return {Number} complexity */ complexity: function() { @@ -225,7 +214,6 @@ /** * Returns object representation of an instance - * @method toObject * @param {Array} propertiesToInclude * @return {Object} object representation of an instance */ @@ -238,7 +226,6 @@ /** * Returns svg representation of an instance - * @method toSVG * @return {String} svg representation of an instance */ toSVG: function() { @@ -283,7 +270,6 @@ /** * Returns {@link fabric.Rect} instance from an SVG element * @static - * @method fabric.Rect.fromElement * @param {SVGElement} element Element to parse * @param {Object} [options] Options object * @return {fabric.Rect} Instance of fabric.Rect @@ -305,7 +291,6 @@ /** * Returns {@link fabric.Rect} instance from an object representation * @static - * @method fabric.Rect.fromObject * @param object {Object} object to create an instance from * @return {Object} instance of fabric.Rect */ diff --git a/src/shadow.class.js b/src/shadow.class.js index 5849b6e2..f66d37c0 100644 --- a/src/shadow.class.js +++ b/src/shadow.class.js @@ -3,46 +3,40 @@ * @class Shadow * @memberOf fabric */ -fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { +fabric.Shadow = fabric.util.createClass(/** @lends fabric.Shadow.prototype */ { /** * Shadow color - * @property * @type String */ color: 'rgb(0,0,0)', /** * Shadow blur - * @property * @type Number */ blur: 0, /** * Shadow horizontal offset - * @property * @type Number */ offsetX: 0, /** * Shadow vertical offset - * @property * @type Number */ offsetY: 0, /** * Whether the shadow should affect stroke operations - * @property * @type Boolean */ affectStroke: false, /** * Constructor - * @method initialize * @param [options] Options object with any of color, blur, offsetX, offsetX properties * @return {fabric.Shadow} thisArg */ @@ -54,7 +48,6 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * Returns object representation of a shadow - * @method toObject * @return {Object} */ toObject: function() { @@ -68,10 +61,9 @@ fabric.Shadow = fabric.util.createClass(/** @scope fabric.Shadow.prototype */ { /** * Returns SVG representation of a shadow - * @method toSVG * @return {String} */ toSVG: function() { } -}); \ No newline at end of file +}); diff --git a/src/spray_brush.class.js b/src/spray_brush.class.js index b28ce99f..a1652b5c 100644 --- a/src/spray_brush.class.js +++ b/src/spray_brush.class.js @@ -2,46 +2,40 @@ * SprayBrush class * @class fabric.SprayBrush */ -fabric.SprayBrush = fabric.util.createClass( fabric.BaseBrush, /** @scope fabric.SprayBrush.prototype */ { +fabric.SprayBrush = fabric.util.createClass( fabric.BaseBrush, /** @lends fabric.SprayBrush.prototype */ { /** * Width of a spray - * @property * @type Number */ width: 10, /** * Density of a spray (number of dots per chunk) - * @property * @type Number */ density: 20, /** * Width of spray dots - * @property * @type Number */ dotWidth: 1, /** * Width variance of spray dots - * @property * @type Number */ dotWidthVariance: 1, /** * Whether opacity of a dot should be random - * @property * @type Boolean */ randomOpacity: false, /** * Constructor - * @method initialize * @param {fabric.Canvas} canvas * @return {fabric.SprayBrush} Instance of a spray brush */ @@ -51,7 +45,7 @@ fabric.SprayBrush = fabric.util.createClass( fabric.BaseBrush, /** @scope fabric }, /** - * @method onMouseDown + * Invoked on mouse down * @param {Object} pointer */ onMouseDown: function(pointer) { @@ -64,7 +58,7 @@ fabric.SprayBrush = fabric.util.createClass( fabric.BaseBrush, /** @scope fabric }, /** - * @method onMouseMove + * Invoked on mouse move * @param {Object} pointer */ onMouseMove: function(pointer) { @@ -73,7 +67,7 @@ fabric.SprayBrush = fabric.util.createClass( fabric.BaseBrush, /** @scope fabric }, /** - * @method onMouseUp + * Invoked on mouse up */ onMouseUp: function() { var originalRenderOnAddition = this.canvas.renderOnAddition; @@ -108,7 +102,7 @@ fabric.SprayBrush = fabric.util.createClass( fabric.BaseBrush, /** @scope fabric }, /** - * @method render + * Renders brush */ render: function() { var ctx = this.canvas.contextTop; @@ -126,7 +120,6 @@ fabric.SprayBrush = fabric.util.createClass( fabric.BaseBrush, /** @scope fabric }, /** - * @method addSprayChunk * @param {Object} pointer */ addSprayChunk: function(pointer) { @@ -160,4 +153,4 @@ fabric.SprayBrush = fabric.util.createClass( fabric.BaseBrush, /** @scope fabric this.sprayChunks.push(this.sprayChunkPoints); } -}); \ No newline at end of file +}); diff --git a/src/stateful.js b/src/stateful.js index c20ea3f3..81a7a380 100644 --- a/src/stateful.js +++ b/src/stateful.js @@ -3,7 +3,6 @@ fabric.util.object.extend(fabric.Object.prototype, { /** * List of properties to consider when checking if state of an object is changed (fabric.Object#hasStateChanged); * as well as for history (undo/redo) purposes - * @property * @type Array */ stateProperties: ( @@ -15,7 +14,6 @@ fabric.util.object.extend(fabric.Object.prototype, { /** * Returns true if state of an object (one if its state properties) was changed - * @method hasStateChanged * @return {Boolean} true if instance' state has changed */ hasStateChanged: function() { @@ -26,7 +24,6 @@ fabric.util.object.extend(fabric.Object.prototype, { /** * Saves a snapshot of object's state (its state properties) - * @method saveState * @return {fabric.Object} thisArg * @chainable */ @@ -39,7 +36,6 @@ fabric.util.object.extend(fabric.Object.prototype, { /** * Setups state of an object - * @method setupState */ setupState: function() { this.originalState = { }; @@ -85,4 +81,4 @@ fabric.util.object.extend(fabric.Object.prototype, { // hasControls // hasBorders // hasRotatingPoint -// rotatingPointOffset \ No newline at end of file +// rotatingPointOffset diff --git a/src/static_canvas.class.js b/src/static_canvas.class.js index 75fa2e1a..a9e3944f 100644 --- a/src/static_canvas.class.js +++ b/src/static_canvas.class.js @@ -19,8 +19,13 @@ * Static canvas class * @class fabric.StaticCanvas * @constructor + * * @param {HTMLElement | String} el <canvas> element to initialize instance on * @param {Object} [options] Options object + * + * @borrows fabric.Observable.observe as fabric.StaticCanvas#observe + * @borrows fabric.Observable.stopObserving as fabric.StaticCanvas#stopObserving + * @borrows fabric.Observable.fire as fabric.StaticCanvas#fire */ fabric.StaticCanvas = function (el, options) { options || (options = { }); @@ -32,26 +37,23 @@ extend(fabric.StaticCanvas.prototype, fabric.Observable); extend(fabric.StaticCanvas.prototype, fabric.Collection); - extend(fabric.StaticCanvas.prototype, /** @scope fabric.StaticCanvas.prototype */ { + extend(fabric.StaticCanvas.prototype, /** @lends fabric.StaticCanvas.prototype */ { /** * Background color of canvas instance - * @property * @type String */ backgroundColor: '', /** * Background image of canvas instance - * Should be set via `setBackgroundImage` - * @property + * Should be set via {@link fabric.StaticCanvas#setBackgroundImage} * @type String */ backgroundImage: '', /** * Opacity of the background image of the canvas instance - * @property * @type Float */ backgroundImageOpacity: 1.0, @@ -59,43 +61,37 @@ /** * Indicates whether the background image should be stretched to fit the * dimensions of the canvas instance. - * @property * @type Boolean */ backgroundImageStretch: true, /** * Overlay image of canvas instance - * Should be set via `setOverlayImage` - * @property + * Should be set via {@link fabric.StaticCanvas#setOverlayImage} * @type String */ overlayImage: '', /** * Left offset of overlay image (if present) - * @property * @type Number */ overlayImageLeft: 0, /** * Top offset of overlay image (if present) - * @property * @type Number */ overlayImageTop: 0, /** * Indicates whether toObject/toDatalessObject should include default values - * @property * @type Boolean */ includeDefaultValues: true, /** * Indicates whether objects' state should be saved - * @property * @type Boolean */ stateful: true, @@ -104,29 +100,25 @@ * Indicates whether {@link fabric.Canvas.prototype.add} should also re-render canvas. * Disabling this option could give a great performance boost when adding a lot of objects to canvas at once * (followed by a manual rendering after addition) - * @property * @type Boolean */ renderOnAddition: true, /** * Function that determines clipping of entire canvas area - * Being passed context as first argument. See clipping canvas area in https://github.com/kangax/fabric.js/wiki/FAQ - * @property + * Being passed context as first argument. See clipping canvas area in {@link https://github.com/kangax/fabric.js/wiki/FAQ} * @type Function */ clipTo: null, /** * Indicates whether object controls (borders/controls) are rendered above overlay image - * @property * @type Boolean */ controlsAboveOverlay: false, /** * Callback; invoked right before object is about to be scaled/rotated - * @method onBeforeScaleRotate * @param {fabric.Object} target Object that's about to be scaled/rotated */ onBeforeScaleRotate: function () { @@ -134,7 +126,6 @@ }, /** - * @method _initStatic * @private */ _initStatic: function(el, options) { @@ -158,7 +149,6 @@ /** * Calculates canvas element offset relative to the document * This method is also attached as "resize" event handler of window - * @method calcOffset * @return {fabric.Canvas} instance * @chainable */ @@ -169,7 +159,6 @@ /** * Sets overlay image for this canvas - * @method setOverlayImage * @param {String} url url of an image to set overlay to * @param {Function} callback callback to invoke when image is loaded and set as an overlay * @param {Object} [options] optional options to set for the overlay image @@ -193,7 +182,6 @@ /** * Sets background image for this canvas - * @method setBackgroundImage * @param {String} url url of an image to set background to * @param {Function} callback callback to invoke when image is loaded and set as background * @param {Object} [options] optional options to set for the background image @@ -217,7 +205,6 @@ /** * Sets background color for this canvas - * @method setBackgroundColor * @param {String|fabric.Pattern} Color of pattern to set background color to * @param {Function} callback callback to invoke when background color is set * @return {fabric.Canvas} thisArg @@ -244,7 +231,6 @@ /** * @private - * @method _createCanvasElement */ _createCanvasElement: function() { var element = fabric.document.createElement('canvas'); @@ -259,7 +245,7 @@ }, /** - * @method _initCanvasElement + * @private * @param {HTMLElement} element */ _initCanvasElement: function(element) { @@ -271,7 +257,7 @@ }, /** - * @method _initOptions + * @private * @param {Object} [options] */ _initOptions: function (options) { @@ -290,7 +276,7 @@ /** * Creates a bottom canvas - * @method _createLowerCanvas + * @private */ _createLowerCanvas: function (canvasEl) { this.lowerCanvasEl = fabric.util.getById(canvasEl) || this._createCanvasElement(); @@ -307,7 +293,6 @@ /** * Returns canvas width (in px) - * @method getWidth * @return {Number} */ getWidth: function () { @@ -316,7 +301,6 @@ /** * Returns canvas height (in px) - * @method getHeight * @return {Number} */ getHeight: function () { @@ -325,7 +309,6 @@ /** * Sets width of this canvas instance - * @method setWidth * @param {Number} width value to set width to * @return {fabric.Canvas} instance * @chainable true @@ -336,7 +319,6 @@ /** * Sets height of this canvas instance - * @method setHeight * @param {Number} height value to set height to * @return {fabric.Canvas} instance * @chainable true @@ -347,7 +329,6 @@ /** * Sets dimensions (width, height) of this canvas instance - * @method setDimensions * @param {Object} dimensions * @return {fabric.Canvas} thisArg * @chainable @@ -362,7 +343,6 @@ /** * Helper for setting width/height * @private - * @method _setDimensions * @param {String} prop property (width|height) * @param {Number} value value to set property to * @return {fabric.Canvas} instance @@ -395,7 +375,6 @@ /** * Returns <canvas> element corresponding to this instance - * @method getElement * @return {HTMLCanvasElement} */ getElement: function () { @@ -404,7 +383,6 @@ /** * Returns currently selected object, if any - * @method getActiveObject * @return {fabric.Object} */ getActiveObject: function() { @@ -413,7 +391,6 @@ /** * Returns currently selected group of object, if any - * @method getActiveGroup * @return {fabric.Group} */ getActiveGroup: function() { @@ -443,7 +420,6 @@ /** * @private - * @method _initObject */ _onObjectAdded: function(obj) { this.stateful && obj.setupState(); @@ -454,7 +430,7 @@ }, /** - * @method private + * @private */ _onObjectRemoved: function(obj) { this.fire('object:removed', { target: obj }); @@ -463,7 +439,6 @@ /** * Returns an array of objects this instance has - * @method getObjects * @return {Array} */ getObjects: function () { @@ -472,7 +447,6 @@ /** * Clears specified context of canvas element - * @method clearContext * @param context {Object} ctx context to clear * @return {fabric.Canvas} thisArg * @chainable @@ -484,7 +458,6 @@ /** * Returns context of canvas where objects are drawn - * @method getContext * @return {CanvasRenderingContext2D} */ getContext: function () { @@ -493,7 +466,6 @@ /** * Clears all contexts (background, main, top) of an instance - * @method clear * @return {fabric.Canvas} thisArg * @chainable */ @@ -516,7 +488,6 @@ /** * Renders both the top canvas and the secondary container canvas. - * @method renderAll * @param allOnTop {Boolean} optional Whether we want to force all images to be rendered on the top canvas * @return {fabric.Canvas} instance * @chainable @@ -595,7 +566,6 @@ /** * @private - * @method _drawBackroundImage */ _drawBackroundImage: function(canvasToDrawOn) { canvasToDrawOn.save(); @@ -613,7 +583,6 @@ /** * Method to render only the top canvas. * Also used to render the group selection box. - * @method renderTop * @return {fabric.Canvas} thisArg * @chainable */ @@ -644,7 +613,6 @@ /** * Draws objects' controls (borders/controls) - * @method drawControls * @param {Object} ctx context to render controls on */ drawControls: function(ctx) { @@ -671,7 +639,6 @@ /** * Exports canvas element to a dataurl image. - * @method toDataURL * @param {Object} options * * `format` the format of the output image. Either "jpeg" or "png". @@ -696,7 +663,6 @@ }, /** - * @method _toDataURL * @private */ __toDataURL: function(format, quality) { @@ -712,7 +678,6 @@ }, /** - * @method _toDataURLWithMultiplier * @private */ __toDataURLWithMultiplier: function(format, quality, multiplier) { @@ -765,7 +730,6 @@ /** * Exports canvas element to a dataurl image (allowing to change image size via multiplier). * @deprecated since 1.0.13 - * @method toDataURLWithMultiplier * @param {String} format (png|jpeg) * @param {Number} multiplier * @param {Number} quality (0..1) @@ -781,7 +745,6 @@ /** * @private - * @method _tempRemoveBordersControlsFromGroup */ _tempRemoveBordersControlsFromGroup: function(group) { group.origHasControls = group.hasControls; @@ -798,7 +761,6 @@ /** * @private - * @method _restoreBordersControlsOnGroup */ _restoreBordersControlsOnGroup: function(group) { group.hideControls = group.origHideControls; @@ -813,7 +775,6 @@ /** * Returns coordinates of a center of canvas. * Returned value is an object with top and left properties - * @method getCenter * @return {Object} object with "top" and "left" number values */ getCenter: function () { @@ -825,7 +786,6 @@ /** * Centers object horizontally. - * @method centerObjectH * @param {fabric.Object} object Object to center * @return {fabric.Canvas} thisArg */ @@ -837,7 +797,6 @@ /** * Centers object vertically. - * @method centerObjectH * @param {fabric.Object} object Object to center * @return {fabric.Canvas} thisArg * @chainable @@ -850,7 +809,6 @@ /** * Centers object vertically and horizontally. - * @method centerObject * @param {fabric.Object} object Object to center * @return {fabric.Canvas} thisArg * @chainable @@ -861,7 +819,6 @@ /** * Returs dataless JSON representation of canvas - * @method toDatalessJSON * @param {Array} propertiesToInclude * @return {String} json string */ @@ -871,7 +828,6 @@ /** * Returns object representation of canvas - * @method toObject * @param {Array} propertiesToInclude * @return {Object} object representation of an instance */ @@ -881,7 +837,6 @@ /** * Returns dataless object representation of canvas - * @method toDatalessObject * @param {Array} propertiesToInclude * @return {Object} object representation of an instance */ @@ -891,7 +846,6 @@ /** * @private - * @method _toObjectMethod */ _toObjectMethod: function (methodName, propertiesToInclude) { var data = { @@ -929,7 +883,6 @@ /** * Returns SVG representation of canvas * @function - * @method toSVG * @param {Object} [options] Options for SVG output (suppressPreamble: true/false (if true xml tag is not included), * viewBox: {x, y, width, height} to define the svg output viewBox) * @return {String} @@ -1002,7 +955,6 @@ /** * Removes an object from canvas and returns it - * @method remove * @param object {Object} Object to remove * @return {Object} removed object */ @@ -1019,7 +971,6 @@ /** * Moves an object to the bottom of the stack of drawn objects - * @method sendToBack * @param object {fabric.Object} Object to send to back * @return {fabric.Canvas} thisArg * @chainable @@ -1032,7 +983,6 @@ /** * Moves an object to the top of the stack of drawn objects - * @method bringToFront * @param object {fabric.Object} Object to send * @return {fabric.Canvas} thisArg * @chainable @@ -1045,7 +995,6 @@ /** * Moves an object one level down in stack of drawn objects - * @method sendBackwards * @param object {fabric.Object} Object to send * @return {fabric.Canvas} thisArg * @chainable @@ -1077,7 +1026,6 @@ /** * Moves an object one level up in stack of drawn objects - * @method bringForward * @param object {fabric.Object} Object to send * @return {fabric.Canvas} thisArg * @chainable @@ -1111,7 +1059,6 @@ /** * Moves an object to specified level in stack of drawn objects - * @method moveTo * @param object {fabric.Object} Object to send * @param {Number} index Position to move to * @return {fabric.Canvas} thisArg @@ -1125,7 +1072,6 @@ /** * Clears a canvas element and removes all event handlers. - * @method dispose * @return {fabric.Canvas} thisArg * @chainable */ @@ -1151,7 +1097,6 @@ /** * @private - * @method _resizeImageToFit * @param {HTMLImageElement} imgEl */ _resizeImageToFit: function (imgEl) { @@ -1168,7 +1113,6 @@ /** * Returns a string representation of an instance - * @method toString * @return {String} string representation of an instance */ fabric.StaticCanvas.prototype.toString = function () { // Assign explicitly since `extend` doesn't take care of DontEnum bug yet @@ -1176,11 +1120,10 @@ '{ objects: ' + this.getObjects().length + ' }>'; }; - extend(fabric.StaticCanvas, /** @scope fabric.StaticCanvas */ { + extend(fabric.StaticCanvas, /** @lends fabric.StaticCanvas */ { /** * @static - * @property EMPTY_JSON * @type String */ EMPTY_JSON: '{"objects": [], "background": "white"}', @@ -1188,7 +1131,6 @@ /** * Takes <canvas> element and transforms its data in such way that it becomes grayscale * @static - * @method toGrayscale * @param {HTMLCanvasElement} canvasEl */ toGrayscale: function (canvasEl) { @@ -1218,7 +1160,6 @@ * Provides a way to check support of some of the canvas methods * (either those of HTMLCanvasElement itself, or rendering context) * - * @method supports * @param methodName {String} Method to check support for; * Could be one of "getImageData", "toDataURL" or "toDataURLWithQuality" * @return {Boolean | null} `true` if method is supported (or at least exists), @@ -1261,7 +1202,6 @@ /** * Returs JSON representation of canvas * @function - * @method toJSON * @param {Array} propertiesToInclude * @return {String} json string */ diff --git a/src/text.class.js b/src/text.class.js index 97c6c980..64de92b8 100644 --- a/src/text.class.js +++ b/src/text.class.js @@ -52,105 +52,90 @@ /** * Font size (in pixels) - * @property * @type Number */ fontSize: 40, /** * Font weight (e.g. bold, normal, 400, 600, 800) - * @property * @type Number */ fontWeight: 'normal', /** * Font family - * @property * @type String */ fontFamily: 'Times New Roman', /** * Text decoration (e.g. underline, overline) - * @property * @type String */ textDecoration: '', /** * Text shadow - * @property * @type String | null */ textShadow: '', /** * Text alignment. Possible values: "left", "center", or "right". - * @property * @type String */ textAlign: 'left', /** * Font style (e.g. italic) - * @property * @type String */ fontStyle: '', /** * Line height - * @property * @type Number */ lineHeight: 1.3, /** * Stroke style. When specified, text is rendered with stroke - * @property * @type String */ stroke: '', /** * Stroke width - * @property * @type Number */ strokeWidth: 1, /** * Background color of an entire text box - * @property * @type String */ backgroundColor: '', /** * Background color of text lines - * @property * @type String */ textBackgroundColor: '', /** * URL of a font file, when using Cufon - * @property * @type String | null */ path: null, /** * Type of an object - * @property * @type String */ type: 'text', /** * Indicates whether canvas native text methods should be used to render text (otherwise, Cufon is used) - * @property * @type Boolean */ useNative: true, @@ -158,7 +143,6 @@ /** * List of properties to consider when checking if state of an object is changed (fabric.Object#hasStateChanged) * as well as for history (undo/redo) purposes - * @property * @type Array */ stateProperties: stateProperties, diff --git a/src/triangle.class.js b/src/triangle.class.js index db71fa59..2946e9c0 100644 --- a/src/triangle.class.js +++ b/src/triangle.class.js @@ -14,18 +14,16 @@ * @class Triangle * @extends fabric.Object */ - fabric.Triangle = fabric.util.createClass(fabric.Object, /** @scope fabric.Triangle.prototype */ { + fabric.Triangle = fabric.util.createClass(fabric.Object, /** @lends fabric.Triangle.prototype */ { /** * Type of an object - * @property * @type String */ type: 'triangle', /** * Constructor - * @method initialize * @param {Object} [options] Options object * @return {Object} thisArg */ @@ -40,7 +38,6 @@ /** * @private - * @method _render * @param ctx {CanvasRenderingContext2D} Context to render on */ _render: function(ctx) { @@ -62,7 +59,6 @@ /** * Returns complexity of an instance - * @method complexity * @return {Number} complexity of this instance */ complexity: function() { @@ -71,7 +67,6 @@ /** * Returns SVG representation of an instance - * @method toSVG * @return {String} svg representation of an instance */ toSVG: function() { @@ -107,7 +102,6 @@ /** * Returns fabric.Triangle instance from an object representation * @static - * @method Canvas.Trangle.fromObject * @param object {Object} object to create an instance from * @return {Object} instance of Canvas.Triangle */ diff --git a/src/util/anim_ease.js b/src/util/anim_ease.js index 14b9b3de..41879f25 100644 --- a/src/util/anim_ease.js +++ b/src/util/anim_ease.js @@ -2,7 +2,6 @@ /** * Quadratic easing in - * @method easeInQuad * @memberOf fabric.util.ease */ function easeInQuad(t, b, c, d) { @@ -11,7 +10,6 @@ /** * Quadratic easing out - * @method easeOutQuad * @memberOf fabric.util.ease */ function easeOutQuad(t, b, c, d) { @@ -20,7 +18,6 @@ /** * Quadratic easing in and out - * @method easeInOutQuad * @memberOf fabric.util.ease */ function easeInOutQuad(t, b, c, d) { @@ -31,7 +28,6 @@ /** * Cubic easing in - * @method easeInCubic * @memberOf fabric.util.ease */ function easeInCubic(t, b, c, d) { @@ -40,7 +36,6 @@ /** * Cubic easing out - * @method easeOutCubic * @memberOf fabric.util.ease */ function easeOutCubic(t, b, c, d) { @@ -49,7 +44,6 @@ /** * Cubic easing in and out - * @method easeInOutCubic * @memberOf fabric.util.ease */ function easeInOutCubic(t, b, c, d) { @@ -60,7 +54,6 @@ /** * Quartic easing in - * @method easeInQuart * @memberOf fabric.util.ease */ function easeInQuart(t, b, c, d) { @@ -69,7 +62,6 @@ /** * Quartic easing out - * @method easeOutQuart * @memberOf fabric.util.ease */ function easeOutQuart(t, b, c, d) { @@ -78,7 +70,6 @@ /** * Quartic easing in and out - * @method easeInOutQuart * @memberOf fabric.util.ease */ function easeInOutQuart(t, b, c, d) { @@ -89,7 +80,6 @@ /** * Quintic easing in - * @method easeInQuint * @memberOf fabric.util.ease */ function easeInQuint(t, b, c, d) { @@ -98,7 +88,6 @@ /** * Quintic easing out - * @method easeOutQuint * @memberOf fabric.util.ease */ function easeOutQuint(t, b, c, d) { @@ -107,7 +96,6 @@ /** * Quintic easing in and out - * @method easeInOutQuint * @memberOf fabric.util.ease */ function easeInOutQuint(t, b, c, d) { @@ -118,7 +106,6 @@ /** * Sinusoidal easing in - * @method easeInSine * @memberOf fabric.util.ease */ function easeInSine(t, b, c, d) { @@ -127,7 +114,6 @@ /** * Sinusoidal easing out - * @method easeOutSine * @memberOf fabric.util.ease */ function easeOutSine(t, b, c, d) { @@ -136,7 +122,6 @@ /** * Sinusoidal easing in and out - * @method easeInOutSine * @memberOf fabric.util.ease */ function easeInOutSine(t, b, c, d) { @@ -145,7 +130,6 @@ /** * Exponential easing in - * @method easeInExpo * @memberOf fabric.util.ease */ function easeInExpo(t, b, c, d) { @@ -154,7 +138,6 @@ /** * Exponential easing out - * @method easeOutExpo * @memberOf fabric.util.ease */ function easeOutExpo(t, b, c, d) { @@ -163,7 +146,6 @@ /** * Exponential easing in and out - * @method easeInOutExpo * @memberOf fabric.util.ease */ function easeInOutExpo(t, b, c, d) { @@ -176,7 +158,6 @@ /** * Circular easing in - * @method easeInCirc * @memberOf fabric.util.ease */ function easeInCirc(t, b, c, d) { @@ -185,7 +166,6 @@ /** * Circular easing out - * @method easeOutCirc * @memberOf fabric.util.ease */ function easeOutCirc(t, b, c, d) { @@ -194,7 +174,6 @@ /** * Circular easing in and out - * @method easeInOutCirc * @memberOf fabric.util.ease */ function easeInOutCirc(t, b, c, d) { @@ -205,7 +184,6 @@ /** * Elastic easing in - * @method easeInElastic * @memberOf fabric.util.ease */ function easeInElastic(t, b, c, d) { @@ -221,7 +199,6 @@ /** * Elastic easing out - * @method easeOutElastic * @memberOf fabric.util.ease */ function easeOutElastic(t, b, c, d) { @@ -237,7 +214,6 @@ /** * Elastic easing in and out - * @method easeInOutElastic * @memberOf fabric.util.ease */ function easeInOutElastic(t, b, c, d) { @@ -254,7 +230,6 @@ /** * Backwards easing in - * @method easeInBack * @memberOf fabric.util.ease */ function easeInBack(t, b, c, d, s) { @@ -264,7 +239,6 @@ /** * Backwards easing out - * @method easeOutBack * @memberOf fabric.util.ease */ function easeOutBack(t, b, c, d, s) { @@ -274,7 +248,6 @@ /** * Backwards easing in and out - * @method easeInOutBack * @memberOf fabric.util.ease */ function easeInOutBack(t, b, c, d, s) { @@ -286,7 +259,6 @@ /** * Bouncing easing in - * @method easeInBounce * @memberOf fabric.util.ease */ function easeInBounce(t, b, c, d) { @@ -295,7 +267,6 @@ /** * Bouncing easing out - * @method easeOutBounce * @memberOf fabric.util.ease */ function easeOutBounce(t, b, c, d) { @@ -312,7 +283,6 @@ /** * Bouncing easing in and out - * @method easeInOutBounce * @memberOf fabric.util.ease */ function easeInOutBounce(t, b, c, d) { @@ -321,6 +291,7 @@ } /** + * Easing functions * See Easing Equations by Robert Penner * @namespace fabric.util.ease */ @@ -357,4 +328,4 @@ easeInOutBounce: easeInOutBounce }; -}()); \ No newline at end of file +}()); diff --git a/src/util/dom_event.js b/src/util/dom_event.js index b148ca91..0acd1892 100644 --- a/src/util/dom_event.js +++ b/src/util/dom_event.js @@ -169,7 +169,6 @@ /** * Cross-browser wrapper for getting event's coordinates - * @method getPointer * @memberOf fabric.util * @param {Event} event * @param {HTMLCanvasElement} upperCanvasEl <canvas> element on which object selection is drawn diff --git a/src/util/dom_misc.js b/src/util/dom_misc.js index 0bac191b..7c424df0 100644 --- a/src/util/dom_misc.js +++ b/src/util/dom_misc.js @@ -4,7 +4,6 @@ /** * Takes id and returns an element with that id (if one exists in a document) - * @method getById * @memberOf fabric.util * @param {String|HTMLElement} id * @return {HTMLElement|null} @@ -15,7 +14,6 @@ /** * Converts an array-like object (e.g. arguments or NodeList) to an array - * @method toArray * @memberOf fabric.util * @param {Object} arrayLike * @return {Array} @@ -42,7 +40,6 @@ /** * Creates specified element with specified attributes - * @method makeElement * @memberOf fabric.util * @param {String} tagName Type of an element to create * @param {Object} [attributes] Attributes to set on an element @@ -66,7 +63,6 @@ /** * Adds class to an element - * @method addClass * @memberOf fabric.util * @param {HTMLElement} element Element to add class to * @param {String} className Class to add to an element @@ -79,7 +75,6 @@ /** * Wraps element with another element - * @method wrapElement * @memberOf fabric.util * @param {HTMLElement} element Element to wrap * @param {HTMLElement|String} wrapper Element to wrap with @@ -99,7 +94,6 @@ /** * Returns offset for a given element - * @method getElementOffset * @function * @memberOf fabric.util * @param {HTMLElement} element Element to get offset for @@ -119,7 +113,6 @@ /** * Returns position of a given element - * @method getElementPosition * @function * @memberOf fabric.util * @param {HTMLElement} element Element to get offset for @@ -155,7 +148,6 @@ /** * Makes element unselectable - * @method makeElementUnselectable * @memberOf fabric.util * @param {HTMLElement} element Element to make unselectable * @return {HTMLElement} Element that was passed in @@ -175,7 +167,6 @@ /** * Makes element selectable - * @method makeElementSelectable * @memberOf fabric.util * @param {HTMLElement} element Element to make selectable * @return {HTMLElement} Element that was passed in @@ -201,7 +192,6 @@ /** * Inserts a script element with a given url into a document; invokes callback, when that script is finished loading - * @method getScript * @memberOf fabric.util * @param {String} url URL of a script to load * @param {Function} callback Callback to execute when script is finished loading @@ -242,4 +232,4 @@ fabric.util.getElementOffset = getElementOffset; fabric.util.getElementPosition = getElementPosition; -})(); \ No newline at end of file +})(); diff --git a/src/util/dom_request.js b/src/util/dom_request.js index 5a53915f..8d13a90e 100644 --- a/src/util/dom_request.js +++ b/src/util/dom_request.js @@ -26,7 +26,6 @@ /** * Cross-browser abstraction for sending XMLHttpRequest - * @method request * @memberOf fabric.util * @param {String} url URL to send XMLHttpRequest to * @param {Object} [options] Options object @@ -69,4 +68,4 @@ } fabric.util.request = request; -})(); \ No newline at end of file +})(); diff --git a/src/util/dom_style.js b/src/util/dom_style.js index e1d1c37a..b451f229 100644 --- a/src/util/dom_style.js +++ b/src/util/dom_style.js @@ -2,7 +2,6 @@ /** * Cross-browser wrapper for setting element's style - * @method setStyle * @memberOf fabric.util * @param {HTMLElement} element * @param {Object} styles @@ -68,4 +67,4 @@ fabric.util.setStyle = setStyle; -})(); \ No newline at end of file +})(); diff --git a/src/util/lang_array.js b/src/util/lang_array.js index f268f55c..ed21d118 100644 --- a/src/util/lang_array.js +++ b/src/util/lang_array.js @@ -5,9 +5,9 @@ if (!Array.prototype.indexOf) { /** * Finds index of an element in an array - * @method indexOf * @param {Any} searchElement * @param {Number} [fromIndex] + * @return {Number} */ Array.prototype.indexOf = function (searchElement /*, fromIndex */ ) { if (this === void 0 || this === null) { @@ -43,9 +43,9 @@ if (!Array.prototype.forEach) { /** * Iterates an array, invoking callback for each element - * @method forEach * @param {Function} fn Callback to invoke for each element * @param {Object} [context] Context to invoke callback in + * @return {Array} */ Array.prototype.forEach = function(fn, context) { for (var i = 0, len = this.length >>> 0; i < len; i++) { @@ -59,9 +59,9 @@ if (!Array.prototype.map) { /** * Returns a result of iterating over an array, invoking callback for each element - * @method map * @param {Function} fn Callback to invoke for each element * @param {Object} [context] Context to invoke callback in + * @return {Array} */ Array.prototype.map = function(fn, context) { var result = [ ]; @@ -77,9 +77,9 @@ if (!Array.prototype.every) { /** * Returns true if a callback returns truthy value for all elements in an array - * @method every * @param {Function} fn Callback to invoke for each element * @param {Object} [context] Context to invoke callback in + * @return {Boolean} */ Array.prototype.every = function(fn, context) { for (var i = 0, len = this.length >>> 0; i < len; i++) { @@ -94,9 +94,9 @@ if (!Array.prototype.some) { /** * Returns true if a callback returns truthy value for at least one element in an array - * @method every * @param {Function} fn Callback to invoke for each element * @param {Object} [context] Context to invoke callback in + * @return {Boolean} */ Array.prototype.some = function(fn, context) { for (var i = 0, len = this.length >>> 0; i < len; i++) { @@ -111,9 +111,9 @@ if (!Array.prototype.filter) { /** * Returns the result of iterating over elements in an array - * @method filter * @param {Function} fn Callback to invoke for each element * @param {Object} [context] Context to invoke callback in + * @return {Array} */ Array.prototype.filter = function(fn, context) { var result = [ ], val; @@ -132,9 +132,9 @@ if (!Array.prototype.reduce) { /** * Returns "folded" (reduced) result of iterating over elements in an array - * @method filter * @param {Function} fn Callback to invoke for each element * @param {Object} [context] Context to invoke callback in + * @return {Any} */ Array.prototype.reduce = function(fn /*, initial*/) { var len = this.length >>> 0, @@ -168,10 +168,10 @@ /** * Invokes method on all items in a given array - * @method invoke * @memberOf fabric.util.array * @param {Array} array Array to iterate over * @param {String} method Name of a method to invoke + * @return {Array} */ function invoke(array, method) { var args = slice.call(arguments, 2), result = [ ]; @@ -183,10 +183,10 @@ /** * Finds maximum value in array (not necessarily "first" one) - * @method max * @memberOf fabric.util.array * @param {Array} array Array to iterate over * @param {String} byProperty + * @return {Any} */ function max(array, byProperty) { if (!array || array.length === 0) return undefined; @@ -212,10 +212,10 @@ /** * Finds minimum value in array (not necessarily "first" one) - * @method min * @memberOf fabric.util.array * @param {Array} array Array to iterate over * @param {String} byProperty + * @return {Any} */ function min(array, byProperty) { if (!array || array.length === 0) return undefined; @@ -241,7 +241,7 @@ } /** - * @namespace Array utilities + * @namespace fabric.util.array */ fabric.util.array = { invoke: invoke, @@ -249,4 +249,4 @@ max: max }; -})(); \ No newline at end of file +})(); diff --git a/src/util/lang_class.js b/src/util/lang_class.js index 04681f5a..cac7a72e 100644 --- a/src/util/lang_class.js +++ b/src/util/lang_class.js @@ -57,7 +57,6 @@ /** * Helper for creation of "classes". Note that pr - * @method createClass * @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) @@ -94,4 +93,4 @@ } fabric.util.createClass = createClass; -})(); \ No newline at end of file +})(); diff --git a/src/util/lang_object.js b/src/util/lang_object.js index 9db87660..f6f4659d 100644 --- a/src/util/lang_object.js +++ b/src/util/lang_object.js @@ -3,9 +3,9 @@ /** * Copies all enumerable properties of one object to another * @memberOf fabric.util.object - * @method extend * @param {Object} destination Where to copy to * @param {Object} source Where to copy from + * @return {Object} */ function extend(destination, source) { // JScript DontEnum bug is not taken care of @@ -17,18 +17,18 @@ /** * Creates an empty object and copies all enumerable properties of another object to it - * @method clone * @memberOf fabric.util.object * @param {Object} object Object to clone + * @return {Object} */ function clone(object) { return extend({ }, object); } - /** @namespace Object utilities */ + /** @namespace fabric.util.object */ fabric.util.object = { extend: extend, clone: clone }; -})(); \ No newline at end of file +})(); diff --git a/src/util/lang_string.js b/src/util/lang_string.js index 9fc1e4ba..92fbf048 100644 --- a/src/util/lang_string.js +++ b/src/util/lang_string.js @@ -3,7 +3,7 @@ if (!String.prototype.trim) { /** * Trims a string (removing whitespace from the beginning and the end) - * @method trim + * @function external:String#trim * @see String#trim on MDN */ String.prototype.trim = function () { @@ -15,7 +15,6 @@ if (!String.prototype.trim) { /** * Camelizes a string * @memberOf fabric.util.string - * @method camelize * @param {String} string String to camelize * @return {String} Camelized version of a string */ @@ -28,7 +27,6 @@ function camelize(string) { /** * Capitalizes a string * @memberOf fabric.util.string - * @method capitalize * @param {String} string String to capitalize * @return {String} Capitalized version of a string */ @@ -39,7 +37,6 @@ function capitalize(string) { /** * Escapes XML in a string * @memberOf fabric.util.string - * @method escapeXml * @param {String} string String to escape * @return {String} Escaped version of a string */ @@ -51,7 +48,10 @@ function escapeXml(string) { .replace(/>/g, '>'); } -/** @namespace String utilities */ +/** + * String utilities + * @namespace fabric.util.string + */ fabric.util.string = { camelize: camelize, capitalize: capitalize, diff --git a/src/util/misc.js b/src/util/misc.js index 8b8cd001..fbd12fe6 100644 --- a/src/util/misc.js +++ b/src/util/misc.js @@ -4,7 +4,7 @@ atan2 = Math.atan2; /** - * @namespace Various utilities + * @namespace fabric.util */ fabric.util = { }; @@ -13,7 +13,6 @@ * Presence of value (and its position in an array) is determined via `Array.prototype.indexOf` * @static * @memberOf fabric.util - * @method removeFromArray * @param {Array} array * @param {Any} value * @return {Array} original array @@ -29,7 +28,6 @@ /** * Returns random number between 2 specified ones. * @static - * @method getRandomInt * @memberOf fabric.util * @param {Number} min lower limit * @param {Number} max upper limit @@ -44,7 +42,6 @@ /** * Transforms degrees to radians. * @static - * @method degreesToRadians * @memberOf fabric.util * @param {Number} degrees value in degrees * @return {Number} value in radians @@ -56,7 +53,6 @@ /** * Transforms radians to degrees. * @static - * @method radiansToDegrees * @memberOf fabric.util * @param {Number} radians value in radians * @return {Number} value in degrees @@ -68,7 +64,6 @@ /** * Rotates `point` around `origin` with `radians` * @static - * @method rotatePoint * @memberOf fabric.util * @param {fabric.Point} The point to rotate * @param {fabric.Point} The origin of the rotation @@ -90,7 +85,6 @@ /** * A wrapper around Number#toFixed, which contrary to native method returns number, not string. * @static - * @method toFixed * @memberOf fabric.util * @param {Number | String} number number to operate on * @param {Number} fractionDigits number of fraction digits to "leave" @@ -103,7 +97,6 @@ /** * Function which always returns `false`. * @static - * @method falseFunction * @memberOf fabric.util * @return {Boolean} */ @@ -113,7 +106,6 @@ /** * Changes value from one to another within certain period of time, invoking callbacks as value is being changed. - * @method animate * @memberOf fabric.util * @param {Object} [options] Animation options * @param {Function} [options.onChange] Callback; invoked on every value change @@ -162,7 +154,6 @@ }; /** * requestAnimationFrame polyfill based on http://paulirish.com/2011/requestanimationframe-for-smart-animating/ - * @method requestAnimFrame * @memberOf fabric.util * @param {Function} callback Callback to invoke * @param {DOMElement} element optional Element to associate with animation @@ -173,7 +164,6 @@ /** * Loads image element from given url and passes it to a callback - * @method loadImage * @memberOf fabric.util * @param {String} url URL representing an image * @param {Function} callback Callback; invoked with loaded image @@ -198,7 +188,6 @@ * Creates corresponding fabric instances from their object representations * @static * @memberOf fabric.util - * @method enlivenObjects * @param {Array} objects Objects to enliven * @param {Function} callback Callback to invoke when all objects are created */ @@ -244,7 +233,6 @@ * Groups SVG elements (usually those retrieved from SVG document) * @static * @memberOf fabric.util - * @method groupSVGElements * @param {Array} elements SVG elements to group * @param {Object} [options] Options object * @return {fabric.Object|fabric.PathGroup} @@ -285,7 +273,6 @@ * Populates an object with properties of another object * @static * @memberOf fabric.util - * @method populateWithProperties * @param {Object} source Source object * @param {Object} destination Destination object * @return {Array} properties Propertie names to include @@ -304,7 +291,6 @@ * This method is used to draw dashed line around selection area. * See dotted stroke in canvas * - * @method drawDashedLine * @param ctx {Canvas} context * @param x {Number} start x coordinate * @param y {Number} start y coordinate @@ -343,7 +329,6 @@ * Creates canvas element and initializes it via excanvas if necessary * @static * @memberOf fabric.util - * @method createCanvasElement * @param {CanvasElement} [canvasEl] optional canvas element to initialize; when not given, element is created implicitly * @return {CanvasElement} initialized canvas element */ @@ -359,7 +344,6 @@ * Creates accessors (getXXX, setXXX) for a "class", based on "stateProperties" array * @static * @memberOf fabric.util - * @method createAccessors * @param {Object} klass "Class" to create accessors for */ function createAccessors(klass) { @@ -387,7 +371,10 @@ } /** - * @method clipContext + * @static + * @memberOf fabric.util + * @param {fabric.Object} receiver Object implementing `clipTo` method + * @param {CanvasRenderingContext2D} ctx Context to clip */ function clipContext(receiver, ctx) { ctx.save(); @@ -400,7 +387,6 @@ * Multiply matrix A by matrix B to nest transformations * @static * @memberOf fabric.util - * @method multiplyTransformMatrices * @param {Array} matrixA First transformMatrix * @param {Array} matrixB Second transformMatrix * @return {Array} The product of the two transform matrices diff --git a/test/lib/canvas_assertions.js b/test/lib/canvas_assertions.js index 91a111e5..99f6fec8 100644 --- a/test/lib/canvas_assertions.js +++ b/test/lib/canvas_assertions.js @@ -1,9 +1,8 @@ (function(){ /** * @private - * @method iterateData * @param {CanvasRenderingContext2D} ctx context to test - * @param {Function} fn Callback, invoked with `currentValue`, `previousValue` and `index`. + * @param {Function} fn Callback, invoked with `currentValue`, `previousValue` and `index`. * Breaks out of the loop if callback returns `false`. */ function iterateData(ctx, fn) { @@ -14,12 +13,11 @@ } } } - + /** - * @method assertColor * @param {CanvasRenderingContext2D} ctx context to test * @param {String} color color in a hex value - * @return {Boolean | null} `true` if all canvas pixels are of a given color, `null` if wrong color is given + * @return {Boolean | null} `true` if all canvas pixels are of a given color, `null` if wrong color is given * @example `assertColor(canvas._oContextContainer, 'ff5555');` */ function assertColor(ctx, color) { @@ -40,9 +38,8 @@ }); return result; } - + /** - * @method assertSameColor * @param {CanvasRenderingContext2D} ctx context to test * @return {Boolean} `true` if all canvas pixels are of the same color * @example `assertSameColor(canvas._oContextContainer);` @@ -61,4 +58,4 @@ // export as global this.assertColor = assertColor; this.assertSameColor = assertSameColor; -})(); \ No newline at end of file +})();