cache + pixelRatio

This commit is contained in:
lavrton
2015-02-14 22:12:54 +07:00
parent 7d65463e3c
commit c3511210f2
23 changed files with 449 additions and 85 deletions

View File

@@ -1311,4 +1311,40 @@ suite('MouseEvents', function() {
}, 20);
});
test('change ratio for hit graph', function() {
var stage = addStage();
var layer = new Konva.Layer();
var circle = new Konva.Circle({
x : stage.width() / 2,
y : stage.height() / 2,
radius : 50,
stroke : 'black',
fill : 'red',
strokeWidth : 5,
draggable : true
});
layer.add(circle);
stage.add(layer);
layer.getHitCanvas().setPixelRatio(0.5);
layer.draw();
var shape = layer.getIntersection({
x : stage.width() / 2 - 55,
y : stage.height() / 2 - 55
});
assert.equal(!!shape, false, 'no shape here');
shape = layer.getIntersection({
x : stage.width() / 2 + 55,
y : stage.height() / 2 + 55
});
assert.equal(!!shape, false, 'no shape here');
shape = layer.getIntersection({
x : stage.width() / 2,
y : stage.height() / 2
});
assert.equal(shape, circle);
});
});