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 calculator up close, in 3D, with a gold star sticker on it

Mason363ac0a00bcee8c
diff --git a/customize/app.css b/customize/app.css
index f0cdc83a..36b44fc4 100644
--- a/customize/app.css
+++ b/customize/app.css
@@ -1,18 +1,22 @@
:root {
- --bg: #e6e8ec;
+ --bg: #f2f1ef;
--ink: #1d1d1f;
--mute: #6e737a;
- --track: #d3d6db;
+ --track: #e3e1dd;
--card: #ffffff;
--btn: #1d1d1f;
--btn-ink: #ffffff;
- --line: #a3a8af;
+ --line: #b9b6b0;
--blue: #0a84ff;
--shadow: 0 8px 18px rgba(0, 0, 0, 0.16);
--ease: cubic-bezier(0.2, 0.9, 0.25, 1);
--spring: cubic-bezier(0.3, 1.5, 0.5, 1);
--t: 210ms;
- --cw: clamp(240px, min(27vw, calc((100vh - 170px) * 0.509)), 380px);
+ /* the calculator, up close: wide enough that its screen and OK key fill the height of the window */
+ --cw: clamp(420px, min(calc((100vh - 24px) * 0.925), calc(60vw - 80px)), 880px);
+ --plate-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1018 2000' preserveAspectRatio='none'%3E%3Cpath fill-rule='evenodd' d='M0 0H1018V2000H0Z M140 107H879A36 36 0 0 1 915 143V707A36 36 0 0 1 879 743H140A36 36 0 0 1 104 707V143A36 36 0 0 1 140 107Z'/%3E%3C/svg%3E");
+ --star-paper: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cpath d='M41.68,12.87 L57.12,36.01 L84.64,32.00 L67.40,53.83 L79.73,78.77 L53.64,69.12 L33.73,88.54 L34.84,60.75 L10.22,47.82 L36.99,40.29Z' fill='black' stroke='black' stroke-width='14' stroke-linejoin='round'/%3E%3C/svg%3E");
+ --star-foil: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cpath d='M41.68,12.87 L57.12,36.01 L84.64,32.00 L67.40,53.83 L79.73,78.77 L53.64,69.12 L33.73,88.54 L34.84,60.75 L10.22,47.82 L36.99,40.29Z' fill='black' stroke='black' stroke-width='3' stroke-linejoin='round'/%3E%3C/svg%3E");
}
* { box-sizing: border-box; }
@@ -31,64 +35,31 @@ a { color: inherit; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }
-/* ---- the top: NumPlay on calculator keys, and GitHub */
-.top { position: absolute; left: 0; right: 0; top: 0; z-index: 3; display: flex; justify-content: space-between; align-items: center; padding: 24px 32px 0; pointer-events: none; }
-.top > * { pointer-events: auto; }
-.logo { display: flex; align-items: center; gap: 12px; border: 0; background: none; padding: 0; cursor: pointer; }
-.logo-icon { width: 40px; height: 40px; border-radius: 18%; box-shadow: 0 3px 8px rgba(0, 0, 0, 0.16); transition: transform 300ms var(--spring); }
-.logo:hover .logo-icon { transform: rotate(-8deg) scale(1.06); }
-.keys { display: flex; gap: 3px; }
-.keys i {
- font-style: normal; font-weight: 700; font-size: 17px; line-height: 1;
- width: 25px; height: 29px; display: flex; align-items: center; justify-content: center;
- border-radius: 8px; color: #2a2a2c;
- background: linear-gradient(#ffffff, #ececee);
- box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.1), 0 1px 0 #c5c7cb, 0 2px 4px rgba(0, 0, 0, 0.12);
- transition: transform 90ms var(--ease), box-shadow 90ms var(--ease);
-}
-.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; }
-/* 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 .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); } }
-
+/* ---- the page: NumPlay, yours, and its games on the left; the calculator, up close, on the right */
main {
- position: relative;
- display: flex; flex-wrap: wrap; justify-content: center; align-items: center;
- gap: 32px 64px;
+ display: grid; grid-template-columns: minmax(0, 1fr) calc(var(--cw) + 96px);
+ grid-template-rows: auto 1fr; grid-template-areas: "head device" "games device";
min-height: 100vh;
- padding: 92px 40px 50px;
}
+.head { grid-area: head; display: flex; flex-wrap: wrap; align-items: flex-end; gap: 14px 16px; padding: 40px 32px 0 56px; }
+.games { grid-area: games; display: flex; flex-direction: column; gap: 14px; padding: 30px 32px 28px 56px; max-width: 560px; }
+.title { border: 0; background: none; padding: 0; cursor: pointer; text-align: left; display: flex; flex-direction: column; line-height: 0.95; }
+.title .word { font-size: clamp(52px, 5.4vw, 80px); font-weight: 800; letter-spacing: -0.045em; }
+.title .word { display: flex; }
+.title .word i { font-style: normal; display: inline-block; transition: transform 260ms var(--spring); }
+.title .word i.lift { transform: translateY(-0.12em); }
+.title:focus-visible { border-radius: 16px; }
+.chips { display: flex; gap: 8px; margin: 0 0 6px auto; }
+.lede { flex-basis: 100%; margin: 4px 0 0; min-height: 1.4em; font-size: 16px; font-weight: 550; color: #858279; transition: opacity 200ms var(--ease); }
+.lede.swap { opacity: 0; }
+.row-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 18px; font-size: 13px; font-weight: 650; color: #858279; }
+.row-head .sub { font-weight: 500; }
+.retro .row-head { justify-content: flex-start; }
/* ---- the game grids */
-.grid { display: grid; gap: 14px; }
-.grid.small { flex: 1 1 260px; max-width: 300px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
-.side { flex: 1 1 260px; max-width: 300px; display: flex; flex-direction: column; gap: 26px; }
-.grid.big { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
+.grid { display: grid; gap: 12px; }
+.grid.small { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 14px 12px; }
+.grid.big { grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 10px; }
.grid.big:empty { display: none; }
.app {
@@ -142,39 +113,88 @@ body.dragging-icon, body.dragging-icon * { cursor: grabbing !important; user-sel
75% { transform: translateX(-2px) scale(0.86); }
}
-/* ---- the calculator, its space bar and the buttons */
-.device { display: flex; align-items: flex-start; gap: 24px; }
-.side-by { display: flex; flex-direction: column; align-items: center; gap: 22px; }
-.meter { display: flex; flex-direction: column; align-items: center; gap: 10px; padding-top: calc(var(--cw) * 0.16); }
-.used { font-size: 22px; font-weight: 750; letter-spacing: -0.5px; font-variant-numeric: tabular-nums; line-height: 1; }
-.bar {
- width: 14px; height: calc(var(--cw) * 1.58); 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: 14px; flex-shrink: 0; height: 0; box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.25); transition: height var(--t) var(--ease); }
-.cap { display: flex; flex-direction: column; gap: 4px; }
+/* ---- the calculator, up close: its screen is the space, its OK key installs, a star sticker on it */
+.device { grid-area: device; position: sticky; top: 0; height: 100vh; overflow: hidden; align-self: start; perspective: 2400px; perspective-origin: 92% 30%; }
+/* a real calculator, built in 3D from its photo (--u is one of the photo's pixels): the front, with a hole
+ where the screen is, the screen down in its recess, the recess's walls, rounded edges and sides, and the
+ top (made by app.js, build3d). It turns a little toward the pointer (--rx, --ry) */
+.calc {
+ position: absolute; left: 40px; top: 30px; width: var(--cw); aspect-ratio: 1018 / 2000; --u: calc(var(--cw) / 1018);
+ transform-style: preserve-3d; transform-origin: 50% 24%; transform: rotateX(var(--rx, 2deg)) rotateY(var(--ry, -12deg));
+}
+.plate, .well, .body3d { position: absolute; inset: 0; }
+.plate { container-type: inline-size; pointer-events: none; }
+.plate > button, #screen { pointer-events: auto; }
+.calc, .well, .body3d { pointer-events: none; } /* (so a click on the sticker, lying on them, is the sticker's) */
+.sticker { pointer-events: auto; }
+.calc-img, .well-img { position: absolute; inset: 0; width: 100%; height: 100%; user-select: none; pointer-events: none; }
+.calc-img {
+ clip-path: inset(0 2.947% 0 2.947%);
+ -webkit-mask: var(--plate-mask) 0 0 / 100% 100% no-repeat; mask: var(--plate-mask) 0 0 / 100% 100% no-repeat;
+}
+.well { transform: translateZ(calc(var(--u) * -14.6)); } /* (a hair under the sticker, which lies on it at 14) */
+.well-img { clip-path: inset(5.35% 10.118% 62.85% 10.216% round calc(var(--u) * 36)); }
+.body3d, .fold, .sticker { transform-style: preserve-3d; }
+.fold { position: absolute; top: 0; height: 100%; width: 0; transform-origin: 0 0; }
+.facet { position: absolute; top: 0; height: 100%; display: block; }
+.body3d .top { position: absolute; left: 0; top: 0; width: 100%; transform-origin: 0 0; transform: rotateX(-90deg); display: block; }
+.body3d .rim { position: absolute; transform-origin: 0 0; display: block; }
+.cap { display: flex; gap: 2px; background: var(--track); border-radius: 999px; padding: 2px; }
.cap button {
- border: 0; background: transparent; padding: 3px 7px; border-radius: 999px; cursor: pointer;
- font-size: 12px; font-weight: 650; color: var(--mute); white-space: nowrap;
+ border: 0; background: transparent; padding: 4px 10px; border-radius: 999px; cursor: pointer;
+ font-size: 12px; font-weight: 650; color: #858279; white-space: nowrap;
transition: background var(--t) var(--ease), color var(--t) var(--ease);
}
-.cap button[aria-checked="true"] { background: var(--btn); color: var(--btn-ink); }
-
-.calc { position: relative; width: var(--cw); aspect-ratio: 1018 / 2000; }
-.calc-img { position: absolute; inset: 0; width: 100%; height: 100%; user-select: none; filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.1)) drop-shadow(0 18px 26px rgba(0, 0, 0, 0.12)); }
-/* the shadow on the table: a soft wide one, and a darker one where it touches */
-.calc .shadow { position: absolute; left: 6%; right: 6%; bottom: -2.2%; height: 6%; pointer-events: none; }
-.calc .shadow::before, .calc .shadow::after { content: ""; position: absolute; border-radius: 50%; }
-.calc .shadow::before { inset: -40% -12%; background: radial-gradient(closest-side, rgba(30, 34, 44, 0.22), rgba(30, 34, 44, 0)); filter: blur(10px); }
-.calc .shadow::after { left: 8%; right: 8%; top: 28%; height: 34%; background: radial-gradient(closest-side, rgba(20, 22, 30, 0.38), rgba(20, 22, 30, 0)); filter: blur(4px); }
+.cap button[aria-checked="true"] { background: var(--card); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1); }
+/* OK, on the keypad (its key, 718,922 r 56 in the picture's pixels), with a tag under it */
+.ok-key {
+ position: absolute; left: 65.03%; top: 43.3%; width: 11%; aspect-ratio: 1; border: 0; padding: 0; border-radius: 50%;
+ background: transparent; cursor: pointer; -webkit-tap-highlight-color: transparent;
+ transition: background 120ms var(--ease), box-shadow 120ms var(--ease);
+}
+.ok-key::after { content: ""; position: absolute; inset: 0; border-radius: 50%; pointer-events: none; animation: okpulse 2.4s ease-out infinite; }
+.ok-key:hover { background: rgba(0, 0, 0, 0.04); }
+.ok-key:hover::after { animation: none; }
+.ok-key:active { background: rgba(0, 0, 0, 0.08); box-shadow: inset 0 3px 8px rgba(0, 0, 0, 0.18); }
+.ok-key:focus-visible { outline-offset: 4px; border-radius: 50%; }
+@keyframes okpulse { 0% { box-shadow: 0 0 0 0 rgba(255, 183, 52, 0.7); } 70% { box-shadow: 0 0 0 1.8cqw rgba(255, 183, 52, 0); } 100% { box-shadow: 0 0 0 0 rgba(255, 183, 52, 0); } }
+.ok-tag {
+ position: absolute; left: 50%; top: calc(100% + 1.3cqw); transform: translateX(-50%); white-space: nowrap;
+ background: var(--btn); color: var(--btn-ink); font-size: max(13px, 1.75cqw); font-weight: 700; padding: 0.75cqw 1.5cqw; border-radius: 1cqw;
+ transition: transform var(--t) var(--spring);
+}
+.ok-key:hover .ok-tag { transform: translateX(-50%) translateY(-1px) scale(1.04); }
+.ok-key.busy::after { animation: spin 700ms linear infinite; border: 0.35cqw solid #ffb734; border-right-color: transparent; inset: -0.6cqw; }
+.ok-key.busy .ok-tag { opacity: 0.6; }
+/* the .nwa itself: a small tag under Back, beside Install */
+.dl {
+ position: absolute; left: 84.28%; top: calc(48.9% + 1.3cqw); transform: translateX(-50%); white-space: nowrap; cursor: pointer;
+ display: flex; align-items: center; gap: 0.6cqw; border: 1px solid #d6d4cf; background: #ffffff; color: var(--ink);
+ font-size: max(12px, 1.5cqw); font-weight: 650; padding: 0.7cqw 1.2cqw; border-radius: 1cqw;
+ transition: transform var(--t) var(--spring), border-color var(--t) var(--ease);
+}
+.dl::before { content: ""; width: 1.1em; height: 1.1em; background: currentColor;
+ -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 4v11'/%3E%3Cpath d='M7 10l5 5 5-5'/%3E%3Cpath d='M5 20h14'/%3E%3C/svg%3E") center / contain no-repeat;
+ mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 4v11'/%3E%3Cpath d='M7 10l5 5 5-5'/%3E%3Cpath d='M5 20h14'/%3E%3C/svg%3E") center / contain no-repeat; }
+.dl:hover { transform: translateX(-50%) translateY(-1px); border-color: #b9b6b0; }
+.dl.busy { opacity: 0.5; }
+/* GitHub: a die-cut star sticker of gold foil, stuck on the calculator by its screen: flat on the frame,
+ down the step into the screen's recess, and round the edge onto the side (app.js folds it, build3d).
+ Each piece shows its own part of one picture (.art, drawn by app.js's stickerRenderer), and the part
+ round the edge peels up under the pointer (--b0 --b1 --b2, app.js) */
+.sticker { position: absolute; text-decoration: none; -webkit-tap-highlight-color: transparent; }
+.sticker:focus-visible { outline-offset: 2px; border-radius: 8px; }
+.leaf { position: absolute; top: 0; height: 100%; overflow: hidden; display: block; transform: translateZ(calc(var(--u) * 0.5)); } /* (a hair off the plastic, as a sticker is) */
+.art, .shade { position: absolute; top: 0; width: var(--star); height: var(--star); display: block; }
+/* each piece's light, darker as it turns away (app.js, shadeStar): over the sticker's own shape only */
+.shade { -webkit-mask: var(--star-paper) center / 100% 100% no-repeat; mask: var(--star-paper) center / 100% 100% no-repeat; background-repeat: no-repeat; }
.screen {
position: absolute; left: 14.538%; top: 7.7%; width: 70.923%; height: 27.1%;
background: #0c0d10; overflow: hidden; container-type: size;
}
+/* the glass over the screen: a soft reflection that moves as the calculator turns */
+.glass { position: absolute; inset: 0; z-index: 6; pointer-events: none;
+ background: linear-gradient(112deg, rgba(255, 255, 255, 0) 30%, rgba(255, 255, 255, 0.07) 42%, rgba(255, 255, 255, 0.02) 50%, rgba(255, 255, 255, 0) 58%) var(--lx, 60%) 0 / 260% 100% no-repeat; }
.status {
position: absolute; left: 0; top: 0; right: 0; height: 7.5%;
background: #ffb734; color: #ffffff;
@@ -207,7 +227,6 @@ body.dragging-icon, body.dragging-icon * { cursor: grabbing !important; user-sel
}
body.dragging .drop-hint { opacity: 1; }
-.actions { display: flex; align-items: center; gap: 10px; }
.chip {
height: 46px; padding: 0 10px 0 9px; border: 0; border-radius: 23px; background: var(--card); cursor: pointer;
display: flex; align-items: center; gap: 6px; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
@@ -232,17 +251,6 @@ body.dragging .drop-hint { opacity: 1; }
border: 2.4px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin 600ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
-.round {
- width: 46px; height: 46px; border-radius: 23px; border: 0; cursor: pointer;
- background: var(--card); color: var(--ink); display: flex; align-items: center; justify-content: center;
- box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
- transition: transform var(--t) var(--spring);
-}
-.round:hover { transform: translateY(-2px); }
-.round:active { transform: scale(0.92); transition-duration: 80ms; }
-.round.busy svg { animation: drop 700ms var(--ease) infinite; }
-@keyframes drop { 0% { transform: translateY(-3px); opacity: 0.4; } 60% { transform: translateY(2px); opacity: 1; } 100% { transform: translateY(2px); opacity: 0.4; } }
-
/* ---- the app's own settings: two small panels over the chips */
.pop {
position: fixed; z-index: 25; width: 330px; background: var(--card); border-radius: 18px; padding: 16px;
@@ -277,36 +285,19 @@ body.dragging .drop-hint { opacity: 1; }
.xl-guide { font-size: 13px; font-weight: 650; color: var(--blue); text-decoration: none; }
.xl-ok { padding: 10px 20px; font-size: 14px; }
-/* ---- Retro-Go: drop your games, they come in as cartridges */
-.retro { display: flex; flex-direction: column; gap: 12px; }
-.retro-head { display: flex; align-items: center; gap: 10px; }
-.retro-head img { width: 34px; height: 34px; border-radius: 18%; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15); }
-.retro-head b { display: block; font-size: 15px; }
-.retro-head .systems { display: block; font-size: 12px; color: var(--mute); font-weight: 600; }
-.drop {
- position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; cursor: pointer;
- border: 2px dashed var(--line); border-radius: 16px; padding: 18px 12px 14px; text-align: center;
- transition: border-color var(--t) var(--ease), background var(--t) var(--ease), transform var(--t) var(--spring);
-}
-.drop:hover, body.dragging .drop { border-color: var(--blue); background: rgba(10, 132, 255, 0.06); }
-.drop:active { transform: scale(0.98); }
-.drop-art { position: relative; width: 74px; height: 46px; margin-bottom: 4px; }
-.drop-art i { position: absolute; bottom: 0; width: 30px; height: 36px; border-radius: 3px 8px 3px 3px; box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.12); transition: transform 260ms var(--spring); }
-.drop-art i::after { content: ""; position: absolute; left: 4px; right: 4px; bottom: 7px; height: 14px; border-radius: 2px; }
-.drop-art .c1 { left: 0; background: #c9c9cf; transform: rotate(-12deg); }
-.drop-art .c1::after { background: #6d8a0c; }
-.drop-art .c2 { left: 22px; background: #d9d9de; z-index: 1; }
-.drop-art .c2::after { background: #c43a2f; }
-.drop-art .c3 { right: 0; background: #cfd6e4; transform: rotate(12deg); }
-.drop-art .c3::after { background: #2f62c4; }
-.drop:hover .c1, body.dragging .c1 { transform: rotate(-18deg) translateY(-4px); }
-.drop:hover .c2, body.dragging .c2 { transform: translateY(-8px); }
-.drop:hover .c3, body.dragging .c3 { transform: rotate(18deg) translateY(-4px); }
-.drop-text { font-size: 15px; font-weight: 700; }
-.drop-sub { font-size: 12px; color: var(--mute); font-weight: 600; letter-spacing: 0.02em; }
+/* ---- Retro-Go: your games come in as cartridges, after a + cartridge */
+.retro { display: flex; flex-direction: column; gap: 10px; }
+.carts-row { display: flex; flex-wrap: wrap; gap: 10px; }
.retro input[type=file] { position: absolute; left: -9999px; }
-.carts { display: flex; flex-wrap: wrap; gap: 10px; }
-.carts:empty { display: none; }
+.add-cart {
+ width: 52px; height: 62px; border-radius: 5px 13px 5px 5px; border: 2px dashed var(--line); color: #858279; cursor: pointer;
+ display: flex; align-items: center; justify-content: center;
+ transition: border-color var(--t) var(--ease), background var(--t) var(--ease), transform var(--t) var(--spring), color var(--t) var(--ease);
+}
+.add-cart:hover, body.dragging .add-cart { border-color: var(--ink); color: var(--ink); transform: translateY(-3px); }
+.add-cart:active { transform: scale(0.94); }
+.add-cart.shake { animation: shake 300ms var(--ease); }
+.carts { display: contents; }
.cart {
position: relative; width: 52px; height: 62px; border: 0; padding: 0; cursor: pointer;
border-radius: 5px 13px 5px 5px; display: flex; flex-direction: column; justify-content: flex-end;
@@ -326,12 +317,6 @@ body.dragging .drop-hint { opacity: 1; }
@keyframes slot { 0% { transform: translateY(-18px) scale(0.8); opacity: 0; } 100% { transform: none; opacity: 1; } }
/* ---- the intro: a few words, the calculator filling up, then the studio */
-.caption {
- position: fixed; left: 50%; top: 22px; z-index: 30; transform: translate(-50%, 8px); pointer-events: none;
- font-size: clamp(24px, 3vw, 40px); font-weight: 800; letter-spacing: -1px; text-align: center; white-space: nowrap;
- opacity: 0; transition: opacity 320ms var(--ease), transform 420ms var(--ease);
-}
-.caption.show { opacity: 1; transform: translate(-50%, 0); }
.intro-skip {
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;
@@ -345,10 +330,10 @@ body.intro .calc { z-index: 2; }
.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)); }
+.drop-cart { position: fixed; z-index: 35; width: 52px; height: 62px; border-radius: 5px 13px 5px 5px; pointer-events: none; box-shadow: inset 0 -6px 0 rgba(0, 0, 0, 0.12); }
+.drop-cart::after { content: ""; position: absolute; left: 6px; right: 6px; bottom: 10px; height: 26px; border-radius: 3px; background: var(--c); }
.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; }
+.press-ring { position: absolute; inset: 0; border-radius: 50%; border: 0.4cqw solid #ffb734; pointer-events: none; }
/* ---- tooltip, toast and the install sheet */
.tip {
@@ -386,34 +371,32 @@ body.intro .calc { z-index: 2; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(14px) scale(0.97); opacity: 0; } }
-.foot { position: absolute; right: 32px; bottom: 18px; font-size: 12px; color: var(--mute); display: flex; gap: 8px; }
+.foot { margin-top: auto; padding-top: 22px; font-size: 12px; color: var(--mute); display: flex; gap: 8px; }
.foot a { color: var(--mute); text-decoration: none; }
.foot a:hover { color: var(--ink); }
.noscript { text-align: center; padding: 0 16px; }
-/* ---- narrow screens: the calculator first, the games below */
-@media (max-width: 980px) {
- :root { --cw: min(300px, 62vw); }
- .top { padding: 16px 16px 0; }
- .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; }
- .grid.small { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; }
- .grid.big { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
- .foot { position: static; justify-content: center; padding: 0 16px 24px; }
- .caption { top: 18px; white-space: normal; width: calc(100vw - 32px); }
+/* ---- narrow screens: NumPlay, yours, then the calculator, then the games */
+@media (max-width: 900px) {
+ :root { --cw: min(560px, calc(100vw - 32px)); }
+ main { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto auto; grid-template-areas: "head" "device" "games"; }
+ .head { padding: 24px 16px 0; }
+ .games { padding: 8px 16px 24px; max-width: none; }
+ .device { position: relative; height: calc(var(--cw) * 1.1 + 30px); margin: 8px auto 0; width: calc(var(--cw) + 40px); perspective-origin: 50% 20%; }
+ .calc { left: 20px; --ry: -8deg; }
+ .foot { justify-content: center; }
+}
+@media (max-width: 600px) {
+ .dl { font-size: 0; gap: 0; padding: 7px 8px; } /* (just the arrow, beside Install) */
+ .dl::before { width: 14px; height: 14px; }
}
@media (max-width: 420px) {
- .keys i { width: 21px; height: 26px; font-size: 15px; }
- .logo-icon { width: 34px; height: 34px; }
.grid.small { grid-template-columns: repeat(5, minmax(0, 1fr)); }
- .grid.big { grid-template-columns: repeat(4, minmax(0, 1fr)); }
- .actions { gap: 8px; }
+ .grid.big { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.chip { padding: 0 8px 0 7px; }
.pop { width: calc(100vw - 32px); }
}
@media (prefers-reduced-motion: reduce) {
:root { --t: 1ms; }
- .app.bounce, .app.shake, .cart.enter, .sheet, .sheet-card, .pop { animation: none; }
+ .app.bounce, .app.shake, .cart.enter, .sheet, .sheet-card, .pop, .ok-key::after { animation: none; }
}
diff --git a/customize/app.js b/customize/app.js
index 08c78bd2..4121daa6 100644
--- a/customize/app.js
+++ b/customize/app.js
@@ -119,7 +119,7 @@
}
// ------------------------------------------------------------------ drawing
- const tiles = new Map(), segs = new Map(), buttons = new Map();
+ const tiles = new Map(), buttons = new Map();
let shownUsed = 0, tween = 0, previewing = null;
function render() {
@@ -173,31 +173,7 @@
});
for (const [k, e] of tiles) if (!seen.has(k)) { e.classList.add('leave'); tiles.delete(k); setTimeout(() => e.remove(), 260); }
- // 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); }
- // (the order of the blocks follows the games' order)
- const want = list.map((it) => segs.get(it.key));
- const live = [...bar.children].filter((c) => want.includes(c));
- if (live.some((c, i) => c !== want[i])) for (const c of want) bar.appendChild(c);
- bar.classList.toggle('over', over);
$('#screen').classList.toggle('over', over);
- bar.setAttribute('aria-label', 'Space used: ' + size(used) + ' of ' + size(cap));
$('#screen').setAttribute('aria-label', 'Space on the calculator: ' + size(used) + ' of ' + size(cap) + ', each game a block its size');
// the numbers
@@ -206,7 +182,6 @@
if (cancel !== tween) return;
const k = Math.min(1, Math.max(0, (now - t0) / 220)), e = 1 - Math.pow(1 - k, 3); // (a frame's time can be before t0)
shownUsed = from + (used - from) * e;
- $('#used').textContent = (shownUsed / MiB).toFixed(2);
if (!previewing) $('#status-line').textContent = (shownUsed / MiB).toFixed(2) + ' OF ' + +(cap / MiB).toFixed(2) + ' MB';
$('#battery').style.width = 'calc(' + Math.min(100, 100 * shownUsed / cap) + '% - 2px)';
if (k < 1) requestAnimationFrame(step);
@@ -232,7 +207,7 @@
const s = solo(), file = s ? byId[s].alone.file : 'NumPlay.nwa';
for (const c of [$('#app-chip'), $('#lang-chip')]) c.disabled = !!s;
$('#download').setAttribute('aria-label', 'Download ' + file);
- $('#download').dataset.tip = 'Download ' + file;
+ $('#download').textContent = file;
$('#app-chip-icon').src = iconUrl();
$('#lang-chip-label').textContent = LANGS[st.lang][0];
renderCarts();
@@ -294,7 +269,7 @@
}
function overflow(bytes) {
toast("That doesn't fit: " + size(bytes) + ' too much' + (st.cap === 'std' ? '. 6 MB can take more' : ''));
- $('#bar').classList.add('over');
+ $('#screen').classList.add('over');
setTimeout(() => render(), 500);
}
function toggle(id, quiet) {
@@ -819,17 +794,21 @@
}
// ------------------------------------------------------------------ the intro
- // 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.
+ // The first time (and when the title is clicked): the calculator rises and boots, NumPlay's
+ // letters come up off its keypad to make the title, the games fly into its screen one by one,
+ // Retro-Go's cartridges drop into their slot, the star sticker goes on and OK presses itself.
+ // The line under the title says what's happening; 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]];
+ const LEDE = 'Free games for your NumWorks. Pick yours, then press OK.';
+ let ledeTimer = 0;
function caption(text) {
const c = $('#caption');
- c.classList.remove('show');
- setTimeout(() => { c.textContent = text; if (text) c.classList.add('show'); }, text ? 160 : 0);
+ clearTimeout(ledeTimer);
+ c.classList.add('swap');
+ ledeTimer = setTimeout(() => { c.textContent = text || LEDE; c.classList.remove('swap'); }, 200);
}
function play(e, frames, opts) {
const a = e.animate(frames, { fill: 'backwards', ...opts });
@@ -845,13 +824,15 @@
intro.on = true;
const run = ++intro.run, alive = () => intro.on && intro.run === run;
closePops(); hidePreview();
+ scrollTo(0, 0);
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;
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')];
+ const letters = [...document.querySelectorAll('.title .word i')];
+ const hide = [$('#calc'), ...letters, $('#caption'), document.querySelector('.chips'), $('#star'),
+ $('#install'), $('#download'), ...buttons.values(), ...document.querySelectorAll('.row-head'), $('#retro'), document.querySelector('.foot')];
for (const e of hide) e.classList.add('ih');
render();
const skip = temp(el('button', 'intro-skip', { type: 'button' }));
@@ -859,7 +840,7 @@
skip.addEventListener('click', endIntro);
body.appendChild(skip);
- // the screen, off; it boots to NumPlay's splash
+ // the calculator comes up, its 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>';
@@ -867,8 +848,7 @@
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 });
+ await play(calc, [{ opacity: 0, translate: '0 55vh' }, { opacity: 1, offset: 0.3 }, { opacity: 1, translate: '0 0' }], { 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' });
@@ -877,38 +857,29 @@
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
+ // NumPlay's letters come up off the keypad, key by key, and make the title
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);
+ const flights = letters.map((key, i) => {
+ const [kx, ky] = LETTER_KEYS[i], sx = cr.left + kx * k, sy = cr.top + ky * k;
+ const [fx, fy] = center(key.getBoundingClientRect());
+ const dx = sx - fx, dy = sy - fy, lift = Math.min(220, Math.abs(dy) * 0.3), d = 80 * i;
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 });
+ { opacity: 0, transform: `translate(${dx}px, ${dy}px) scale(0.45) rotate(0deg)` },
+ { opacity: 1, offset: 0.12, transform: `translate(${dx}px, ${dy - 20}px) scale(0.5) rotate(-8deg)` },
+ { offset: 0.6, transform: `translate(${dx * 0.3}px, ${dy * 0.3 - lift}px) scale(0.9) rotate(${i % 2 ? 12 : -12}deg)` },
+ { opacity: 1, transform: 'translate(0, 0) scale(1) rotate(0deg)' }], { duration: 860, delay: d, 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;
- // the games wave in, then fly into the calculator, which fills up block by block
+ // the games come in, then fly into the calculator, which fills up block by block
caption('Free games for your NumWorks');
- 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);
+ play($('#caption'), [{ opacity: 0 }, { opacity: 1 }], { duration: 300, delay: 200 });
+ const all = [...buttons.values()];
+ all.forEach((b, i) => play(b, [{ opacity: 0, transform: 'translateY(22px) scale(0.5)' }, { opacity: 0.5, transform: 'translateY(0) scale(0.9)' }],
+ { duration: 460, delay: 14 * i, easing: SPRING }));
+ for (const h of document.querySelectorAll('.games .row-head')) if (!h.closest('#retro')) play(h, [{ opacity: 0 }, { opacity: 1 }], { duration: 400, delay: 300 });
+ await wait(420 + 14 * all.length);
if (!alive()) return;
caption('Pick the ones you want');
play(splash, [{ opacity: 1, transform: 'scale(1)' }, { opacity: 0, transform: 'scale(1.3)' }], { duration: 380, delay: 200, fill: 'forwards' });
@@ -923,6 +894,7 @@
render();
bump(b, 'bounce');
const t = tiles.get(id), mr = map.getBoundingClientRect();
+ if (!t) { await wait(step); continue; }
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: '' }));
@@ -930,8 +902,8 @@
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' })
+ { offset: 0.55, transform: `translate(${dx * 0.55}px, ${dy * 0.55 - 70}px) scale(0.85) rotate(${dx > 0 ? 18 : -18}deg)`, opacity: 1 },
+ { transform: `translate(${dx}px, ${dy}px) scale(0.3) rotate(0)`, opacity: 0.2 }], { duration: 640, easing: 'cubic-bezier(0.5, 0, 0.2, 1)', fill: 'forwards' })
.then(() => g.remove());
await wait(step);
}
@@ -941,29 +913,43 @@
// Retro-Go: three cartridges drop into its slot
if (rg) {
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);
+ play($('#retro .row-head'), [{ opacity: 0 }, { opacity: 1 }], { duration: 300 });
+ await play($('#retro'), [{ opacity: 0, transform: 'translateY(16px)' }, { opacity: 1, transform: 'none' }], { duration: 460, easing: OUT });
+ const slot = $('#drop').getBoundingClientRect();
+ const drops = [[SYS[1], -16, -40], [SYS[3], 10, 25], [SYS[4], -4, 50]].map(([sys, x, rot], i) => {
+ const c = temp(el('i', 'drop-cart'));
+ Object.assign(c.style, { left: slot.left + 'px', top: slot.top + 'px', background: sys.shell });
+ c.style.setProperty('--c', sys.color);
+ body.appendChild(c);
+ return play(c, [{ opacity: 0, transform: `translate(${x}px, -${200 + 50 * i}px) rotate(${rot}deg)` }, { opacity: 1, offset: 0.25 },
+ { opacity: 1, offset: 0.85, transform: 'translate(0, 0) rotate(0deg)' }, { opacity: 0, transform: 'translate(0, 6px) scale(0.9)' }],
+ { duration: 820, delay: 150 * i, easing: 'cubic-bezier(0.35, 1.4, 0.55, 1)', fill: 'forwards' });
+ });
+ await Promise.all(drops);
+ play($('#drop'), [{ transform: 'scale(1)' }, { transform: 'scale(1.08)', offset: 0.4 }, { transform: 'scale(1)' }], { duration: 360 });
+ await wait(500);
if (!alive()) return;
}
- // and Install presses itself
- caption('Install it in one click');
- 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 });
+ // the star sticker goes on, and OK presses itself
+ caption('Press OK to install');
+ const lift = calc.getBoundingClientRect().width / 1018 * 160; // (from above, onto the calculator)
+ play($('#star'), [{ opacity: 0, transform: 'translateZ(' + lift + 'px) rotateZ(-30deg)' }, { opacity: 1, offset: 0.3 },
+ { opacity: 1, transform: 'translateZ(0) rotateZ(0deg)' }], { duration: 620, easing: SPRING });
+ play(document.querySelector('.chips'), [{ opacity: 0, transform: 'translateY(10px)' }, { opacity: 1, transform: 'none' }], { duration: 460, easing: OUT });
play(document.querySelector('.foot'), [{ opacity: 0 }, { opacity: 1 }], { duration: 600 });
- await wait(200);
+ const ok = $('#install');
+ await play(ok, [{ opacity: 0 }, { opacity: 1 }], { duration: 300 });
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' });
+ await wait(300);
+ await play(ok, [{ background: 'rgba(0, 0, 0, 0)', boxShadow: 'inset 0 0 0 rgba(0, 0, 0, 0)' },
+ { background: 'rgba(0, 0, 0, 0.08)', boxShadow: 'inset 0 3px 8px rgba(0, 0, 0, 0.2)', offset: 0.3 },
+ { background: 'rgba(0, 0, 0, 0)', boxShadow: 'inset 0 0 0 rgba(0, 0, 0, 0)' }], { duration: 420, 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);
+ ok.appendChild(ring);
+ play($('#download'), [{ opacity: 0 }, { opacity: 1 }], { duration: 500 });
+ await play(ring, [{ opacity: 0.9, transform: 'scale(1)' }, { opacity: 0, transform: 'scale(1.7)' }], { duration: 700, easing: 'ease-out', fill: 'forwards' });
+ await wait(700);
if (alive()) endIntro();
}
function endIntro() {
@@ -982,21 +968,318 @@
render();
}
- // ------------------------------------------------------------------ the logo's keys, GitHub
+ // ------------------------------------------------------------------ the calculator in 3D, and its sticker
+ // The calculator is built from its photo (1018 by 2000 pixels; --u is one of them on the page): its front
+ // has a hole where the screen sits, down in a recess 14 deep, with the recess's walls round it; its long
+ // edges are rounded (a quarter circle of 30, as the photo shows them) before its sides, 132 deep. The
+ // star sticker is one piece of foil laid over all of that: flat on the frame by the screen, down the step
+ // into the recess, and round the edge onto the side. Each surface is lit from the same light.
+ const STAR = { size: 230, from: 849, lip: 915, step: 14, edge: 988, top: 215 }; // (the artwork's span, unfolded)
+ const EDGE_R = 30, EDGE_N = 9, EDGE_C = 2 * EDGE_R * Math.sin(Math.PI / 4 / EDGE_N), DEPTH = 132;
+ const EDGE_A = Array.from({ length: EDGE_N }, (_, i) => (i + 0.5) * 90 / EDGE_N); // (each facet's angle)
+ const LIGHT = [-0.25, -0.6, 0.76];
+ const lit = (n) => 0.78 + 0.22 * (n[0] * LIGHT[0] + n[1] * LIGHT[1] + n[2] * LIGHT[2]) / 0.76; // (the front is 1)
+ const U = (n) => 'calc(var(--u) * ' + (+n.toFixed(3)) + ')';
+ const grey = (n, base) => { const v = Math.round(Math.min(255, base * lit(n))); return 'rgb(' + v + ',' + v + ',' + v + ')'; };
+ const part = (parent, tag, cls, css) => { const e = el(tag, cls); Object.assign(e.style, css); parent.appendChild(e); return e; };
+ const deg = (a) => a * Math.PI / 180;
+ // The sticker itself is a picture drawn by a small WebGL shader, from a map of what's where on it (drawn
+ // with a 2D canvas: the white vinyl die-cut round a star, the gold foil on it, the ink printed on the foil,
+ // and the height of it all, for its rounded edge and the line embossed in the foil). The vinyl is matte
+ // white with a soft edge and a thin shadow under it; the foil is metal, so it shows the room it's in (soft
+ // lights up left and up right, a strip light above, a darker floor), with a fine grain, and that sliding
+ // across it as the calculator turns; the ink is matte; a clear gloss coat over it all catches the
+ // pointer's light. Every piece of the sticker on the calculator copies this one picture.
+ const ART = 512;
+ const sticker = { draw: null, leaves: [], text: ['STAR', 'ON GITHUB'], view: [0.3, 0.05], light: [-0.5, 0.6, 0.8] };
+ function starPath(ctx, k, scale) { // (the star of app.css's --star-paper: 100 units, turned -12 degrees)
+ ctx.beginPath();
+ for (let i = 0; i < 10; i++) {
+ const a = deg(-90 + 36 * i - 12), r = (i % 2 ? 17.5 : 40) * scale;
+ const x = (50 + r * Math.cos(a)) * k, y = (52 + r * Math.sin(a)) * k;
+ if (i) ctx.lineTo(x, y); else ctx.moveTo(x, y);
+ }
+ ctx.closePath();
+ }
+ function stickerMap() {
+ const k = ART / 100;
+ const layer = (draw, blur) => {
+ const c = el('canvas');
+ c.width = c.height = ART;
+ const x = c.getContext('2d', { willReadFrequently: true });
+ if (blur) x.filter = 'blur(' + blur + 'px)';
+ x.fillStyle = x.strokeStyle = '#ffffff';
+ x.lineJoin = 'round';
+ draw(x);
+ return x.getImageData(0, 0, ART, ART).data;
+ };
+ const font = (w, px) => w + ' ' + px + 'px -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif';
+ const vinyl = (x) => { starPath(x, k, 1); x.lineWidth = 14 * k; x.fill(); x.stroke(); };
+ const foil = (x) => { starPath(x, k, 1); x.lineWidth = 3 * k; x.fill(); x.stroke(); };
+ const ridge = (x) => { starPath(x, k, 0.8); x.lineWidth = 0.8 * k; x.stroke(); };
+ const ink = (x) => {
+ const [big, small] = sticker.text;
+ x.translate(50 * k, 53 * k);
+ x.rotate(deg(-12));
+ x.textAlign = 'center';
+ x.font = font(800, (big.length > 3 ? 11.5 : 14.5) * k);
+ x.fillText(big, 0, 2.5 * k);
+ x.font = font(750, 3.6 * k);
+ if ('letterSpacing' in x) x.letterSpacing = (0.5 * k) + 'px';
+ x.fillText(small, 0, 8.6 * k);
+ };
+ const V = layer(vinyl), F = layer(foil), I = layer(ink), Vb = layer(vinyl, 0.9 * k), Fb = layer(foil, 0.3 * k), Rb = layer(ridge, 0.35 * k);
+ const out = new Uint8Array(ART * ART * 4);
+ for (let i = 3; i < out.length; i += 4) {
+ out[i - 3] = V[i]; out[i - 2] = F[i]; out[i - 1] = I[i];
+ out[i] = Math.min(255, Vb[i] * 0.6 + Fb[i] * 0.16 + Rb[i] * 0.3 + I[i] * 0.04);
+ }
+ return out;
+ }
+ const STICKER_FS = `precision highp float;
+ varying vec2 uv;
+ uniform sampler2D map;
+ uniform vec3 light; // toward the light, in the sticker's space (x right, y up, z out of it)
+ uniform vec2 view; // where the viewer is, as the calculator turns
+ uniform float px;
+ uniform float shadowed; // (the pieces round the edge overlap a little: only the flat ones draw the shadow)
+ float H(vec2 q) { return texture2D(map, q).a; }
+ float hash(vec2 q) { return fract(sin(dot(q, vec2(12.9898, 78.233))) * 43758.5453); }
+ float blob(vec2 q, vec2 c, float r) { vec2 d = q - c; return exp(-dot(d, d) / r); }
+ // the room behind the viewer, as a mirror at this angle sees it: brighter above, a soft box up left, a
+ // strip light across the ceiling, a window to the right, something dark low down
+ float room(vec3 R) {
+ vec2 q = R.xy / max(R.z, 0.2);
+ float e = 0.34 + 0.24 * clamp(q.y + 0.35, 0.0, 1.0);
+ e += 1.3 * blob(q, vec2(-0.55, 0.12), 0.035);
+ e += 0.85 * exp(-pow((q.y - 0.3 + 0.18 * q.x) / 0.035, 2.0));
+ e += 0.75 * blob(q, vec2(0.22, -0.08), 0.02);
+ e -= 0.24 * blob(q, vec2(-0.25, -0.5), 0.06);
+ return max(e, 0.05);
+ }
+ void main() {
+ vec4 m = texture2D(map, uv);
+ float g = hash(floor(uv * 640.0));
+ vec3 n = normalize(vec3((H(uv - vec2(px, 0.0)) - H(uv + vec2(px, 0.0))) * 9.0 + (g - 0.5) * 0.05 * m.g,
+ (H(uv + vec2(0.0, px)) - H(uv - vec2(0.0, px))) * 9.0 + (hash(floor(uv * 640.0) + 7.0) - 0.5) * 0.05 * m.g, 1.0));
+ vec2 p = (uv - 0.5) * vec2(1.0, -1.0);
+ vec3 V = normalize(vec3(view - p * 0.9, 1.0)), L = normalize(light), R = reflect(-V, n);
+ float e = room(R) + 1.1 * pow(max(dot(R, L), 0.0), 16.0);
+ float flake = pow(g, 28.0) * pow(max(dot(R, L), 0.0), 3.0) * 1.4;
+ vec3 gold = vec3(1.0, 0.76, 0.33);
+ vec3 foil = gold * e * (0.92 + 0.16 * g) + vec3(1.0, 0.95, 0.82) * (pow(max(e - 0.9, 0.0), 2.0) * 0.5 + flake);
+ float diff = max(dot(n, L), 0.0);
+ vec3 vinyl = vec3(0.968, 0.964, 0.955) * (0.8 + 0.2 * diff) * (0.985 + 0.03 * hash(floor(uv * 860.0)));
+ vec3 ink = vec3(0.2, 0.12, 0.02) * (0.85 + 0.15 * diff);
+ vec3 c = mix(vinyl, foil, m.g);
+ c = mix(c, ink, m.b * m.g);
+ vec3 h = normalize(L + V);
+ c += pow(max(dot(n, h), 0.0), 160.0) * 0.6 + pow(1.0 - max(dot(n, V), 0.0), 4.0) * 0.1;
+ float shadow = shadowed * (1.0 - m.r) * texture2D(map, uv + vec2(-light.x, light.y) * 2.5 * px).a * 0.34;
+ gl_FragColor = vec4(c * m.r, m.r + shadow);
+ }`;
+ function stickerRenderer() {
+ const c = el('canvas');
+ c.width = c.height = ART;
+ const gl = c.getContext('webgl', { premultipliedAlpha: true, preserveDrawingBuffer: true, antialias: false });
+ if (!gl) { // (no WebGL: the same sticker, flat)
+ const x = c.getContext('2d'), k = ART / 100;
+ x.lineJoin = 'round';
+ return () => {
+ x.clearRect(0, 0, ART, ART);
+ starPath(x, k, 1); x.lineWidth = 14 * k; x.fillStyle = x.strokeStyle = '#f6f5f2'; x.fill(); x.stroke();
+ const gr = x.createLinearGradient(0, 0, ART, ART);
+ gr.addColorStop(0, '#fbe7a1'); gr.addColorStop(0.5, '#c8901a'); gr.addColorStop(1, '#f2cf6a');
+ starPath(x, k, 1); x.lineWidth = 3 * k; x.fillStyle = x.strokeStyle = gr; x.fill(); x.stroke();
+ return c;
+ };
+ }
+ const sh = (type, src) => { const o = gl.createShader(type); gl.shaderSource(o, src); gl.compileShader(o); return o; };
+ const prog = gl.createProgram();
+ gl.attachShader(prog, sh(gl.VERTEX_SHADER, 'attribute vec2 p; varying vec2 uv; void main() { uv = vec2(p.x * 0.5 + 0.5, 0.5 - p.y * 0.5); gl_Position = vec4(p, 0.0, 1.0); }'));
+ gl.attachShader(prog, sh(gl.FRAGMENT_SHADER, STICKER_FS));
+ gl.linkProgram(prog);
+ gl.useProgram(prog);
+ gl.bindBuffer(gl.ARRAY_BUFFER, gl.createBuffer());
+ gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([-1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, 1]), gl.STATIC_DRAW);
+ const p = gl.getAttribLocation(prog, 'p');
+ gl.enableVertexAttribArray(p);
+ gl.vertexAttribPointer(p, 2, gl.FLOAT, false, 0, 0);
+ gl.bindTexture(gl.TEXTURE_2D, gl.createTexture());
+ for (const [k, v] of [[gl.TEXTURE_MIN_FILTER, gl.LINEAR], [gl.TEXTURE_MAG_FILTER, gl.LINEAR], [gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE], [gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE]])
+ gl.texParameteri(gl.TEXTURE_2D, k, v);
+ const upload = (data) => gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, ART, ART, 0, gl.RGBA, gl.UNSIGNED_BYTE, data);
+ upload(stickerMap());
+ sticker.remap = () => upload(stickerMap());
+ const u = (n) => gl.getUniformLocation(prog, n);
+ gl.uniform1f(u('px'), 1 / ART);
+ gl.viewport(0, 0, ART, ART);
+ return (shadowed) => {
+ gl.uniform1f(u('shadowed'), shadowed ? 1 : 0);
+ gl.uniform3fv(u('light'), sticker.light);
+ gl.uniform2fv(u('view'), sticker.view);
+ gl.clearColor(0, 0, 0, 0);
+ gl.clear(gl.COLOR_BUFFER_BIT);
+ gl.drawArrays(gl.TRIANGLES, 0, 6);
+ return c;
+ };
+ }
+ // draw the sticker, then each of its pieces on the calculator
+ function paintSticker() {
+ if (!sticker.draw) return;
+ for (const shadowed of [true, false]) {
+ const src = sticker.draw(shadowed);
+ for (const l of sticker.leaves) if (l.shadowed === shadowed) { l.x.clearRect(0, 0, ART, ART); l.x.drawImage(src, 0, 0); }
+ }
+ }
+
+ function build3d() {
+ const body = document.querySelector('.body3d'), star = $('#star');
+ // the rounded edges and the sides: the quarter circle in facets, then the side
+ const step = 90 / EDGE_N;
+ for (const dir of [1, -1]) {
+ let f = part(body, 'i', 'fold', { left: U(dir > 0 ? 1018 - EDGE_R : EDGE_R), transform: 'rotateY(' + step / 2 * dir + 'deg)' });
+ EDGE_A.forEach((a, i) => {
+ const n0 = [Math.sin(deg(a - step / 2)) * dir, 0, Math.cos(deg(a - step / 2))], n1 = [Math.sin(deg(a + step / 2)) * dir, 0, Math.cos(deg(a + step / 2))];
+ part(f, 'i', 'facet', { left: dir > 0 ? '0' : U(-EDGE_C - 1.2), width: U(EDGE_C + 1.2),
+ background: 'linear-gradient(' + (dir > 0 ? 90 : 270) + 'deg, ' + grey(n0, 248) + ', ' + grey(n1, 248) + ')' });
+ f = part(f, 'i', 'fold', { left: U(EDGE_C * dir), transform: 'rotateY(' + (i < EDGE_N - 1 ? step : step / 2) * dir + 'deg)' });
+ });
+ const side = DEPTH - EDGE_R, n = [dir, 0, 0]; // (its front edge meets the last facet's light)
+ part(f, 'i', 'facet', { left: dir > 0 ? '0' : U(-side), width: U(side),
+ background: 'linear-gradient(' + (dir > 0 ? 90 : 270) + 'deg, ' + grey(n, 246) + ', ' + grey(n, 240) + ' 46%, ' + grey(n, 214) + ' 47%, ' +
+ grey(n, 236) + ' 48.5%, ' + grey(n, 222) + ')' });
+ }
+ // the top, its ends following the rounded edges
+ const prof = [[0, 0]];
+ for (const a of EDGE_A) { const [x, y] = prof[prof.length - 1]; prof.push([x + EDGE_C * Math.cos(deg(a)), y + EDGE_C * Math.sin(deg(a))]); }
+ const right = prof.map(([x, y]) => [1018 - EDGE_R + x, y]), left = prof.map(([x, y]) => [EDGE_R - x, y]);
+ const poly = right.concat([[1018, DEPTH], [0, DEPTH]], left.slice().reverse())
+ .map(([x, y]) => (100 * x / 1018).toFixed(3) + '% ' + U(y)).join(', ');
+ part(body, 'i', 'top', { height: U(DEPTH), clipPath: 'polygon(' + poly + ')',
+ background: 'linear-gradient(' + grey([0, -1, 0], 244) + ', ' + grey([0, -1, 0], 236) + ' 46%, ' + grey([0, -1, 0], 212) + ' 47%, ' +
+ grey([0, -1, 0], 232) + ' 48.5%, ' + grey([0, -1, 0], 220) + ')' });
+ // the walls of the screen's recess, all the way round its rounded corners
+ const X0 = 104, X1 = 915, Y0 = 107, Y1 = 743, R = 36, ring = [];
+ const corner = (cx, cy, a0) => { for (let i = 0; i <= 4; i++) { const a = deg(a0 + 22.5 * i); ring.push([cx + R * Math.cos(a), cy + R * Math.sin(a)]); } };
+ corner(X1 - R, Y0 + R, -90); corner(X1 - R, Y1 - R, 0); corner(X0 + R, Y1 - R, 90); corner(X0 + R, Y0 + R, 180);
+ ring.forEach(([x, y], i) => {
+ const [x2, y2] = ring[(i + 1) % ring.length], len = Math.hypot(x2 - x, y2 - y);
+ if (len < 0.01) return;
+ const phi = Math.atan2(y2 - y, x2 - x), n = [-Math.sin(phi), Math.cos(phi), 0]; // (facing into the recess)
+ part(body, 'i', 'rim', { left: U(x), top: U(y), width: U(len + 0.6), height: U(14.6),
+ transform: 'rotateZ(' + (phi * 180 / Math.PI).toFixed(2) + 'deg) rotateX(-90deg)',
+ background: 'linear-gradient(' + grey(n, 236) + ', ' + grey(n, 214) + ')' });
+ });
+ // the sticker: each piece shows its own span of the one artwork
+ const S = STAR;
+ Object.assign(star.style, { left: (100 * S.lip / 1018) + '%', top: (100 * S.top / 2000) + '%', width: U(S.edge - S.lip), height: U(S.size) });
+ star.style.setProperty('--star', U(S.size));
+ const art = (key) => {
+ const a = el('canvas', 'art');
+ a.width = a.height = ART;
+ sticker.leaves.push({ x: a.getContext('2d'), shadowed: ['front', 'step', 'floor'].includes(key) });
+ return a;
+ };
+ const leaf = (parent, from, to, x, key, over = 0) => { // (over: how far it runs under the next piece)
+ const l = part(parent, 'span', 'leaf', { left: U(x), width: U(to - from + over) });
+ const a = art(key);
+ a.style.left = U(S.from - from);
+ l.appendChild(a);
+ const sh = part(l, 'span', 'shade', { left: U(S.from - from), backgroundSize: U(to - from + over) + ' 100%', backgroundPosition: U(from - S.from) + ' 0' });
+ sh.dataset.piece = key;
+ sh.dataset.end = (100 * (to - from) / (to - from + over)).toFixed(2); // (its light runs on over the overlap)
+ return l;
+ };
+ const fold = (parent, x, transform) => part(parent, 'span', 'fold', { left: U(x), transform });
+ leaf(star, S.lip, S.edge, 0, 'front', 1.5);
+ let f = fold(star, 0, 'rotateY(-90deg)'); // down the step...
+ leaf(f, S.lip - S.step, S.lip, -S.step, 'step');
+ f = fold(f, -S.step, 'rotateY(90deg)'); // ...onto the recess's floor
+ leaf(f, S.from, S.lip - S.step, -(S.lip - S.step - S.from), 'floor');
+ let g = fold(star, S.edge - S.lip, 'rotateY(var(--b0))'); // round the edge, onto the side
+ let u = S.edge;
+ EDGE_A.forEach((a, i) => {
+ leaf(g, u, u + EDGE_C, 0, 'bend' + i, 1.5); // (a little over the next, so no hairline shows between them)
+ u += EDGE_C;
+ g = fold(g, EDGE_C, 'rotateY(var(--b' + (i < EDGE_N - 1 ? 1 : 2) + '))');
+ });
+ leaf(g, u, S.from + S.size, 0, 'side');
+ shadeStar(0);
+ sticker.draw = stickerRenderer();
+ paintSticker();
+ // (a click on any piece of it: GitHub)
+ star.addEventListener('click', (e) => { e.preventDefault(); window.open(star.href, '_blank', 'noopener'); });
+ }
+ // how much light each piece of the sticker gets, as the part round the edge lifts (0 to 1)
+ function shadeStar(lift) {
+ const k = 1 - 0.85 * lift, step = 90 / EDGE_N * k, star = $('#star');
+ star.style.setProperty('--b0', (step / 2).toFixed(2) + 'deg');
+ star.style.setProperty('--b1', step.toFixed(2) + 'deg');
+ star.style.setProperty('--b2', (step / 2).toFixed(2) + 'deg');
+ // (each piece from the light at its one edge to the light at its other, so the curve has no bands)
+ const at = (a) => lit([Math.sin(deg(a)), 0, Math.cos(deg(a))]);
+ const dark = (l) => 'rgba(20, 14, 0, ' + Math.max(0, 1 - l).toFixed(3) + ')';
+ const light = { front: [1, 1], step: [lit([-1, 0, 0]) * 0.94, lit([-1, 0, 0]) * 0.94], floor: [0.97, 0.97], side: [at(90 * k), at(90 * k) * 0.97] };
+ EDGE_A.forEach((a, i) => { light['bend' + i] = [at((a - 45 / EDGE_N) * k), at((a + 45 / EDGE_N) * k)]; });
+ for (const sh of star.querySelectorAll('.shade')) {
+ const [l0, l1] = light[sh.dataset.piece];
+ sh.style.backgroundImage = 'linear-gradient(90deg, ' + dark(l0) + ', ' + dark(l1) + ' ' + sh.dataset.end + '%, ' + dark(l1) + ')';
+ }
+ }
+
+ // The calculator turns a little toward the pointer. The light on the foil comes from where the pointer
+ // is, and under the pointer the part of the sticker round the edge peels up off the side.
+ function depth() {
+ if (matchMedia('(prefers-reduced-motion: reduce)').matches) return;
+ const calc = $('#calc'), star = $('#star'), REST = [0, -0.08];
+ let mx = innerWidth * 0.6, my = innerHeight * 0.2, tx = REST[0], ty = REST[1], x = tx, y = ty;
+ let over = false, lift = 0, raf = 0;
+ const clamp = (v, a, b) => Math.max(a, Math.min(b, v));
+ const draw = () => {
+ raf = 0;
+ x += (tx - x) * 0.07; y += (ty - y) * 0.07;
+ calc.style.setProperty('--ry', (-12 + x * 14).toFixed(2) + 'deg');
+ calc.style.setProperty('--rx', (2 - y * 6).toFixed(2) + 'deg');
+ calc.style.setProperty('--lx', (100 - (x + 0.5) * 100).toFixed(1) + '%');
+ const r = star.getBoundingClientRect(), cx = r.left + r.width * 0.68, cy = r.top + r.height / 2;
+ const want = over ? 0.45 + 0.55 * clamp((mx - r.left) / (r.width * 1.3), 0, 1) : 0;
+ lift += (want - lift) * 0.14;
+ // (the pointer is the light; the calculator's turn is where the sticker is seen from)
+ sticker.light = [(mx - cx) / 260, -(my - cy) / 260, 0.85];
+ sticker.view = [(12 - x * 14) / 38 + 0.12, (2 - y * 6) / 38];
+ paintSticker();
+ shadeStar(lift);
+ if (Math.abs(tx - x) + Math.abs(ty - y) > 0.0005 || Math.abs(want - lift) > 0.002) raf = requestAnimationFrame(draw);
+ };
+ const kick = () => { if (!raf) raf = requestAnimationFrame(draw); };
+ addEventListener('pointermove', (e) => {
+ if (e.pointerType === 'touch') return;
+ mx = e.clientX; my = e.clientY;
+ tx = mx / innerWidth - 0.5; ty = my / innerHeight - 0.5;
+ kick();
+ }, { passive: true });
+ document.documentElement.addEventListener('pointerleave', () => { tx = REST[0]; ty = REST[1]; kick(); });
+ star.addEventListener('pointerenter', (e) => { if (e.pointerType !== 'touch') { over = true; kick(); } });
+ star.addEventListener('pointerleave', () => { over = false; kick(); });
+ kick();
+ }
+
+ // ------------------------------------------------------------------ the title's letters, GitHub
function logoKeys() {
- const keys = [...document.querySelectorAll('.keys i')];
+ const keys = [...document.querySelectorAll('.title .word i')];
let busy = false;
const wave = () => {
- if (busy) return;
+ if (busy || intro.on) return;
busy = true;
keys.forEach((k, i) => {
- setTimeout(() => k.classList.add('down'), 45 * i);
- setTimeout(() => k.classList.remove('down'), 45 * i + 130);
+ setTimeout(() => k.classList.add('lift'), 40 * i);
+ setTimeout(() => k.classList.remove('lift'), 40 * i + 160);
});
- setTimeout(() => { busy = false; }, 45 * keys.length + 200);
+ setTimeout(() => { busy = false; }, 40 * keys.length + 300);
};
$('#logo').addEventListener('pointerenter', wave);
- $('#logo').addEventListener('click', () => { wave(); if (intro.on) endIntro(); else playIntro(); });
+ $('#logo').addEventListener('click', () => { if (intro.on) endIntro(); else playIntro(); });
}
async function stars() {
try {
@@ -1007,9 +1290,9 @@
n = String((await r.json()).stargazers_count);
sessionStorage.setItem('numplay-stars', n);
}
- const v = +n, b = $('#stars');
- b.textContent = v >= 1000 ? (v / 1000).toFixed(v >= 10000 ? 0 : 1) + 'k' : String(v);
- b.hidden = false;
+ const v = +n, t = v >= 1000 ? (v / 1000).toFixed(v >= 10000 ? 0 : 1) + 'k' : String(v);
+ sticker.text = [t, v === 1 ? 'STAR' : 'STARS'];
+ if (sticker.remap) { sticker.remap(); paintSticker(); }
} catch (e) { /* (offline, or GitHub said no: the button still works) */ }
}
@@ -1150,10 +1433,9 @@
if (rg) {
$('#retro').hidden = false;
- $('#retro-icon').src = KIT + 'icons/' + rg.id + '.png';
const exts = Object.keys(EXT).filter((x) => (rg.systems || [1, 2, 3]).includes(EXT[x]));
$('#rom-file').accept = exts.map((x) => '.' + x).join(',');
- $('#drop-sub').textContent = exts.map((x) => '.' + x).join(' ');
+ $('#drop').dataset.tip = 'Add a game|' + exts.map((x) => '.' + x).join(' ') + ', or drop the files anywhere';
$('#rom-file').addEventListener('change', (e) => { addRoms([...e.target.files]); e.target.value = ''; });
let depth = 0;
const files = (e) => e.dataTransfer && [...e.dataTransfer.types].includes('Files');
@@ -1170,6 +1452,8 @@
}
tips();
logoKeys();
+ build3d();
+ depth();
const first = (!store('numplay-intro') && !location.hash) || /[?&]intro\b/.test(location.search); // (or ?intro, to see it)
restore();
if (st.lang !== 'en') loadKit(st.lang).then(render).catch(() => { st.lang = 'en'; render(); });
diff --git a/customize/apple-touch-icon.png b/customize/apple-touch-icon.png
new file mode 100644
index 00000000..a2fc4ed9
Binary files /dev/null and b/customize/apple-touch-icon.png differ
diff --git a/customize/favicon.png b/customize/favicon.png
new file mode 100644
index 00000000..f0738e83
Binary files /dev/null and b/customize/favicon.png differ
diff --git a/customize/index.html b/customize/index.html
index b5938a29..c12a334e 100644
--- a/customize/index.html
+++ b/customize/index.html
@@ -7,8 +7,9 @@
<title>NumPlay Studio: free games for your NumWorks calculator</title>
<meta name="description" content="Pick the free games you want for your NumWorks calculator, add your own Game Boy, NES and Sega games, and get one app with all of them. NumPlay Studio builds it right in your browser.">
<link rel="canonical" href="https://mason363.github.io/NumPlay/customize/">
-<link rel="icon" href="kit/variants/NumPlay.png">
-<meta name="theme-color" content="#e6e8ec">
+<link rel="icon" href="favicon.png" type="image/png">
+<link rel="apple-touch-icon" href="apple-touch-icon.png">
+<meta name="theme-color" content="#f2f1ef">
<meta property="og:type" content="website">
<meta property="og:site_name" content="NumPlay">
<meta property="og:title" content="NumPlay Studio: free games for your NumWorks calculator">
@@ -41,36 +42,61 @@
<body>
<h1 class="sr">NumPlay Studio: pick free games for your NumWorks calculator, add your own Game Boy, NES and Sega games, and install one app with all of them</h1>
-<header class="top">
- <button id="logo" class="logo" type="button" aria-label="NumPlay: play the intro again" data-tip="Play the intro again">
- <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" 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">&#9733;</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>
-
-<div id="caption" class="caption" aria-live="polite"></div>
-
<main id="studio">
- <section id="small" class="grid small" aria-label="Games in NumPlay"></section>
+ <div class="head">
+ <button id="logo" class="title" type="button" aria-label="NumPlay: play the intro again" data-tip="Play the intro again">
+ <span class="word" aria-hidden="true"><i>N</i><i>u</i><i>m</i><i>P</i><i>l</i><i>a</i><i>y</i></span>
+ </button>
+ <div class="chips">
+ <button id="app-chip" type="button" class="chip" aria-haspopup="dialog" aria-expanded="false" data-tip="Its icon, name and how it opens">
+ <img id="app-chip-icon" src="kit/variants/NumPlay.png" alt="" width="28" height="28">
+ <svg class="caret" viewBox="0 0 12 12" width="10" height="10" aria-hidden="true"><path d="M3 4.5l3 3 3-3" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"/></svg>
+ </button>
+ <button id="lang-chip" type="button" class="chip lang" aria-haspopup="dialog" aria-expanded="false" data-tip="Its language">
+ <span id="lang-chip-label">EN</span>
+ <svg class="caret" viewBox="0 0 12 12" width="10" height="10" aria-hidden="true"><path d="M3 4.5l3 3 3-3" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"/></svg>
+ </button>
+ </div>
+ <p id="caption" class="lede" aria-live="polite">Free games for your NumWorks. Pick yours, then press OK.</p>
+ </div>
- <section class="device" aria-label="Your calculator">
- <div class="meter">
- <span id="used" class="used">0.00</span>
- <div id="bar" class="bar" role="img" aria-label="Space used"></div>
+ <div class="games">
+ <section id="small" class="grid small" aria-label="Games in NumPlay"></section>
+ <div class="row-head">
+ <span>Big games</span>
<div class="cap" role="radiogroup" aria-label="App space">
<button type="button" role="radio" data-cap="std" aria-checked="true" data-tip="Every NumWorks">1.94 MB</button>
- <button type="button" role="radio" data-cap="xl" aria-checked="false" data-tip="Enlarged Extra Apps, with Nwagra">6 MB</button>
+ <button type="button" role="radio" data-cap="xl" aria-checked="false" data-tip="With Enlarged Extra Apps">6 MB</button>
</div>
</div>
- <div class="side-by">
- <div id="calc" class="calc">
- <div class="shadow" aria-hidden="true"></div>
- <img class="calc-img" src="calculator.webp" alt="A NumWorks calculator" draggable="false" width="1018" height="2000">
+ <section id="big" class="grid big" aria-label="Big games"></section>
+ <section id="retro" class="retro" aria-label="Retro-Go" hidden>
+ <div class="row-head"><span>Retro-Go</span><span class="sub">Game Boy, NES and Sega games you own</span></div>
+ <div class="carts-row">
+ <div id="carts" class="carts" aria-label="Your Retro-Go games"></div>
+ <label id="drop" class="add-cart" for="rom-file" data-tip="Add a game|.gb .gbc .nes .sms .gg, or drop the files anywhere">
+ <svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" aria-hidden="true"><path d="M12 5v14"/><path d="M5 12h14"/></svg>
+ <span class="sr">Add Game Boy, NES or Sega games</span>
+ </label>
+ <input id="rom-file" type="file" multiple accept=".gb,.gbc,.nes,.sms,.gg">
+ </div>
+ </section>
+ <footer class="foot">
+ <a href="https://github.com/Mason363/NumPlay">Made by Mason Chen as part of NumPlay</a>
+ <span aria-hidden="true">·</span>
+ <a href="../">NumPlay's page</a>
+ </footer>
+ </div>
+
+ <section class="device" aria-label="Your calculator">
+ <div id="calc" class="calc">
+ <div class="plate">
+ <img class="calc-img" src="calculator.webp" alt="A NumWorks calculator, up close" draggable="false" width="1018" height="2000">
+ <button id="install" class="ok-key" type="button" aria-label="Install it on my calculator"><span class="ok-tag">Install</span></button>
+ <button id="download" class="dl" type="button" aria-label="Download NumPlay.nwa">NumPlay.nwa</button>
+ </div>
+ <div class="well">
+ <img class="well-img" src="calculator.webp" alt="" draggable="false" width="1018" height="2000">
<div id="screen" class="screen" role="img" aria-label="Space on the calculator">
<div class="status"><span id="status-line"></span><span class="battery"><i id="battery"></i></span></div>
<div id="map" class="map"></div>
@@ -78,39 +104,11 @@
<div class="drop-hint" aria-hidden="true">
<svg viewBox="0 0 24 24" width="30" height="30" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 4v11"/><path d="M7 10l5 5 5-5"/><path d="M5 20h14"/></svg>
</div>
+ <i class="glass" aria-hidden="true"></i>
</div>
</div>
- <div class="actions">
- <button id="app-chip" type="button" class="chip" aria-haspopup="dialog" aria-expanded="false" data-tip="Icon, name and how it opens">
- <img id="app-chip-icon" src="kit/variants/NumPlay.png" alt="" width="28" height="28">
- <svg class="caret" viewBox="0 0 12 12" width="10" height="10" aria-hidden="true"><path d="M3 4.5l3 3 3-3" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"/></svg>
- </button>
- <button id="lang-chip" type="button" class="chip lang" aria-haspopup="dialog" aria-expanded="false" data-tip="The app's language">
- <span id="lang-chip-label">EN</span>
- <svg class="caret" viewBox="0 0 12 12" width="10" height="10" aria-hidden="true"><path d="M3 4.5l3 3 3-3" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"/></svg>
- </button>
- <button id="install" type="button" class="install"><span>Install</span></button>
- <button id="download" type="button" class="round" aria-label="Download NumPlay.nwa" data-tip="Download NumPlay.nwa">
- <svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 4v12"/><path d="M6 11l6 6 6-6"/><path d="M5 20h14"/></svg>
- </button>
- </div>
- </div>
- </section>
-
- <section class="side" aria-label="Big games and Retro-Go">
- <div id="big" class="grid big"></div>
- <div id="retro" class="retro" hidden>
- <div class="retro-head">
- <img id="retro-icon" alt="" width="34" height="34">
- <div><b>Retro-Go</b><span class="systems">Game Boy · NES · Sega</span></div>
- </div>
- <label id="drop" class="drop" for="rom-file">
- <span class="drop-art" aria-hidden="true"><i class="c1"></i><i class="c2"></i><i class="c3"></i></span>
- <span class="drop-text">Drop your games here</span>
- <span id="drop-sub" class="drop-sub">.gb .gbc .nes .sms .gg</span>
- </label>
- <input id="rom-file" type="file" multiple accept=".gb,.gbc,.nes,.sms,.gg">
- <div id="carts" class="carts" aria-label="Your Retro-Go games"></div>
+ <div class="body3d" aria-hidden="true"></div>
+ <a id="star" class="sticker" href="https://github.com/Mason363/NumPlay" target="_blank" rel="noopener" aria-label="Star NumPlay on GitHub" data-tip="Star NumPlay on GitHub|it helps more people find it"></a>
</div>
</section>
</main>
@@ -167,11 +165,6 @@
</div>
</div>
-<footer class="foot">
- <a href="https://github.com/Mason363/NumPlay">Made by Mason Chen as part of NumPlay</a>
- <span aria-hidden="true">·</span>
- <a href="../">NumPlay's page</a>
-</footer>
<noscript><p class="noscript">NumPlay Studio needs JavaScript to build your NumPlay. You can also <a href="https://github.com/Mason363/NumPlay/releases/latest/download/NumPlay.nwa">download NumPlay.nwa</a> with every game.</p></noscript>