promoted to v4.7.1, and improved Shape docs

This commit is contained in:
Eric Rowell 2013-09-16 22:05:28 -07:00
parent bf15d0679f
commit a2a4c6df2b
13 changed files with 71 additions and 10 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "KineticJS", "name": "KineticJS",
"version": "4.7.0", "version": "4.7.1",
"devDependencies": { "devDependencies": {
"grunt-contrib-jshint": "~0.5.4", "grunt-contrib-jshint": "~0.5.4",
"grunt-contrib-nodeunit": "~0.1.2", "grunt-contrib-nodeunit": "~0.1.2",

View File

@ -100,14 +100,13 @@ var Kinetic = {};
* y: 10,<br> * y: 10,<br>
* fill: 'red',<br> * fill: 'red',<br>
* // a Kinetic.Canvas renderer is passed into the drawFunc function<br> * // a Kinetic.Canvas renderer is passed into the drawFunc function<br>
* drawFunc: function(canvas) {<br> * drawFunc: function(context) {<br>
* var context = canvas.getContext();<br>
* context.beginPath();<br> * context.beginPath();<br>
* context.moveTo(200, 50);<br> * context.moveTo(200, 50);<br>
* context.lineTo(420, 80);<br> * context.lineTo(420, 80);<br>
* context.quadraticCurveTo(300, 100, 260, 170);<br> * context.quadraticCurveTo(300, 100, 260, 170);<br>
* context.closePath();<br> * context.closePath();<br>
* canvas.fillStroke(this);<br> * context.fillStrokeShape(this);<br>
* }<br> * }<br>
*}); *});
*/ */

View File

@ -97,10 +97,12 @@
* @name getTension * @name getTension
* @method * @method
* @memberof Kinetic.Blob.prototype * @memberof Kinetic.Blob.prototype
* @returns {Number}
*/ */
/** /**
* set tension * set tension
* @name setTension
* @method * @method
* @memberof Kinetic.Blob.prototype * @memberof Kinetic.Blob.prototype
* @param {Number} tension * @param {Number} tension
@ -109,12 +111,15 @@
Kinetic.Factory.addPointsGetterSetter(Kinetic.Blob, 'points'); Kinetic.Factory.addPointsGetterSetter(Kinetic.Blob, 'points');
/** /**
* get points array * get points array
* @name getPoints
* @method * @method
* @memberof Kinetic.Blob.prototype * @memberof Kinetic.Blob.prototype
* @returns {Array}
*/ */
/** /**
* set points array * set points array
* @name setPoints
* @method * @method
* @memberof Kinetic.Blob.prototype * @memberof Kinetic.Blob.prototype
* @param {Array} can be an array of point objects or an array * @param {Array} can be an array of point objects or an array

View File

@ -47,16 +47,20 @@
context.closePath(); context.closePath();
context.fillStrokeShape(this); context.fillStrokeShape(this);
}, },
// implements Shape.prototype.getWidth()
getWidth: function() { getWidth: function() {
return this.getRadius() * 2; return this.getRadius() * 2;
}, },
// implements Shape.prototype.getHeight()
getHeight: function() { getHeight: function() {
return this.getRadius() * 2; return this.getRadius() * 2;
}, },
// implements Shape.prototype.setWidth()
setWidth: function(width) { setWidth: function(width) {
Kinetic.Node.prototype.setWidth.call(this, width); Kinetic.Node.prototype.setWidth.call(this, width);
this.setRadius(width / 2); this.setRadius(width / 2);
}, },
// implements Shape.prototype.setHeight()
setHeight: function(height) { setHeight: function(height) {
Kinetic.Node.prototype.setHeight.call(this, height); Kinetic.Node.prototype.setHeight.call(this, height);
this.setRadius(height / 2); this.setRadius(height / 2);
@ -69,6 +73,7 @@
/** /**
* set radius * set radius
* @name setRadius
* @method * @method
* @memberof Kinetic.Circle.prototype * @memberof Kinetic.Circle.prototype
* @param {Number} radius * @param {Number} radius
@ -76,7 +81,9 @@
/** /**
* get radius * get radius
* @name getRadius
* @method * @method
* @memberof Kinetic.Circle.prototype * @memberof Kinetic.Circle.prototype
* @returns {Number}
*/ */
})(); })();

