mirror of
https://codeberg.org/ashley/poke.git
synced 2024-11-29 17:08:49 +01:00
awa
This commit is contained in:
parent
9e5dd4f5f1
commit
c3b0209489
1 changed files with 11 additions and 15 deletions
|
@ -2112,20 +2112,19 @@ const oddCtx = oddCanvas.getContext("2d");
|
||||||
const evenCtx = evenCanvas.getContext("2d");
|
const evenCtx = evenCanvas.getContext("2d");
|
||||||
|
|
||||||
const canvasOpacity = "0.4";
|
const canvasOpacity = "0.4";
|
||||||
|
|
||||||
let intervalId;
|
let intervalId;
|
||||||
let oddFrame = true;
|
let oddFrame = true;
|
||||||
|
|
||||||
const setFrameInterval = () => {
|
const getFrameInterval = () => {
|
||||||
const cores = navigator.hardwareConcurrency || 2
|
const cores = navigator.hardwareConcurrency || 2;
|
||||||
return Math.max(500 / cores, 33);
|
return Math.max(500 / cores, 33);
|
||||||
};
|
};
|
||||||
|
|
||||||
const adjustCanvasSize = () => {
|
const adjustCanvasSize = () => {
|
||||||
const cores = navigator.hardwareConcurrency || 2;
|
const cores = navigator.hardwareConcurrency || 2;
|
||||||
|
const size = Math.min(1000, 800 / cores);
|
||||||
oddCanvas.style.width = evenCanvas.style.width = `${Math.min(1000, 800 / cores)}px`;
|
oddCanvas.style.width = evenCanvas.style.width = `${size}px`;
|
||||||
oddCanvas.style.height = evenCanvas.style.height = `${Math.min(1000, 600 / cores)}px`;
|
oddCanvas.style.height = evenCanvas.style.height = `${size * 0.75}px`;
|
||||||
};
|
};
|
||||||
|
|
||||||
const drawFrame = () => {
|
const drawFrame = () => {
|
||||||
|
@ -2150,7 +2149,7 @@ const transitionToEvenCanvas = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const drawStart = () => {
|
const drawStart = () => {
|
||||||
const frameIntervalMs = setFrameInterval(); // Get optimized frame interval
|
const frameIntervalMs = getFrameInterval();
|
||||||
intervalId = window.setInterval(drawFrame, frameIntervalMs);
|
intervalId = window.setInterval(drawFrame, frameIntervalMs);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -2159,17 +2158,13 @@ const drawPause = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const init = () => {
|
const init = () => {
|
||||||
// Fixes an issue where Firefox/Chromium fails to load the ambient mode
|
|
||||||
AMvideo.pause();
|
AMvideo.pause();
|
||||||
AMvideo.play();
|
AMvideo.play();
|
||||||
|
adjustCanvasSize();
|
||||||
adjustCanvasSize(); // Adjust canvas size based on hardware
|
|
||||||
|
|
||||||
AMvideo.addEventListener("play", drawStart, false);
|
AMvideo.addEventListener("play", drawStart, false);
|
||||||
AMvideo.addEventListener("pause", drawPause, false);
|
AMvideo.addEventListener("pause", drawPause, false);
|
||||||
AMvideo.addEventListener("ended", drawPause, false);
|
AMvideo.addEventListener("ended", drawPause, false);
|
||||||
|
oddCanvas.style.transition = evenCanvas.style.transition = `opacity ${getFrameInterval()}ms`;
|
||||||
oddCanvas.style.transition = evenCanvas.style.transition = `opacity ${setFrameInterval()}ms`;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const cleanup = () => {
|
const cleanup = () => {
|
||||||
|
@ -2182,6 +2177,7 @@ const cleanup = () => {
|
||||||
window.addEventListener("load", init);
|
window.addEventListener("load", init);
|
||||||
window.addEventListener("unload", cleanup);
|
window.addEventListener("unload", cleanup);
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
<style>
|
<style>
|
||||||
.video-player-container, #video {
|
.video-player-container, #video {
|
||||||
|
|
Loading…
Reference in a new issue