mirror of
https://github.com/konvajs/konva.git
synced 2025-07-16 22:33:51 +08:00
Merge pull request #68 from pronebird/fix-tween-color-alpha
Fix color alpha rounding bug. (Fixes #67)
This commit is contained in:
commit
aac7fe3e8c
@ -156,7 +156,7 @@
|
|||||||
Math.round(start.r + diff.r * i) + ',' +
|
Math.round(start.r + diff.r * i) + ',' +
|
||||||
Math.round(start.g + diff.g * i) + ',' +
|
Math.round(start.g + diff.g * i) + ',' +
|
||||||
Math.round(start.b + diff.b * i) + ',' +
|
Math.round(start.b + diff.b * i) + ',' +
|
||||||
Math.round(start.a + diff.a * i) + ')';
|
(start.a + diff.a * i) + ')';
|
||||||
} else {
|
} else {
|
||||||
newVal = start + (diff * i);
|
newVal = start + (diff * i);
|
||||||
}
|
}
|
||||||
|
@ -156,17 +156,25 @@ suite('Tween', function() {
|
|||||||
layer.add(circle);
|
layer.add(circle);
|
||||||
stage.add(layer);
|
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 endFill = 'rgba(' + c.r + ',' + c.g + ',' + c.b + ',' + c.a + ')';
|
||||||
|
var midFill = 'rgba(128,128,0,0.75)';
|
||||||
|
|
||||||
var tween = new Konva.Tween({
|
var tween = new Konva.Tween({
|
||||||
node: circle,
|
node: circle,
|
||||||
duration: 0.1,
|
duration: duration,
|
||||||
fill : endFill,
|
fill : endFill,
|
||||||
onFinish : function() {
|
onFinish : function() {
|
||||||
assert.equal(endFill, circle.fill());
|
assert.equal(endFill, circle.fill());
|
||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
tween.seek(duration * 0.5);
|
||||||
|
assert.equal(midFill, circle.fill());
|
||||||
|
|
||||||
|
tween.seek(0);
|
||||||
tween.play();
|
tween.play();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user