View File

@ -35,18 +35,22 @@
context.closePath(); context.closePath();
context.fillStrokeShape(this); context.fillStrokeShape(this);
}, },
// implements Shape.prototype.getWidth()
getWidth: function() { getWidth: function() {
return this.getRadius().x * 2; return this.getRadius().x * 2;
}, },
// implements Shape.prototype.getHeight()
getHeight: function() { getHeight: function() {
return this.getRadius().y * 2; return this.getRadius().y * 2;
}, },
// implements Shape.prototype.setWidth()
setWidth: function(width) { setWidth: function(width) {
Kinetic.Node.prototype.setWidth.call(this, width); Kinetic.Node.prototype.setWidth.call(this, width);
this.setRadius({ this.setRadius({
x: width / 2 x: width / 2
}); });
}, },
// implements Shape.prototype.setHeight()
setHeight: function(height) { setHeight: function(height) {
Kinetic.Node.prototype.setHeight.call(this, height); Kinetic.Node.prototype.setHeight.call(this, height);
this.setRadius({ this.setRadius({
@ -62,7 +66,8 @@
/** /**
* set radius * set radius
* @name setRadius * @name setRadius
* @methodOf Kinetic.Ellipse.prototype * @method
* @memberof Kinetic.Ellipse.prototype
* @param {Object|Array} radius * @param {Object|Array} radius
* radius can be a number, in which the ellipse becomes a circle, * radius can be a number, in which the ellipse becomes a circle,
* it can be an object with an x and y component, or it * it can be an object with an x and y component, or it
@ -75,6 +80,8 @@
/** /**
* get radius * get radius
* @name getRadius * @name getRadius
* @methodOf Kinetic.Ellipse.prototype * @method
* @memberof Kinetic.Ellipse.prototype
* @returns {Object}
*/ */
})(); })();

View File

@ -160,6 +160,10 @@
* @memberof Kinetic.Image.prototype * @memberof Kinetic.Image.prototype
* @param {Function} [callback] callback function to be called once * @param {Function} [callback] callback function to be called once
* the image hit region has been created * the image hit region has been created
* @example
* image.createImageHitRegion(function() {<br>
* layer.drawHit();<br>
* });
*/ */
createImageHitRegion: function(callback) { createImageHitRegion: function(callback) {
var that = this, var that = this,
@ -252,6 +256,7 @@
* @name getImage * @name getImage
* @method * @method
* @memberof Kinetic.Image.prototype * @memberof Kinetic.Image.prototype
* @returns {ImageObject}
*/ */
Kinetic.Factory.addBoxGetterSetter(Kinetic.Image, 'crop'); Kinetic.Factory.addBoxGetterSetter(Kinetic.Image, 'crop');
@ -311,7 +316,7 @@
* @name getCrop * @name getCrop
* @method * @method
* @memberof Kinetic.Image.prototype * @memberof Kinetic.Image.prototype
* @return {Object} * @returns {Object}
*/ */
/** /**
@ -319,6 +324,7 @@
* @name getCropX * @name getCropX
* @method * @method
* @memberof Kinetic.Image.prototype * @memberof Kinetic.Image.prototype
* @returns {Number}
*/ */
/** /**
@ -326,6 +332,7 @@
* @name getCropY * @name getCropY
* @method * @method
* @memberof Kinetic.Image.prototype * @memberof Kinetic.Image.prototype
* @returns {Number}
*/ */
/** /**
@ -333,6 +340,7 @@
* @name getCropWidth * @name getCropWidth
* @method * @method
* @memberof Kinetic.Image.prototype * @memberof Kinetic.Image.prototype
* @returns {Number}
*/ */
/** /**
@ -340,6 +348,7 @@
* @name getCropHeight * @name getCropHeight
* @method * @method
* @memberof Kinetic.Image.prototype * @memberof Kinetic.Image.prototype
* @returns {Number}
*/ */
Kinetic.Factory.addFilterGetterSetter(Kinetic.Image, 'filter'); Kinetic.Factory.addFilterGetterSetter(Kinetic.Image, 'filter');
@ -357,5 +366,6 @@
* @name getFilter * @name getFilter
* @method * @method
* @memberof Kinetic.Image.prototype * @memberof Kinetic.Image.prototype
* @returns {Function)}
*/ */
})(); })();

