mirror of
https://github.com/konvajs/konva.git
synced 2025-07-15 16:33:15 +08:00
updated more docs for Arc, Circle, Ellipse, and Image
This commit is contained in:
parent
66b65f1c19
commit
b0dbee91b6
@ -75,10 +75,10 @@
|
|||||||
* @param {Number} outerRadius
|
* @param {Number} outerRadius
|
||||||
* @returns {Number}
|
* @returns {Number}
|
||||||
* @example
|
* @example
|
||||||
* // get outer radius
|
* // get outer radius<br>
|
||||||
* var outerRadius = arc.outerRadius();
|
* var outerRadius = arc.outerRadius();<br><br>
|
||||||
*
|
*
|
||||||
* // set outer radius
|
* // set outer radius<br>
|
||||||
* arc.outerRadius(20);
|
* arc.outerRadius(20);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -92,10 +92,10 @@
|
|||||||
* @param {Number} angle
|
* @param {Number} angle
|
||||||
* @returns {Number}
|
* @returns {Number}
|
||||||
* @example
|
* @example
|
||||||
* // get angle
|
* // get angle<br>
|
||||||
* var angle = arc.angle();
|
* var angle = arc.angle();<br><br>
|
||||||
*
|
*
|
||||||
* // set angle
|
* // set angle<br>
|
||||||
* arc.angle(20);
|
* arc.angle(20);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -109,13 +109,13 @@
|
|||||||
* @param {Number} clockwise
|
* @param {Number} clockwise
|
||||||
* @returns {Number}
|
* @returns {Number}
|
||||||
* @example
|
* @example
|
||||||
* // get clockwise flag
|
* // get clockwise flag<br>
|
||||||
* var clockwise = arc.clockwise();
|
* var clockwise = arc.clockwise();<br><br>
|
||||||
*
|
*
|
||||||
* // draw arc counter-clockwise
|
* // draw arc counter-clockwise<br>
|
||||||
* arc.clockwise(false);
|
* arc.clockwise(false);<br><br>
|
||||||
*
|
*
|
||||||
* // draw arc clockwise
|
* // draw arc clockwise<br>
|
||||||
* arc.clockwise(true);
|
* arc.clockwise(true);
|
||||||
*/
|
*/
|
||||||
})();
|
})();
|
||||||
|
@ -13,22 +13,12 @@
|
|||||||
* @@shapeParams
|
* @@shapeParams
|
||||||
* @@nodeParams
|
* @@nodeParams
|
||||||
* @example
|
* @example
|
||||||
* // create simple circle
|
* // create circle
|
||||||
* var circle = new Kinetic.Circle({<br>
|
* var circle = new Kinetic.Circle({<br>
|
||||||
* radius: 40,<br>
|
* radius: 40,<br>
|
||||||
* fill: 'red',<br>
|
* fill: 'red',<br>
|
||||||
* stroke: 'black'<br>
|
* stroke: 'black'<br>
|
||||||
* strokeWidth: 5<br>
|
* strokeWidth: 5<br>
|
||||||
* });<br><br>
|
|
||||||
*
|
|
||||||
* // create ellipse<br>
|
|
||||||
* var circle = new Kinetic.Circle({<br>
|
|
||||||
* radius: 5,<br>
|
|
||||||
* fill: 'red',<br>
|
|
||||||
* stroke: 'black'<br>
|
|
||||||
* strokeWidth: 5,<br>
|
|
||||||
* scaleX: 2,<br>
|
|
||||||
* strokeScaleEnabled: false<br>
|
|
||||||
* });
|
* });
|
||||||
*/
|
*/
|
||||||
Kinetic.Circle = function(config) {
|
Kinetic.Circle = function(config) {
|
||||||
@ -73,18 +63,17 @@
|
|||||||
Kinetic.Factory.addGetterSetter(Kinetic.Circle, 'radius', 0);
|
Kinetic.Factory.addGetterSetter(Kinetic.Circle, 'radius', 0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set radius
|
* get/set radius
|
||||||
* @name setRadius
|
* @name radius
|
||||||
* @method
|
* @method
|
||||||
* @memberof Kinetic.Circle.prototype
|
* @memberof Kinetic.Circle.prototype
|
||||||
* @param {Number} radius
|
* @param {Number} radius
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* get radius
|
|
||||||
* @name getRadius
|
|
||||||
* @method
|
|
||||||
* @memberof Kinetic.Circle.prototype
|
|
||||||
* @returns {Number}
|
* @returns {Number}
|
||||||
|
* @example
|
||||||
|
* // get radius<br>
|
||||||
|
* var radius = circle.radius();<br><br>
|
||||||
|
*
|
||||||
|
* // set radius<br>
|
||||||
|
* circle.radius(10);<br>
|
||||||
*/
|
*/
|
||||||
})();
|
})();
|
||||||
|
@ -24,14 +24,16 @@
|
|||||||
this.sceneFunc(this._sceneFunc);
|
this.sceneFunc(this._sceneFunc);
|
||||||
},
|
},
|
||||||
_sceneFunc: function(context) {
|
_sceneFunc: function(context) {
|
||||||
var r = this.getRadius();
|
var r = this.getRadius(),
|
||||||
|
rx = r.x,
|
||||||
|
ry = r.y;
|
||||||
|
|
||||||
context.beginPath();
|
context.beginPath();
|
||||||
context.save();
|
context.save();
|
||||||
if(r.x !== r.y) {
|
if(rx !== ry) {
|
||||||
context.scale(1, r.y / r.x);
|
context.scale(1, ry / rx);
|
||||||
}
|
}
|
||||||
context.arc(0, 0, r.x, 0, PIx2, false);
|
context.arc(0, 0, rx, 0, PIx2, false);
|
||||||
context.restore();
|
context.restore();
|
||||||
context.closePath();
|
context.closePath();
|
||||||
context.fillStrokeShape(this);
|
context.fillStrokeShape(this);
|
||||||
@ -65,52 +67,53 @@
|
|||||||
Kinetic.Factory.addPointGetterSetter(Kinetic.Ellipse, 'radius', 0);
|
Kinetic.Factory.addPointGetterSetter(Kinetic.Ellipse, 'radius', 0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set radius
|
* get/set radius
|
||||||
* @name setRadius
|
* @name setRadius
|
||||||
* @method
|
* @method
|
||||||
* @memberof Kinetic.Ellipse.prototype
|
* @memberof Kinetic.Ellipse.prototype
|
||||||
* @param {Object} radius
|
* @param {Object} radius
|
||||||
* @param {Number} radius.x
|
* @param {Number} radius.x
|
||||||
* @param {Number} radius.y
|
* @param {Number} radius.y
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* get radius
|
|
||||||
* @name getRadius
|
|
||||||
* @method
|
|
||||||
* @memberof Kinetic.Ellipse.prototype
|
|
||||||
* @returns {Object}
|
* @returns {Object}
|
||||||
|
* @example
|
||||||
|
* // get radius<br>
|
||||||
|
* var radius = ellipse.radius();<br><br>
|
||||||
|
*
|
||||||
|
* // set radius<br>
|
||||||
|
* ellipse.radius({<br>
|
||||||
|
* x: 200,<br>
|
||||||
|
* y: 100<br>
|
||||||
|
* });
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set radius x
|
* get/set radius x
|
||||||
* @name setRadiusX
|
* @name setRadiusX
|
||||||
* @method
|
* @method
|
||||||
* @memberof Kinetic.Ellipse.prototype
|
* @memberof Kinetic.Ellipse.prototype
|
||||||
* @param {Number} x
|
* @param {Number} x
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* get radius x
|
|
||||||
* @name getRadiusX
|
|
||||||
* @method
|
|
||||||
* @memberof Kinetic.Ellipse.prototype
|
|
||||||
* @returns {Number}
|
* @returns {Number}
|
||||||
|
* @example
|
||||||
|
* // get radius x<br>
|
||||||
|
* var radiusX = ellipse.radiusX();<br><br>
|
||||||
|
*
|
||||||
|
* // set radius x<br>
|
||||||
|
* ellipse.radiusX(200);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set radius y
|
* get/set radius y
|
||||||
* @name setRadiusY
|
* @name setRadiusY
|
||||||
* @method
|
* @method
|
||||||
* @memberof Kinetic.Ellipse.prototype
|
* @memberof Kinetic.Ellipse.prototype
|
||||||
* @param {Number} y
|
* @param {Number} y
|
||||||
|
* @returns {Number}
|
||||||
|
* @example
|
||||||
|
* // get radius y<br>
|
||||||
|
* var radiusY = ellipse.radiusY();<br><br>
|
||||||
|
*
|
||||||
|
* // set radius y<br>
|
||||||
|
* ellipse.radiusY(200);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
|
||||||
* get radius y
|
|
||||||
* @name getRadiusY
|
|
||||||
* @method
|
|
||||||
* @memberof Kinetic.Ellipse.prototype
|
|
||||||
* @returns {Number}
|
|
||||||
*/
|
|
||||||
})();
|
})();
|
@ -110,18 +110,22 @@
|
|||||||
|
|
||||||
Kinetic.Factory.addBoxGetterSetter(Kinetic.Image, 'crop', 0);
|
Kinetic.Factory.addBoxGetterSetter(Kinetic.Image, 'crop', 0);
|
||||||
/**
|
/**
|
||||||
* set crop
|
* get/set crop
|
||||||
* @method
|
* @method
|
||||||
* @name setCrop
|
* @name crop
|
||||||
* @memberof Kinetic.Image.prototype
|
* @memberof Kinetic.Image.prototype
|
||||||
* @param {Object} crop
|
* @param {Object} crop
|
||||||
* @param {Number} crop.x
|
* @param {Number} crop.x
|
||||||
* @param {Number} crop.y
|
* @param {Number} crop.y
|
||||||
* @param {Number} crop.width
|
* @param {Number} crop.width
|
||||||
* @param {Number} crop.height
|
* @param {Number} crop.height
|
||||||
|
* @returns {Object}
|
||||||
* @example
|
* @example
|
||||||
* // set crop x, y, width and height<br>
|
* // get crop<br>
|
||||||
* image.setCrop({<br>
|
* var crop = image.crop();<br><br>
|
||||||
|
*
|
||||||
|
* // set crop<br>
|
||||||
|
* image.crop({<br>
|
||||||
* x: 20,<br>
|
* x: 20,<br>
|
||||||
* y: 20,<br>
|
* y: 20,<br>
|
||||||
* width: 20,<br>
|
* width: 20,<br>
|
||||||
@ -129,75 +133,63 @@
|
|||||||
* });
|
* });
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
|
||||||
* get crop
|
|
||||||
* @name getCrop
|
|
||||||
* @method
|
|
||||||
* @memberof Kinetic.Image.prototype
|
|
||||||
* @returns {Object}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set crop x
|
* get/set crop x
|
||||||
* @method
|
* @method
|
||||||
* @name setCropX
|
* @name cropX
|
||||||
* @memberof Kinetic.Image.prototype
|
* @memberof Kinetic.Image.prototype
|
||||||
* @param {Number} x
|
* @param {Number} x
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* get crop x
|
|
||||||
* @name getCropX
|
|
||||||
* @method
|
|
||||||
* @memberof Kinetic.Image.prototype
|
|
||||||
* @returns {Number}
|
* @returns {Number}
|
||||||
|
* @example
|
||||||
|
* // get crop x<br>
|
||||||
|
* var cropX = image.cropX();<br><br>
|
||||||
|
*
|
||||||
|
* // set crop x<br>
|
||||||
|
* image.cropX(20);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set crop y
|
* get/set crop y
|
||||||
* @name setCropY
|
* @name cropY
|
||||||
* @method
|
* @method
|
||||||
* @memberof Kinetic.Image.prototype
|
* @memberof Kinetic.Image.prototype
|
||||||
* @param {Number} y
|
* @param {Number} y
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* get crop y
|
|
||||||
* @name getCropY
|
|
||||||
* @method
|
|
||||||
* @memberof Kinetic.Image.prototype
|
|
||||||
* @returns {Number}
|
* @returns {Number}
|
||||||
|
* @example
|
||||||
|
* // get crop y<br>
|
||||||
|
* var cropY = image.cropY();<br><br>
|
||||||
|
*
|
||||||
|
* // set crop y<br>
|
||||||
|
* image.cropY(20);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set cropWidth
|
* get/set crop width
|
||||||
* @name setCropWidth
|
* @name cropWidth
|
||||||
* @method
|
* @method
|
||||||
* @memberof Kinetic.Image.prototype
|
* @memberof Kinetic.Image.prototype
|
||||||
* @param {Number} width
|
* @param {Number} width
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* get crop width
|
|
||||||
* @name getCropWidth
|
|
||||||
* @method
|
|
||||||
* @memberof Kinetic.Image.prototype
|
|
||||||
* @returns {Number}
|
* @returns {Number}
|
||||||
|
* @example
|
||||||
|
* // get crop width<br>
|
||||||
|
* var cropWidth = image.cropWidth();<br><br>
|
||||||
|
*
|
||||||
|
* // set crop width<br>
|
||||||
|
* image.cropWidth(20);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set cropHeight
|
* get/set crop height
|
||||||
* @name setCropHeight
|
* @name cropHeight
|
||||||
* @method
|
* @method
|
||||||
* @memberof Kinetic.Image.prototype
|
* @memberof Kinetic.Image.prototype
|
||||||
* @param {Number} height
|
* @param {Number} height
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* get crop height
|
|
||||||
* @name getCropHeight
|
|
||||||
* @method
|
|
||||||
* @memberof Kinetic.Image.prototype
|
|
||||||
* @returns {Number}
|
* @returns {Number}
|
||||||
|
* @example
|
||||||
|
* // get crop height<br>
|
||||||
|
* var cropHeight = image.cropHeight();<br><br>
|
||||||
|
*
|
||||||
|
* // set crop height<br>
|
||||||
|
* image.cropHeight(20);
|
||||||
*/
|
*/
|
||||||
})();
|
})();
|
||||||
|
Loading…
Reference in New Issue
Block a user