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