Skip to content

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.

NumPlay Studio: the space bar beside the calculator again, and the games fill their column

Mason3630cfd85f8a695
diff --git a/customize/app.css b/customize/app.css
index e131174f..e52efe4b 100644
--- a/customize/app.css
+++ b/customize/app.css
@@ -16,7 +16,7 @@
/* the columns: what NumPlay is and its games, the calculator up close, the big games and your own */
--left: clamp(330px, 29vw, 540px);
--side: clamp(250px, 21vw, 390px);
- --cw: clamp(400px, min(calc((100vh - 24px) * 0.925), calc(100vw - var(--left) - var(--side) - 40px)), 820px);
+ --cw: clamp(400px, min(calc((100vh - 24px) * 0.925), calc(100vw - var(--left) - var(--side) - 150px)), 820px);
}
* { box-sizing: border-box; }
@@ -57,6 +57,8 @@ main {
/* ---- the game grids: the same size for every game, the best first */
.grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px 12px; }
.grid.big { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px 14px; }
+/* (beside the calculator the games fill their column: app.js, fitGrid, picks how many to a row and how big) */
+.grid.small.fit { grid-template-columns: repeat(var(--cols), var(--s)); justify-content: space-between; row-gap: calc(var(--s) * 0.3); }
.grid:empty { display: none; }
.app {
@@ -110,6 +112,17 @@ body.dragging-icon, body.dragging-icon * { cursor: grabbing !important; user-sel
/* ---- the calculator, up close: its screen is the space, OK installs, Back downloads, a star sticker on it */
.device { grid-area: device; position: sticky; top: 0; height: 100vh; overflow: hidden; align-self: start; perspective: 2400px; perspective-origin: 50% 32%; }
+/* beside the calculator: the space used, a block for each game, stacked from the bottom in the launcher's order */
+.meter { position: absolute; z-index: 1; left: calc(50% - var(--cw) / 2 - 66px); width: 52px; top: calc(30px + var(--cw) * 0.105); bottom: 34px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
+.used { font-size: 18px; font-weight: 750; letter-spacing: -0.4px; font-variant-numeric: tabular-nums; line-height: 1; }
+.cap-of { font-size: 12px; font-weight: 600; color: var(--mute); white-space: nowrap; font-variant-numeric: tabular-nums; line-height: 1; }
+.bar {
+ flex: 1; width: 14px; border-radius: 7px; background: var(--track); overflow: hidden;
+ display: flex; flex-direction: column-reverse;
+ box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.12); transition: box-shadow var(--t) var(--ease);
+}
+.bar.over { box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.12), 0 0 0 3px rgba(255, 69, 58, 0.45); }
+.seg { display: block; width: 100%; flex-shrink: 0; height: 0; box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.25); transition: height var(--t) var(--ease); }
/* a real calculator, built in 3D from its photo (--u is one of the photo's pixels): the front, with holes for
the screen and the keys; the screen down in its recess with the recess's walls; the keys standing up with
their sides; rounded edges, sides and top (app.js, build3d). It faces you, and turns a little toward the
@@ -357,6 +370,7 @@ html.intro-wait main { opacity: 0; }
.games { padding: 8px 16px 0; }
.side { padding: 22px 16px 24px; }
.device { position: relative; height: calc(var(--cw) * 1.1 + 30px); margin: 8px auto 0; width: calc(var(--cw) + 40px); perspective-origin: 50% 20%; }
+ .meter { display: none; }
.foot { justify-content: center; }
}
@media (max-width: 520px) {
diff --git a/customize/app.js b/customize/app.js
index b8df112d..11453251 100644
--- a/customize/app.js
+++ b/customize/app.js
@@ -119,7 +119,7 @@
}
// ------------------------------------------------------------------ drawing
- const tiles = new Map(), buttons = new Map();
+ const tiles = new Map(), segs = new Map(), buttons = new Map();
let shownUsed = 0, previewing = null;
function render() {
@@ -165,6 +165,30 @@
});
for (const [k, e] of tiles) if (!seen.has(k)) { e.remove(); tiles.delete(k); }
+ // the bar beside it: the same blocks, stacked in the launcher's order
+ const bar = $('#bar'), keys = new Set();
+ list.forEach((it, i) => {
+ let e = segs.get(it.key);
+ if (!e) {
+ e = el('span', 'seg');
+ let next = null; // (in its place among the blocks there already)
+ for (let j = i + 1; j < list.length && !next; j++) next = segs.get(list[j].key) || null;
+ segs.set(it.key, e);
+ bar.insertBefore(e, next);
+ void e.offsetHeight; // (so its height grows from nothing)
+ }
+ e.style.height = Math.min(100, 100 * it.bytes / cap) + '%';
+ e.style.background = 'linear-gradient(90deg, ' + mix(it.color, 0.25) + ', ' + it.color + ' 55%, ' + mix(it.color, -0.3) + ')';
+ e.dataset.tip = it.name + '|' + size(it.bytes);
+ keys.add(it.key);
+ });
+ for (const [k, e] of segs) if (!keys.has(k)) { e.style.height = '0'; segs.delete(k); setTimeout(() => e.remove(), 260); }
+ const want = list.map((it) => segs.get(it.key));
+ if ([...bar.children].filter((c) => want.includes(c)).some((c, i) => c !== want[i])) for (const c of want) bar.appendChild(c);
+ bar.classList.toggle('over', over);
+ $('#used').textContent = (used / MiB).toFixed(2);
+ $('#cap-of').textContent = 'of ' + +(cap / MiB).toFixed(2) + ' MB';
+
$('#screen').classList.toggle('over', over);
$('#screen').setAttribute('aria-label', 'Space on the calculator: ' + size(used) + ' of ' + size(cap) + ', each game a block its size');
@@ -1278,6 +1302,7 @@
// 1. the calculator, then the words, then the games in their places (a wave down the grid)
anim($('.device'), [{ opacity: 0 }, { opacity: 1 }], { duration: 700, easing: 'linear' });
anim($('#calc'), [{ translate: '0 80px', scale: '0.93' }, { translate: '0 0', scale: '1' }], { duration: 1400, easing: E.out });
+ anim($('.meter'), [{ opacity: 0, transform: 'translateY(24px)' }, { opacity: 1, transform: 'none' }], { duration: 900, delay: 500, easing: E.out });
anim($('.title span'), [{ transform: 'translateY(108%)' }, { transform: 'none' }], { duration: 1000, delay: 180, easing: E.out });
anim($('.lede'), [{ opacity: 0, transform: 'translateY(16px)' }, { opacity: 1, transform: 'none' }], { duration: 900, delay: 340, easing: E.out });
anim($('.chips'), [{ opacity: 0, transform: 'translateY(10px)' }, { opacity: 1, transform: 'none' }], { duration: 800, delay: 420, easing: E.out });
@@ -1294,6 +1319,8 @@
const id = key, gi = games.indexOf(id);
const at = key === '_free' ? 700 : key === '_core' ? 980 : gi >= 0 ? T0 + gi * GAP + FLY * 0.82 : T0 + games.length * GAP + FLY;
anim(e, [{ opacity: 0, scale: '0.55' }, { opacity: 1, scale: '1' }], { duration: key === '_free' ? 500 : 620, delay: at, easing: key === '_free' ? 'linear' : E.spring });
+ const sg = segs.get(key);
+ if (sg) anim(sg, [{ height: '0%' }, { height: sg.style.height }], { duration: 560, delay: at, easing: E.out });
const it = list.find((x) => x.key === key);
if (it) landed.push([at, it.bytes]);
}
@@ -1330,6 +1357,7 @@
const target = landed.reduce((a, [at, bytes]) => a + (t >= at ? bytes : 0), 0);
shown += (target - shown) * 0.2;
$('#status-line').textContent = (shown / MiB).toFixed(2) + ' OF ' + +(cap / MiB).toFixed(2) + ' MB';
+ $('#used').textContent = (shown / MiB).toFixed(2);
$('#battery').style.width = 'calc(' + Math.min(100, 100 * shown / cap) + '% - 2px)';
if (t < end) raf = requestAnimationFrame(frame); else finish();
};
@@ -1361,6 +1389,23 @@
introRun = finish;
}
+ // the games in NumPlay fill their column down to the bottom of the window: as many to a row, and as big, as fits
+ // (in the narrower layouts, where more comes under them, five to a row)
+ function fitGrid() {
+ const box = $('#small'), n = box.children.length;
+ if (!n || innerWidth <= 1180) { box.classList.remove('fit'); return; }
+ const W = box.clientWidth, H = innerHeight - (box.getBoundingClientRect().top + scrollY) - 34;
+ let best = null;
+ for (let c = 3; c <= 7; c++) {
+ const r = Math.ceil(n / c), s = Math.min(W / (c + (c - 1) * 0.22), H / (r + (r - 1) * 0.3));
+ if (!best || s > best.s) best = { c, s };
+ }
+ if (H < 160 || best.s < 36) { box.classList.remove('fit'); return; }
+ box.style.setProperty('--cols', best.c);
+ box.style.setProperty('--s', Math.floor(Math.min(best.s, 124)) + 'px');
+ box.classList.add('fit');
+ }
+
// ------------------------------------------------------------------ start
async function start() {
try {
@@ -1404,6 +1449,9 @@
}
sortable(small);
sortable(big);
+ fitGrid();
+ addEventListener('resize', () => requestAnimationFrame(fitGrid));
+ if (document.fonts) document.fonts.ready.then(fitGrid);
// the app's settings
const sec = $('#secret');
diff --git a/customize/index.html b/customize/index.html
index a10cd7a3..1a94e3f1 100644
--- a/customize/index.html
+++ b/customize/index.html
@@ -96,6 +96,11 @@
</aside>
<section class="device" aria-label="Your calculator">
+ <div class="meter" aria-hidden="true">
+ <span id="used" class="used">0.00</span>
+ <div id="bar" class="bar"></div>
+ <span id="cap-of" class="cap-of"></span>
+ </div>
<div id="calc" class="calc">
<div class="plate">
<img class="calc-img" src="calculator.webp" alt="A NumWorks calculator" draggable="false" width="1018" height="2000">