Animating canvas to look like tv noise

前端 未结 7 2140
野趣味
野趣味 2020-12-22 17:22

I have a function named generateNoise() which creates a canvas element and paints random RGBA values to it; which, gives the appearance of noise.


<
7条回答
  •  别那么骄傲
    2020-12-22 18:06

    You can do it like this:

    window.setInterval('generateNoise(.8)',50);

    The 2nd arg 50 is a delay in milliseconds. Increasing 50 will slow it down and decreasing visa versa.

    though.. this is going to severely affect web page performance. If it were me, I'd do the rendering server-side and render a handful of frame iterations and output as an animated gif. Not quite the same as infinite randomness, but would be a huge performance boost and IMO most people won't even notice.

提交回复
热议问题