reworked transformation matrix operations with drag and drop

This commit is contained in:
Eric Rowell
2012-03-24 20:52:17 -07:00
parent 1fa41e6692
commit f312c0cf9d
8 changed files with 171 additions and 71 deletions

View File

@@ -1031,7 +1031,7 @@ Test.prototype.tests = {
layer.add(circle);
layer.draw();
},
'SHAPES - move shape, group, and layer, and then get absolute position': function(containerId) {
'TRANSFORMS - move shape, group, and layer, and then get absolute position': function(containerId) {
var stage = new Kinetic.Stage({
container: containerId,
width: 578,
@@ -1069,6 +1069,44 @@ Test.prototype.tests = {
layer.draw();
},
'TRANSFORMS - scale layer, rotate group, position shape, and then get absolute position': function(containerId) {
var stage = new Kinetic.Stage({
container: containerId,
width: 578,
height: 200
});
var layer = new Kinetic.Layer({
scale: {
x: 2,
y: 2
}
});
var group = new Kinetic.Group({
x: 100,
rotationDeg: 90
});
var rect = new Kinetic.Rect({
x: 50,
y: 10,
width: 100,
height: 50,
fill: 'green',
stroke: 'black',
strokeWidth: 4,
draggable: true
});
group.add(rect);
layer.add(group);
stage.add(layer);
// test absolute positions
test(rect.getAbsolutePosition().x == 180, 'rect should be at x = 180');
test(rect.getAbsolutePosition().y == 100, 'rect should be at y = 100');
layer.draw();
},
'SHAPES - hide circle': function(containerId) {
var stage = new Kinetic.Stage({
container: containerId,