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",
"version": "4.7.0",
"version": "4.7.1",
"devDependencies": {
"grunt-contrib-jshint": "~0.5.4",
"grunt-contrib-nodeunit": "~0.1.2",

View File

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

View File

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

View File

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

View File

@ -35,18 +35,22 @@
context.closePath();
context.fillStrokeShape(this);
},
// implements Shape.prototype.getWidth()
getWidth: function() {
return this.getRadius().x * 2;
},
// implements Shape.prototype.getHeight()
getHeight: function() {
return this.getRadius().y * 2;
},
// implements Shape.prototype.setWidth()
setWidth: function(width) {
Kinetic.Node.prototype.setWidth.call(this, width);
this.setRadius({
x: width / 2
});
},
// implements Shape.prototype.setHeight()
setHeight: function(height) {
Kinetic.Node.prototype.setHeight.call(this, height);
this.setRadius({
@ -62,7 +66,8 @@
/**
* set radius
* @name setRadius
* @methodOf Kinetic.Ellipse.prototype
* @method
* @memberof Kinetic.Ellipse.prototype
* @param {Object|Array} radius
* 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
@ -75,6 +80,8 @@
/**
* get radius
* @name getRadius
* @methodOf Kinetic.Ellipse.prototype
* @method
* @memberof Kinetic.Ellipse.prototype
* @returns {Object}
*/
})();

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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