View File

@ -62,6 +62,7 @@
Kinetic.Factory.addPointsGetterSetter(Kinetic.Line, 'points'); Kinetic.Factory.addPointsGetterSetter(Kinetic.Line, 'points');
/** /**
* set points array * set points array
* @name setPoints
* @method * @method
* @memberof Kinetic.Line.prototype * @memberof Kinetic.Line.prototype
* @param {Array} can be an array of point objects or an array * @param {Array} can be an array of point objects or an array
@ -70,7 +71,9 @@
/** /**
* get points array * get points array
* @name getPoints
* @method * @method
* @memberof Kinetic.Line.prototype * @memberof Kinetic.Line.prototype
* @returns {Array}
*/ */
})(); })();

View File

@ -45,6 +45,7 @@
Kinetic.Factory.addPointsGetterSetter(Kinetic.Polygon, 'points'); Kinetic.Factory.addPointsGetterSetter(Kinetic.Polygon, 'points');
/** /**
* set points array * set points array
* @name setPoints
* @method * @method
* @memberof Kinetic.Polygon.prototype * @memberof Kinetic.Polygon.prototype
* @param {Array} can be an array of point objects or an array * @param {Array} can be an array of point objects or an array
@ -53,7 +54,9 @@
/** /**
* get points array * get points array
* @name getPoints
* @method * @method
* @memberof Kinetic.Polygon.prototype * @memberof Kinetic.Polygon.prototype
* @returns {Array}
*/ */
})(); })();

View File

@ -71,6 +71,7 @@
* @name getCornerRadius * @name getCornerRadius
* @method * @method
* @memberof Kinetic.Rect.prototype * @memberof Kinetic.Rect.prototype
* @returns {Number}
*/ */
})(); })();

View File

@ -84,10 +84,12 @@
* @name getTension * @name getTension
* @method * @method
* @memberof Kinetic.Spline.prototype * @memberof Kinetic.Spline.prototype
* @returns {Number}
*/ */
/** /**
* set tension * set tension
* @name setTension
* @method * @method
* @memberof Kinetic.Spline.prototype * @memberof Kinetic.Spline.prototype
* @param {Number} tension * @param {Number} tension
@ -96,12 +98,15 @@
Kinetic.Factory.addPointsGetterSetter(Kinetic.Spline, 'points'); Kinetic.Factory.addPointsGetterSetter(Kinetic.Spline, 'points');
/** /**
* get points array * get points array
* @name getPoints
* @method * @method
* @memberof Kinetic.Spline.prototype * @memberof Kinetic.Spline.prototype
* @returns {Array}
*/ */
/** /**
* set points array * set points array
* @name setPoints
* @method * @method
* @memberof Kinetic.Spline.prototype * @memberof Kinetic.Spline.prototype
* @param {Array} can be an array of point objects or an array * @param {Array} can be an array of point objects or an array

View File

@ -185,6 +185,7 @@
* @name getAnimation * @name getAnimation
* @method * @method
* @memberof Kinetic.Sprite.prototype * @memberof Kinetic.Sprite.prototype
* @returns {String}
*/ */
Kinetic.Factory.addGetterSetter(Kinetic.Sprite, 'animations'); Kinetic.Factory.addGetterSetter(Kinetic.Sprite, 'animations');
@ -202,6 +203,7 @@
* @name getAnimations * @name getAnimations
* @method * @method
* @memberof Kinetic.Sprite.prototype * @memberof Kinetic.Sprite.prototype
* @returns {Object}
*/ */
Kinetic.Factory.addGetterSetter(Kinetic.Sprite, 'image'); Kinetic.Factory.addGetterSetter(Kinetic.Sprite, 'image');
@ -219,6 +221,7 @@
* @name getImage * @name getImage
* @method * @method
* @memberof Kinetic.Sprite.prototype * @memberof Kinetic.Sprite.prototype
* @returns {ImageObject}
*/ */
Kinetic.Factory.addGetterSetter(Kinetic.Sprite, 'index', 0); Kinetic.Factory.addGetterSetter(Kinetic.Sprite, 'index', 0);
@ -236,6 +239,7 @@
* @name getIndex * @name getIndex
* @method * @method
* @memberof Kinetic.Sprite.prototype * @memberof Kinetic.Sprite.prototype
* @returns {Integer}
*/ */
Kinetic.Factory.addGetterSetter(Kinetic.Sprite, 'frameRate', 17); Kinetic.Factory.addGetterSetter(Kinetic.Sprite, 'frameRate', 17);
@ -254,6 +258,7 @@
* @name getFrameRate * @name getFrameRate
* @method * @method
* @memberof Kinetic.Sprite.prototype * @memberof Kinetic.Sprite.prototype
* @returns {Number}
*/ */
})(); })();

