Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <body>
- <canvas id='c'></canvas>
- <script>
- var canvas = document.getElementById('c');
- var ctx = canvas.getContext('2d');
- var w = canvas.width = 1260;
- var h = canvas.height = 580;
- var t1 = new Date().getTime();
- var frame_count = 0;
- ctx.font = 'normal 400 24px/2 Unknown Font, sans-serif';
- var img = ctx.createImageData(w, h);
- var index_init = 0;
- for (var x = 0; x < w; x++) {
- for (var y = 0; y < h; y++) {
- img.data[index_init + 3] = 255; // alpha
- index_init += 4;
- }
- }
- function animate() {
- var index = 0;
- for (var x = 0; x < w; x++) {
- for (var y = 0; y < h; y++) {
- img.data[index ] = Math.floor(Math.random()*255);
- img.data[index + 1] = Math.floor(Math.random()*255);
- img.data[index + 2] = Math.floor(Math.random()*255);
- // alpha channel is constant
- index += 4;
- }
- }
- ctx.putImageData(img, 0, 0);
- frame_count++;
- if (frame_count % 50 == 0) {
- var fps = frame_count / (new Date().getTime() - t1) * 1000;
- window.status = fps.toFixed(2) + " fps";
- }
- setTimeout(animate, 0);
- }
- animate();
- </script>
- </body>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement