|
|
下落速度要调整,需要换一个刷新机制,改一句。在下面的函数,把红色那句,
(function draw(){
ctx.fillStyle = 'rgba(0, 0, 0, 0.1)';
ctx.fillRect(0, 0, w, h);
ctx.fillStyle = '#0f0';
ctx.font = fontsize + 'px arial';
for(var j = 0; j < drops.length; j ++){
let text = texts[Math.floor(Math.random() * texts.length)];
ctx.fillText(text, j * fontsize + fontsize / 2 + 1, drops[j] * fontsize);
if(drops[j]*fontsize > h || Math.random() > 0.95){
drops[j] = 0;
}
drops[j]++;
}
requestAnimationFrame(draw);
})();
换成:
setTimeout(draw,80);
其中,80还可以调整,数字越小,速度越大 |
|