随着时间的推移,颜色会随着动态形状而褪色

Color fade over time with kineticjs shapes

本文关键字:动态 褪色 时间 颜色      更新时间:2023-09-26

我有一个关于颜色褪色的简单问题。

我想让一种颜色与另一种颜色在持续时间上混合。如果我使用动力学,你可以使用:. transitionto()。你可以设置一个持续时间,他会在给定的持续时间内执行动作。

遗憾的是,它只适用于不透明度和移动。颜色仍然会立即添加,而不是随着时间的推移而混合。两种颜色怎么还能有渐隐效果呢?

TransitionTo只用于数值,color不是数值,所以你不能在它上面使用TransitionTo

要过渡颜色,你必须创建自己的解决方案。

试试现有的jQuery: http://jsfiddle.net/sg3s/ktTD6/

jQuery(function($) {
$('#bg-animated').hover(function() {
    $(this).data('bg-original', $(this).css('backgroundColor')).animate({
        backgroundColor: '#FF0000'
    }, 500);
}, function() {
    $(this).animate({
        backgroundColor: $(this).data('bg-original')
    }, 500);
});
});

Background color change transition with jquery