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:
Eric Rowell
2012-06-12 09:57:29 -07:00
parent 6d4738cd2b
commit 2455000f5c
6 changed files with 62 additions and 8 deletions

View File

@@ -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() {