mirror of
https://github.com/konvajs/konva.git
synced 2025-10-15 12:34:52 +08:00
new drawHitFromCache Shape method replaces Image createImageHitRegion
This commit is contained in:
@@ -544,4 +544,56 @@ suite('Shape', function() {
|
||||
|
||||
|
||||
});
|
||||
|
||||
// ======================================================
|
||||
test('create image hit region', function(done) {
|
||||
var imageObj = new Image();
|
||||
|
||||
var stage = addStage();
|
||||
var layer = new Kinetic.Layer();
|
||||
|
||||
imageObj.onload = function() {
|
||||
|
||||
var lion = new Kinetic.Image({
|
||||
x: 200,
|
||||
y: 40,
|
||||
image: imageObj,
|
||||
draggable: true,
|
||||
shadowColor: 'black',
|
||||
shadowBlur: 10,
|
||||
shadowOffset: 20,
|
||||
shadowOpacity: 0.2
|
||||
});
|
||||
|
||||
// override color key with black
|
||||
lion.colorKey = '#000000';
|
||||
Kinetic.shapes['#000000'] = lion;
|
||||
|
||||
layer.add(lion);
|
||||
|
||||
stage.add(layer);
|
||||
|
||||
lion.cache();
|
||||
|
||||
|
||||
//document.body.appendChild(lion._cache.canvas.hit._canvas);
|
||||
|
||||
|
||||
lion.drawHitFromCache();
|
||||
|
||||
|
||||
layer.draw();
|
||||
|
||||
|
||||
done();
|
||||
|
||||
|
||||
};
|
||||
imageObj.src = 'assets/lion.png';
|
||||
|
||||
showHit(layer);
|
||||
|
||||
layer.hitCanvas._canvas.style.border='2px solid black';
|
||||
});
|
||||
|
||||
});
|
Reference in New Issue
Block a user