mirror of
https://github.com/konvajs/konva.git
synced 2025-04-05 20:48:28 +08:00
more unit tests working, more refactoring
This commit is contained in:
parent
86686eb590
commit
a57d6c6106
@ -218,19 +218,18 @@
|
||||
* @method
|
||||
* @memberof Kinetic.Container.prototype
|
||||
* @param {Object} pos
|
||||
* @param {Number} pos.x
|
||||
* @param {Number} pos.y
|
||||
* @returns {Array} array of shapes
|
||||
*/
|
||||
getAllIntersections: function() {
|
||||
var pos = Kinetic.Util._getXY(Array.prototype.slice.call(arguments));
|
||||
getAllIntersections: function(pos) {
|
||||
var arr = [];
|
||||
var shapes = this.find('Shape');
|
||||
|
||||
var len = shapes.length;
|
||||
for(var n = 0; n < len; n++) {
|
||||
var shape = shapes[n];
|
||||
this.find('Shape').each(function(shape) {
|
||||
if(shape.isVisible() && shape.intersects(pos)) {
|
||||
arr.push(shape);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return arr;
|
||||
},
|
||||
@ -297,19 +296,16 @@
|
||||
Kinetic.Container.prototype.get = Kinetic.Container.prototype.find;
|
||||
|
||||
// add getters setters
|
||||
Kinetic.Factory.addBoxGetterSetter(Kinetic.Container, 'clip');
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Container, 'clip');
|
||||
|
||||
/**
|
||||
* set clip
|
||||
* @method
|
||||
* @name setClip
|
||||
* @memberof Kinetic.Container.prototype
|
||||
* @param {Object|Array}
|
||||
* @param {Object} clip {x:x, y:y, width:width, height:height}
|
||||
* @example
|
||||
* // set clip x, y, width and height with an array<br>
|
||||
* image.setClip([20, 20, 100, 100]);<br><br>
|
||||
*
|
||||
* // set clip x, y, width and height with an object<br>
|
||||
* // set clip x, y, width and height<br>
|
||||
* image.setClip({<br>
|
||||
* x: 20,<br>
|
||||
* y: 20,<br>
|
||||
@ -318,44 +314,21 @@
|
||||
* });
|
||||
*/
|
||||
|
||||
/**
|
||||
* set clipX
|
||||
* @method
|
||||
* @name setClipX
|
||||
* @memberof Kinetic.Container.prototype
|
||||
* @param {Number} x
|
||||
*/
|
||||
|
||||
/**
|
||||
* set clipY
|
||||
* @name setClipY
|
||||
* @method
|
||||
* @memberof Kinetic.Container.prototype
|
||||
* @param {Number} y
|
||||
*/
|
||||
|
||||
/**
|
||||
* set clipWidth
|
||||
* @name setClipWidth
|
||||
* @method
|
||||
* @memberof Kinetic.Container.prototype
|
||||
* @param {Number} width
|
||||
*/
|
||||
|
||||
/**
|
||||
* set clipHeight
|
||||
* @name setClipHeight
|
||||
* @method
|
||||
* @memberof Kinetic.Container.prototype
|
||||
* @param {Number} height
|
||||
*/
|
||||
|
||||
/**
|
||||
* get clip
|
||||
* @name getClip
|
||||
* @method
|
||||
* @memberof Kinetic.Container.prototype
|
||||
* @return {Object}
|
||||
* @returns {Object}
|
||||
*/
|
||||
|
||||
Kinetic.Factory.addComponentGetterSetter(Kinetic.Container, 'clip', 'x', 0);
|
||||
/**
|
||||
* set clip x
|
||||
* @method
|
||||
* @name setClipX
|
||||
* @memberof Kinetic.Container.prototype
|
||||
* @param {Number} x
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -363,6 +336,16 @@
|
||||
* @name getClipX
|
||||
* @method
|
||||
* @memberof Kinetic.Container.prototype
|
||||
* @returns {Number}
|
||||
*/
|
||||
|
||||
Kinetic.Factory.addComponentGetterSetter(Kinetic.Container, 'clip', 'y', 0);
|
||||
/**
|
||||
* set clip y
|
||||
* @name setClipY
|
||||
* @method
|
||||
* @memberof Kinetic.Container.prototype
|
||||
* @param {Number} y
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -370,6 +353,16 @@
|
||||
* @name getClipY
|
||||
* @method
|
||||
* @memberof Kinetic.Container.prototype
|
||||
* @returns {Number}
|
||||
*/
|
||||
|
||||
Kinetic.Factory.addComponentGetterSetter(Kinetic.Container, 'clip', 'width', 0);
|
||||
/**
|
||||
* set clip width
|
||||
* @name setClipWidth
|
||||
* @method
|
||||
* @memberof Kinetic.Container.prototype
|
||||
* @param {Number} width
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -377,6 +370,16 @@
|
||||
* @name getClipWidth
|
||||
* @method
|
||||
* @memberof Kinetic.Container.prototype
|
||||
* @returns {Number}
|
||||
*/
|
||||
|
||||
Kinetic.Factory.addComponentGetterSetter(Kinetic.Container, 'clip', 'height', 0);
|
||||
/**
|
||||
* set clip height
|
||||
* @name setClipHeight
|
||||
* @method
|
||||
* @memberof Kinetic.Container.prototype
|
||||
* @param {Number} height
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -384,6 +387,6 @@
|
||||
* @name getClipHeight
|
||||
* @method
|
||||
* @memberof Kinetic.Container.prototype
|
||||
* @returns {Number}
|
||||
*/
|
||||
|
||||
})();
|
||||
|
@ -226,8 +226,8 @@
|
||||
this.transform(m[0], m[1], m[2], m[3], m[4], m[5]);
|
||||
},
|
||||
_clip: function(container) {
|
||||
var clipX = container.getClipX() || 0,
|
||||
clipY = container.getClipY() || 0,
|
||||
var clipX = container.getClipX(),
|
||||
clipY = container.getClipY(),
|
||||
clipWidth = container.getClipWidth(),
|
||||
clipHeight = container.getClipHeight();
|
||||
|
||||
|
10
src/Layer.js
10
src/Layer.js
@ -44,11 +44,13 @@
|
||||
* method for determining if a point intersects a shape or not
|
||||
* @method
|
||||
* @memberof Kinetic.Layer.prototype
|
||||
* @param {Kinetic.Shape|null} shape
|
||||
* @param {Object} pos
|
||||
* @param {Number} pos.x
|
||||
* @param {Number} pos.y
|
||||
* @returns {Kinetic.Shape}
|
||||
*/
|
||||
getIntersection: function() {
|
||||
var pos = Kinetic.Util._getXY(Array.prototype.slice.call(arguments)),
|
||||
obj, i, intersectionOffset, shape;
|
||||
getIntersection: function(pos) {
|
||||
var obj, i, intersectionOffset, shape;
|
||||
|
||||
if(this.isVisible()) {
|
||||
for (i=0; i<INTERSECTION_OFFSETS_LEN; i++) {
|
||||
|
@ -633,7 +633,7 @@
|
||||
y += changeY;
|
||||
}
|
||||
|
||||
this.setPosition(x, y);
|
||||
this.setPosition({x:x, y:y});
|
||||
return this;
|
||||
},
|
||||
_eachAncestorReverse: function(func, includeSelf) {
|
||||
|
13
src/Shape.js
13
src/Shape.js
@ -106,14 +106,13 @@
|
||||
* because it performs much better
|
||||
* @method
|
||||
* @memberof Kinetic.Shape.prototype
|
||||
* @param {Object} point point can be an object containing
|
||||
* an x and y property, or it can be an array with two elements
|
||||
* in which the first element is the x component and the second
|
||||
* element is the y component
|
||||
* @param {Object} point
|
||||
* @param {Number} point.x
|
||||
* @param {Number} point.y
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
intersects: function() {
|
||||
var pos = Kinetic.Util._getXY(Array.prototype.slice.call(arguments)),
|
||||
stage = this.getStage(),
|
||||
intersects: function(pos) {
|
||||
var stage = this.getStage(),
|
||||
bufferHitCanvas = stage.bufferHitCanvas,
|
||||
p;
|
||||
|
||||
|
10
src/Stage.js
10
src/Stage.js
@ -254,11 +254,13 @@
|
||||
* method for determining if a point intersects a shape or not
|
||||
* @method
|
||||
* @memberof Kinetic.Stage.prototype
|
||||
* @param {Kinetic.Shape} shape
|
||||
* @param {Object} pos
|
||||
* @param {Number} pos.x
|
||||
* @param {Number} pos.y
|
||||
* @returns {Kinetic.Shape}
|
||||
*/
|
||||
getIntersection: function() {
|
||||
var pos = Kinetic.Util._getXY(Array.prototype.slice.call(arguments)),
|
||||
layers = this.getChildren(),
|
||||
getIntersection: function(pos) {
|
||||
var layers = this.getChildren(),
|
||||
len = layers.length,
|
||||
end = len - 1,
|
||||
n, shape;
|
||||
|
@ -4,7 +4,7 @@ suite('Container', function() {
|
||||
test('clip', function() {
|
||||
var stage = addStage();
|
||||
var layer = new Kinetic.Layer({
|
||||
clip: [0, 0, stage.getWidth() / 2, 100]
|
||||
clip: {x:0, y:0, width:stage.getWidth() / 2, height:100}
|
||||
});
|
||||
var group = new Kinetic.Group();
|
||||
var circle = new Kinetic.Circle({
|
||||
|
@ -68,7 +68,7 @@ suite('Node', function() {
|
||||
|
||||
assert.equal(circle.getFill(), 'red');
|
||||
|
||||
circle.setAttr('position', 5, 6);
|
||||
circle.setAttr('position', {x: 5, y: 6});
|
||||
|
||||
assert.equal(circle.getX(), 5);
|
||||
assert.equal(circle.getY(), 6);
|
||||
@ -574,7 +574,7 @@ suite('Node', function() {
|
||||
width: 200,
|
||||
height: 50,
|
||||
fill: 'blue',
|
||||
shadowOffset: [10, 10],
|
||||
shadowOffset: {x: 10, y: 10},
|
||||
});
|
||||
|
||||
var circle = new Kinetic.Circle({
|
||||
@ -608,9 +608,9 @@ suite('Node', function() {
|
||||
radiusChanged++;
|
||||
});
|
||||
|
||||
circle.setRadius(70, 20);
|
||||
circle.setRadius(70);
|
||||
|
||||
rect.setSize(210);
|
||||
rect.setSize({width: 210, height: 210});
|
||||
rect.setShadowOffset({
|
||||
x: 20
|
||||
});
|
||||
@ -776,7 +776,7 @@ suite('Node', function() {
|
||||
assert.equal(rect.getScale().y, 0.5);
|
||||
assert.equal(rect.getRotation(), 20 * Math.PI / 180);
|
||||
|
||||
rect.setScale(2, 0.3);
|
||||
rect.setScale({x:2, y:0.3});
|
||||
assert.equal(rect.getScale().x, 2);
|
||||
assert.equal(rect.getScale().y, 0.3);
|
||||
|
||||
@ -1131,7 +1131,7 @@ suite('Node', function() {
|
||||
assert.equal(rect.getOffset().x, 40);
|
||||
assert.equal(rect.getOffset().y, 20);
|
||||
|
||||
rect.setOffset(80, 40);
|
||||
rect.setOffset({x:80, y:40});
|
||||
|
||||
assert.equal(rect.getOffsetX(), 80);
|
||||
assert.equal(rect.getOffsetY(), 40);
|
||||
@ -1203,7 +1203,7 @@ suite('Node', function() {
|
||||
layer.add(rect);
|
||||
stage.add(layer);
|
||||
|
||||
rect.setShadowOffset([1, 2]);
|
||||
rect.setShadowOffset({x:1, y:2});
|
||||
assert.equal(rect.getShadowOffset().x, 1);
|
||||
assert.equal(rect.getShadowOffset().y, 2);
|
||||
// make sure we still have the other properties
|
||||
@ -1218,16 +1218,12 @@ suite('Node', function() {
|
||||
assert.equal(rect.getShadowOffset().y, 4);
|
||||
|
||||
// test partial setting
|
||||
rect.setShadowOffset({
|
||||
x: 5
|
||||
});
|
||||
rect.setShadowOffsetX(5);
|
||||
assert.equal(rect.getShadowOffset().x, 5);
|
||||
assert.equal(rect.getShadowOffset().y, 4);
|
||||
|
||||
// test partial setting
|
||||
rect.setShadowOffset({
|
||||
y: 6
|
||||
});
|
||||
rect.setShadowOffsetY(6);
|
||||
assert.equal(rect.getShadowOffset().x, 5);
|
||||
assert.equal(rect.getShadowOffset().y, 6);
|
||||
|
||||
@ -1248,11 +1244,11 @@ suite('Node', function() {
|
||||
layer.add(rect);
|
||||
stage.add(layer);
|
||||
|
||||
rect.setOffset(1, 2);
|
||||
rect.setOffset({x:1, y: 2});
|
||||
assert.equal(rect.getOffset().x, 1);
|
||||
assert.equal(rect.getOffset().y, 2);
|
||||
|
||||
rect.setOffset([3, 4]);
|
||||
rect.setOffset({x:3, y:4});
|
||||
assert.equal(rect.getOffset().x, 3);
|
||||
assert.equal(rect.getOffset().y, 4);
|
||||
|
||||
@ -1263,15 +1259,11 @@ suite('Node', function() {
|
||||
assert.equal(rect.getOffset().x, 5);
|
||||
assert.equal(rect.getOffset().y, 6);
|
||||
|
||||
rect.setOffset({
|
||||
x: 7
|
||||
});
|
||||
rect.setOffsetX(7);
|
||||
assert.equal(rect.getOffset().x, 7);
|
||||
assert.equal(rect.getOffset().y, 6);
|
||||
|
||||
rect.setOffset({
|
||||
y: 8
|
||||
});
|
||||
rect.setOffsetY(8);
|
||||
assert.equal(rect.getOffset().x, 7);
|
||||
assert.equal(rect.getOffset().y, 8);
|
||||
|
||||
@ -1292,11 +1284,11 @@ suite('Node', function() {
|
||||
layer.add(rect);
|
||||
stage.add(layer);
|
||||
|
||||
rect.setPosition(1, 2);
|
||||
rect.setPosition({x:1, y:2});
|
||||
assert.equal(rect.getPosition().x, 1);
|
||||
assert.equal(rect.getPosition().y, 2);
|
||||
|
||||
rect.setPosition([3, 4]);
|
||||
rect.setPosition({x:3, y:4});
|
||||
assert.equal(rect.getPosition().x, 3);
|
||||
assert.equal(rect.getPosition().y, 4);
|
||||
|
||||
@ -1307,19 +1299,15 @@ suite('Node', function() {
|
||||
assert.equal(rect.getPosition().x, 5);
|
||||
assert.equal(rect.getPosition().y, 6);
|
||||
|
||||
rect.setPosition({
|
||||
x: 7
|
||||
});
|
||||
rect.setX(7);
|
||||
assert.equal(rect.getPosition().x, 7);
|
||||
assert.equal(rect.getPosition().y, 6);
|
||||
|
||||
rect.setPosition({
|
||||
y: 8
|
||||
});
|
||||
rect.setY(8);
|
||||
assert.equal(rect.getPosition().x, 7);
|
||||
assert.equal(rect.getPosition().y, 8);
|
||||
|
||||
rect.move(10);
|
||||
rect.move({x: 10, y: 10});
|
||||
assert.equal(rect.getPosition().x, 17);
|
||||
assert.equal(rect.getPosition().y, 18);
|
||||
|
||||
|
@ -91,10 +91,10 @@ suite('Stage', function() {
|
||||
|
||||
assert.equal(stage.getSize().width, 578);
|
||||
assert.equal(stage.getSize().height, 200);
|
||||
stage.setSize(1, 2);
|
||||
stage.setSize({width:1, height:2});
|
||||
assert.equal(stage.getSize().width, 1);
|
||||
assert.equal(stage.getSize().height, 2);
|
||||
stage.setSize(3);
|
||||
stage.setSize({width: 3, height: 3});
|
||||
assert.equal(stage.getSize().width, 3);
|
||||
assert.equal(stage.getSize().height, 3);
|
||||
stage.setSize({
|
||||
@ -103,27 +103,23 @@ suite('Stage', function() {
|
||||
});
|
||||
assert.equal(stage.getSize().width, 4);
|
||||
assert.equal(stage.getSize().height, 5);
|
||||
stage.setSize({
|
||||
width: 6
|
||||
});
|
||||
stage.setWidth(6);
|
||||
assert.equal(stage.getSize().width, 6);
|
||||
assert.equal(stage.getSize().height, 5);
|
||||
stage.setSize({
|
||||
height: 7
|
||||
});
|
||||
stage.setHeight(7);
|
||||
assert.equal(stage.getSize().width, 6);
|
||||
assert.equal(stage.getSize().height, 7);
|
||||
stage.setSize([8, 9]);
|
||||
stage.setSize({width: 8, height: 9});
|
||||
assert.equal(stage.getSize().width, 8);
|
||||
assert.equal(stage.getSize().height, 9);
|
||||
stage.setSize([1, 1, 10, 11]);
|
||||
stage.setSize({width:10, height:11});
|
||||
assert.equal(stage.getSize().width, 10);
|
||||
assert.equal(stage.getSize().height, 11);
|
||||
|
||||
layer.add(circle);
|
||||
stage.add(layer);
|
||||
|
||||
stage.setSize(333, 155);
|
||||
stage.setSize({width:333, height:155});
|
||||
|
||||
assert.equal(stage.getSize().width, 333);
|
||||
assert.equal(stage.getSize().height, 155);
|
||||
@ -169,9 +165,9 @@ suite('Stage', function() {
|
||||
layer.add(greenCircle);
|
||||
stage.add(layer);
|
||||
|
||||
assert.equal(stage.getIntersection(300, 100).getId(), 'greenCircle', 'shape should be greenCircle');
|
||||
assert.equal(stage.getIntersection(380, 100).getId(), 'redCircle', 'shape should be redCircle');
|
||||
assert.equal(stage.getIntersection(100, 100), null, 'shape should be null');
|
||||
assert.equal(stage.getIntersection({x:300, y:100}).getId(), 'greenCircle', 'shape should be greenCircle');
|
||||
assert.equal(stage.getIntersection({x:380, y:100}).getId(), 'redCircle', 'shape should be redCircle');
|
||||
assert.equal(stage.getIntersection({x:100, y:100}), null, 'shape should be null');
|
||||
|
||||
|
||||
});
|
||||
@ -213,10 +209,10 @@ suite('Stage', function() {
|
||||
layer.add(greenCircle);
|
||||
stage.add(layer);
|
||||
|
||||
assert.equal(stage.getIntersection(370, 93).getId(), 'greenCircle', 'shape should be greenCircle');
|
||||
assert.equal(stage.getIntersection({x:370, y:93}).getId(), 'greenCircle', 'shape should be greenCircle');
|
||||
// TODO: this passes in the browser but fails in phantomjs. no idea why.
|
||||
//assert.equal(stage.getIntersection(371, 93).getId(), 'greenCircle', 'shape should be greenCircle');
|
||||
assert.equal(stage.getIntersection(372, 93).getId(), 'redCircle', 'shape should be redCircle');
|
||||
assert.equal(stage.getIntersection({x:372, y:93}).getId(), 'redCircle', 'shape should be redCircle');
|
||||
|
||||
//console.log(layer.hitCanvas.context._context.getImageData(1, 1, 1, 1).data)
|
||||
|
||||
@ -253,50 +249,50 @@ suite('Stage', function() {
|
||||
stage.add(layer);
|
||||
|
||||
// test individual shapes
|
||||
assert.equal(stage.getAllIntersections(266, 114).length, 1, '17) getAllIntersections should return one shape');
|
||||
assert.equal(stage.getAllIntersections(266, 114)[0].getId(), 'greenCircle', '19) first intersection should be greenCircle');
|
||||
assert.equal(stage.getAllIntersections({x: 266, y:114}).length, 1, '17) getAllIntersections should return one shape');
|
||||
assert.equal(stage.getAllIntersections({x: 266, y:114})[0].getId(), 'greenCircle', '19) first intersection should be greenCircle');
|
||||
|
||||
assert.equal(stage.getAllIntersections(414, 115).length, 1, '18) getAllIntersections should return one shape');
|
||||
assert.equal(stage.getAllIntersections(414, 115)[0].getId(), 'redCircle', '20) first intersection should be redCircle');
|
||||
assert.equal(stage.getAllIntersections({x: 414, y:115}).length, 1, '18) getAllIntersections should return one shape');
|
||||
assert.equal(stage.getAllIntersections({x: 414, y:115})[0].getId(), 'redCircle', '20) first intersection should be redCircle');
|
||||
|
||||
assert.equal(stage.getAllIntersections(350, 118).length, 2, '1) getAllIntersections should return two shapes');
|
||||
assert.equal(stage.getAllIntersections(350, 118)[0].getId(), 'redCircle', '2) first intersection should be redCircle');
|
||||
assert.equal(stage.getAllIntersections(350, 118)[1].getId(), 'greenCircle', '3) second intersection should be greenCircle');
|
||||
assert.equal(stage.getAllIntersections({x: 350, y:118}).length, 2, '1) getAllIntersections should return two shapes');
|
||||
assert.equal(stage.getAllIntersections({x: 350, y:118})[0].getId(), 'redCircle', '2) first intersection should be redCircle');
|
||||
assert.equal(stage.getAllIntersections({x: 350, y:118})[1].getId(), 'greenCircle', '3) second intersection should be greenCircle');
|
||||
|
||||
// hide green circle. make sure only red circle is in result set
|
||||
greenCircle.hide();
|
||||
layer.draw();
|
||||
|
||||
assert.equal(stage.getAllIntersections(350, 118).length, 1, '4) getAllIntersections should return one shape');
|
||||
assert.equal(stage.getAllIntersections(350, 118)[0].getId(), 'redCircle', '5) first intersection should be redCircle');
|
||||
assert.equal(stage.getAllIntersections({x: 350, y:118}).length, 1, '4) getAllIntersections should return one shape');
|
||||
assert.equal(stage.getAllIntersections({x: 350, y:118})[0].getId(), 'redCircle', '5) first intersection should be redCircle');
|
||||
|
||||
// show green circle again. make sure both circles are in result set
|
||||
greenCircle.show();
|
||||
layer.draw();
|
||||
|
||||
assert.equal(stage.getAllIntersections(350, 118).length, 2, '6) getAllIntersections should return two shapes');
|
||||
assert.equal(stage.getAllIntersections(350, 118)[0].getId(), 'redCircle', '7) first intersection should be redCircle');
|
||||
assert.equal(stage.getAllIntersections(350, 118)[1].getId(), 'greenCircle', '8) second intersection should be greenCircle');
|
||||
assert.equal(stage.getAllIntersections({x: 350, y:118}).length, 2, '6) getAllIntersections should return two shapes');
|
||||
assert.equal(stage.getAllIntersections({x: 350, y:118})[0].getId(), 'redCircle', '7) first intersection should be redCircle');
|
||||
assert.equal(stage.getAllIntersections({x: 350, y:118})[1].getId(), 'greenCircle', '8) second intersection should be greenCircle');
|
||||
|
||||
// hide red circle. make sure only green circle is in result set
|
||||
redCircle.hide();
|
||||
layer.draw();
|
||||
|
||||
assert.equal(stage.getAllIntersections(350, 118).length, 1, '9) getAllIntersections should return one shape');
|
||||
assert.equal(stage.getAllIntersections(350, 118)[0].getId(), 'greenCircle', '10) first intersection should be greenCircle');
|
||||
assert.equal(stage.getAllIntersections({x: 350, y:118}).length, 1, '9) getAllIntersections should return one shape');
|
||||
assert.equal(stage.getAllIntersections({x: 350, y:118})[0].getId(), 'greenCircle', '10) first intersection should be greenCircle');
|
||||
|
||||
// show red circle again. make sure both circles are in result set
|
||||
redCircle.show();
|
||||
layer.draw();
|
||||
|
||||
assert.equal(stage.getAllIntersections(350, 118).length, 2, '11) getAllIntersections should return two shapes');
|
||||
assert.equal(stage.getAllIntersections(350, 118)[0].getId(), 'redCircle', '12) first intersection should be redCircle');
|
||||
assert.equal(stage.getAllIntersections(350, 118)[1].getId(), 'greenCircle', '13) second intersection should be greenCircle');
|
||||
assert.equal(stage.getAllIntersections({x: 350, y:118}).length, 2, '11) getAllIntersections should return two shapes');
|
||||
assert.equal(stage.getAllIntersections({x: 350, y:118})[0].getId(), 'redCircle', '12) first intersection should be redCircle');
|
||||
assert.equal(stage.getAllIntersections({x: 350, y:118})[1].getId(), 'greenCircle', '13) second intersection should be greenCircle');
|
||||
|
||||
// test from layer
|
||||
assert.equal(layer.getAllIntersections(350, 118).length, 2, '14) getAllIntersections should return two shapes');
|
||||
assert.equal(layer.getAllIntersections(350, 118)[0].getId(), 'redCircle', '15) first intersection should be redCircle');
|
||||
assert.equal(layer.getAllIntersections(350, 118)[1].getId(), 'greenCircle', '16) second intersection should be greenCircle');
|
||||
assert.equal(layer.getAllIntersections({x: 350, y:118}).length, 2, '14) getAllIntersections should return two shapes');
|
||||
assert.equal(layer.getAllIntersections({x: 350, y:118})[0].getId(), 'redCircle', '15) first intersection should be redCircle');
|
||||
assert.equal(layer.getAllIntersections({x: 350, y:118})[1].getId(), 'greenCircle', '16) second intersection should be greenCircle');
|
||||
|
||||
});
|
||||
|
||||
@ -316,7 +312,7 @@ suite('Stage', function() {
|
||||
layer.add(circle);
|
||||
stage.add(layer);
|
||||
|
||||
stage.setScale(0.5);
|
||||
stage.setScale({x:0.5, y:0.5});
|
||||
|
||||
assert.equal(stage.getScale().x, 0.5, 'stage scale x should be 0.5');
|
||||
assert.equal(stage.getScale().y, 0.5, 'stage scale y should be 0.5');
|
||||
@ -336,7 +332,7 @@ suite('Stage', function() {
|
||||
strokeWidth: 4
|
||||
});
|
||||
|
||||
stage.setScale(0.5);
|
||||
stage.setScale({x:0.5, y:0.5});
|
||||
|
||||
assert.equal(stage.getScale().x, 0.5, 'stage scale x should be 0.5');
|
||||
assert.equal(stage.getScale().y, 0.5, 'stage scale y should be 0.5');
|
||||
|
@ -15,8 +15,6 @@ suite('Rect', function(){
|
||||
stroke: 'blue'
|
||||
});
|
||||
|
||||
console.log(rect)
|
||||
|
||||
layer.add(rect);
|
||||
stage.add(layer);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user