Merge pull request #68 from pronebird/fix-tween-color-alpha

Fix color alpha rounding bug. (Fixes #67)
This commit is contained in:
Anton Lavrenov 2015-04-23 06:38:25 +07:00
commit aac7fe3e8c
2 changed files with 11 additions and 3 deletions

View File

@ -156,7 +156,7 @@
Math.round(start.r + diff.r * i) + ',' +
Math.round(start.g + diff.g * i) + ',' +
Math.round(start.b + diff.b * i) + ',' +
Math.round(start.a + diff.a * i) + ')';
(start.a + diff.a * i) + ')';
} else {
newVal = start + (diff * i);
}

View File

@ -156,17 +156,25 @@ suite('Tween', function() {
layer.add(circle);
stage.add(layer);
var c = Konva.Util.colorToRGBA('green');
var duration = 0.1;
var c = Konva.Util.colorToRGBA('rgba(0,255,0,0.5)');
var endFill = 'rgba(' + c.r + ',' + c.g + ',' + c.b + ',' + c.a + ')';
var midFill = 'rgba(128,128,0,0.75)';
var tween = new Konva.Tween({
node: circle,
duration: 0.1,
duration: duration,
fill : endFill,
onFinish : function() {
assert.equal(endFill, circle.fill());
done();
}
});
tween.seek(duration * 0.5);
assert.equal(midFill, circle.fill());
tween.seek(0);
tween.play();
});