Video: voxel titles, new opening with world turn, app punch-ins and callouts, six-screen montage, props sequence; site carries the new film
This commit is contained in:
37 files changed
+2672
-165
No files matched your search
@@ -0,0 +1,127 @@
|
||||
// Cubes and flat text on a 2× canvas.
|
||||
|
||||
/** Film clock: 112 BPM. */
|
||||
export const BEAT = 60 / 112;
|
||||
export const BAR = 4 * BEAT;
|
||||
export const SIX = BEAT / 4;
|
||||
|
||||
/** Start of 1-based bar `b`, in seconds. */
|
||||
export const bar = (b) => (b - 1) * BAR;
|
||||
|
||||
/** CSS cubic-bezier timing, solved by bisection. */
|
||||
function bezier(x1, y1, x2, y2) {
|
||||
const at = (a, b, u) => 3 * a * u * (1 - u) ** 2 + 3 * b * u * u * (1 - u) + u ** 3;
|
||||
return (x) => {
|
||||
if (x <= 0) return 0;
|
||||
if (x >= 1) return 1;
|
||||
let [lo, hi] = [0, 1];
|
||||
for (let i = 0; i < 40; i++) {
|
||||
const mid = (lo + hi) / 2;
|
||||
if (at(x1, x2, mid) < x) lo = mid;
|
||||
else hi = mid;
|
||||
}
|
||||
return at(y1, y2, (lo + hi) / 2);
|
||||
};
|
||||
}
|
||||
|
||||
export const settle = bezier(0.2, 0.8, 0.3, 1);
|
||||
export const glide = bezier(0.65, 0, 0.35, 1);
|
||||
export const clamp = (u) => Math.min(1, Math.max(0, u));
|
||||
|
||||
const lin = (c) => (c <= 0.04045 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4);
|
||||
const gam = (c) => (c <= 0.0031308 ? 12.92 * c : 1.055 * c ** (1 / 2.4) - 0.055);
|
||||
|
||||
/** `hex` mixed with black `p` in oklab, as CSS rgb. */
|
||||
function shade(hex, p) {
|
||||
const [r, g, b] = [1, 3, 5].map((i) => lin(parseInt(hex.slice(i, i + 2), 16) / 255));
|
||||
const l = Math.cbrt(0.4122214708 * r + 0.5363325363 * g + 0.0514459929 * b) * (1 - p);
|
||||
const m = Math.cbrt(0.2119034982 * r + 0.6806995451 * g + 0.1073969566 * b) * (1 - p);
|
||||
const s = Math.cbrt(0.0883024619 * r + 0.2817188376 * g + 0.6299787005 * b) * (1 - p);
|
||||
const [L, M, S] = [l ** 3, m ** 3, s ** 3];
|
||||
const out = [
|
||||
4.0767416621 * L - 3.3077115913 * M + 0.2309699292 * S,
|
||||
-1.2684380046 * L + 2.6097574011 * M - 0.3413193965 * S,
|
||||
-0.0041960863 * L - 0.7034186147 * M + 1.707614701 * S,
|
||||
];
|
||||
return `rgb(${out.map((c) => Math.round(clamp(gam(c)) * 255)).join(",")})`;
|
||||
}
|
||||
|
||||
const tones = new Map();
|
||||
|
||||
/** Top, left and right fills of a tone. */
|
||||
function faces(tone) {
|
||||
if (!tones.has(tone)) tones.set(tone, [tone, shade(tone, 0.09), shade(tone, 0.2)]);
|
||||
return tones.get(tone);
|
||||
}
|
||||
|
||||
/** Orthographic view: isometric pitch, chosen yaw about z. */
|
||||
export function view(yaw, cell, ox = 0, oy = 0) {
|
||||
const pitch = Math.atan(1 / Math.SQRT2);
|
||||
const [ca, sa, se] = [Math.cos(yaw), Math.sin(yaw), Math.sin(pitch)];
|
||||
const k = 1 / Math.cos(pitch);
|
||||
return {
|
||||
cell,
|
||||
ox,
|
||||
oy,
|
||||
p: (x, y, z) => [ox + (x * ca - y * sa) * k * cell, oy + ((x * sa + y * ca) * se * k - z) * cell],
|
||||
depth: (x, y, z) => x * sa + y * ca + z * Math.SQRT1_2,
|
||||
};
|
||||
}
|
||||
|
||||
/** Screen bounds of boxes under view `v`. */
|
||||
export function bounds(v, boxes) {
|
||||
const pts = boxes.flatMap((b) =>
|
||||
[0, 1].flatMap((i) => [0, 1].flatMap((j) => [0, 1].map((k) => v.p(b.x + i * b.w, b.y + j * b.d, b.z + k * b.h)))),
|
||||
);
|
||||
const xs = pts.map(([x]) => x);
|
||||
const ys = pts.map(([, y]) => y);
|
||||
return { x0: Math.min(...xs), x1: Math.max(...xs), y0: Math.min(...ys), y1: Math.max(...ys) };
|
||||
}
|
||||
|
||||
function poly(ctx, pts) {
|
||||
ctx.beginPath();
|
||||
pts.forEach(([x, y], i) => (i ? ctx.lineTo(x, y) : ctx.moveTo(x, y)));
|
||||
ctx.closePath();
|
||||
ctx.fill();
|
||||
}
|
||||
|
||||
/** One box: outline, left, right, top; seams hidden. */
|
||||
function cube(ctx, v, b) {
|
||||
const [x0, y0, z0, x1, y1, z1] = [b.x, b.y, b.z, b.x + b.w, b.y + b.d, b.z + b.h];
|
||||
const [top, left, right] = faces(b.tone);
|
||||
const p = v.p;
|
||||
ctx.globalAlpha = b.a ?? 1;
|
||||
if (ctx.globalAlpha >= 1) {
|
||||
ctx.fillStyle = left;
|
||||
poly(ctx, [p(x0, y1, z0), p(x1, y1, z0), p(x1, y0, z0), p(x1, y0, z1), p(x0, y0, z1), p(x0, y1, z1)]);
|
||||
}
|
||||
ctx.fillStyle = left;
|
||||
poly(ctx, [p(x0, y1, z0), p(x1, y1, z0), p(x1, y1, z1), p(x0, y1, z1)]);
|
||||
ctx.fillStyle = right;
|
||||
poly(ctx, [p(x1, y1, z0), p(x1, y0, z0), p(x1, y0, z1), p(x1, y1, z1)]);
|
||||
ctx.fillStyle = top;
|
||||
poly(ctx, [p(x0, y0, z1), p(x1, y0, z1), p(x1, y1, z1), p(x0, y1, z1)]);
|
||||
ctx.globalAlpha = 1;
|
||||
}
|
||||
|
||||
/** Boxes back to front under view `v`. */
|
||||
export function cubes(ctx, v, boxes) {
|
||||
const key = (b) => v.depth(b.x + b.w / 2, b.y + b.d / 2, b.z + b.h / 2);
|
||||
[...boxes]
|
||||
.filter((b) => (b.a ?? 1) > 0.002)
|
||||
.sort((a, b) => key(a) - key(b))
|
||||
.forEach((b) => cube(ctx, v, b));
|
||||
}
|
||||
|
||||
/** Flat system text; CJK falls to PingFang SC. */
|
||||
export function text(ctx, { s, x, y, size, weight = 200, color, a = 1, align = "center", track = 0 }) {
|
||||
if (a <= 0) return;
|
||||
ctx.globalAlpha = a;
|
||||
ctx.fillStyle = color;
|
||||
ctx.font = `${weight} ${size}px "Ely SF", "PingFang SC", sans-serif`;
|
||||
ctx.letterSpacing = `${track}px`;
|
||||
ctx.textAlign = align;
|
||||
ctx.textBaseline = "alphabetic";
|
||||
ctx.fillText(s, x, y);
|
||||
ctx.globalAlpha = 1;
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
// A cube font: caps 7 high, x-height 5, descender 2.
|
||||
|
||||
/** Rows 0–8, baseline row 6; '#' marks a cube. */
|
||||
const SHAPES = {
|
||||
E: ["#####", "#....", "#....", "####.", "#....", "#....", "#####"],
|
||||
L: ["#....", "#....", "#....", "#....", "#....", "#....", "#####"],
|
||||
Y: ["#...#", "#...#", ".#.#.", "..#..", "..#..", "..#..", "..#.."],
|
||||
O: [".###.", "#...#", "#...#", "#...#", "#...#", "#...#", ".###."],
|
||||
D: ["####.", "#...#", "#...#", "#...#", "#...#", "#...#", "####."],
|
||||
T: ["#####", "..#..", "..#..", "..#..", "..#..", "..#..", "..#.."],
|
||||
S: [".####", "#....", "#....", ".###.", "....#", "....#", "####."],
|
||||
P: ["####.", "#...#", "#...#", "####.", "#....", "#....", "#...."],
|
||||
F: ["#####", "#....", "#....", "####.", "#....", "#....", "#...."],
|
||||
M: ["#...#", "##.##", "#.#.#", "#.#.#", "#...#", "#...#", "#...#"],
|
||||
l: ["##.", ".#.", ".#.", ".#.", ".#.", ".#.", ".##"],
|
||||
y: ["....", "....", "#..#", "#..#", "#..#", "#..#", ".###", "...#", "###."],
|
||||
f: ["..##", ".#..", "####", ".#..", ".#..", ".#..", ".#.."],
|
||||
i: ["#", ".", "#", "#", "#", "#", "#"],
|
||||
c: ["....", "....", ".###", "#...", "#...", "#...", ".###"],
|
||||
e: ["....", "....", ".##.", "#..#", "####", "#...", ".###"],
|
||||
o: ["....", "....", ".##.", "#..#", "#..#", "#..#", ".##."],
|
||||
a: ["....", "....", ".##.", "...#", ".###", "#..#", ".###"],
|
||||
b: ["#...", "#...", "###.", "#..#", "#..#", "#..#", "###."],
|
||||
h: ["#...", "#...", "###.", "#..#", "#..#", "#..#", "#..#"],
|
||||
w: [".....", ".....", "#...#", "#...#", "#.#.#", "#.#.#", ".#.#."],
|
||||
r: ["....", "....", "#.##", "##..", "#...", "#...", "#..."],
|
||||
k: ["#...", "#...", "#..#", "#.#.", "##..", "#.#.", "#..#"],
|
||||
0: [".##.", "#..#", "#..#", "#..#", "#..#", "#..#", ".##."],
|
||||
1: [".#.", "##.", ".#.", ".#.", ".#.", ".#.", "###"],
|
||||
".": [".", ".", ".", ".", ".", ".", "#"],
|
||||
"·": [".", ".", ".", "#", ".", ".", "."],
|
||||
};
|
||||
|
||||
/** Columns a space takes. */
|
||||
const SPACE = 3;
|
||||
|
||||
/** Cells of `text`: col, row from top, glyph index. */
|
||||
export function cells(text) {
|
||||
const out = [];
|
||||
let col = 0;
|
||||
[...text].forEach((ch, glyph) => {
|
||||
if (ch === " ") {
|
||||
col += SPACE - 1;
|
||||
return;
|
||||
}
|
||||
const rows = SHAPES[ch];
|
||||
if (!rows) throw new Error(`no glyph for ${ch}`);
|
||||
rows.forEach((line, row) =>
|
||||
[...line].forEach((c, i) => {
|
||||
if (c === "#") out.push({ col: col + i, row, glyph });
|
||||
}),
|
||||
);
|
||||
col += rows[0].length + 1;
|
||||
});
|
||||
return { cells: out, width: col - 1 };
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title>Ely voxel type</title>
|
||||
<style>
|
||||
body {
|
||||
margin: 0;
|
||||
font-family: -apple-system, "PingFang SC", sans-serif;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<span style="font-weight: 300">Ely 六个桌面应用</span>
|
||||
<script type="module" src="./main.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,32 @@
|
||||
// Page entry: renders one scene frame to PNG data.
|
||||
import { SCENES } from "./scenes.js";
|
||||
|
||||
const sf = new FontFace("Ely SF", "url(/SFNS.ttf)", { weight: "1 1000" });
|
||||
document.fonts.add(await sf.load());
|
||||
await document.fonts.load('300 20px "PingFang SC"', "六");
|
||||
|
||||
const big = document.createElement("canvas");
|
||||
big.width = 3840;
|
||||
big.height = 2160;
|
||||
const out = document.createElement("canvas");
|
||||
out.width = 1920;
|
||||
out.height = 1080;
|
||||
|
||||
/** Global frame `f` of scene `name`, as base64 PNG. */
|
||||
function render(name, f) {
|
||||
const scene = SCENES.find((s) => s.name === name);
|
||||
if (!scene) throw new Error(`unknown scene ${name}`);
|
||||
const ctx = big.getContext("2d");
|
||||
ctx.setTransform(1, 0, 0, 1, 0, 0);
|
||||
ctx.clearRect(0, 0, big.width, big.height);
|
||||
ctx.setTransform(2, 0, 0, 2, 0, 0);
|
||||
scene.draw(ctx, f / 30);
|
||||
const small = out.getContext("2d");
|
||||
small.clearRect(0, 0, 1920, 1080);
|
||||
small.imageSmoothingEnabled = true;
|
||||
small.imageSmoothingQuality = "high";
|
||||
small.drawImage(big, 0, 0, 1920, 1080);
|
||||
return out.toDataURL("image/png").split(",")[1];
|
||||
}
|
||||
|
||||
window.type = { scenes: SCENES.map(({ draw, ...s }) => s), render };
|
||||
@@ -0,0 +1,88 @@
|
||||
// Renders voxel titles to PNG frames, manifests and previews.
|
||||
import { spawnSync } from "node:child_process";
|
||||
import { mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
||||
import { createServer } from "node:http";
|
||||
import { dirname, extname, join, resolve } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { chromium } from "../scenes/node_modules/playwright/index.mjs";
|
||||
|
||||
const here = dirname(fileURLToPath(import.meta.url));
|
||||
const out = resolve(here, "../out/extra");
|
||||
const PAGES = 4;
|
||||
const TYPES = { ".html": "text/html", ".js": "text/javascript", ".ttf": "font/ttf" };
|
||||
const SF = "/System/Library/Fonts/SFNS.ttf";
|
||||
|
||||
const server = createServer((req, res) => {
|
||||
const name = new URL(req.url, "http://x").pathname;
|
||||
if (name === "/SFNS.ttf") {
|
||||
res.writeHead(200, { "content-type": TYPES[".ttf"] }).end(readFileSync(SF));
|
||||
return;
|
||||
}
|
||||
const path = join(here, name);
|
||||
const type = TYPES[extname(path)];
|
||||
if (!type || !path.startsWith(here)) {
|
||||
res.writeHead(404).end();
|
||||
return;
|
||||
}
|
||||
res.writeHead(200, { "content-type": type }).end(readFileSync(path));
|
||||
});
|
||||
await new Promise((ok) => server.listen(0, "127.0.0.1", ok));
|
||||
const url = `http://127.0.0.1:${server.address().port}/index.html`;
|
||||
const browser = await chromium.launch();
|
||||
|
||||
/** A page; any page error stops the run. */
|
||||
async function open() {
|
||||
const page = await browser.newPage({ viewport: { width: 400, height: 200 } });
|
||||
page.on("pageerror", (e) => {
|
||||
throw e;
|
||||
});
|
||||
await page.goto(url, { waitUntil: "networkidle" });
|
||||
await page.evaluate(() => document.fonts.ready);
|
||||
await page.waitForFunction(() => window.type);
|
||||
return page;
|
||||
}
|
||||
|
||||
const pages = await Promise.all(Array.from({ length: PAGES }, open));
|
||||
const all = await pages[0].evaluate(() => window.type.scenes);
|
||||
const png = async (page, name, f) => Buffer.from(await page.evaluate(([n, f]) => window.type.render(n, f), [name, f]), "base64");
|
||||
|
||||
/** Each scene's frames, manifest and preview MP4. */
|
||||
async function scene(page, s) {
|
||||
const dir = join(out, s.name);
|
||||
rmSync(dir, { recursive: true, force: true });
|
||||
mkdirSync(dir, { recursive: true });
|
||||
for (let f = s.first; f < s.first + s.count; f++) writeFileSync(join(dir, `${String(f).padStart(5, "0")}.png`), await png(page, s.name, f));
|
||||
const manifest = { name: s.name, first: s.first, count: s.count, fps: 30, kind: s.kind };
|
||||
writeFileSync(join(dir, "manifest.json"), JSON.stringify(manifest, null, 1));
|
||||
const input = ["-framerate", "30", "-start_number", String(s.first), "-i", join(dir, "%05d.png")];
|
||||
const paper = ["-f", "lavfi", "-i", `color=c=0xfbfbfa:s=1920x1080:r=30:d=${s.count / 30}`];
|
||||
const args = s.kind === "over" ? [...paper, ...input, "-filter_complex", "[0][1]overlay=shortest=1"] : input;
|
||||
const enc = ["-c:v", "libx264", "-preset", "slow", "-crf", "14", "-pix_fmt", "yuv420p", "-movflags", "+faststart"];
|
||||
const run = spawnSync("ffmpeg", ["-y", "-v", "error", ...args, ...enc, join(out, `${s.name}.mp4`)], { stdio: "inherit" });
|
||||
if (run.status !== 0) throw new Error(`ffmpeg failed for ${s.name}`);
|
||||
console.log(`${s.name}: ${s.kind} frames ${s.first}..${s.first + s.count - 1}`);
|
||||
}
|
||||
|
||||
/** Stills of chosen global frames, for looking. */
|
||||
async function stills(dir, frames) {
|
||||
mkdirSync(dir, { recursive: true });
|
||||
for (const f of frames) {
|
||||
const s = all.find((s) => f >= s.first && f < s.first + s.count);
|
||||
if (!s) throw new Error(`no scene at frame ${f}`);
|
||||
writeFileSync(join(dir, `${s.name}-${f}.png`), await png(pages[0], s.name, f));
|
||||
}
|
||||
}
|
||||
|
||||
const args = process.argv.slice(2);
|
||||
if (args[0] === "--stills") {
|
||||
await stills(resolve(args[1]), args.slice(2).map(Number));
|
||||
} else {
|
||||
const unknown = args.filter((n) => !all.some((s) => s.name === n));
|
||||
if (unknown.length) throw new Error(`unknown scenes: ${unknown.join(", ")}`);
|
||||
const queue = all.filter((s) => !args.length || args.includes(s.name));
|
||||
await Promise.all(pages.map(async (page) => {
|
||||
for (let s = queue.shift(); s; s = queue.shift()) await scene(page, s);
|
||||
}));
|
||||
}
|
||||
await browser.close();
|
||||
server.close();
|
||||
@@ -0,0 +1,180 @@
|
||||
// The film's voxel titles, timed on sixteenths.
|
||||
import { cells } from "./glyphs.js";
|
||||
import { BAR, BEAT, SIX, bar, bounds, clamp, cubes, settle, text, view } from "./draw.js";
|
||||
|
||||
const DARK_FIELD = "#252525";
|
||||
const LIGHT = "#e9e9e6";
|
||||
const INK = "#4d4d51";
|
||||
const ACCENT = "#3d7fe5";
|
||||
const SOFT = "#6e6e73";
|
||||
const BODY = "#48484a";
|
||||
const YAW = (12 * Math.PI) / 180;
|
||||
const GAP = 0.06;
|
||||
const LAND = 0.2;
|
||||
|
||||
/** Cubes of `s`; `tone` picks a tone per glyph. */
|
||||
function word(s, tone) {
|
||||
return cells(s).cells.map((c) => ({ ...c, tone: tone(c.glyph) }));
|
||||
}
|
||||
|
||||
/** A cell's box, raised `dz`, height scaled `h`. */
|
||||
function box(c, dz = 0, a = 1, h = 1) {
|
||||
const s = 1 - 2 * GAP;
|
||||
return { x: c.col + GAP, y: GAP, z: 6 - c.row + GAP + dz, w: s, d: s, h: s * h, tone: c.tone, a };
|
||||
}
|
||||
|
||||
/** Each cell's slot: a rising sweep, `n` sixteenths wide. */
|
||||
function slots(list, n, lean = 0.5) {
|
||||
const key = (c) => c.col + lean * (6 - c.row);
|
||||
const keys = list.map(key);
|
||||
const [lo, hi] = [Math.min(...keys), Math.max(...keys)];
|
||||
return list.map((c) => Math.min(n - 1, Math.floor(((key(c) - lo) / (hi - lo + 1e-6)) * n)));
|
||||
}
|
||||
|
||||
/** Drop one cell, landing at `land`; null before. */
|
||||
function arrive(t, land) {
|
||||
const p = (t - (land - LAND)) / LAND;
|
||||
if (p <= 0) return null;
|
||||
const e = settle(clamp(p));
|
||||
return { dz: 1 - e, a: e };
|
||||
}
|
||||
|
||||
/** Lift one cell and fade, ending at `end`. */
|
||||
function lift(t, end, span) {
|
||||
const e = settle(clamp((t - (end - span)) / span));
|
||||
return { dz: e, a: 1 - e };
|
||||
}
|
||||
|
||||
/** View placing `list` with its bounds at an anchor. */
|
||||
function place(list, cell, { cx, left, cy }) {
|
||||
const b = bounds(view(YAW, cell), list.map((c) => box(c)));
|
||||
const ox = left !== undefined ? left - b.x0 : cx - (b.x0 + b.x1) / 2;
|
||||
return view(YAW, cell, ox, cy - (b.y0 + b.y1) / 2);
|
||||
}
|
||||
|
||||
/** Scales view `v` by `s` about screen point (px, py). */
|
||||
function zoom(v, s, px, py) {
|
||||
return view(YAW, v.cell * s, px + (v.ox - px) * s, py + (v.oy - py) * s);
|
||||
}
|
||||
|
||||
/** Screen y just below the word, left of screen `x`. */
|
||||
function under(v, x) {
|
||||
let c = 0;
|
||||
while (v.p(c, 1, -2)[0] < x) c++;
|
||||
return v.p(c, 1, -2)[1];
|
||||
}
|
||||
|
||||
/** Small stable noise per cell. */
|
||||
const hash = (c, k) => {
|
||||
const x = Math.sin(c.col * 127.1 + c.row * 311.7 + k * 74.7) * 43758.5453;
|
||||
return x - Math.floor(x);
|
||||
};
|
||||
|
||||
/** Bars 1–2: ELY builds, then breaks into falling tiles. */
|
||||
function ely(ctx, t) {
|
||||
ctx.fillStyle = DARK_FIELD;
|
||||
ctx.fillRect(0, 0, 1920, 1080);
|
||||
const list = word("ELY", () => LIGHT);
|
||||
const last = list.find((c) => c.col === 14 && c.row === 6);
|
||||
last.tone = ACCENT;
|
||||
const rest = list.filter((c) => c !== last);
|
||||
const slot = new Map(rest.map((c, i) => [c, slots(rest, 20)[i]]));
|
||||
slot.set(last, 23);
|
||||
const end = 2 * BAR;
|
||||
const u = clamp(t / end);
|
||||
const v = zoom(place(list, 46, { cx: 960, cy: 520 }), 1.42 - 0.42 * (1 - (1 - u) ** 1.6), 960, 540);
|
||||
const boxes = list.flatMap((c) => {
|
||||
const at = arrive(t, (slot.get(c) + 1) * SIX);
|
||||
if (!at) return [];
|
||||
const start = (28 + Math.floor((c.col / 17) * 4)) * SIX;
|
||||
const τ = t - start;
|
||||
if (τ <= 0) return [box(c, at.dz, at.a)];
|
||||
const flat = settle(clamp(τ / 0.1));
|
||||
const b = box(c, -48 * τ * τ, 1, 1 - 0.78 * flat);
|
||||
b.x += (hash(c, 1) - 0.5) * 5 * τ;
|
||||
b.y += (0.4 + hash(c, 2)) * 9 * τ * τ;
|
||||
return [b];
|
||||
});
|
||||
cubes(ctx, v, boxes);
|
||||
}
|
||||
|
||||
/** Bars 7–8: "Ely Office" stands in the lower third. */
|
||||
function title(ctx, t) {
|
||||
const t0 = bar(7);
|
||||
const end = bar(9);
|
||||
const list = word("Ely Office", () => INK);
|
||||
const slot = slots(list, 6);
|
||||
const v = place(list, 22, { cx: 960, cy: 780 });
|
||||
const left = bounds(v, list.map((c) => box(c))).x0;
|
||||
const gone = lift(t, end, SIX);
|
||||
const boxes = list.flatMap((c, i) => {
|
||||
const at = arrive(t, t0 + (slot[i] + 1) * SIX);
|
||||
return at ? [box(c, at.dz + gone.dz, at.a * gone.a)] : [];
|
||||
});
|
||||
cubes(ctx, v, boxes);
|
||||
const a = settle(clamp((t - (bar(8) - LAND)) / LAND)) * gone.a;
|
||||
const y = under(v, left + 300) + 52;
|
||||
text(ctx, { s: "Six desktop apps", x: left, y, size: 34, color: BODY, a, align: "left" });
|
||||
text(ctx, { s: "六个桌面应用", x: left, y: y + 46, size: 28, color: SOFT, a, align: "left", track: 2 });
|
||||
}
|
||||
|
||||
/** An app's first bar: its name builds at left. */
|
||||
function app(name, b) {
|
||||
return (ctx, t) => {
|
||||
const t0 = bar(b);
|
||||
const list = word(name, () => INK);
|
||||
const build = slots(list, 8);
|
||||
const out = slots(list, 4, 0);
|
||||
const v = place(list, 16, { left: 112, cy: 800 });
|
||||
const boxes = list.flatMap((c, i) => {
|
||||
const at = arrive(t, t0 + (build[i] + 1) * SIX);
|
||||
if (!at) return [];
|
||||
const gone = lift(t, t0 + (13 + out[i]) * SIX, LAND);
|
||||
return [box(c, at.dz + gone.dz, at.a * gone.a)];
|
||||
});
|
||||
cubes(ctx, v, boxes);
|
||||
};
|
||||
}
|
||||
|
||||
/** Bars 41–42: name, version, availability, address. */
|
||||
function end(ctx, t) {
|
||||
const t0 = bar(41);
|
||||
const list = word("Ely Office 0.1.0", (g) => (g >= 11 ? ACCENT : LIGHT));
|
||||
const name = list.filter((c) => c.glyph < 11);
|
||||
const version = list.filter((c) => c.glyph >= 11);
|
||||
const slot = new Map([
|
||||
...name.map((c, i) => [c, slots(name, 8)[i]]),
|
||||
...version.map((c, i) => [c, 8 + slots(version, 4)[i]]),
|
||||
]);
|
||||
const v = place(list, 21, { cx: 960, cy: 616 });
|
||||
const left = bounds(v, list.map((c) => box(c))).x0;
|
||||
const boxes = list.flatMap((c) => {
|
||||
const at = arrive(t, t0 + (slot.get(c) + 1) * SIX);
|
||||
return at ? [box(c, at.dz, at.a)] : [];
|
||||
});
|
||||
cubes(ctx, v, boxes);
|
||||
const fade = (when) => settle(clamp((t - (when - LAND)) / LAND));
|
||||
const a = fade(t0 + 3 * BEAT);
|
||||
const y = under(v, left + 620) + 56;
|
||||
const line = { x: left, align: "left", a };
|
||||
text(ctx, { ...line, s: "macOS now · Windows and Linux soon", y, size: 34, color: "#c4c2c0" });
|
||||
text(ctx, { ...line, s: "macOS 现已推出 · Windows 与 Linux 即将推出", y: y + 46, size: 28, color: "#acaaa8" });
|
||||
const url = "github.com/ZacharyZhang-NY/ElyOffice";
|
||||
text(ctx, { ...line, s: url, y: y + 122, size: 30, color: "#f5f5f7", a: fade(t0 + BAR), weight: 400 });
|
||||
}
|
||||
|
||||
const frame = (s) => Math.round(s * 30);
|
||||
|
||||
/** One range of global frames per bar span. */
|
||||
function span(name, kind, from, to, draw, first = frame(bar(from))) {
|
||||
return { name, kind, first, count: frame(bar(to)) - first, draw };
|
||||
}
|
||||
|
||||
const APPS = ["Doc", "Table", "Show", "PDF", "Tree", "Mark"];
|
||||
|
||||
export const SCENES = [
|
||||
{ name: "type-ely", kind: "base", first: 0, count: 129, draw: ely },
|
||||
{ name: "type-title", kind: "over", first: 386, count: 129, draw: title },
|
||||
...APPS.map((a, i) => span(`type-${a.toLowerCase()}`, "over", 9 + 4 * i, 10 + 4 * i, app(`Ely${a}`, 9 + 4 * i))),
|
||||
{ name: "type-end", kind: "over", first: 2572, count: 128, draw: end },
|
||||
];
|
||||
Reference in new issue
Block a user