Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.
TypeScript cross-platformelectronffmpegopen-sourceproduct-demorustscreen-capturescreen-recorderscreen-recordingscreen-studioscreencastspeech-to-texttypescriptvideo-editingvideo-editorwaylandwgpuwhisper
fix(website): read the cursor hotspots the way the app reads them
Etienne Lescot45371fad71ed
diff --git a/website/scripts/gen-recreation.mjs b/website/scripts/gen-recreation.mjsindex 830e2600d..bbfca399b 100644--- a/website/scripts/gen-recreation.mjs+++ b/website/scripts/gen-recreation.mjs@@ -109,7 +109,7 @@ const { buildClipSection, isSilenceWord, SILENCE_THRESHOLD_SEC } = await appModu);// Importable as-is: its only import is `import type { NativeCursorType }`, which// Node's type stripping removes, so the `@/` alias never has to resolve.-const { CURSOR_THEMES, DEFAULT_CURSOR_SPRITES, DEFAULT_CURSOR_THEME_ID } = await appModule(+const { CURSOR_THEMES, DEFAULT_CURSOR_THEME_ID, resolveCursorSprites } = await appModule("src/lib/cursor/cursorThemes.ts",);@@ -801,8 +801,10 @@ const CONTROLS = {* this table rather than eyeball a `transform-origin`. The two sources spell* hotspots differently and that is the trap: `DEFAULT_CURSOR_SPRITES` stores* fractions of the image (0.119), while a theme stores the same quantity against- * the ~32-logical reference the file header describes (1.5, i.e. 1.5/32). Both- * are normalised to a fraction here, once.+ * the 32-logical reference the file header describes (1.5, i.e. 1.5/32). The+ * magnitude cannot tell them apart — a theme's `hotspotX: 1` is one unit in, an+ * arrow tip, and reads as the sprite's right edge if taken for a fraction — so+ * the application's own `resolveCursorSprites` does the conversion here too.*/const CURSOR_PICKER = [DEFAULT_CURSOR_THEME_ID,@@ -817,20 +819,27 @@ const CURSOR_PICKER = ["pokemon-neon-gengar",];-const REF = 32;-const frac = (v) => Number((v > 1 ? v / REF : v).toFixed(4));+const round4 = (v) => Number(v.toFixed(4));function cursorSprite(id, kind) {- if (id === DEFAULT_CURSOR_THEME_ID) {- const a = DEFAULT_CURSOR_SPRITES[kind];- if (!a) throw new Error(`default sprites have no ${kind}`);- return { name: "Default", hotspotX: frac(a.hotspotX), hotspotY: frac(a.hotspotY) };+ const isDefault = id === DEFAULT_CURSOR_THEME_ID;+ const theme = isDefault ? null : CURSOR_THEMES.find((t) => t.id === id);+ if (!isDefault && !theme) {+ throw new Error(`unknown cursor theme ${id} — it is not in CURSOR_THEMES`);}- const theme = CURSOR_THEMES.find((t) => t.id === id);- if (!theme) throw new Error(`unknown cursor theme ${id} — it is not in CURSOR_THEMES`);- const a = theme.assets[kind];- if (!a) throw new Error(`cursor theme ${id} ships no ${kind} sprite`);- return { name: theme.name, hotspotX: frac(a.hotspotX), hotspotY: frac(a.hotspotY) };+ // resolveCursorSprites falls back to the built-in art for a kind the pack+ // does not ship, which is right in the application and wrong here: the+ // picker would show the default arrow under a pack's name.+ if (theme && !theme.assets[kind]) {+ throw new Error(`cursor theme ${id} ships no ${kind} sprite`);+ }+ const sprite = resolveCursorSprites(theme?.id ?? null)[kind];+ if (!sprite) throw new Error(`default sprites have no ${kind}`);+ return {+ name: theme?.name ?? "Default",+ hotspotX: round4(sprite.hotspotX),+ hotspotY: round4(sprite.hotspotY),+ };}const CURSORS = {diff --git a/website/src/components/Recreation/generated.ts b/website/src/components/Recreation/generated.tsindex 922b02ef9..ebc070aaf 100644--- a/website/src/components/Recreation/generated.ts+++ b/website/src/components/Recreation/generated.ts@@ -1708,14 +1708,14 @@ export const CURSORS = {id: "spring-gradient",name: "Spring Gradient",hotspotX: 0.0469,- hotspotY: 0.5,+ hotspotY: 0.0156,src: "/img/cursors/02-arrow.png",},{id: "black-and-rainbow-stroke-gradient-animated",name: "Black & Rainbow Stroke Gradient Animated",hotspotX: 0.05,- hotspotY: 0.96,+ hotspotY: 0.03,src: "/img/cursors/03-arrow.png",},{@@ -1728,22 +1728,22 @@ export const CURSORS = {{id: "hollow-knight-and-game-arrow",name: "Hollow Knight & Game Arrow",- hotspotX: 0.5,- hotspotY: 0.5,+ hotspotX: 0.0156,+ hotspotY: 0.0156,src: "/img/cursors/05-arrow.png",},{id: "mickey-mouse-black-hand-inflated-glove",name: "Mickey Mouse Black Hand Inflated Glove",hotspotX: 0.0781,- hotspotY: 0.5,+ hotspotY: 0.0156,src: "/img/cursors/06-arrow.png",},{id: "sanrio-kuromi-skull-arrow",name: "Sanrio Kuromi Skull Arrow",hotspotX: 0.0469,- hotspotY: 0.5,+ hotspotY: 0.0156,src: "/img/cursors/07-arrow.png",},{@@ -1756,8 +1756,8 @@ export const CURSORS = {{id: "pokemon-neon-gengar",name: "Pokemon Neon Gengar",- hotspotX: 1,- hotspotY: 0.5,+ hotspotX: 0.0313,+ hotspotY: 0.0156,src: "/img/cursors/09-arrow.png",},],diff --git a/website/src/components/Recreation/scene.ts b/website/src/components/Recreation/scene.tsindex 095e9c420..247a4e533 100644--- a/website/src/components/Recreation/scene.ts+++ b/website/src/components/Recreation/scene.ts@@ -271,11 +271,15 @@ export const CLIPS = [{ from: 13.23, to: 42, selected: false },] as const;-/** Three zooms, each with the scene time the wizard places it. */+/** Three zooms, each with the scene time the wizard places it.+ *+ * Two decimals, always: the app labels a zoom pill `scale.toFixed(2) + "×"`+ * (V4Timeline.tsx), so "1.5×" and "2×" are strings it never renders — the same+ * class of tell as a hand-typed cursor-size value. */export const ZOOMS = [- { from: 12.6, to: 13.7, label: "1.5×", scale: 1.5, placedAt: 16.15, origin: "52% 58%" },+ { from: 12.6, to: 13.7, label: "1.50×", scale: 1.5, placedAt: 16.15, origin: "52% 58%" },{ from: 16.25, to: 17.15, label: "1.80×", scale: 1.8, placedAt: 16.35, origin: "52% 58%" },- { from: 17.6, to: 18.45, label: "2×", scale: 2, placedAt: 16.55, origin: "36% 30%" },+ { from: 17.6, to: 18.45, label: "2.00×", scale: 2, placedAt: 16.55, origin: "36% 30%" },] as const;/** The speed ramp, and the window over which the footage clock runs 2.2x. */