Revert "tutorial: remove unnecessary call performance.now() inside raf"

This reverts commit 159cf86df6.
pull/5515/head
fivemru 5 years ago
parent 12a9acf5d6
commit 7bea867c91

@ -5,9 +5,9 @@
onMount(() => {
const ctx = canvas.getContext('2d');
let frame = requestAnimationFrame(loop);
let frame;
function loop(t) {
(function loop() {
frame = requestAnimationFrame(loop);
const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
@ -17,6 +17,8 @@
const x = i % canvas.width;
const y = i / canvas.height >>> 0;
const t = window.performance.now();
const r = 64 + (128 * x / canvas.width) + (64 * Math.sin(t / 1000));
const g = 64 + (128 * y / canvas.height) + (64 * Math.cos(t / 1000));
const b = 128;
@ -28,7 +30,7 @@
}
ctx.putImageData(imageData, 0, 0);
}
}());
return () => {
cancelAnimationFrame(frame);

@ -5,9 +5,9 @@
onMount(() => {
const ctx = canvas.getContext('2d');
let frame = requestAnimationFrame(loop);
let frame;
function loop(t) {
(function loop() {
frame = requestAnimationFrame(loop);
const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
@ -17,6 +17,8 @@
const x = i % canvas.width;
const y = i / canvas.height >>> 0;
const t = window.performance.now();
const r = 64 + (128 * x / canvas.width) + (64 * Math.sin(t / 1000));
const g = 64 + (128 * y / canvas.height) + (64 * Math.cos(t / 1000));
const b = 128;
@ -28,7 +30,7 @@
}
ctx.putImageData(imageData, 0, 0);
}
}());
return () => {
cancelAnimationFrame(frame);

Loading…
Cancel
Save