mirror of
https://github.com/konvajs/konva.git
synced 2025-09-18 18:27:58 +08:00
cleaned up some cropping logic in Image, and added a cropping unit test
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -121,6 +121,35 @@ Test.Modules.IMAGE = {
|
||||
};
|
||||
imageObj.src = '../assets/darth-vader.jpg';
|
||||
},
|
||||
'crop add and scale image': function(containerId) {
|
||||
var imageObj = new Image();
|
||||
imageObj.onload = function() {
|
||||
var stage = new Kinetic.Stage({
|
||||
container: containerId,
|
||||
width: 578,
|
||||
height: 200
|
||||
});
|
||||
var layer = new Kinetic.Layer();
|
||||
darth = new Kinetic.Image({
|
||||
x: 200,
|
||||
y: 75,
|
||||
image: imageObj,
|
||||
width: 107,
|
||||
height: 75,
|
||||
crop: [186, 211, 292 - 186, 285 - 211],
|
||||
draggable: true,
|
||||
scale: [0.5, 0.5]
|
||||
});
|
||||
|
||||
layer.add(darth);
|
||||
stage.add(layer);
|
||||
|
||||
//console.log(layer.toDataURL());
|
||||
|
||||
warn(layer.toDataURL() === dataUrls['crop and scale image'], 'problem rendering cropped and scaled image');
|
||||
};
|
||||
imageObj.src = '../assets/darth-vader.jpg';
|
||||
},
|
||||
'create image hit region': function(containerId) {
|
||||
var imageObj = new Image();
|
||||
|
||||
|
Reference in New Issue
Block a user