2012-03-07 13:45:48 +08:00
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
// Rect
|
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
/**
|
|
|
|
* Rect constructor
|
|
|
|
* @constructor
|
|
|
|
* @augments Kinetic.Shape
|
|
|
|
* @param {Object} config
|
|
|
|
*/
|
|
|
|
Kinetic.Rect = function(config) {
|
2012-04-05 15:06:00 +08:00
|
|
|
this.shapeType = "Rect";
|
|
|
|
|
2012-03-07 13:45:48 +08:00
|
|
|
config.drawFunc = function() {
|
|
|
|
var context = this.getContext();
|
|
|
|
context.beginPath();
|
2012-03-31 14:57:10 +08:00
|
|
|
this.applyLineJoin();
|
2012-03-07 13:45:48 +08:00
|
|
|
context.rect(0, 0, this.width, this.height);
|
|
|
|
context.closePath();
|
|
|
|
this.fillStroke();
|
|
|
|
};
|
|
|
|
// call super constructor
|
|
|
|
Kinetic.Shape.apply(this, [config]);
|
|
|
|
};
|
|
|
|
/*
|
|
|
|
* Rect methods
|
|
|
|
*/
|
|
|
|
Kinetic.Rect.prototype = {
|
|
|
|
/**
|
|
|
|
* set width
|
|
|
|
* @param {Number} width
|
|
|
|
*/
|
|
|
|
setWidth: function(width) {
|
|
|
|
this.width = width;
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* get width
|
|
|
|
*/
|
|
|
|
getWidth: function() {
|
|
|
|
return this.width;
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* set height
|
|
|
|
* @param {Number} height
|
|
|
|
*/
|
|
|
|
setHeight: function(height) {
|
|
|
|
this.height = height;
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* get height
|
|
|
|
*/
|
|
|
|
getHeight: function() {
|
|
|
|
return this.height;
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* set width and height
|
|
|
|
* @param {Number} width
|
|
|
|
* @param {Number} height
|
|
|
|
*/
|
|
|
|
setSize: function(width, height) {
|
|
|
|
this.width = width;
|
|
|
|
this.height = height;
|
2012-03-31 15:08:50 +08:00
|
|
|
},
|
|
|
|
/**
|
|
|
|
* return rect size
|
|
|
|
*/
|
|
|
|
getSize: function() {
|
|
|
|
return {
|
|
|
|
width: this.width,
|
|
|
|
height: this.height
|
|
|
|
};
|
2012-03-07 13:45:48 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// extend Shape
|
2012-03-12 14:01:23 +08:00
|
|
|
Kinetic.GlobalObject.extend(Kinetic.Rect, Kinetic.Shape);
|