Free games for graphing calculators: NumWorks, TI-Nspire CX, Casio fx-CG50 and soon TI-84 Plus CE. Balatro, Celeste, Hollow Knight, Minecraft and more.
C calculatorcalculator-gamescasiochesscrossy-roaddrive-madfx-cg50gamesgeometry-dashgraphing-calculatorndlessnumworksnumworks-appsnumworks-calculatornumworks-gamenumworks-gamestetristi-84-plus-ceti-nspire
NumPlay Studio: a new intro, a star key, and clean previews
Mason363b469785f8bc3
diff --git a/customize/app.css b/customize/app.cssindex 2433a583..5444f9bb 100644--- a/customize/app.css+++ b/customize/app.css@@ -48,15 +48,33 @@ a { color: inherit; }}.keys i.y { background: linear-gradient(#ffd25f, #f5b83a); color: #ffffff; text-shadow: 0 1px 1px rgba(150, 90, 0, 0.35); box-shadow: inset 0 -2px 0 rgba(150, 90, 0, 0.18), 0 1px 0 #d39a24, 0 2px 4px rgba(0, 0, 0, 0.14); }.keys i.down { transform: translateY(2px); box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.18), 0 0 0 #c5c7cb; }-.star {- display: flex; align-items: center; gap: 10px; text-decoration: none;- background: var(--btn); color: var(--btn-ink); padding: 12px 18px 12px 16px; border-radius: 999px;- font-size: 15px; font-weight: 650; box-shadow: 0 6px 16px rgba(0, 0, 0, 0.18);- transition: transform var(--t) var(--spring);+/* the GitHub corner: a calculator key with a star on it, and a little screen with the count */+.star { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--ink); padding: 4px; }+.star-text { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.15; }+.star-text b { font-size: 16px; font-weight: 750; letter-spacing: -0.2px; }+.star-text small { display: flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; color: var(--mute); }+.star-lcd {+ position: relative; height: 46px; min-width: 66px; padding: 12px 12px 6px; border-radius: 9px; overflow: hidden;+ background: #0c0d10; color: #ffffff; display: flex; align-items: center; justify-content: center;+ box-shadow: 0 0 0 4px #ffffff, 0 0 0 5px #d6d8dc, 0 6px 14px rgba(0, 0, 0, 0.16);+}+.star-lcd i { position: absolute; left: 0; right: 0; top: 0; height: 7px; background: #ffb734; }+.star-lcd b { font-size: 19px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: 0.5px; }+.star-key {+ position: relative; width: 50px; height: 48px; border-radius: 14px; display: flex; align-items: center; justify-content: center;+ background: linear-gradient(#ffd25f, #f5b83a);+ box-shadow: inset 0 -3px 0 rgba(150, 90, 0, 0.2), 0 2px 0 #d39a24, 0 6px 12px rgba(0, 0, 0, 0.16);+ transition: transform 90ms var(--ease), box-shadow 90ms var(--ease);+}+.star-key svg { filter: drop-shadow(0 1px 1px rgba(150, 90, 0, 0.45)); transition: transform 300ms var(--spring); }+.star-key::after {+ content: "★"; position: absolute; left: 50%; top: 4px; color: #f5b70a; font-size: 16px; opacity: 0; pointer-events: none;+ transform: translate(-50%, 0) scale(0.6);}-.star:hover { transform: translateY(-2px) scale(1.03); }-.star .count { background: rgba(255, 255, 255, 0.16); padding: 3px 9px; border-radius: 999px; font-size: 13px; display: flex; align-items: center; gap: 4px; }-.star .count::before { content: "★"; color: #f5b70a; }+.star:hover .star-key { transform: translateY(2px); box-shadow: inset 0 1px 2px rgba(150, 90, 0, 0.25), 0 0 0 #d39a24, 0 3px 6px rgba(0, 0, 0, 0.14); }+.star:hover .star-key svg { transform: rotate(72deg) scale(1.05); }+.star:hover .star-key::after { animation: rise-star 900ms var(--ease) forwards; }+@keyframes rise-star { 0% { opacity: 0; transform: translate(-50%, 0) scale(0.6); } 25% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -34px) scale(1.1) rotate(25deg); } }main {position: relative;@@ -95,8 +113,8 @@ body.dragging-icon, body.dragging-icon * { cursor: grabbing !important; user-selbackground: var(--blue); color: #ffffff; box-shadow: 0 0 0 2.5px var(--bg), 0 2px 4px rgba(0, 0, 0, 0.2);transform: scale(0); transition: transform 180ms var(--spring), background 120ms var(--ease);}-.app .badge svg { width: 12px; height: 12px; }-.app .badge .plus { display: none; }+.app .badge svg { width: 13px; height: 13px; color: #ffffff; }+.app .badge .b-plus { display: none; }/* in: in colour, lifted, a blue tick */.app.on img { box-shadow: var(--shadow); }.app.on .badge { transform: scale(1); }@@ -105,8 +123,8 @@ body.dragging-icon, body.dragging-icon * { cursor: grabbing !important; user-sel.app.off img { filter: grayscale(0.85) contrast(0.9); }.app.off:hover { opacity: 0.78; transform: scale(0.93); }.app.off:hover .badge { transform: scale(1); background: #8e939a; }-.app.off .badge .tick, .app.nofit .badge .tick { display: none; }-.app.off .badge .plus { display: block; }+.app.off .badge .b-tick, .app.nofit .badge .b-tick { display: none; }+.app.off .badge .b-plus { display: block; }.app.nofit { transform: scale(0.86); opacity: 0.22; }.app.nofit img { filter: grayscale(1); }.app.on:hover { transform: translateY(-2px); }@@ -314,15 +332,19 @@ body.dragging .drop-hint { opacity: 1; }position: fixed; left: 50%; bottom: 28px; z-index: 30; transform: translateX(-50%); border: 0; cursor: pointer;background: rgba(29, 29, 31, 0.08); color: var(--mute); font-size: 13px; font-weight: 650; padding: 8px 16px; border-radius: 999px;}-body.intro .grid.small, body.intro .side, body.intro .meter, body.intro .actions, body.intro .top, body.intro .foot { transition: opacity 500ms var(--ease), transform 600ms var(--ease); }-body.intro.s0 .grid.small, body.intro.s0 .side, body.intro.s0 .meter, body.intro.s0 .actions, body.intro.s0 .top, body.intro.s0 .foot,-body.intro.s1 .side, body.intro.s1 .meter, body.intro.s1 .actions, body.intro.s1 .top, body.intro.s1 .foot,-body.intro.s2 .actions, body.intro.s2 .top, body.intro.s2 .foot { opacity: 0; transform: translateY(10px); pointer-events: none; }-body.intro .calc { transition: transform 700ms var(--ease), opacity 500ms var(--ease); }-body.intro.s0 .calc { transform: translateY(24px) scale(0.97); }-body.intro.s0.start .calc { opacity: 0; }-body.intro.s3 .install { animation: beat 900ms var(--ease) 2; }-@keyframes beat { 0%, 100% { transform: scale(1); } 40% { transform: scale(1.08); } }+.ih { opacity: 0 !important; }+body.intro { overflow: hidden; }+body.intro .calc { z-index: 2; }+.boot { position: absolute; inset: 7.5% 0 0 0; z-index: 4; background: #0c0d10; display: flex; align-items: center; justify-content: center; overflow: hidden; }+.boot .crt { position: absolute; left: 0; right: 0; top: 50%; height: 1.2%; margin-top: -0.6%; background: #ffffff; transform: scaleX(0); box-shadow: 0 0 12px #ffffff; }+.boot .splash { display: flex; flex-direction: column; align-items: center; gap: 2cqh; opacity: 0; }+.boot .splash img { width: 24cqw; border-radius: 18%; box-shadow: 0 0 0 0.8cqw rgba(255, 255, 255, 0.08), 0 2cqh 5cqh rgba(0, 0, 0, 0.6); }+.boot .splash b { color: #ffffff; font-size: 11cqh; font-weight: 800; letter-spacing: -0.03em; }+.boot .splash span { color: #ffb734; font-size: 5cqh; font-weight: 700; letter-spacing: 0.2em; text-transform: uppercase; }+.keyflash { position: absolute; width: 15%; aspect-ratio: 1; border-radius: 50%; pointer-events: none; z-index: 3;+ background: radial-gradient(closest-side, rgba(255, 220, 120, 0.95), rgba(255, 183, 52, 0.45) 55%, rgba(255, 183, 52, 0)); }+.ghost-icon { position: fixed; z-index: 35; border-radius: 18%; pointer-events: none; box-shadow: 0 10px 24px rgba(0, 0, 0, 0.25); }+.press-ring { position: absolute; inset: 0; border-radius: inherit; border: 2px solid var(--btn); pointer-events: none; }/* ---- tooltip, toast and the install sheet */.tip {@@ -369,8 +391,7 @@ body.intro.s3 .install { animation: beat 900ms var(--ease) 2; }@media (max-width: 980px) {:root { --cw: min(300px, 62vw); }.top { padding: 16px 16px 0; }- .star span { display: none; }- .star { padding: 10px 14px; }+ .star-text { display: none; }main { padding: 84px 16px 32px; gap: 28px; }.device { order: -1; gap: 16px; }.grid.small, .side { flex-basis: 100%; max-width: 560px; }diff --git a/customize/app.js b/customize/app.jsindex f5a63aa8..138919eb 100644--- a/customize/app.js+++ b/customize/app.js@@ -5,7 +5,7 @@'use strict';(() => {const KIT = 'kit/';- const PREVIEWS = '../docs/media/gallery/';+ const MEDIA = '../docs/media/'; // the games' clips (kit.json: previews/ or gallery/)const MiB = 1048576;// Enlarged Extra Apps (nwagyu's Nwagra): it moves the end of the app area from the end of// Epsilon's slot to the end of the 8 MB flash, so apps go from 0x90200000 to 0x90800000@@ -253,7 +253,7 @@clearTimeout(previewTimer);previewing = id;const p = $('#preview'), img = p.querySelector('img');- const src = PREVIEWS + id + '.gif';+ const src = MEDIA + (g.preview === true ? 'gallery/' + id + '.gif' : g.preview);if (img.getAttribute('src') !== src) img.src = src;p.classList.add('show');$('#status-line').textContent = g.title.toUpperCase();@@ -768,66 +768,164 @@}// ------------------------------------------------------------------ the intro- // A few words while the calculator fills up, the first time and when the logo is clicked- const intro = { on: false, run: 0 };+ // The first time (and when the logo is clicked): the calculator rises and boots, NumPlay's+ // letters come off its keypad to make the logo, the games fly into its screen one by one,+ // Retro-Go's cartridges drop in, Install presses itself. A few words on the way; any key skips.+ const intro = { on: false, run: 0, anims: [], temps: [] };+ const OUT = 'cubic-bezier(0.2, 0.9, 0.25, 1)', SPRING = 'cubic-bezier(0.3, 1.45, 0.5, 1)';+ // where NumPlay's letters sit on the keypad (their alpha keys), in the calculator picture's pixels+ const LETTER_KEYS = [[340, 1474], [677, 1598], [172, 1474], [677, 1474], [857, 1354], [159, 1242], [509, 1722]];function caption(text) {const c = $('#caption');c.classList.remove('show');- setTimeout(() => { c.textContent = text; if (text) c.classList.add('show'); }, text ? 180 : 0);+ setTimeout(() => { c.textContent = text; if (text) c.classList.add('show'); }, text ? 160 : 0);}+ function play(e, frames, opts) {+ const a = e.animate(frames, { fill: 'backwards', ...opts });+ intro.anims.push(a);+ e.classList.remove('ih');+ return a.finished.catch(() => {});+ }+ const temp = (e) => { intro.temps.push(e); return e; };+ const center = (r) => [r.left + r.width / 2, r.top + r.height / 2];+async function playIntro() {- if (intro.on) return;- if (matchMedia('(prefers-reduced-motion: reduce)').matches) return;+ if (intro.on || matchMedia('(prefers-reduced-motion: reduce)').matches) return;intro.on = true;- const run = ++intro.run, alive = () => intro.run === run;+ const run = ++intro.run, alive = () => intro.on && intro.run === run;closePops(); hidePreview();const target = ordered(), roms = st.roms;+ intro.restore = () => { st.picked = new Set(target); st.roms = roms; };+ st.picked = new Set(); st.roms = [];const body = document.body;- const skip = el('button', 'intro-skip', { type: 'button' });+ body.classList.add('intro');+ const hide = [$('#calc'), document.querySelector('.logo-icon'), ...document.querySelectorAll('.keys i'), $('#star'),+ ...buttons.values(), document.querySelector('.meter'), document.querySelector('.side'), document.querySelector('.actions'), document.querySelector('.foot')];+ for (const e of hide) e.classList.add('ih');+ render();+ const skip = temp(el('button', 'intro-skip', { type: 'button' }));skip.textContent = 'Skip';skip.addEventListener('click', endIntro);body.appendChild(skip);- st.picked = new Set(); st.roms = [];- body.classList.add('intro', 's0', 'start');- render();- intro.restore = () => { st.picked = new Set(target); st.roms = roms; };- await wait(60);++ // the screen, off; it boots to NumPlay's splash+ const screen = $('#screen'), calc = $('#calc');+ const boot = temp(el('div', 'boot'));+ boot.innerHTML = '<i class="crt"></i><div class="splash"><img alt=""><b>NumPlay</b><span>free games</span></div>';+ boot.querySelector('img').src = KIT + 'variants/NumPlay.png';+ screen.appendChild(boot);+ previewing = 'intro';+ $('#status-line').textContent = '';+ await play(calc, [{ opacity: 0, transform: 'perspective(1400px) translateY(70vh) rotateX(42deg) scale(0.86)' },+ { opacity: 1, offset: 0.35 }, { opacity: 1, transform: 'perspective(1400px) translateY(0) rotateX(0) scale(1)' }], { duration: 900, easing: OUT });+ if (!alive()) return;+ const crt = boot.querySelector('.crt'), splash = boot.querySelector('.splash');+ await play(crt, [{ transform: 'scaleX(0)', opacity: 1 }, { transform: 'scaleX(1)', opacity: 1 }], { duration: 170, easing: 'ease-in', fill: 'forwards' });+ play(crt, [{ transform: 'scaleX(1) scaleY(1)', opacity: 1 }, { transform: 'scaleX(1) scaleY(140)', opacity: 0 }], { duration: 320, easing: 'ease-out', fill: 'forwards' });+ $('#status-line').textContent = 'NUMPLAY';+ await play(splash, [{ opacity: 0, transform: 'scale(0.5)' }, { opacity: 1, transform: 'scale(1)' }], { duration: 460, delay: 140, easing: SPRING, fill: 'forwards' });+ if (!alive()) return;++ // NumPlay's letters come off the keypad, key by key, and make the logo+ const cr = calc.getBoundingClientRect(), k = cr.width / 1018;+ const keys = [...document.querySelectorAll('.keys i')];+ const flights = keys.map((key, i) => {+ const [kx, ky] = LETTER_KEYS[i], sx = cr.left + kx * k, sy = cr.top + ky * k * (cr.height / cr.width) / (2000 / 1018);+ const r = key.getBoundingClientRect(), [fx, fy] = center(r);+ const flash = temp(el('i', 'keyflash'));+ flash.style.left = (kx / 10.18) + '%';+ flash.style.top = (ky / 20) + '%';+ calc.appendChild(flash);+ const d = 80 * i;+ play(flash, [{ opacity: 0, transform: 'translate(-50%, -50%) scale(0.5)' }, { opacity: 1, offset: 0.3 },+ { opacity: 0, transform: 'translate(-50%, -50%) scale(1.5)' }], { duration: 520, delay: d, easing: 'ease-out', fill: 'forwards' });+ const dx = sx - fx, dy = sy - fy, lift = Math.min(260, Math.abs(dy) * 0.35);+ return play(key, [+ { opacity: 0, transform: `translate(${dx}px, ${dy}px) scale(1.9) rotate(0deg)` },+ { opacity: 1, offset: 0.12, transform: `translate(${dx}px, ${dy - 24}px) scale(2) rotate(-8deg)` },+ { offset: 0.6, transform: `translate(${dx * 0.35}px, ${dy * 0.35 - lift}px) scale(1.25) rotate(${i % 2 ? 14 : -14}deg)` },+ { opacity: 1, transform: 'translate(0, 0) scale(1) rotate(0deg)' }], { duration: 820, delay: d + 60, easing: OUT });+ });+ play(document.querySelector('.logo-icon'), [{ opacity: 0, transform: 'scale(0) rotate(-90deg)' }, { opacity: 1, transform: 'scale(1) rotate(0)' }],+ { duration: 560, delay: 80 * keys.length + 200, easing: SPRING });+ await Promise.all(flights);if (!alive()) return;- body.classList.remove('start');++ // the games wave in, then fly into the calculator, which fills up block by blockcaption('Free games for your NumWorks');- await wait(1500);+ const all = [...buttons.values()].filter((b) => b.parentNode.id === 'small');+ all.forEach((b, i) => play(b, [{ opacity: 0, transform: 'translateY(26px) scale(0.4) rotate(-12deg)' },+ { opacity: 0.5, transform: 'translateY(0) scale(0.9) rotate(0)' }], { duration: 480, delay: 16 * i, easing: SPRING }));+ play(document.querySelector('.meter'), [{ opacity: 0, transform: 'translateX(30px)' }, { opacity: 1, transform: 'none' }], { duration: 600, delay: 200, easing: OUT });+ await wait(450 + 16 * all.length);if (!alive()) return;- body.classList.replace('s0', 's1');caption('Pick the ones you want');- await wait(500);+ play(splash, [{ opacity: 1, transform: 'scale(1)' }, { opacity: 0, transform: 'scale(1.3)' }], { duration: 380, delay: 200, fill: 'forwards' });+ play(boot, [{ opacity: 1 }, { opacity: 0 }], { duration: 500, delay: 300, fill: 'forwards' });+ const map = $('#map');+ const step = Math.max(40, Math.min(100, 1300 / Math.max(target.length, 1)));for (const id of target) {if (!alive()) return;+ const b = buttons.get(id), from = b.getBoundingClientRect();st.picked.add(id);- bump(buttons.get(id), 'bounce');+ if (st.picked.size === 1) previewing = null;render();- await wait(target.length > 16 ? 45 : 80);+ bump(b, 'bounce');+ const t = tiles.get(id), mr = map.getBoundingClientRect();+ const tx = mr.left + (parseFloat(t.style.left) + parseFloat(t.style.width) / 2) / 100 * mr.width;+ const ty = mr.top + (parseFloat(t.style.top) + parseFloat(t.style.height) / 2) / 100 * mr.height;+ const g = temp(el('img', 'ghost-icon', { src: KIT + 'icons/' + id + '.png', alt: '' }));+ Object.assign(g.style, { left: from.left + 'px', top: from.top + 'px', width: from.width + 'px', height: from.height + 'px' });+ body.appendChild(g);+ const [fx, fy] = center(from), dx = tx - fx, dy = ty - fy;+ play(g, [{ transform: 'translate(0, 0) scale(1) rotate(0)', opacity: 1 },+ { offset: 0.55, transform: `translate(${dx * 0.55}px, ${dy * 0.55 - 70}px) scale(0.75) rotate(${dx > 0 ? 20 : -20}deg)`, opacity: 1 },+ { transform: `translate(${dx}px, ${dy}px) scale(0.18) rotate(0)`, opacity: 0.2 }], { duration: 640, easing: 'cubic-bezier(0.5, 0, 0.2, 1)', fill: 'forwards' })+ .then(() => g.remove());+ await wait(step);}- await wait(700);+ await wait(500);if (!alive()) return;- body.classList.replace('s1', 's2');++ // Retro-Go: three cartridges drop into its slotif (rg) {- caption('Add Game Boy, NES and Sega games');- await wait(1600);+ caption('Add your Game Boy, NES and Sega games');+ await play(document.querySelector('.side'), [{ opacity: 0, transform: 'translateX(40px)' }, { opacity: 1, transform: 'none' }], { duration: 520, easing: OUT });+ const carts = [...document.querySelectorAll('.drop-art i')];+ carts.forEach((c, i) => play(c, [{ opacity: 0 }, { opacity: 1, offset: 0.25 }, { opacity: 1 }], { duration: 780, delay: 130 * i }));+ await Promise.all(carts.map((c, i) => play(c, [ // (added to each cartridge's own tilt)+ { transform: `translateY(-${220 + 60 * i}px) rotate(${[-40, 25, 50][i]}deg)`, composite: 'add' },+ { transform: 'translateY(0) rotate(0deg)', composite: 'add' }], { duration: 780, delay: 130 * i, easing: 'cubic-bezier(0.35, 1.6, 0.55, 1)' })));+ play($('#drop'), [{ transform: 'scale(1)' }, { transform: 'scale(1.04)', offset: 0.4 }, { transform: 'scale(1)' }], { duration: 360 });+ await wait(600);if (!alive()) return;}- body.classList.replace('s2', 's3');++ // and Install presses itselfcaption('Install it in one click');- await wait(1700);+ await play(document.querySelector('.actions'), [{ opacity: 0, transform: 'translateY(30px)' }, { opacity: 1, transform: 'none' }], { duration: 560, easing: OUT });+ play($('#star'), [{ opacity: 0, transform: 'translateX(60px) rotate(8deg)' }, { opacity: 1, transform: 'none' }], { duration: 700, easing: SPRING });+ play(document.querySelector('.foot'), [{ opacity: 0 }, { opacity: 1 }], { duration: 600 });+ await wait(200);+ if (!alive()) return;+ await play($('#install'), [{ transform: 'scale(1)' }, { transform: 'scale(0.9)', offset: 0.25 }, { transform: 'scale(1.08)', offset: 0.6 }, { transform: 'scale(1)' }], { duration: 620, easing: 'ease-out' });+ const ring = temp(el('i', 'press-ring'));+ $('#install').appendChild(ring);+ await play(ring, [{ opacity: 0.6, transform: 'scale(0.9)' }, { opacity: 0, transform: 'scale(1.6)' }], { duration: 700, easing: 'ease-out', fill: 'forwards' });+ await wait(500);if (alive()) endIntro();}function endIntro() {if (!intro.on) return;intro.on = false;intro.run++;+ for (const a of intro.anims) a.cancel();+ for (const e of intro.temps) e.remove();+ intro.anims = []; intro.temps = [];+ for (const e of document.querySelectorAll('.ih')) e.classList.remove('ih');+ document.body.classList.remove('intro');+ previewing = null;if (intro.restore) intro.restore();- document.body.classList.remove('intro', 's0', 's1', 's2', 's3', 'start');- const s = document.querySelector('.intro-skip');- if (s) s.remove();caption('');store('numplay-intro', '1');render();@@ -921,8 +1019,8 @@} catch (e) { custom = null; }const small = $('#small'), big = $('#big');- const badge = '<span class="badge"><svg class="tick" viewBox="0 0 12 12"><path d="M2.5 6.2l2.3 2.3 4.7-5" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>' +- '<svg class="plus" viewBox="0 0 12 12"><path d="M6 2.5v7M2.5 6h7" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg></span>';+ const badge = '<span class="badge"><svg class="b-tick" viewBox="0 0 12 12"><path d="M2.5 6.2l2.3 2.3 4.7-5" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round"/></svg>' ++ '<svg class="b-plus" viewBox="0 0 12 12"><path d="M6 2.5v7M2.5 6h7" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round"/></svg></span>';for (const g of kit.games) {if (g === rg) continue;const b = el('button', 'app off', { type: 'button', 'aria-label': g.title, 'aria-pressed': 'false', 'data-id': g.id });diff --git a/customize/index.html b/customize/index.htmlindex f537b93c..3bf9b60b 100644--- a/customize/index.html+++ b/customize/index.html@@ -46,10 +46,10 @@<img class="logo-icon" src="kit/variants/NumPlay.png" alt="" width="40" height="40"><span class="keys" aria-hidden="true"><i>N</i><i>u</i><i>m</i><i class="y">P</i><i class="y">l</i><i class="y">a</i><i class="y">y</i></span></button>- <a id="star" class="star" href="https://github.com/Mason363/NumPlay" target="_blank" rel="noopener">- <svg viewBox="0 0 16 16" width="20" height="20" aria-hidden="true"><path fill="currentColor" d="M8 0a8 8 0 0 0-2.53 15.59c.4.07.55-.17.55-.38v-1.33c-2.23.48-2.7-1.07-2.7-1.07-.36-.92-.89-1.17-.89-1.17-.73-.5.06-.49.06-.49.8.06 1.23.83 1.23.83.72 1.22 1.88.87 2.34.66.07-.52.28-.87.5-1.07-1.78-.2-3.65-.89-3.65-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82a7.6 7.6 0 0 1 4 0c1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.870 3.75-3.66 3.95.29.25.54.73.54 1.48v2.2c0 .21.15.46.55.38A8 8 0 0 0 8 0z"/></svg>- <span>Star on GitHub</span>- <b id="stars" class="count" hidden></b>+ <a id="star" class="star" href="https://github.com/Mason363/NumPlay" target="_blank" rel="noopener" aria-label="Star NumPlay on GitHub">+ <span class="star-text"><b>Star NumPlay</b><small><svg viewBox="0 0 16 16" width="13" height="13" aria-hidden="true"><path fill="currentColor" d="M8 0a8 8 0 0 0-2.53 15.59c.4.07.55-.17.55-.38v-1.33c-2.23.48-2.7-1.07-2.7-1.07-.36-.92-.89-1.17-.89-1.17-.73-.5.06-.49.06-.49.8.06 1.23.83 1.23.83.72 1.22 1.88.87 2.34.66.07-.52.28-.87.5-1.07-1.78-.2-3.65-.89-3.65-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82a7.6 7.6 0 0 1 4 0c1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.66 3.95.29.25.54.73.54 1.48v2.2c0 .21.15.46.55.38A8 8 0 0 0 8 0z"/></svg>on GitHub</small></span>+ <span class="star-lcd" aria-hidden="true"><i></i><b id="stars">★</b></span>+ <span class="star-key" aria-hidden="true"><svg viewBox="0 0 24 24" width="24" height="24"><path fill="#ffffff" d="M12 2.6l2.85 5.9 6.5.9-4.72 4.55 1.15 6.45L12 17.3l-5.78 3.1 1.15-6.45L2.65 9.4l6.5-.9z"/></svg></span></a></header>diff --git a/tools/kit.py b/tools/kit.pyindex bff25ea0..e50a7719 100644--- a/tools/kit.py+++ b/tools/kit.py@@ -139,7 +139,9 @@ def main():icon = icon_of(i)if icon:shutil.copy(icon, os.path.join(O, "icons", i + ".png"))- preview = os.path.exists(os.path.join(ROOT, "docs", "media", "gallery", f"{i}.gif"))+ # the clip the website plays: from the emulator (tools/previews.py), else the gallery's GIF+ preview = next((f"{d}/{i}.gif" for d in ("previews", "gallery")+ if os.path.exists(os.path.join(ROOT, "docs", "media", d, f"{i}.gif"))), None)thumb = os.path.join(ROOT, "docs", "media", f"thumb_{i}.png")if os.path.exists(thumb):shutil.copy(thumb, os.path.join(O, "thumbs", i + ".png"))diff --git a/tools/previews.py b/tools/previews.pynew file mode 100644index 00000000..66dd0c60--- /dev/null+++ b/tools/previews.py@@ -0,0 +1,65 @@+#!/usr/bin/env python3+"""Records the clips NumPlay Studio plays on its calculator's screen when you point at a game.++Most games use their gallery GIF (docs/media/gallery); those filmed on a real calculator get a+clip of their own from the emulator instead, here, in docs/media/previews/<id>.gif: the game+played by a short key script, recorded from the screen itself.++Usage: tools/previews.py [id ...] (build/apps/*.nwa must be built)+"""+import os+import subprocess+import sys+import tempfile++ROOT = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..")+OUT = os.path.join(ROOT, "docs", "media", "previews")+++def presses(*items):+ return ",".join(f"{t}-{t + (h[0] if h else 90)}:{k}" for t, k, *h in items)+++def every(t0, t1, step, key, hold=90):+ return ",".join(f"{t}-{t + hold}:{key}" for t in range(t0, t1, step))+++# id: (app, key script, the part to keep in ms, frames a second)+DEMOS = {+ "numdash": ("NumDash.nwa", presses((2500, "ok"), (3700, "ok", 8000)), (3900, 10900), 25),+ "crossyroad": ("CrossyRoad.nwa", every(1500, 10000, 420, "up") + "," + presses((4300, "left")), (1700, 5400), 20),+ "numdrive": ("NumDrive.nwa", presses((1500, "right", 7000)), (2200, 6400), 20),+ "balatro": ("Balatro.nwa", presses((1500, "ok"), (2500, "ok"), (3500, "ok"), (5000, "ok"), (5400, "right"),+ (5800, "ok"), (6200, "right"), (6600, "ok"), (7100, "exe")), (4600, 11600), 15),+ # past the door and the dealer, a name typed on the waiver and signed (EXE), then the game+ "buckshot": ("BuckshotRoulette.nwa", every(1500, 15000, 900, "ok") + "," + presses((15300, "exe")) + "," ++ every(17000, 27000, 1300, "ok"), (16500, 25500), 15),+ "tetris": ("Tetris.nwa", presses((1200, "ok")) + "," + every(2200, 9000, 700, "up") + "," ++ every(2500, 9000, 1400, "left") + "," + every(3100, 9000, 1400, "right") + "," ++ every(3400, 9000, 700, "down", 300), (2400, 8400), 20),+ "celeste": ("Celeste.nwa", presses((2500, "ok"), (4000, "ok"), (5500, "ok"), (7000, "ok"), (8500, "ok"),+ (10500, "right", 5500)) + "," + every(11200, 16000, 900, "ok", 200),+ (10200, 16000), 20),+}+++def main():+ ids = sys.argv[1:] or list(DEMOS)+ os.makedirs(OUT, exist_ok=True)+ for gid in ids:+ app, keys, (t0, t1), fps = DEMOS[gid]+ with tempfile.TemporaryDirectory() as d:+ frames = os.path.join(d, "frames")+ subprocess.run([sys.executable, os.path.join(ROOT, "tools", "emu.py"), os.path.join(ROOT, "build", "apps", app),+ "--ms", str(t1 + 200), "--keys", keys, "--frames", frames, "--fps", str(fps), "--out", d],+ check=True, stdout=subprocess.DEVNULL)+ gif = os.path.join(OUT, gid + ".gif")+ subprocess.run([sys.executable, os.path.join(ROOT, "tools", "record.py"), "--frames", frames, "--out", d,+ "--gif", f"{t0}-{t1}:{gid}.gif", "--fps", str(fps)], check=True, stdout=subprocess.DEVNULL)+ os.replace(os.path.join(d, gid + ".gif"), gif)+ subprocess.run(["gifsicle", "-O3", "--batch", gif], check=False)+ print(f"{gid}: {os.path.getsize(gif) // 1024} KB")+++if __name__ == "__main__":+ main()