tween color properties

This commit is contained in:
lavrton
2015-02-16 06:31:28 +07:00
parent 7a7ea97c31
commit 36f4ab5346
6 changed files with 616 additions and 146 deletions

View File

@@ -303,4 +303,41 @@ suite('Manual', function() {
layer.draw();
});
});
});
test('tween color', function() {
var stage = addStage();
var layer = new Konva.Layer();
var circle = new Konva.Circle({
x: 100,
y: stage.getHeight() / 2,
radius: 70,
fill: 'red',
stroke: 'blue',
strokeWidth: 4,
shadowOffsetX : 10,
shadowOffsetY : 10,
shadowColor : 'black'
});
var text = new Konva.Text({
text : 'click on circle to start tween'
});
layer.add(circle, text);
stage.add(layer);
circle.on('click', function() {
var tween = new Konva.Tween({
node: circle,
duration: 1,
fill : Konva.Util.getRandomColor(),
stroke : Konva.Util.getRandomColor(),
shadowColor : Konva.Util.getRandomColor()
});
tween.play();
});
});
});

View File

@@ -139,4 +139,36 @@ suite('Tween', function() {
});
test('color tweening', function(done) {
var stage = addStage();
var layer = new Konva.Layer();
var circle = new Konva.Circle({
x: 100,
y: stage.getHeight() / 2,
radius: 70,
fill: 'red',
stroke: 'blue',
strokeWidth: 4
});
layer.add(circle);
stage.add(layer);
var c = Konva.Util.colorToRGBA('green');
var endFill = 'rgba(' + c.r + ',' + c.g + ',' + c.b + ',' + c.a + ')';
var tween = new Konva.Tween({
node: circle,
duration: 0.1,
fill : endFill,
onFinish : function() {
assert.equal(endFill, circle.fill());
done();
}
});
tween.play();
});
});