tutorial: remove unneccessary performance.now() call inside raf (#5513)

pull/5704/head
fivem 4 years ago committed by GitHub
parent e750b7284e
commit ddd79e3f9d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -5,9 +5,9 @@
onMount(() => {
const ctx = canvas.getContext('2d');
let frame;
let frame = requestAnimationFrame(loop);
(function loop() {
function loop(t) {
frame = requestAnimationFrame(loop);
const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
@ -17,8 +17,6 @@
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;
@ -30,7 +28,7 @@
}
ctx.putImageData(imageData, 0, 0);
}());
}
return () => {
cancelAnimationFrame(frame);

@ -5,9 +5,9 @@
onMount(() => {
const ctx = canvas.getContext('2d');
let frame;
let frame = requestAnimationFrame(loop);
(function loop() {
function loop(t) {
frame = requestAnimationFrame(loop);
const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
@ -17,8 +17,6 @@
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;
@ -30,7 +28,7 @@
}
ctx.putImageData(imageData, 0, 0);
}());
}
return () => {
cancelAnimationFrame(frame);

Loading…
Cancel
Save