mirror of
https://github.com/konvajs/konva.git
synced 2026-03-03 16:58:33 +08:00
finally got around to adding return docs for every node method
This commit is contained in:
@@ -189,6 +189,7 @@
|
|||||||
b = obj && obj.b !== undefined ? obj.b | 0 : this.getAttr(attr + UPPER_B);
|
b = obj && obj.b !== undefined ? obj.b | 0 : this.getAttr(attr + UPPER_B);
|
||||||
|
|
||||||
this._setAttr(attr, HASH + Kinetic.Util._rgbToHex(r, g, b));
|
this._setAttr(attr, HASH + Kinetic.Util._rgbToHex(r, g, b));
|
||||||
|
return this;
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -199,19 +200,22 @@
|
|||||||
var obj = {};
|
var obj = {};
|
||||||
obj[c] = val;
|
obj[c] = val;
|
||||||
this[prefix + RGB](obj);
|
this[prefix + RGB](obj);
|
||||||
|
return this;
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
addPointsSetter: function(constructor, attr) {
|
addPointsSetter: function(constructor, attr) {
|
||||||
var method = SET + Kinetic.Util._capitalize(attr);
|
var method = SET + Kinetic.Util._capitalize(attr);
|
||||||
constructor.prototype[method] = function(val) {
|
constructor.prototype[method] = function(val) {
|
||||||
this._setAttr('points', val);
|
this._setAttr('points', val);
|
||||||
|
return this;
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
addSetter: function(constructor, attr) {
|
addSetter: function(constructor, attr) {
|
||||||
var method = SET + Kinetic.Util._capitalize(attr);
|
var method = SET + Kinetic.Util._capitalize(attr);
|
||||||
|
|
||||||
constructor.prototype[method] = function(val) {
|
constructor.prototype[method] = function(val) {
|
||||||
this._setAttr(attr, val);
|
this._setAttr(attr, val);
|
||||||
|
return this;
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
addPointSetter: function(constructor, attr) {
|
addPointSetter: function(constructor, attr) {
|
||||||
@@ -235,6 +239,8 @@
|
|||||||
}
|
}
|
||||||
this._fireChangeEvent(attr, oldVal, pos);
|
this._fireChangeEvent(attr, oldVal, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return this;
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
addBoxSetter: function(constructor, attr) {
|
addBoxSetter: function(constructor, attr) {
|
||||||
@@ -265,6 +271,8 @@
|
|||||||
}
|
}
|
||||||
this._fireChangeEvent(attr, oldVal, box);
|
this._fireChangeEvent(attr, oldVal, box);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return this;
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
addRotationSetter: function(constructor, attr) {
|
addRotationSetter: function(constructor, attr) {
|
||||||
@@ -274,25 +282,12 @@
|
|||||||
// radians
|
// radians
|
||||||
constructor.prototype[method] = function(val) {
|
constructor.prototype[method] = function(val) {
|
||||||
this._setAttr(attr, val);
|
this._setAttr(attr, val);
|
||||||
|
return this;
|
||||||
};
|
};
|
||||||
// degrees
|
// degrees
|
||||||
constructor.prototype[method + DEG] = function(deg) {
|
constructor.prototype[method + DEG] = function(deg) {
|
||||||
this._setAttr(attr, Kinetic.Util._degToRad(deg));
|
this._setAttr(attr, Kinetic.Util._degToRad(deg));
|
||||||
};
|
return this;
|
||||||
},
|
|
||||||
|
|
||||||
// add adders
|
|
||||||
addPointAdder: function(constructor, attr) {
|
|
||||||
var that = this,
|
|
||||||
baseMethod = ADD + Kinetic.Util._removeLastLetter(Kinetic.Util._capitalize(attr));
|
|
||||||
|
|
||||||
constructor.prototype[baseMethod] = function(pos) {
|
|
||||||
var oldVal = this.attrs[attr];
|
|
||||||
|
|
||||||
if (pos) {
|
|
||||||
this.attrs[attr].push(pos);
|
|
||||||
this._fireChangeEvent(attr, oldVal, pos);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
103
src/Node.js
103
src/Node.js
@@ -84,11 +84,13 @@
|
|||||||
* clear cached variables
|
* clear cached variables
|
||||||
* @method
|
* @method
|
||||||
* @memberof Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
|
* @returns {Kinetic.Node}
|
||||||
* @example
|
* @example
|
||||||
* node.clearCache();
|
* node.clearCache();
|
||||||
*/
|
*/
|
||||||
clearCache: function() {
|
clearCache: function() {
|
||||||
this.cache = {};
|
this.cache = {};
|
||||||
|
return this;
|
||||||
},
|
},
|
||||||
_clearCache: function(attr){
|
_clearCache: function(attr){
|
||||||
delete this.cache[attr];
|
delete this.cache[attr];
|
||||||
@@ -146,6 +148,7 @@
|
|||||||
* @memberof Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
* @param {String} evtStr e.g. 'click', 'mousedown touchstart', 'mousedown.foo touchstart.foo'
|
* @param {String} evtStr e.g. 'click', 'mousedown touchstart', 'mousedown.foo touchstart.foo'
|
||||||
* @param {Function} handler The handler function is passed an event object
|
* @param {Function} handler The handler function is passed an event object
|
||||||
|
* @returns {Kinetic.Node}
|
||||||
* @example
|
* @example
|
||||||
* // add click listener<br>
|
* // add click listener<br>
|
||||||
* node.on('click', function() {<br>
|
* node.on('click', function() {<br>
|
||||||
@@ -222,6 +225,7 @@
|
|||||||
* @method
|
* @method
|
||||||
* @memberof Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
* @param {String} evtStr e.g. 'click', 'mousedown touchstart', '.foobar'
|
* @param {String} evtStr e.g. 'click', 'mousedown touchstart', '.foobar'
|
||||||
|
* @returns {Kinetic.Node}
|
||||||
* @example
|
* @example
|
||||||
* // remove listener<br>
|
* // remove listener<br>
|
||||||
* node.off('click');<br><br>
|
* node.off('click');<br><br>
|
||||||
@@ -260,6 +264,7 @@
|
|||||||
* remove self from parent, but don't destroy
|
* remove self from parent, but don't destroy
|
||||||
* @method
|
* @method
|
||||||
* @memberof Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
|
* @returns {Kinetic.Node}
|
||||||
* @example
|
* @example
|
||||||
* node.remove();
|
* node.remove();
|
||||||
*/
|
*/
|
||||||
@@ -301,6 +306,7 @@
|
|||||||
* @method
|
* @method
|
||||||
* @memberof Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
* @param {String} attr
|
* @param {String} attr
|
||||||
|
* @returns {Integer|String|Object|Array}
|
||||||
* @example
|
* @example
|
||||||
* var x = node.getAttr('x');
|
* var x = node.getAttr('x');
|
||||||
*/
|
*/
|
||||||
@@ -318,6 +324,7 @@
|
|||||||
* get ancestors
|
* get ancestors
|
||||||
* @method
|
* @method
|
||||||
* @memberof Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
|
* @returns {Kinetic.Collection}
|
||||||
* @example
|
* @example
|
||||||
* shape.getAncestors().each(function(node) {
|
* shape.getAncestors().each(function(node) {
|
||||||
* console.log(node.getId());
|
* console.log(node.getId());
|
||||||
@@ -338,6 +345,7 @@
|
|||||||
* get attrs object literal
|
* get attrs object literal
|
||||||
* @method
|
* @method
|
||||||
* @memberof Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
|
* @returns {Object}
|
||||||
*/
|
*/
|
||||||
getAttrs: function() {
|
getAttrs: function() {
|
||||||
return this.attrs || {};
|
return this.attrs || {};
|
||||||
@@ -347,6 +355,7 @@
|
|||||||
* @method
|
* @method
|
||||||
* @memberof Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
* @param {Object} config object containing key value pairs
|
* @param {Object} config object containing key value pairs
|
||||||
|
* @returns {Kinetic.Node}
|
||||||
* @example
|
* @example
|
||||||
* node.setAttrs({<br>
|
* node.setAttrs({<br>
|
||||||
* x: 5,<br>
|
* x: 5,<br>
|
||||||
@@ -437,6 +446,7 @@
|
|||||||
* is invisible, this means that the node is also invisible
|
* is invisible, this means that the node is also invisible
|
||||||
* @method
|
* @method
|
||||||
* @memberof Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
|
* @returns {Boolean}
|
||||||
*/
|
*/
|
||||||
isVisible: function() {
|
isVisible: function() {
|
||||||
return this._getCache(VISIBLE, this._isVisible);
|
return this._getCache(VISIBLE, this._isVisible);
|
||||||
@@ -454,6 +464,7 @@
|
|||||||
* show node
|
* show node
|
||||||
* @method
|
* @method
|
||||||
* @memberof Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
|
* @returns {Kinetic.Node}
|
||||||
*/
|
*/
|
||||||
show: function() {
|
show: function() {
|
||||||
this.setVisible(true);
|
this.setVisible(true);
|
||||||
@@ -463,6 +474,7 @@
|
|||||||
* hide node. Hidden nodes are no longer detectable
|
* hide node. Hidden nodes are no longer detectable
|
||||||
* @method
|
* @method
|
||||||
* @memberof Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
|
* @returns {Kinetic.Node}
|
||||||
*/
|
*/
|
||||||
hide: function() {
|
hide: function() {
|
||||||
this.setVisible(false);
|
this.setVisible(false);
|
||||||
@@ -472,6 +484,7 @@
|
|||||||
* get zIndex relative to the node's siblings who share the same parent
|
* get zIndex relative to the node's siblings who share the same parent
|
||||||
* @method
|
* @method
|
||||||
* @memberof Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
|
* @returns {Integer}
|
||||||
*/
|
*/
|
||||||
getZIndex: function() {
|
getZIndex: function() {
|
||||||
return this.index || 0;
|
return this.index || 0;
|
||||||
@@ -481,6 +494,7 @@
|
|||||||
* and ancestor indices
|
* and ancestor indices
|
||||||
* @method
|
* @method
|
||||||
* @memberof Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
|
* @returns {Integer}
|
||||||
*/
|
*/
|
||||||
getAbsoluteZIndex: function() {
|
getAbsoluteZIndex: function() {
|
||||||
var level = this.getLevel(),
|
var level = this.getLevel(),
|
||||||
@@ -520,6 +534,7 @@
|
|||||||
* be >= 2
|
* be >= 2
|
||||||
* @method
|
* @method
|
||||||
* @memberof Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
|
* @returns {Integer}
|
||||||
*/
|
*/
|
||||||
getLevel: function() {
|
getLevel: function() {
|
||||||
var level = 0,
|
var level = 0,
|
||||||
@@ -538,6 +553,7 @@
|
|||||||
* @param {Object} pos
|
* @param {Object} pos
|
||||||
* @param {Number} pos.x
|
* @param {Number} pos.x
|
||||||
* @param {Nubmer} pos.y
|
* @param {Nubmer} pos.y
|
||||||
|
* @returns {Kinetic.Node}
|
||||||
* @example
|
* @example
|
||||||
* // set x and <br>
|
* // set x and <br>
|
||||||
* node.setPosition({<br>
|
* node.setPosition({<br>
|
||||||
@@ -554,6 +570,7 @@
|
|||||||
* get node position relative to parent
|
* get node position relative to parent
|
||||||
* @method
|
* @method
|
||||||
* @memberof Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
|
* @returns {Object}
|
||||||
*/
|
*/
|
||||||
getPosition: function() {
|
getPosition: function() {
|
||||||
return {
|
return {
|
||||||
@@ -565,6 +582,7 @@
|
|||||||
* get absolute position relative to the top left corner of the stage container div
|
* get absolute position relative to the top left corner of the stage container div
|
||||||
* @method
|
* @method
|
||||||
* @memberof Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
|
* @returns {Object}
|
||||||
*/
|
*/
|
||||||
getAbsolutePosition: function() {
|
getAbsolutePosition: function() {
|
||||||
var absoluteMatrix = this.getAbsoluteTransform().getMatrix(),
|
var absoluteMatrix = this.getAbsoluteTransform().getMatrix(),
|
||||||
@@ -585,6 +603,7 @@
|
|||||||
* @param {Object} pos
|
* @param {Object} pos
|
||||||
* @param {Number} pos.x
|
* @param {Number} pos.x
|
||||||
* @param {Number} pos.y
|
* @param {Number} pos.y
|
||||||
|
* @returns {Kinetic.Node}
|
||||||
*/
|
*/
|
||||||
setAbsolutePosition: function(pos) {
|
setAbsolutePosition: function(pos) {
|
||||||
var trans = this._clearTransform(),
|
var trans = this._clearTransform(),
|
||||||
@@ -655,6 +674,7 @@
|
|||||||
* @param {Object} change
|
* @param {Object} change
|
||||||
* @param {Number} change.x
|
* @param {Number} change.x
|
||||||
* @param {Number} change.y
|
* @param {Number} change.y
|
||||||
|
* @returns {Kinetic.Node}
|
||||||
* @example
|
* @example
|
||||||
* // move node in x direction by 1px and y direction by 2px<br>
|
* // move node in x direction by 1px and y direction by 2px<br>
|
||||||
* node.move({<br>
|
* node.move({<br>
|
||||||
@@ -703,6 +723,7 @@
|
|||||||
* @method
|
* @method
|
||||||
* @memberof Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
* @param {Number} theta
|
* @param {Number} theta
|
||||||
|
* @returns {Kinetic.Node}
|
||||||
*/
|
*/
|
||||||
rotate: function(theta) {
|
rotate: function(theta) {
|
||||||
this.setRotation(this.getRotation() + theta);
|
this.setRotation(this.getRotation() + theta);
|
||||||
@@ -713,6 +734,7 @@
|
|||||||
* @method
|
* @method
|
||||||
* @memberof Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
* @param {Number} deg
|
* @param {Number} deg
|
||||||
|
* @returns {Kinetic.Node}
|
||||||
*/
|
*/
|
||||||
rotateDeg: function(deg) {
|
rotateDeg: function(deg) {
|
||||||
this.setRotation(this.getRotation() + Kinetic.Util._degToRad(deg));
|
this.setRotation(this.getRotation() + Kinetic.Util._degToRad(deg));
|
||||||
@@ -722,6 +744,7 @@
|
|||||||
* move node to the top of its siblings
|
* move node to the top of its siblings
|
||||||
* @method
|
* @method
|
||||||
* @memberof Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
|
* @returns {Boolean}
|
||||||
*/
|
*/
|
||||||
moveToTop: function() {
|
moveToTop: function() {
|
||||||
var index = this.index;
|
var index = this.index;
|
||||||
@@ -734,6 +757,7 @@
|
|||||||
* move node up
|
* move node up
|
||||||
* @method
|
* @method
|
||||||
* @memberof Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
|
* @returns {Boolean}
|
||||||
*/
|
*/
|
||||||
moveUp: function() {
|
moveUp: function() {
|
||||||
var index = this.index,
|
var index = this.index,
|
||||||
@@ -750,6 +774,7 @@
|
|||||||
* move node down
|
* move node down
|
||||||
* @method
|
* @method
|
||||||
* @memberof Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
|
* @returns {Boolean}
|
||||||
*/
|
*/
|
||||||
moveDown: function() {
|
moveDown: function() {
|
||||||
var index = this.index;
|
var index = this.index;
|
||||||
@@ -765,6 +790,7 @@
|
|||||||
* move node to the bottom of its siblings
|
* move node to the bottom of its siblings
|
||||||
* @method
|
* @method
|
||||||
* @memberof Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
|
* @returns {Boolean}
|
||||||
*/
|
*/
|
||||||
moveToBottom: function() {
|
moveToBottom: function() {
|
||||||
var index = this.index;
|
var index = this.index;
|
||||||
@@ -781,6 +807,7 @@
|
|||||||
* @method
|
* @method
|
||||||
* @memberof Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
* @param {Integer} zIndex
|
* @param {Integer} zIndex
|
||||||
|
* @returns {Kinetic.Node}
|
||||||
*/
|
*/
|
||||||
setZIndex: function(zIndex) {
|
setZIndex: function(zIndex) {
|
||||||
var index = this.index;
|
var index = this.index;
|
||||||
@@ -793,6 +820,7 @@
|
|||||||
* get absolute opacity
|
* get absolute opacity
|
||||||
* @method
|
* @method
|
||||||
* @memberof Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
|
* @returns {Number}
|
||||||
*/
|
*/
|
||||||
getAbsoluteOpacity: function() {
|
getAbsoluteOpacity: function() {
|
||||||
return this._getCache(ABSOLUTE_OPACITY, this._getAbsoluteOpacity);
|
return this._getCache(ABSOLUTE_OPACITY, this._getAbsoluteOpacity);
|
||||||
@@ -809,6 +837,7 @@
|
|||||||
* @method
|
* @method
|
||||||
* @memberof Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
* @param {Container} newContainer
|
* @param {Container} newContainer
|
||||||
|
* @returns {Kinetic.Node}
|
||||||
* @example
|
* @example
|
||||||
* // move node from current layer into layer2<br>
|
* // move node from current layer into layer2<br>
|
||||||
* node.moveTo(layer2);
|
* node.moveTo(layer2);
|
||||||
@@ -822,6 +851,7 @@
|
|||||||
* convert Node into an object for serialization. Returns an object.
|
* convert Node into an object for serialization. Returns an object.
|
||||||
* @method
|
* @method
|
||||||
* @memberof Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
|
* @returns {Object}
|
||||||
*/
|
*/
|
||||||
toObject: function() {
|
toObject: function() {
|
||||||
var type = Kinetic.Util,
|
var type = Kinetic.Util,
|
||||||
@@ -850,6 +880,7 @@
|
|||||||
* convert Node into a JSON string. Returns a JSON string.
|
* convert Node into a JSON string. Returns a JSON string.
|
||||||
* @method
|
* @method
|
||||||
* @memberof Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
|
* @returns {String}}
|
||||||
*/
|
*/
|
||||||
toJSON: function() {
|
toJSON: function() {
|
||||||
return JSON.stringify(this.toObject());
|
return JSON.stringify(this.toObject());
|
||||||
@@ -858,6 +889,7 @@
|
|||||||
* get parent container
|
* get parent container
|
||||||
* @method
|
* @method
|
||||||
* @memberof Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
|
* @returns {Kinetic.Node}
|
||||||
*/
|
*/
|
||||||
getParent: function() {
|
getParent: function() {
|
||||||
return this.parent;
|
return this.parent;
|
||||||
@@ -866,6 +898,7 @@
|
|||||||
* get layer ancestor
|
* get layer ancestor
|
||||||
* @method
|
* @method
|
||||||
* @memberof Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
|
* @returns {Kinetic.Layer}
|
||||||
*/
|
*/
|
||||||
getLayer: function() {
|
getLayer: function() {
|
||||||
var parent = this.getParent();
|
var parent = this.getParent();
|
||||||
@@ -875,6 +908,7 @@
|
|||||||
* get stage ancestor
|
* get stage ancestor
|
||||||
* @method
|
* @method
|
||||||
* @memberof Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
|
* @returns {Kinetic.Stage}
|
||||||
*/
|
*/
|
||||||
getStage: function() {
|
getStage: function() {
|
||||||
return this._getCache(STAGE, this._getStage);
|
return this._getCache(STAGE, this._getStage);
|
||||||
@@ -896,6 +930,7 @@
|
|||||||
* @param {EventObject} evt event object
|
* @param {EventObject} evt event object
|
||||||
* @param {Boolean} bubble setting the value to false, or leaving it undefined, will result in the event
|
* @param {Boolean} bubble setting the value to false, or leaving it undefined, will result in the event
|
||||||
* not bubbling. Setting the value to true will result in the event bubbling.
|
* not bubbling. Setting the value to true will result in the event bubbling.
|
||||||
|
* @returns {Kinetic.Node}
|
||||||
* @example
|
* @example
|
||||||
* // manually fire click event<br>
|
* // manually fire click event<br>
|
||||||
* node.fire('click');<br><br>
|
* node.fire('click');<br><br>
|
||||||
@@ -927,6 +962,7 @@
|
|||||||
* account its ancestor transforms
|
* account its ancestor transforms
|
||||||
* @method
|
* @method
|
||||||
* @memberof Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
|
* @returns {Kinetic.Transform}
|
||||||
*/
|
*/
|
||||||
getAbsoluteTransform: function() {
|
getAbsoluteTransform: function() {
|
||||||
return this._getCache(ABSOLUTE_TRANSFORM, this._getAbsoluteTransform);
|
return this._getCache(ABSOLUTE_TRANSFORM, this._getAbsoluteTransform);
|
||||||
@@ -942,6 +978,15 @@
|
|||||||
}, true);
|
}, true);
|
||||||
return am;
|
return am;
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
* get transform of the node
|
||||||
|
* @method
|
||||||
|
* @memberof Kinetic.Node.prototype
|
||||||
|
* @returns {Kinetic.Transform}
|
||||||
|
*/
|
||||||
|
getTransform: function() {
|
||||||
|
return this._getCache(TRANSFORM, this._getTransform);
|
||||||
|
},
|
||||||
_getTransform: function() {
|
_getTransform: function() {
|
||||||
var m = new Kinetic.Transform(),
|
var m = new Kinetic.Transform(),
|
||||||
x = this.getX(),
|
x = this.getX(),
|
||||||
@@ -979,6 +1024,7 @@
|
|||||||
* @method
|
* @method
|
||||||
* @memberof Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
* @param {Object} attrs override attrs
|
* @param {Object} attrs override attrs
|
||||||
|
* @returns {Kinetic.Node}
|
||||||
* @example
|
* @example
|
||||||
* // simple clone<br>
|
* // simple clone<br>
|
||||||
* var clone = node.clone();<br><br>
|
* var clone = node.clone();<br><br>
|
||||||
@@ -1035,6 +1081,7 @@
|
|||||||
* @param {Number} [config.quality] jpeg quality. If using an "image/jpeg" mimeType,
|
* @param {Number} [config.quality] jpeg quality. If using an "image/jpeg" mimeType,
|
||||||
* you can specify the quality from 0 to 1, where 0 is very poor quality and 1
|
* you can specify the quality from 0 to 1, where 0 is very poor quality and 1
|
||||||
* is very high quality
|
* is very high quality
|
||||||
|
* @returns {String}
|
||||||
*/
|
*/
|
||||||
toDataURL: function(config) {
|
toDataURL: function(config) {
|
||||||
config = config || {};
|
config = config || {};
|
||||||
@@ -1079,6 +1126,7 @@
|
|||||||
* @param {Number} [config.quality] jpeg quality. If using an "image/jpeg" mimeType,
|
* @param {Number} [config.quality] jpeg quality. If using an "image/jpeg" mimeType,
|
||||||
* you can specify the quality from 0 to 1, where 0 is very poor quality and 1
|
* you can specify the quality from 0 to 1, where 0 is very poor quality and 1
|
||||||
* is very high quality
|
* is very high quality
|
||||||
|
* @returns {Image}
|
||||||
* @example
|
* @example
|
||||||
* var image = node.toImage({<br>
|
* var image = node.toImage({<br>
|
||||||
* callback: function(img) {<br>
|
* callback: function(img) {<br>
|
||||||
@@ -1098,6 +1146,7 @@
|
|||||||
* @param {Object} size
|
* @param {Object} size
|
||||||
* @param {Number} width
|
* @param {Number} width
|
||||||
* @param {Number} height
|
* @param {Number} height
|
||||||
|
* @returns {Kinetic.Node}
|
||||||
*/
|
*/
|
||||||
setSize: function(size) {
|
setSize: function(size) {
|
||||||
this.setWidth(size.width);
|
this.setWidth(size.width);
|
||||||
@@ -1108,6 +1157,7 @@
|
|||||||
* get size
|
* get size
|
||||||
* @method
|
* @method
|
||||||
* @memberof Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
|
* @returns {Object}
|
||||||
*/
|
*/
|
||||||
getSize: function() {
|
getSize: function() {
|
||||||
return {
|
return {
|
||||||
@@ -1119,6 +1169,7 @@
|
|||||||
* get width
|
* get width
|
||||||
* @method
|
* @method
|
||||||
* @memberof Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
|
* @returns {Integer}
|
||||||
*/
|
*/
|
||||||
getWidth: function() {
|
getWidth: function() {
|
||||||
return this.attrs.width || 0;
|
return this.attrs.width || 0;
|
||||||
@@ -1127,6 +1178,7 @@
|
|||||||
* get height
|
* get height
|
||||||
* @method
|
* @method
|
||||||
* @memberof Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
|
* @returns {Integer}
|
||||||
*/
|
*/
|
||||||
getHeight: function() {
|
getHeight: function() {
|
||||||
return this.attrs.height || 0;
|
return this.attrs.height || 0;
|
||||||
@@ -1135,6 +1187,7 @@
|
|||||||
* get class name, which may return Stage, Layer, Group, or shape class names like Rect, Circle, Text, etc.
|
* get class name, which may return Stage, Layer, Group, or shape class names like Rect, Circle, Text, etc.
|
||||||
* @method
|
* @method
|
||||||
* @memberof Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
|
* @returns {String}
|
||||||
*/
|
*/
|
||||||
getClassName: function() {
|
getClassName: function() {
|
||||||
return this.className || this.nodeType;
|
return this.className || this.nodeType;
|
||||||
@@ -1143,6 +1196,7 @@
|
|||||||
* get the node type, which may return Stage, Layer, Group, or Node
|
* get the node type, which may return Stage, Layer, Group, or Node
|
||||||
* @method
|
* @method
|
||||||
* @memberof Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
|
* @returns {String}
|
||||||
*/
|
*/
|
||||||
getType: function() {
|
getType: function() {
|
||||||
return this.nodeType;
|
return this.nodeType;
|
||||||
@@ -1187,6 +1241,7 @@
|
|||||||
* @method
|
* @method
|
||||||
* @memberof Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
* @param {String} id
|
* @param {String} id
|
||||||
|
* @returns {Kinetic.Node}
|
||||||
*/
|
*/
|
||||||
setId: function(id) {
|
setId: function(id) {
|
||||||
var oldId = this.getId();
|
var oldId = this.getId();
|
||||||
@@ -1201,6 +1256,7 @@
|
|||||||
* @method
|
* @method
|
||||||
* @memberof Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
* @param {String} name
|
* @param {String} name
|
||||||
|
* @returns {Kinetic.Node}
|
||||||
*/
|
*/
|
||||||
setName: function(name) {
|
setName: function(name) {
|
||||||
var oldName = this.getName();
|
var oldName = this.getName();
|
||||||
@@ -1215,7 +1271,8 @@
|
|||||||
* @method
|
* @method
|
||||||
* @memberof Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
* @param {String} attr
|
* @param {String} attr
|
||||||
* #param {*} val
|
* @param {*} val
|
||||||
|
* @returns {Kinetic.Node}
|
||||||
* @example
|
* @example
|
||||||
* node.setAttr('x', 5);
|
* node.setAttr('x', 5);
|
||||||
*/
|
*/
|
||||||
@@ -1297,26 +1354,15 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* draw both scene and hit graphs. If the node being drawn is the stage, all of the layers will be cleared and redra
|
* draw both scene and hit graphs. If the node being drawn is the stage, all of the layers will be cleared and redrawn
|
||||||
* @method
|
* @method
|
||||||
* @memberof Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
* the scene renderer
|
* @returns {Kinetic.Node}
|
||||||
*/
|
*/
|
||||||
draw: function() {
|
draw: function() {
|
||||||
this.drawScene();
|
this.drawScene();
|
||||||
this.drawHit();
|
this.drawHit();
|
||||||
return this;
|
return this;
|
||||||
},
|
|
||||||
isDraggable: function() {
|
|
||||||
return false;
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* get transform of the node
|
|
||||||
* @method
|
|
||||||
* @memberof Kinetic.Node.prototype
|
|
||||||
*/
|
|
||||||
getTransform: function() {
|
|
||||||
return this._getCache(TRANSFORM, this._getTransform);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -1366,6 +1412,7 @@
|
|||||||
* @method
|
* @method
|
||||||
* @memberof Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
* @param {Number} x
|
* @param {Number} x
|
||||||
|
* @returns {Kinetic.Node}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1373,6 +1420,7 @@
|
|||||||
* @name getX
|
* @name getX
|
||||||
* @method
|
* @method
|
||||||
* @memberof Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
|
* @returns {Object}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Kinetic.Factory.addGetterSetter(Kinetic.Node, 'y', 0);
|
Kinetic.Factory.addGetterSetter(Kinetic.Node, 'y', 0);
|
||||||
@@ -1383,6 +1431,7 @@
|
|||||||
* @method
|
* @method
|
||||||
* @memberof Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
* @param {Number} y
|
* @param {Number} y
|
||||||
|
* @returns {Kinetic.Node}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1390,6 +1439,7 @@
|
|||||||
* @name getY
|
* @name getY
|
||||||
* @method
|
* @method
|
||||||
* @memberof Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
|
* @returns {Integer}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Kinetic.Factory.addGetterSetter(Kinetic.Node, 'opacity', 1);
|
Kinetic.Factory.addGetterSetter(Kinetic.Node, 'opacity', 1);
|
||||||
@@ -1402,6 +1452,7 @@
|
|||||||
* @method
|
* @method
|
||||||
* @memberof Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
* @param {Object} opacity
|
* @param {Object} opacity
|
||||||
|
* @returns {Kinetic.Node}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1409,6 +1460,7 @@
|
|||||||
* @name getOpacity
|
* @name getOpacity
|
||||||
* @method
|
* @method
|
||||||
* @memberof Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
|
* @returns {Number}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Kinetic.Factory.addGetter(Kinetic.Node, 'name');
|
Kinetic.Factory.addGetter(Kinetic.Node, 'name');
|
||||||
@@ -1418,6 +1470,7 @@
|
|||||||
* @name getName
|
* @name getName
|
||||||
* @method
|
* @method
|
||||||
* @memberof Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
|
* @returns {String}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Kinetic.Factory.addGetter(Kinetic.Node, 'id');
|
Kinetic.Factory.addGetter(Kinetic.Node, 'id');
|
||||||
@@ -1427,6 +1480,7 @@
|
|||||||
* @name getId
|
* @name getId
|
||||||
* @method
|
* @method
|
||||||
* @memberof Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
|
* @returns {String}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Kinetic.Factory.addRotationGetterSetter(Kinetic.Node, 'rotation', 0);
|
Kinetic.Factory.addRotationGetterSetter(Kinetic.Node, 'rotation', 0);
|
||||||
@@ -1437,6 +1491,7 @@
|
|||||||
* @method
|
* @method
|
||||||
* @memberof Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
* @param {Number} theta
|
* @param {Number} theta
|
||||||
|
* @returns {Kinetic.Node}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1445,6 +1500,7 @@
|
|||||||
* @method
|
* @method
|
||||||
* @memberof Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
* @param {Number} deg
|
* @param {Number} deg
|
||||||
|
* @returns {Kinetic.Node}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1452,6 +1508,7 @@
|
|||||||
* @name getRotationDeg
|
* @name getRotationDeg
|
||||||
* @method
|
* @method
|
||||||
* @memberof Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
|
* @returns {Number}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1459,6 +1516,7 @@
|
|||||||
* @name getRotation
|
* @name getRotation
|
||||||
* @method
|
* @method
|
||||||
* @memberof Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
|
* @returns {Number}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Kinetic.Factory.addPointGetterSetter(Kinetic.Node, 'scale', 1);
|
Kinetic.Factory.addPointGetterSetter(Kinetic.Node, 'scale', 1);
|
||||||
@@ -1471,6 +1529,7 @@
|
|||||||
* @param {Number} scale.y
|
* @param {Number} scale.y
|
||||||
* @method
|
* @method
|
||||||
* @memberof Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
|
* @returns {Kinetic.Node}
|
||||||
* @example
|
* @example
|
||||||
* // set x and y <br>
|
* // set x and y <br>
|
||||||
* shape.setScale({<br>
|
* shape.setScale({<br>
|
||||||
@@ -1484,6 +1543,7 @@
|
|||||||
* @name getScale
|
* @name getScale
|
||||||
* @method
|
* @method
|
||||||
* @memberof Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
|
* @returns {Object}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1492,6 +1552,7 @@
|
|||||||
* @param {Number} x
|
* @param {Number} x
|
||||||
* @method
|
* @method
|
||||||
* @memberof Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
|
* @returns {Kinetic.Node}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1499,6 +1560,7 @@
|
|||||||
* @name getScaleX
|
* @name getScaleX
|
||||||
* @method
|
* @method
|
||||||
* @memberof Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
|
* @returns {Number}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1507,6 +1569,7 @@
|
|||||||
* @param {Number} y
|
* @param {Number} y
|
||||||
* @method
|
* @method
|
||||||
* @memberof Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
|
* @returns {Kinetic.Node}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1514,6 +1577,7 @@
|
|||||||
* @name getScaleY
|
* @name getScaleY
|
||||||
* @method
|
* @method
|
||||||
* @memberof Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
|
* @returns {Integer}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Kinetic.Factory.addPointGetterSetter(Kinetic.Node, 'skew', 0);
|
Kinetic.Factory.addPointGetterSetter(Kinetic.Node, 'skew', 0);
|
||||||
@@ -1526,6 +1590,7 @@
|
|||||||
* @param {Number} skew.y
|
* @param {Number} skew.y
|
||||||
* @method
|
* @method
|
||||||
* @memberof Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
|
* @returns {Kinetic.Node}
|
||||||
* @example
|
* @example
|
||||||
* // set x and y <br>
|
* // set x and y <br>
|
||||||
* shape.setSkew({<br>
|
* shape.setSkew({<br>
|
||||||
@@ -1548,6 +1613,7 @@
|
|||||||
* @param {Number} x
|
* @param {Number} x
|
||||||
* @method
|
* @method
|
||||||
* @memberof Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
|
* @returns {Kinetic.Node}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1564,6 +1630,7 @@
|
|||||||
* @param {Number} y
|
* @param {Number} y
|
||||||
* @method
|
* @method
|
||||||
* @memberof Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
|
* @returns {Kinetic.Node}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1583,6 +1650,7 @@
|
|||||||
* @memberof Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
* @param {Number} x
|
* @param {Number} x
|
||||||
* @param {Number} y
|
* @param {Number} y
|
||||||
|
* @returns {Kinetic.Node}
|
||||||
* @example
|
* @example
|
||||||
* // set x and y <br>
|
* // set x and y <br>
|
||||||
* shape.setOffset({<br>
|
* shape.setOffset({<br>
|
||||||
@@ -1605,6 +1673,7 @@
|
|||||||
* @method
|
* @method
|
||||||
* @memberof Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
* @param {Number} x
|
* @param {Number} x
|
||||||
|
* @returns {Kinetic.Node}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1621,6 +1690,7 @@
|
|||||||
* @method
|
* @method
|
||||||
* @memberof Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
* @param {Number} y
|
* @param {Number} y
|
||||||
|
* @returns {Kinetic.Node}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1639,6 +1709,7 @@
|
|||||||
* @method
|
* @method
|
||||||
* @memberof Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
* @param {Number} width
|
* @param {Number} width
|
||||||
|
* @returns {Kinetic.Node}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Kinetic.Factory.addSetter(Kinetic.Node, 'height', 0);
|
Kinetic.Factory.addSetter(Kinetic.Node, 'height', 0);
|
||||||
@@ -1649,6 +1720,7 @@
|
|||||||
* @method
|
* @method
|
||||||
* @memberof Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
* @param {Number} height
|
* @param {Number} height
|
||||||
|
* @returns {Kinetic.Node}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Kinetic.Factory.addGetterSetter(Kinetic.Node, 'listening', 'inherit');
|
Kinetic.Factory.addGetterSetter(Kinetic.Node, 'listening', 'inherit');
|
||||||
@@ -1659,6 +1731,7 @@
|
|||||||
* @method
|
* @method
|
||||||
* @memberof Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
* @param {Boolean|String} listening
|
* @param {Boolean|String} listening
|
||||||
|
* @returns {Kinetic.Node}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1677,6 +1750,7 @@
|
|||||||
* @method
|
* @method
|
||||||
* @memberof Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
* @param {Boolean} visible
|
* @param {Boolean} visible
|
||||||
|
* @returns {Kinetic.Node}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1685,6 +1759,7 @@
|
|||||||
* @name getVisible
|
* @name getVisible
|
||||||
* @method
|
* @method
|
||||||
* @memberof Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
|
* @returns {Boolean}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Kinetic.Collection.mapMethods([
|
Kinetic.Collection.mapMethods([
|
||||||
|
|||||||
Reference in New Issue
Block a user