mirror of
https://github.com/konvajs/konva.git
synced 2025-09-19 10:47:59 +08:00
deprecated Ellipse shape, since you can create ellipses now with circles. updated tests
This commit is contained in:
@@ -1,78 +0,0 @@
|
||||
(function() {
|
||||
/**
|
||||
* Ellipse constructor
|
||||
* @constructor
|
||||
* @augments Kinetic.Shape
|
||||
* @param {Object} config
|
||||
* @param {Number|Array|Object} config.radius defines x and y radius
|
||||
* {{ShapeParams}}
|
||||
* {{NodeParams}}
|
||||
*/
|
||||
Kinetic.Ellipse = function(config) {
|
||||
this._initEllipse(config);
|
||||
};
|
||||
|
||||
Kinetic.Ellipse.prototype = {
|
||||
_initEllipse: function(config) {
|
||||
this.createAttrs();
|
||||
|
||||
// call super constructor
|
||||
Kinetic.Shape.call(this, config);
|
||||
this.shapeType = 'Ellipse';
|
||||
this._setDrawFuncs();
|
||||
},
|
||||
drawFunc: function(canvas) {
|
||||
var context = canvas.getContext(), r = this.getRadius();
|
||||
context.beginPath();
|
||||
context.save();
|
||||
if(r.x !== r.y) {
|
||||
context.scale(1, r.y / r.x);
|
||||
}
|
||||
context.arc(0, 0, r.x, 0, Math.PI * 2, true);
|
||||
context.restore();
|
||||
context.closePath();
|
||||
canvas.fillStroke(this);
|
||||
},
|
||||
getWidth: function() {
|
||||
return this.getRadius().x * 2;
|
||||
},
|
||||
getHeight: function() {
|
||||
return this.getRadius().y * 2;
|
||||
},
|
||||
setWidth: function(width) {
|
||||
Kinetic.Node.prototype.setWidth.call(this, width);
|
||||
this.setRadius({
|
||||
x: width / 2
|
||||
});
|
||||
},
|
||||
setHeight: function(height) {
|
||||
Kinetic.Node.prototype.setHeight.call(this, height);
|
||||
this.setRadius({
|
||||
y: height / 2
|
||||
});
|
||||
}
|
||||
};
|
||||
Kinetic.Util.extend(Kinetic.Ellipse, Kinetic.Shape);
|
||||
|
||||
// add getters setters
|
||||
Kinetic.Node.addPointGetterSetter(Kinetic.Ellipse, 'radius', 0);
|
||||
|
||||
/**
|
||||
* set radius
|
||||
* @name setRadius
|
||||
* @methodOf 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
|
||||
* can be an array in which the first element is the x component
|
||||
* and the second element is the y component. The x component
|
||||
* defines the horizontal radius and the y component
|
||||
* defines the vertical radius
|
||||
*/
|
||||
|
||||
/**
|
||||
* get radius
|
||||
* @name getRadius
|
||||
* @methodOf Kinetic.Ellipse.prototype
|
||||
*/
|
||||
})();
|
Reference in New Issue
Block a user