mirror of
https://github.com/konvajs/konva.git
synced 2025-11-08 02:24:44 +08:00
merge pull request #115 which improves get() design, and also enables the ability to select by node ttype
This commit is contained in:
@@ -2595,6 +2595,141 @@ Test.prototype.tests = {
|
||||
test(group.get('Group').length === 0, 'group should have 0 groups');
|
||||
|
||||
},
|
||||
'CONTAINER - node and shape type selector': function(containerId) {
|
||||
var stage = new Kinetic.Stage({
|
||||
container: containerId,
|
||||
width: 578,
|
||||
height: 200
|
||||
});
|
||||
var layer = new Kinetic.Layer();
|
||||
var layer2 = new Kinetic.Layer();
|
||||
var fooLayer = new Kinetic.Layer();
|
||||
var group = new Kinetic.Group();
|
||||
|
||||
var blue = new Kinetic.Rect({
|
||||
x: 100,
|
||||
y: 50,
|
||||
width: 100,
|
||||
height: 50,
|
||||
fill: 'blue'
|
||||
});
|
||||
|
||||
var red = new Kinetic.Rect({
|
||||
x: 150,
|
||||
y: 75,
|
||||
width: 100,
|
||||
height: 50,
|
||||
fill: 'red'
|
||||
});
|
||||
|
||||
var green = new Kinetic.Rect({
|
||||
x: 200,
|
||||
y: 100,
|
||||
width: 100,
|
||||
height: 50,
|
||||
fill: 'green'
|
||||
});
|
||||
|
||||
var blueCircle = new Kinetic.Circle({
|
||||
x: 350,
|
||||
y: 75,
|
||||
radius: 40,
|
||||
fill: 'blue'
|
||||
});
|
||||
|
||||
var redCircle = new Kinetic.Circle({
|
||||
x: 400,
|
||||
y: 125,
|
||||
radius: 40,
|
||||
fill: 'red'
|
||||
});
|
||||
|
||||
var textpath = new Kinetic.TextPath({
|
||||
y: 35,
|
||||
textStroke: 'black',
|
||||
textStrokeWidth: 1,
|
||||
textFill: 'orange',
|
||||
fontSize: '18',
|
||||
fontFamily: 'Arial',
|
||||
text: 'The quick brown fox jumped over the lazy dog\'s back',
|
||||
data: "M 10,10 300,150 550,150"
|
||||
});
|
||||
|
||||
var path = new Kinetic.Path({
|
||||
x: 200,
|
||||
y: -75,
|
||||
data: 'M200,100h100v50z',
|
||||
fill: '#ccc',
|
||||
stroke: '#333',
|
||||
strokeWidth: 2,
|
||||
shadow: {
|
||||
color: 'black',
|
||||
blur: 2,
|
||||
offset: [10, 10],
|
||||
opacity: 0.5
|
||||
},
|
||||
});
|
||||
|
||||
var poly = new Kinetic.RegularPolygon({
|
||||
x: stage.getWidth()/2,
|
||||
y: stage.getHeight()/2,
|
||||
sides: 5,
|
||||
radius: 50,
|
||||
fill: 'green',
|
||||
stroke: 'blue',
|
||||
strokeWidth: 5,
|
||||
name: 'foobar'
|
||||
});
|
||||
|
||||
group.add(red);
|
||||
group.add(redCircle);
|
||||
layer.add(blue);
|
||||
layer.add(green);
|
||||
layer.add(blueCircle);
|
||||
layer.add(group);
|
||||
layer2.add(textpath);
|
||||
layer2.add(path);
|
||||
layer2.add(poly);
|
||||
stage.add(layer);
|
||||
stage.add(layer2);
|
||||
stage.add(fooLayer);
|
||||
|
||||
test(stage.get('Shape').length === 8, 'stage should have 5 shapes');
|
||||
test(stage.get('Layer').length === 3, 'stage should have 2 layers');
|
||||
test(stage.get('Group').length === 1, 'stage should have 1 group');
|
||||
test(stage.get('Rect').length === 3, 'stage should have 3 rects');
|
||||
test(stage.get('Circle').length === 2, 'stage should have 2 circles');
|
||||
test(stage.get('RegularPolygon').length === 1, 'stage should have 1 regular polygon');
|
||||
test(stage.get('TextPath').length === 1, 'stage should have 1 text path');
|
||||
test(stage.get('Path').length === 1, 'stage should have 1 path');
|
||||
|
||||
test(layer.get('Shape').length === 5, 'layer should have 5 shapes');
|
||||
test(layer.get('Layer').length === 0, 'layer should have 0 layers');
|
||||
test(layer.get('Group').length === 1, 'layer should have 1 group');
|
||||
test(layer.get('Rect').length === 3, 'layer should have 3 rects');
|
||||
test(layer.get('Circle').length === 2, 'layer should have 2 circles');
|
||||
test(layer.get('RegularPolygon').length === 0, 'layer should have 0 regular polygon');
|
||||
test(layer.get('TextPath').length === 0, 'layer should have 0 text path');
|
||||
test(layer.get('Path').length === 0, 'layer should have 0 path');
|
||||
|
||||
test(layer2.get('Shape').length === 3, 'layer2 should have 3 shapes');
|
||||
test(layer2.get('Layer').length === 0, 'layer2 should have 0 layers');
|
||||
test(layer2.get('Group').length === 0, 'layer2 should have 0 group');
|
||||
test(layer2.get('RegularPolygon').length === 1, 'layer2 should have 1 regular polygon');
|
||||
test(layer2.get('TextPath').length === 1, 'layer2 should have 1 text path');
|
||||
test(layer2.get('Path').length === 1, 'layer2 should have 1 path');
|
||||
|
||||
test(fooLayer.get('Shape').length === 0, 'layer should have 0 shapes');
|
||||
test(fooLayer.get('Group').length === 0, 'layer should have 0 groups');
|
||||
test(fooLayer.get('Rect').length === 0, 'layer should have 0 rects');
|
||||
test(fooLayer.get('Circle').length === 0, 'layer should have 0 circles');
|
||||
|
||||
test(group.get('Shape').length === 2, 'group should have 2 shape');
|
||||
test(group.get('Layer').length === 0, 'group should have 0 layers');
|
||||
test(group.get('Group').length === 0, 'group should have 0 groups');
|
||||
test(group.get('Rect').length === 1, 'group should have 1 rects');
|
||||
test(group.get('Circle').length === 1, 'gropu should have 1 circles');
|
||||
},
|
||||
'SHAPE - text getters and setters': function(containerId) {
|
||||
var stage = new Kinetic.Stage({
|
||||
container: containerId,
|
||||
@@ -2762,7 +2897,7 @@ Test.prototype.tests = {
|
||||
});
|
||||
*/
|
||||
},
|
||||
'*SHAPE - text multi line with shadows': function(containerId) {
|
||||
'SHAPE - text multi line with shadows': function(containerId) {
|
||||
var stage = new Kinetic.Stage({
|
||||
container: containerId,
|
||||
width: 578,
|
||||
|
||||
Reference in New Issue
Block a user