mirror of
https://github.com/konvajs/konva.git
synced 2025-11-18 09:07:30 +08:00
fixed set fill attr bug which occurred when instantiating the fill with a string color and then setting it later to a fill object such as a gradient or pattern. The fix will apply to any attr which can be a string or object
This commit is contained in:
@@ -1840,6 +1840,42 @@ Test.prototype.tests = {
|
||||
};
|
||||
imageObj.src = '../darth-vader.jpg';
|
||||
},
|
||||
'SHAPE - set image fill to color then 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();
|
||||
circle = new Kinetic.Circle({
|
||||
x: 200,
|
||||
y: 60,
|
||||
radius: 50,
|
||||
fill: 'blue'
|
||||
});
|
||||
|
||||
layer.add(circle);
|
||||
stage.add(layer);
|
||||
|
||||
test(circle.getFill() === 'blue', 'circle fill should be blue');
|
||||
|
||||
circle.setFill({
|
||||
image: imageObj,
|
||||
repeat: 'no-repeat',
|
||||
offset: [-200, -70]
|
||||
});
|
||||
|
||||
test(circle.getFill().image !== undefined, 'circle fill image should be defined');
|
||||
test(circle.getFill().repeat === 'no-repeat', 'circle fill repeat should be no-repeat');
|
||||
test(circle.getFill().offset.x === -200, 'circle fill offset x should be -200');
|
||||
test(circle.getFill().offset.y === -70, 'circle fill offset y should be -70');
|
||||
|
||||
layer.draw();
|
||||
};
|
||||
imageObj.src = '../darth-vader.jpg';
|
||||
},
|
||||
'SHAPE - add sprite': function(containerId) {
|
||||
var imageObj = new Image();
|
||||
imageObj.onload = function() {
|
||||
|
||||
Reference in New Issue
Block a user