View File

@ -150,17 +150,19 @@
this._setAttr(TEXT, str); this._setAttr(TEXT, str);
}, },
/** /**
* get width * get width of text area, which includes padding
* @method * @method
* @memberof Kinetic.Text.prototype * @memberof Kinetic.Text.prototype
* @returns {Number}
*/ */
getWidth: function() { getWidth: function() {
return this.attrs.width === AUTO ? this.getTextWidth() + this.getPadding() * 2 : this.attrs.width; return this.attrs.width === AUTO ? this.getTextWidth() + this.getPadding() * 2 : this.attrs.width;
}, },
/** /**
* get the height of the text area, which takes into account multi-line text and padding * get the height of the text area, which takes into account multi-line text, line heights, and padding
* @method * @method
* @memberof Kinetic.Text.prototype * @memberof Kinetic.Text.prototype
* @returns {Number}
*/ */
getHeight: function() { getHeight: function() {
return this.attrs.height === AUTO ? (this.getTextHeight() * this.textArr.length * this.getLineHeight()) + this.getPadding() * 2 : this.attrs.height; return this.attrs.height === AUTO ? (this.getTextHeight() * this.textArr.length * this.getLineHeight()) + this.getPadding() * 2 : this.attrs.height;
@ -169,6 +171,7 @@
* get text width * get text width
* @method * @method
* @memberof Kinetic.Text.prototype * @memberof Kinetic.Text.prototype
* @returns {Number}
*/ */
getTextWidth: function() { getTextWidth: function() {
return this.textWidth; return this.textWidth;
@ -177,6 +180,7 @@
* get text height * get text height
* @method * @method
* @memberof Kinetic.Text.prototype * @memberof Kinetic.Text.prototype
* @returns {Number}
*/ */
getTextHeight: function() { getTextHeight: function() {
return this.textHeight; return this.textHeight;
@ -330,6 +334,7 @@
* @name getFontFamily * @name getFontFamily
* @method * @method
* @memberof Kinetic.Text.prototype * @memberof Kinetic.Text.prototype
* @returns {String}
*/ */
Kinetic.Factory.addGetterSetter(Kinetic.Text, 'fontSize', 12); Kinetic.Factory.addGetterSetter(Kinetic.Text, 'fontSize', 12);
@ -339,7 +344,7 @@
* @name setFontSize * @name setFontSize
* @method * @method
* @memberof Kinetic.Text.prototype * @memberof Kinetic.Text.prototype
* @param {int} fontSize * @param {Number} fontSize
*/ */
/** /**
@ -347,6 +352,7 @@
* @name getFontSize * @name getFontSize
* @method * @method
* @memberof Kinetic.Text.prototype * @memberof Kinetic.Text.prototype
* @returns {Number}
*/ */
Kinetic.Factory.addGetterSetter(Kinetic.Text, 'fontStyle', NORMAL); Kinetic.Factory.addGetterSetter(Kinetic.Text, 'fontStyle', NORMAL);
@ -364,6 +370,7 @@
* @name getFontStyle * @name getFontStyle
* @method * @method
* @memberof Kinetic.Text.prototype * @memberof Kinetic.Text.prototype
* @returns {String}
*/ */
Kinetic.Factory.addGetterSetter(Kinetic.Text, 'padding', 0); Kinetic.Factory.addGetterSetter(Kinetic.Text, 'padding', 0);
@ -381,6 +388,7 @@
* @name getPadding * @name getPadding
* @method * @method
* @memberof Kinetic.Text.prototype * @memberof Kinetic.Text.prototype
* @returns {Number}
*/ */
Kinetic.Factory.addGetterSetter(Kinetic.Text, 'align', LEFT); Kinetic.Factory.addGetterSetter(Kinetic.Text, 'align', LEFT);
@ -398,6 +406,7 @@
* @name getAlign * @name getAlign
* @method * @method
* @memberof Kinetic.Text.prototype * @memberof Kinetic.Text.prototype
* @returns {String}
*/ */
Kinetic.Factory.addGetterSetter(Kinetic.Text, 'lineHeight', 1); Kinetic.Factory.addGetterSetter(Kinetic.Text, 'lineHeight', 1);
@ -415,6 +424,7 @@
* @name getLineHeight * @name getLineHeight
* @method * @method
* @memberof Kinetic.Text.prototype * @memberof Kinetic.Text.prototype
* @returns {Number}
*/ */
Kinetic.Factory.addGetterSetter(Kinetic.Text, 'wrap', WORD); Kinetic.Factory.addGetterSetter(Kinetic.Text, 'wrap', WORD);
@ -432,6 +442,7 @@
* @name getWrap * @name getWrap
* @method * @method
* @memberof Kinetic.Text.prototype * @memberof Kinetic.Text.prototype
* @returns {String}
*/ */
Kinetic.Factory.addGetter(Kinetic.Text, TEXT, EMPTY_STRING); Kinetic.Factory.addGetter(Kinetic.Text, TEXT, EMPTY_STRING);
@ -441,6 +452,7 @@
* @name getText * @name getText
* @method * @method
* @memberof Kinetic.Text.prototype * @memberof Kinetic.Text.prototype
* @returns {String}
*/ */
Kinetic.Factory.addSetter(Kinetic.Text, 'width'); Kinetic.Factory.addSetter(Kinetic.Text, 'width');

View File

@ -57,6 +57,7 @@
* @name getRadius * @name getRadius
* @method * @method
* @memberof Kinetic.Wedge.prototype * @memberof Kinetic.Wedge.prototype
* @returns {Number}
*/ */
Kinetic.Factory.addRotationGetterSetter(Kinetic.Wedge, 'angle', 0); Kinetic.Factory.addRotationGetterSetter(Kinetic.Wedge, 'angle', 0);
@ -82,6 +83,7 @@
* @name getAngle * @name getAngle
* @method * @method
* @memberof Kinetic.Wedge.prototype * @memberof Kinetic.Wedge.prototype
* @returns {Number}
*/ */
/** /**
@ -89,6 +91,7 @@
* @name getAngleDeg * @name getAngleDeg
* @method * @method
* @memberof Kinetic.Wedge.prototype * @memberof Kinetic.Wedge.prototype
* @returns {Number}
*/ */
Kinetic.Factory.addGetterSetter(Kinetic.Wedge, 'clockwise', false); Kinetic.Factory.addGetterSetter(Kinetic.Wedge, 'clockwise', false);
@ -107,5 +110,6 @@
* @name getClockwise * @name getClockwise
* @method * @method
* @memberof Kinetic.Wedge.prototype * @memberof Kinetic.Wedge.prototype
* @returns {Boolean}
*/ */
})(); })();