2012-11-30 12:15:01 +08:00
|
|
|
(function() {
|
|
|
|
/**
|
|
|
|
* Wedge constructor
|
|
|
|
* @constructor
|
|
|
|
* @augments Kinetic.Shape
|
|
|
|
* @param {Object} config
|
2012-12-23 15:08:03 +08:00
|
|
|
* @param {Number} config.angle
|
2013-03-22 01:10:21 +08:00
|
|
|
* @param {Number} config.angleDeg angle in degrees
|
2012-12-23 15:08:03 +08:00
|
|
|
* @param {Number} config.radius
|
2013-01-03 15:55:56 +08:00
|
|
|
* @param {Boolean} [config.clockwise]
|
2013-06-02 01:27:44 +08:00
|
|
|
* @@shapeParams
|
|
|
|
* @@nodeParams
|
2013-05-18 11:56:24 +08:00
|
|
|
* @example
|
|
|
|
* // draw a wedge that's pointing downwards<br>
|
|
|
|
* var wedge = new Kinetic.Wedge({<br>
|
|
|
|
* radius: 40,<br>
|
|
|
|
* fill: 'red',<br>
|
|
|
|
* stroke: 'black'<br>
|
|
|
|
* strokeWidth: 5,<br>
|
|
|
|
* angleDeg: 60,<br>
|
|
|
|
* rotationDeg: -120<br>
|
|
|
|
* });
|
2012-11-30 12:15:01 +08:00
|
|
|
*/
|
|
|
|
Kinetic.Wedge = function(config) {
|
|
|
|
this._initWedge(config);
|
|
|
|
};
|
|
|
|
|
|
|
|
Kinetic.Wedge.prototype = {
|
|
|
|
_initWedge: function(config) {
|
2013-03-15 23:33:05 +08:00
|
|
|
this.createAttrs();
|
2012-11-30 12:15:01 +08:00
|
|
|
|
|
|
|
// call super constructor
|
|
|
|
Kinetic.Shape.call(this, config);
|
2013-05-20 12:48:48 +08:00
|
|
|
this.className = 'Wedge';
|
2012-11-30 12:15:01 +08:00
|
|
|
this._setDrawFuncs();
|
|
|
|
},
|
2012-12-10 01:52:33 +08:00
|
|
|
drawFunc: function(canvas) {
|
|
|
|
var context = canvas.getContext();
|
2012-11-30 12:15:01 +08:00
|
|
|
context.beginPath();
|
|
|
|
context.arc(0, 0, this.getRadius(), 0, this.getAngle(), this.getClockwise());
|
|
|
|
context.lineTo(0, 0);
|
|
|
|
context.closePath();
|
2012-12-10 01:52:33 +08:00
|
|
|
canvas.fillStroke(this);
|
2012-11-30 12:15:01 +08:00
|
|
|
}
|
|
|
|
};
|
2013-05-08 14:51:02 +08:00
|
|
|
Kinetic.Util.extend(Kinetic.Wedge, Kinetic.Shape);
|
2012-11-30 12:15:01 +08:00
|
|
|
|
|
|
|
// add getters setters
|
2013-03-15 23:33:05 +08:00
|
|
|
Kinetic.Node.addGetterSetter(Kinetic.Wedge, 'radius', 0);
|
2012-11-30 12:15:01 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* set radius
|
|
|
|
* @name setRadius
|
2013-05-16 15:28:49 +08:00
|
|
|
* @method
|
|
|
|
* @memberof Kinetic.Wedge.prototype
|
2012-11-30 12:15:01 +08:00
|
|
|
* @param {Number} radius
|
|
|
|
*/
|
|
|
|
|
2013-05-03 01:22:21 +08:00
|
|
|
/**
|
|
|
|
* get radius
|
|
|
|
* @name getRadius
|
2013-05-16 15:28:49 +08:00
|
|
|
* @method
|
|
|
|
* @memberof Kinetic.Wedge.prototype
|
2013-05-03 01:22:21 +08:00
|
|
|
*/
|
|
|
|
|
2013-05-08 01:19:54 +08:00
|
|
|
Kinetic.Node.addRotationGetterSetter(Kinetic.Wedge, 'angle', 0);
|
2013-05-03 01:22:21 +08:00
|
|
|
|
2012-11-30 12:15:01 +08:00
|
|
|
/**
|
|
|
|
* set angle
|
|
|
|
* @name setAngle
|
2013-05-16 15:28:49 +08:00
|
|
|
* @method
|
|
|
|
* @memberof Kinetic.Wedge.prototype
|
2012-11-30 12:15:01 +08:00
|
|
|
* @param {Number} angle
|
|
|
|
*/
|
2013-05-03 01:22:21 +08:00
|
|
|
|
|
|
|
/**
|
2013-03-22 01:10:21 +08:00
|
|
|
* set angle in degrees
|
|
|
|
* @name setAngleDeg
|
2013-05-16 15:28:49 +08:00
|
|
|
* @method
|
|
|
|
* @memberof Kinetic.Wedge.prototype
|
2013-03-22 01:10:21 +08:00
|
|
|
* @param {Number} angleDeg
|
|
|
|
*/
|
2012-11-30 12:15:01 +08:00
|
|
|
|
2013-05-03 01:22:21 +08:00
|
|
|
/**
|
|
|
|
* get angle
|
|
|
|
* @name getAngle
|
2013-05-16 15:28:49 +08:00
|
|
|
* @method
|
|
|
|
* @memberof Kinetic.Wedge.prototype
|
2012-11-30 12:15:01 +08:00
|
|
|
*/
|
|
|
|
|
2013-05-03 01:22:21 +08:00
|
|
|
/**
|
|
|
|
* get angle in degrees
|
|
|
|
* @name getAngleDeg
|
2013-05-16 15:28:49 +08:00
|
|
|
* @method
|
|
|
|
* @memberof Kinetic.Wedge.prototype
|
2012-11-30 12:15:01 +08:00
|
|
|
*/
|
|
|
|
|
2013-05-03 01:22:21 +08:00
|
|
|
Kinetic.Node.addGetterSetter(Kinetic.Wedge, 'clockwise', false);
|
|
|
|
|
2012-11-30 12:15:01 +08:00
|
|
|
/**
|
2013-05-03 01:22:21 +08:00
|
|
|
* set clockwise draw direction. If set to true, the wedge will be drawn clockwise
|
|
|
|
* If set to false, the wedge will be drawn anti-clockwise. The default is false.
|
|
|
|
* @name setClockwise
|
2013-05-16 15:28:49 +08:00
|
|
|
* @method
|
|
|
|
* @memberof Kinetic.Wedge.prototype
|
2013-05-03 01:22:21 +08:00
|
|
|
* @param {Boolean} clockwise
|
2013-03-22 01:10:21 +08:00
|
|
|
*/
|
2012-11-30 12:15:01 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* get clockwise
|
|
|
|
* @name getClockwise
|
2013-05-16 15:28:49 +08:00
|
|
|
* @method
|
|
|
|
* @memberof Kinetic.Wedge.prototype
|
2012-11-30 12:15:01 +08:00
|
|
|
*/
|
|
|
|
})();
|