blob: 25b9642b7af7c8f29d436fb48a960a0ad5064186 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
<!DOCTYPE html>
<html>
<head><title>rAF test</title></head>
<body>
<canvas id=c width=300 height=300></canvas>
<script>
c = document.getElementById('c');
x = c.getContext("2d");
x.fillStyle = 'black';
x.fillRect(0, 0, c.width, c.height);
function raf() {
x.fillStyle = 'red';
x.fillRect(
Math.random() * c.width,
Math.random() * c.height,
Math.random() * 10,
Math.random() * 10
);
requestAnimationFrame(raf);
}
requestAnimationFrame(raf);
</script>
</body>
</html>
|