mirror of
https://github.com/Hopiu/fabric.js.git
synced 2026-04-01 13:20:25 +00:00
Documentation additions.
This commit is contained in:
parent
531267fcce
commit
3416d8a090
15 changed files with 71 additions and 45 deletions
|
|
@ -12,12 +12,14 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* Circle class
|
||||
* @class Circle
|
||||
* @extends fabric.Object
|
||||
*/
|
||||
fabric.Circle = fabric.util.createClass(fabric.Object, /** @scope fabric.Circle.prototype */ {
|
||||
|
||||
/**
|
||||
* Type of an object
|
||||
* @property
|
||||
* @type String
|
||||
*/
|
||||
|
|
@ -133,10 +135,10 @@
|
|||
* Returns {@link fabric.Circle} instance from an SVG element
|
||||
* @static
|
||||
* @method fabric.Circle.fromElement
|
||||
* @param element {SVGElement} element to parse
|
||||
* @param options {Object} options object
|
||||
* @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 {Object} Instance of fabric.Circle
|
||||
*/
|
||||
fabric.Circle.fromElement = function(element, options) {
|
||||
options || (options = { });
|
||||
|
|
|
|||
|
|
@ -12,12 +12,14 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* Ellipse class
|
||||
* @class Ellipse
|
||||
* @extends fabric.Object
|
||||
*/
|
||||
fabric.Ellipse = fabric.util.createClass(fabric.Object, /** @scope fabric.Ellipse.prototype */ {
|
||||
|
||||
/**
|
||||
* Type of an object
|
||||
* @property
|
||||
* @type String
|
||||
*/
|
||||
|
|
@ -27,7 +29,7 @@
|
|||
* Constructor
|
||||
* @method initialize
|
||||
* @param {Object} [options] Options object
|
||||
* @return {Object} thisArg
|
||||
* @return {fabric.Ellipse} thisArg
|
||||
*/
|
||||
initialize: function(options) {
|
||||
options = options || { };
|
||||
|
|
|
|||
|
|
@ -19,9 +19,9 @@
|
|||
* It converts the hand writting to a SVG Path and adds this
|
||||
* path to the canvas.
|
||||
*
|
||||
* @metod init
|
||||
* @param fabricCanvas {FabricCanvas}
|
||||
*
|
||||
* @metod initialize
|
||||
* @param fabricCanvas {fabric.Canvas}
|
||||
* @return {fabric.FreeDrawing}
|
||||
*/
|
||||
initialize: function(fabricCanvas) {
|
||||
this.canvas = fabricCanvas;
|
||||
|
|
@ -127,9 +127,11 @@
|
|||
},
|
||||
|
||||
/**
|
||||
* @method getPathBoundingBox
|
||||
* @param points {Array of points}
|
||||
*/
|
||||
* Retursn bounding box of a path based on given points
|
||||
* @method getPathBoundingBox
|
||||
* @param points {Array}
|
||||
* @return {Object}
|
||||
*/
|
||||
getPathBoundingBox: function(points) {
|
||||
var xBounds = [],
|
||||
yBounds = [],
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@
|
|||
fabric.Gradient = fabric.util.createClass(/** @scope fabric.Gradient.prototype */ {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @method initialize
|
||||
* @param options optional Options with x1, y1, x2, y2 and colorStops
|
||||
*/
|
||||
|
|
@ -80,6 +81,7 @@
|
|||
fabric.util.object.extend(fabric.Gradient, {
|
||||
|
||||
/**
|
||||
* Returns {@link fabric.Gradient} instance from an SVG element
|
||||
* @method fromElement
|
||||
* @static
|
||||
* @memberof fabric.Gradient
|
||||
|
|
@ -135,8 +137,11 @@
|
|||
},
|
||||
|
||||
/**
|
||||
* Returns {@link fabric.Gradient} instance from its object representation
|
||||
* @method forObject
|
||||
* @static
|
||||
* @param obj
|
||||
* @param [options]
|
||||
* @memberof fabric.Gradient
|
||||
*/
|
||||
forObject: function(obj, options) {
|
||||
|
|
|
|||
|
|
@ -23,12 +23,14 @@
|
|||
};
|
||||
|
||||
/**
|
||||
* Group class
|
||||
* @class Group
|
||||
* @extends fabric.Object
|
||||
*/
|
||||
fabric.Group = fabric.util.createClass(fabric.Object, /** @scope fabric.Group.prototype */ {
|
||||
|
||||
/**
|
||||
* Type of an object
|
||||
* @property
|
||||
* @type String
|
||||
*/
|
||||
|
|
@ -510,12 +512,12 @@
|
|||
});
|
||||
|
||||
/**
|
||||
* Returns fabric.Group instance from an object representation
|
||||
* Returns {@link fabric.Group} instance from an object representation
|
||||
* @static
|
||||
* @method fabric.Group.fromObject
|
||||
* @param object {Object} object to create a group from
|
||||
* @param options {Object} options object
|
||||
* @return {fabric.Group} an instance of fabric.Group
|
||||
* @param {Object} object Object to create a group from
|
||||
* @param {Object} [options] Options object
|
||||
* @return {fabric.Group} An instance of fabric.Group
|
||||
*/
|
||||
fabric.Group.fromObject = function(object, callback) {
|
||||
fabric.util.enlivenObjects(object.objects, function(enlivenedObjects) {
|
||||
|
|
|
|||
|
|
@ -14,18 +14,14 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* Image class
|
||||
* @class Image
|
||||
* @extends fabric.Object
|
||||
*/
|
||||
fabric.Image = fabric.util.createClass(fabric.Object, /** @scope fabric.Image.prototype */ {
|
||||
|
||||
/**
|
||||
* @property
|
||||
* @type Boolean
|
||||
*/
|
||||
active: false,
|
||||
|
||||
/**
|
||||
* Type of an object
|
||||
* @property
|
||||
* @type String
|
||||
*/
|
||||
|
|
@ -34,7 +30,8 @@
|
|||
/**
|
||||
* Constructor
|
||||
* @param {HTMLImageElement | String} element Image element
|
||||
* @param {Object} options optional
|
||||
* @param {Object} [options] Options object
|
||||
* @return {fabric.Image}
|
||||
*/
|
||||
initialize: function(element, options) {
|
||||
options || (options = { });
|
||||
|
|
@ -127,9 +124,9 @@
|
|||
},
|
||||
|
||||
/**
|
||||
* Returns svg representation of an instance
|
||||
* Returns SVG representation of an instance
|
||||
* @method toSVG
|
||||
* @return {string} svg representation of an instance
|
||||
* @return {String} svg representation of an instance
|
||||
*/
|
||||
toSVG: function() {
|
||||
return '<g transform="' + this.getSvgTransform() + '">'+
|
||||
|
|
@ -164,7 +161,7 @@
|
|||
|
||||
/**
|
||||
* Returns a clone of an instance
|
||||
* @mthod clone
|
||||
* @method clone
|
||||
* @param {Array} propertiesToInclude
|
||||
* @param {Function} callback Callback is invoked with a clone as a first argument
|
||||
*/
|
||||
|
|
@ -268,7 +265,7 @@
|
|||
/**
|
||||
* @private
|
||||
* @method _initConfig
|
||||
* @param {Object} options Options object
|
||||
* @param {Object} [options] Options object
|
||||
*/
|
||||
_initConfig: function(options) {
|
||||
options || (options = { });
|
||||
|
|
@ -292,7 +289,7 @@
|
|||
/**
|
||||
* @private
|
||||
* @method _setWidthHeight
|
||||
* @param {Object} options Object with width/height properties
|
||||
* @param {Object} [options] Object with width/height properties
|
||||
*/
|
||||
_setWidthHeight: function(options) {
|
||||
this.width = 'width' in options
|
||||
|
|
@ -321,14 +318,19 @@
|
|||
*/
|
||||
fabric.Image.CSS_CANVAS = "canvas-img";
|
||||
|
||||
/**
|
||||
* 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 callback {Function} optional
|
||||
* @param {Object} object
|
||||
* @param {Function} [callback] Callback to invoke when an image instance is created
|
||||
*/
|
||||
fabric.Image.fromObject = function(object, callback) {
|
||||
var img = fabric.document.createElement('img'),
|
||||
|
|
@ -397,6 +399,11 @@
|
|||
fabric.Image.fromURL(parsedAttributes['xlink:href'], callback, extend(parsedAttributes, options));
|
||||
};
|
||||
|
||||
/**
|
||||
* Indicates that instances of this type are async
|
||||
* @static
|
||||
* @type Boolean
|
||||
*/
|
||||
fabric.Image.async = true;
|
||||
|
||||
})(typeof exports !== 'undefined' ? exports : this);
|
||||
|
|
|
|||
|
|
@ -12,12 +12,14 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* Line class
|
||||
* @class Line
|
||||
* @extends fabric.Object
|
||||
*/
|
||||
fabric.Line = fabric.util.createClass(fabric.Object, /** @scope fabric.Line.prototype */ {
|
||||
|
||||
/**
|
||||
* Type of an object
|
||||
* @property
|
||||
* @type String
|
||||
*/
|
||||
|
|
@ -50,7 +52,7 @@
|
|||
/**
|
||||
* @private
|
||||
* @method _setWidthHeight
|
||||
* @param {Object} options
|
||||
* @param {Object} [options] Options
|
||||
*/
|
||||
_setWidthHeight: function(options) {
|
||||
options || (options = { });
|
||||
|
|
@ -128,9 +130,9 @@
|
|||
},
|
||||
|
||||
/**
|
||||
* Returns svg representation of an instance
|
||||
* Returns SVG representation of an instance
|
||||
* @method toSVG
|
||||
* @return {string} svg representation of an instance
|
||||
* @return {String} svg representation of an instance
|
||||
*/
|
||||
toSVG: function() {
|
||||
return [
|
||||
|
|
|
|||
|
|
@ -320,7 +320,7 @@
|
|||
* @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
|
||||
* @param {Object} [options] Options object
|
||||
* @param {Function} [reviver] Method for further parsing of SVG elements, called after each fabric object created.
|
||||
*/
|
||||
function parseElements(elements, callback, options, reviver) {
|
||||
|
|
|
|||
|
|
@ -778,7 +778,7 @@
|
|||
* @static
|
||||
* @method fabric.Path.fromElement
|
||||
* @param {SVGElement} element to parse
|
||||
* @param {Object} options object
|
||||
* @param {Object} [options] Options object
|
||||
* @return {fabric.Path} Instance of fabric.Path
|
||||
*/
|
||||
fabric.Path.fromElement = function(element, options) {
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* Polygon class
|
||||
* @class Polygon
|
||||
* @extends fabric.Object
|
||||
*/
|
||||
|
|
@ -30,7 +31,7 @@
|
|||
* Constructor
|
||||
* @method initialize
|
||||
* @param {Array} points Array of points
|
||||
* @param {Object} options Options object
|
||||
* @param {Object} [options] Options object
|
||||
* @return {fabric.Polygon} thisArg
|
||||
*/
|
||||
initialize: function(points, options) {
|
||||
|
|
@ -74,7 +75,7 @@
|
|||
/**
|
||||
* Returns svg representation of an instance
|
||||
* @method toSVG
|
||||
* @return {string} svg representation of an instance
|
||||
* @return {String} svg representation of an instance
|
||||
*/
|
||||
toSVG: function() {
|
||||
var points = [];
|
||||
|
|
@ -131,11 +132,11 @@
|
|||
fabric.Polygon.ATTRIBUTE_NAMES = 'fill fill-opacity opacity stroke stroke-width transform'.split(' ');
|
||||
|
||||
/**
|
||||
* Returns fabric.Polygon instance from an SVG element
|
||||
* 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
|
||||
* @param {Object} [options] Options object
|
||||
* @return {fabric.Polygon}
|
||||
*/
|
||||
fabric.Polygon.fromElement = function(element, options) {
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* Polyline class
|
||||
* @class Polyline
|
||||
* @extends fabric.Object
|
||||
*/
|
||||
|
|
@ -56,7 +57,7 @@
|
|||
},
|
||||
|
||||
/**
|
||||
* Returns svg representation of an instance
|
||||
* Returns SVG representation of an instance
|
||||
* @method toSVG
|
||||
* @return {string} svg representation of an instance
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -244,7 +244,7 @@
|
|||
|
||||
/**
|
||||
* @method _initOptions
|
||||
* @param {Object} options
|
||||
* @param {Object} [options]
|
||||
*/
|
||||
_initOptions: function (options) {
|
||||
for (var prop in options) {
|
||||
|
|
|
|||
|
|
@ -577,7 +577,7 @@
|
|||
},
|
||||
|
||||
/**
|
||||
* Returns svg representation of an instance
|
||||
* Returns SVG representation of an instance
|
||||
* @method toSVG
|
||||
* @return {string} svg representation of an instance
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -10,12 +10,14 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* Triangle class
|
||||
* @class Triangle
|
||||
* @extends fabric.Object
|
||||
*/
|
||||
fabric.Triangle = fabric.util.createClass(fabric.Object, /** @scope fabric.Triangle.prototype */ {
|
||||
|
||||
/**
|
||||
* Type of an object
|
||||
* @property
|
||||
* @type String
|
||||
*/
|
||||
|
|
@ -24,7 +26,7 @@
|
|||
/**
|
||||
* Constructor
|
||||
* @method initialize
|
||||
* @param options {Object} options object
|
||||
* @param {Object} [options] Options object
|
||||
* @return {Object} thisArg
|
||||
*/
|
||||
initialize: function(options) {
|
||||
|
|
@ -69,9 +71,9 @@
|
|||
},
|
||||
|
||||
/**
|
||||
* Returns svg representation of an instance
|
||||
* Returns SVG representation of an instance
|
||||
* @method toSVG
|
||||
* @return {string} svg representation of an instance
|
||||
* @return {String} svg representation of an instance
|
||||
*/
|
||||
toSVG: function() {
|
||||
|
||||
|
|
|
|||
|
|
@ -211,8 +211,8 @@
|
|||
* @memberOf fabric.util
|
||||
* @method groupSVGElements
|
||||
* @param {Array} elements
|
||||
* @param {Object} options optional
|
||||
* @return {String} path optional
|
||||
* @param {Object} [options] Options object
|
||||
* @return {fabric.Object|fabric.PathGroup}
|
||||
*/
|
||||
function groupSVGElements(elements, options, path) {
|
||||
var object = elements.length > 1
|
||||
|
|
|
|||
Loading…
Reference in a new issue