此刻,线条永久地粘在一起,形成了一幅画。我希望每次通过setInterval()调用该函数时,都要绘制和重置这条线,从而创建一个类似于动画的脑波波纹。
下面是我当前的源代码:
var rippleEffect = function(){
var co = [];
for(var i=0; i<=5; i++){
var r = Math.floor(Math.random()*250);
co.push(r);
//each time through the loop throws/pushes 6 random numbers to array 'co' for bezier curve.
}
var canvas = document.getElementById('brainWave');
var context = canvas.getContext('2d');
context.beginPath();
context.moveTo(500, 75);
context.bezierCurveTo(co[0], co[1], co[2], co[3], co[4], co[5]);
context.lineWidth = 2;
// line color
context.strokeStyle = '#444';
context.stroke(); //exicute the stroke based on the structions we've provided.
};
setInterval(ripple,100); //this re-calls the functions every few miller-seconds.
.clearRect()是解决方案的一部分吗?
发布于 2013-11-26 18:07:18
我不太清楚您想要做什么,但是下面是对您的代码的一些观察:
祝你的项目好运:)
https://stackoverflow.com/questions/20222954
复制相似问题