mirror of
https://github.com/Hopiu/fabric.js.git
synced 2026-05-28 14:58:16 +00:00
Change inline docs to conform to jsdoc3
This commit is contained in:
parent
40d5a52492
commit
c16dcf88a4
56 changed files with 405 additions and 1644 deletions
|
|
@ -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';
|
||||
|
|
|
|||
1020
dist/all.js
vendored
1020
dist/all.js
vendored
File diff suppressed because it is too large
Load diff
12
dist/all.min.js
vendored
12
dist/all.min.js
vendored
File diff suppressed because one or more lines are too long
BIN
dist/all.min.js.gz
vendored
BIN
dist/all.min.js.gz
vendored
Binary file not shown.
|
|
@ -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;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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() { };
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
});
|
||||
})();
|
||||
})();
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
})(typeof exports !== 'undefined' ? exports : this);
|
||||
|
|
|
|||
|
|
@ -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}
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
})();
|
||||
})();
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
})(typeof exports !== 'undefined' ? exports : this);
|
||||
|
|
|
|||
|
|
@ -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
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -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() { };
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
});
|
||||
})();
|
||||
})();
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 @@
|
|||
}
|
||||
});
|
||||
|
||||
})();
|
||||
})();
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
on: observe,
|
||||
off: stopObserving,
|
||||
trigger: fire
|
||||
};
|
||||
})();
|
||||
|
|
|
|||
|
|
@ -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}
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -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 <path> element
|
||||
* @static
|
||||
* @method fabric.Path.fromElement
|
||||
* @param {SVGElement} element to parse
|
||||
* @param {Object} [options] Options object
|
||||
* @return {fabric.Path} Instance of fabric.Path
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
})(typeof exports !== 'undefined' ? exports : this);
|
||||
|
|
|
|||
|
|
@ -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}
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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}
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -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}
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -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
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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
|
||||
// rotatingPointOffset
|
||||
|
|
|
|||
|
|
@ -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
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -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 <a href="http://gizma.com/easing/">Easing Equations by Robert Penner</a>
|
||||
* @namespace fabric.util.ease
|
||||
*/
|
||||
|
|
@ -357,4 +328,4 @@
|
|||
easeInOutBounce: easeInOutBounce
|
||||
};
|
||||
|
||||
}());
|
||||
}());
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
})();
|
||||
})();
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
})();
|
||||
})();
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
})();
|
||||
})();
|
||||
|
|
|
|||
|
|
@ -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
|
||||
};
|
||||
|
||||
})();
|
||||
})();
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
})();
|
||||
})();
|
||||
|
|
|
|||
|
|
@ -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
|
||||
};
|
||||
|
||||
})();
|
||||
})();
|
||||
|
|
|
|||
|
|
@ -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 <a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/String/Trim">String#trim on MDN</a>
|
||||
*/
|
||||
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,
|
||||
|
|
|
|||
|
|
@ -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 <a href="http://stackoverflow.com/questions/4576724/dotted-stroke-in-canvas">dotted stroke in canvas</a>
|
||||
*
|
||||
* @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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
})();
|
||||
})();
|
||||
|
|
|
|||
Loading…
Reference in a new issue