mirror of
https://github.com/konvajs/konva.git
synced 2025-09-18 18:27:58 +08:00
all shape and plugin tests are now passing again
This commit is contained in:
@@ -94,14 +94,14 @@
|
||||
|
||||
// box
|
||||
addBoxGetterSetter: function(constructor, attr) {
|
||||
this.addPointGetter(constructor, attr);
|
||||
this.addPointSetter(constructor, attr);
|
||||
this.addBoxGetter(constructor, attr);
|
||||
this.addBoxSetter(constructor, attr);
|
||||
},
|
||||
addBoxGetter: function(constructor, attr) {
|
||||
var method = GET + Kinetic.Util._capitalize(attr),
|
||||
getX = method + UPPER_X,
|
||||
getY = method + UPPER_Y,
|
||||
getWidth = method + UPPER_WIDTH,
|
||||
getX = method + UPPER_X,
|
||||
getY = method + UPPER_Y,
|
||||
getWidth = method + UPPER_WIDTH,
|
||||
getHeight = method + UPPER_HEIGHT;
|
||||
|
||||
constructor.prototype[method] = function() {
|
||||
@@ -115,10 +115,10 @@
|
||||
},
|
||||
addBoxSetter: function(constructor, attr) {
|
||||
var method = SET + Kinetic.Util._capitalize(attr),
|
||||
setX = SET + method + UPPER_X,
|
||||
setY = SET + method + UPPER_Y,
|
||||
setWidth = SET + method + UPPER_WIDTH,
|
||||
setHeight = SET + method + UPPER_HEIGHT;
|
||||
setX = method + UPPER_X,
|
||||
setY = method + UPPER_Y,
|
||||
setWidth = method + UPPER_WIDTH,
|
||||
setHeight = method + UPPER_HEIGHT;
|
||||
|
||||
constructor.prototype[method] = function(val) {
|
||||
this[setX](val.x);
|
||||
|
120
src/Shape.js
120
src/Shape.js
@@ -610,6 +610,66 @@
|
||||
* @memberof Kinetic.Shape.prototype
|
||||
*/
|
||||
|
||||
Kinetic.Factory.addPointGetterSetter(Kinetic.Shape, 'shadowOffset');
|
||||
|
||||
/**
|
||||
* set shadow offset
|
||||
* @name setShadowOffset
|
||||
* @method
|
||||
* @memberof Kinetic.Shape.prototype
|
||||
* @param {Object} offset
|
||||
* @param {Number} offset.x
|
||||
* @param {Number} offset.y
|
||||
* @example
|
||||
* // set x and y<br>
|
||||
* shape.setShadowOffset({<br>
|
||||
* x: 20<br>
|
||||
* y: 10
|
||||
* });
|
||||
*/
|
||||
|
||||
/**
|
||||
* get shadow offset
|
||||
* @name getShadowOffset
|
||||
* @method
|
||||
* @memberof Kinetic.Shape.prototype
|
||||
* @returns {Object}
|
||||
*/
|
||||
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Shape, 'shadowOffsetX', 0);
|
||||
|
||||
/**
|
||||
* set shadow offset x
|
||||
* @name setShadowOffsetX
|
||||
* @method
|
||||
* @memberof Kinetic.Shape.prototype
|
||||
* @param {Number} x
|
||||
*/
|
||||
|
||||
/**
|
||||
* get shadow offset x
|
||||
* @name getShadowOffsetX
|
||||
* @method
|
||||
* @memberof Kinetic.Shape.prototype
|
||||
*/
|
||||
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Shape, 'shadowOffsetY', 0);
|
||||
|
||||
/**
|
||||
* set shadow offset y
|
||||
* @name setShadowOffsetY
|
||||
* @method
|
||||
* @memberof Kinetic.Shape.prototype
|
||||
* @param {Number} y
|
||||
*/
|
||||
|
||||
/**
|
||||
* get shadow offset y
|
||||
* @name getShadowOffsetY
|
||||
* @method
|
||||
* @memberof Kinetic.Shape.prototype
|
||||
*/
|
||||
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Shape, 'fillPatternImage');
|
||||
|
||||
/**
|
||||
@@ -1287,66 +1347,6 @@
|
||||
* @memberof Kinetic.Shape.prototype
|
||||
*/
|
||||
|
||||
Kinetic.Factory.addPointGetterSetter(Kinetic.Shape, 'shadowOffset');
|
||||
|
||||
/**
|
||||
* set shadow offset
|
||||
* @name setShadowOffset
|
||||
* @method
|
||||
* @memberof Kinetic.Shape.prototype
|
||||
* @param {Object} offset
|
||||
* @param {Number} offset.x
|
||||
* @param {Number} offset.y
|
||||
* @example
|
||||
* // set x and y<br>
|
||||
* shape.setShadowOffset({<br>
|
||||
* x: 20<br>
|
||||
* y: 10
|
||||
* });
|
||||
*/
|
||||
|
||||
/**
|
||||
* get shadow offset
|
||||
* @name getShadowOffset
|
||||
* @method
|
||||
* @memberof Kinetic.Shape.prototype
|
||||
* @returns {Object}
|
||||
*/
|
||||
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Shape, 'shadowOffsetX', 0);
|
||||
|
||||
/**
|
||||
* set shadow offset x
|
||||
* @name setShadowOffsetX
|
||||
* @method
|
||||
* @memberof Kinetic.Shape.prototype
|
||||
* @param {Number} x
|
||||
*/
|
||||
|
||||
/**
|
||||
* get shadow offset x
|
||||
* @name getShadowOffsetX
|
||||
* @method
|
||||
* @memberof Kinetic.Shape.prototype
|
||||
*/
|
||||
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Shape, 'shadowOffsetY', 0);
|
||||
|
||||
/**
|
||||
* set shadow offset y
|
||||
* @name setShadowOffsetY
|
||||
* @method
|
||||
* @memberof Kinetic.Shape.prototype
|
||||
* @param {Number} y
|
||||
*/
|
||||
|
||||
/**
|
||||
* get shadow offset y
|
||||
* @name getShadowOffsetY
|
||||
* @method
|
||||
* @memberof Kinetic.Shape.prototype
|
||||
*/
|
||||
|
||||
Kinetic.Factory.addRotationGetterSetter(Kinetic.Shape, 'fillPatternRotation', 0);
|
||||
|
||||
/**
|
||||
|
@@ -43,7 +43,7 @@
|
||||
drawFunc: function(context) {
|
||||
var width = this.getWidth(),
|
||||
height = this.getHeight(),
|
||||
crop,
|
||||
crop, cropWidth, cropHeight,
|
||||
params,
|
||||
image;
|
||||
|
||||
@@ -65,13 +65,11 @@
|
||||
image = this.getImage();
|
||||
|
||||
if (image) {
|
||||
crop = this.getCrop();
|
||||
if (crop) {
|
||||
crop.x = crop.x || 0;
|
||||
crop.y = crop.y || 0;
|
||||
crop.width = crop.width || image.width - crop.x;
|
||||
crop.height = crop.height || image.height - crop.y;
|
||||
params = [image, crop.x, crop.y, crop.width, crop.height, 0, 0, width, height];
|
||||
crop = this.getCrop(),
|
||||
cropWidth = crop.width;
|
||||
cropHeight = crop.height;
|
||||
if (cropWidth && cropHeight) {
|
||||
params = [image, crop.x, crop.y, cropWidth, cropHeight, 0, 0, width, height];
|
||||
} else {
|
||||
params = [image, 0, 0, width, height];
|
||||
}
|
||||
@@ -111,12 +109,12 @@
|
||||
width = this.getWidth(),
|
||||
height = this.getHeight(),
|
||||
filter = this.getFilter(),
|
||||
crop = this.getCrop() || {},
|
||||
crop = this.getCrop(),
|
||||
filterCanvas, context, imageData;
|
||||
|
||||
// Determine the region we are cropping
|
||||
crop.x = crop.x || 0;
|
||||
crop.y = crop.y || 0;
|
||||
crop.x = crop.x;
|
||||
crop.y = crop.y;
|
||||
crop.width = crop.width || width - crop.x;
|
||||
crop.height = crop.height || height - crop.y;
|
||||
|
||||
@@ -347,7 +345,7 @@
|
||||
* @returns {Number}
|
||||
*/
|
||||
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Image, 'cropHheight', 0);
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Image, 'cropHeight', 0);
|
||||
/**
|
||||
* set cropHeight
|
||||
* @name setCropHeight
|
||||
|
@@ -119,7 +119,7 @@ suite('Path', function() {
|
||||
strokeWidth: 2,
|
||||
shadowColor: 'maroon',
|
||||
shadowBlur: 2,
|
||||
shadowOffset: [10, 10],
|
||||
shadowOffset: {x:10, y:10},
|
||||
shadowOpacity: 0.5,
|
||||
draggable: true
|
||||
});
|
||||
|
@@ -18,6 +18,8 @@ suite('Image', function(){
|
||||
draggable: true
|
||||
});
|
||||
|
||||
console.log(darth);
|
||||
|
||||
layer.add(darth);
|
||||
stage.add(layer);
|
||||
|
||||
|
Reference in New Issue
Block a user