mirror of
https://github.com/konvajs/konva.git
synced 2025-06-28 15:23:44 +08:00
36 lines
859 B
JavaScript
36 lines
859 B
JavaScript
///////////////////////////////////////////////////////////////////////
|
|
// Circle
|
|
///////////////////////////////////////////////////////////////////////
|
|
/**
|
|
* Circle constructor
|
|
* @param {Object} config
|
|
*/
|
|
Kinetic.Circle = function(config){
|
|
config.drawFunc = function(){
|
|
var canvas = this.getCanvas();
|
|
var context = this.getContext();
|
|
context.beginPath();
|
|
context.arc(0, 0, this.radius, 0, Math.PI * 2, true);
|
|
context.closePath();
|
|
this.fillStroke();
|
|
};
|
|
|
|
// call super constructor
|
|
Kinetic.Shape.apply(this, [config]);
|
|
};
|
|
|
|
/*
|
|
* Circle methods
|
|
*/
|
|
Kinetic.Circle.prototype = {
|
|
setRadius: function(radius){
|
|
this.radius = radius;
|
|
},
|
|
getRadius: function(){
|
|
return this.radius;
|
|
}
|
|
};
|
|
|
|
// extend Shape
|
|
Kinetic.GlobalObject.extend(Kinetic.Circle, Kinetic.Shape);
|