Rotate the background with every track
The poster behind the frame was one of two, picked by hand and then left there all night. It now turns over on every track change the way the animations do, and never as the same picture twice: a shuffle bag over whatever images sit in assets/, each shown at a random zoom between 1.15 and 1.9 and cropped around a randomly chosen point of the poster. The list is read from the directory rather than written out in config.js. The old one named two files that are no longer there, which is the failure mode a hand-kept list has; now a poster joins the rotation, with its own button on the queue page, by being dropped in the folder. Zoom never goes below 1.15. These are portrait prints and the screen is wide, so cover fits the poster's full width and crops vertically — at 1 the paper margin shows as a grey stripe down both sides. 1.15 cuts at least 13% off the width of every crop a 1920x1080 screen can produce. The crop is drawn into a screen-sized canvas rather than handed to CSS as an object-fit rule on a full-size <img>. The scans are 3508x4950, which is a 70MB texture per layer and two of them composited for the length of the fade; instead each pick is fetched, resized off the main thread to roughly screen resolution, drawn once, and closed. A swap costs about 400ms of async work, all of it before the fade begins, and no full-size bitmap is held anywhere. Nothing about the posters' resolution reaches the compositor, so assets/ can keep the 300 dpi originals. Backgrounds pin and unpin like animations: DEFAULT_BACKGROUND is now the auto cycle, the queue page's row leads with Auto, and isBackground() guards the socket handler and the restored queue.json against a key that no longer names a file. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01H9v2Xoa6eoeGYpK6gp95k9
This commit is contained in:
+17
-20
@@ -1,12 +1,13 @@
|
||||
import { connect } from '/shared/socket.js';
|
||||
import { OVERLAP_SECONDS, HARD_CUT_SECONDS, BACKGROUNDS, AUTO_ANIMATION } from '/config.js';
|
||||
import { OVERLAP_SECONDS, HARD_CUT_SECONDS, AUTO_BACKGROUND, AUTO_ANIMATION } from '/config.js';
|
||||
import { createPlayer, loadApi, STATE } from './yt.js';
|
||||
import { startAnimationCycle } from './motion.js';
|
||||
import { startBackgroundCycle } from './backdrop.js';
|
||||
import { requestCapture } from './capture.js';
|
||||
|
||||
const TICK_MS = 250;
|
||||
|
||||
let state = { items: [], currentId: null, background: 'pink', animation: AUTO_ANIMATION };
|
||||
let state = { items: [], currentId: null, background: AUTO_BACKGROUND, animation: AUTO_ANIMATION };
|
||||
let decks = [];
|
||||
let active = 0;
|
||||
let transition = null; // { until, duration, from, to } while crossfading
|
||||
@@ -17,22 +18,12 @@ const socket = connect({ onMessage, onStatus });
|
||||
|
||||
// --- backgrounds --------------------------------------------------------
|
||||
|
||||
const backgroundLayer = document.getElementById('backgrounds');
|
||||
const backgroundImages = new Map();
|
||||
|
||||
for (const [key, { src }] of Object.entries(BACKGROUNDS)) {
|
||||
const img = document.createElement('img');
|
||||
img.src = src;
|
||||
img.alt = '';
|
||||
backgroundLayer.appendChild(img);
|
||||
backgroundImages.set(key, img);
|
||||
}
|
||||
|
||||
function applyBackground(key) {
|
||||
for (const [name, img] of backgroundImages) img.classList.toggle('active', name === key);
|
||||
}
|
||||
|
||||
applyBackground(state.background);
|
||||
// Runs from page load, not from the start gate: the poster is what is on
|
||||
// screen while the party waits for someone to click Start.
|
||||
const backgrounds = startBackgroundCycle(
|
||||
document.getElementById('backgrounds'),
|
||||
state.background,
|
||||
);
|
||||
|
||||
// --- start gate ---------------------------------------------------------
|
||||
|
||||
@@ -247,8 +238,9 @@ function finishTransition() {
|
||||
decks[to].setOpacity(1);
|
||||
active = to;
|
||||
|
||||
// New track, new animation.
|
||||
// New track, new animation, new poster and crop.
|
||||
animations?.next();
|
||||
backgrounds.next();
|
||||
|
||||
if (advance) socket.send({ type: 'trackEnded', id: outgoingId });
|
||||
}
|
||||
@@ -326,8 +318,9 @@ function onMessage(msg) {
|
||||
if (msg.type !== 'state') return;
|
||||
|
||||
const previousAnimation = state.animation;
|
||||
const previousBackground = state.background;
|
||||
state = msg.state;
|
||||
applyBackground(state.background);
|
||||
if (state.background !== previousBackground) backgrounds.setMode(state.background);
|
||||
if (state.animation !== previousAnimation) animations?.setMode(state.animation);
|
||||
updateGate();
|
||||
pumpProbe();
|
||||
@@ -349,6 +342,9 @@ window.__player = {
|
||||
nextAnimation() {
|
||||
return animations?.next() ?? null;
|
||||
},
|
||||
nextBackground() {
|
||||
return backgrounds.next();
|
||||
},
|
||||
get state() {
|
||||
return {
|
||||
state,
|
||||
@@ -356,6 +352,7 @@ window.__player = {
|
||||
transition,
|
||||
decks: decks.map((d) => d.itemId),
|
||||
animation: animations?.name ?? null,
|
||||
background: backgrounds.key,
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user