#!/usr/bin/env node // Draws the flat icons of the redesigned apps and writes every file made from them. // // node scripts/draw-app-icons.mjs [--objects ] // // The drawings are here, as SVG in each app's own colours (assets/design//DECISIONS.md "Icon"); nothing is // painted. For each app it writes, into the tree: // - the iPhone icon, light, dark and tinted (AppIcon-1024.png, -dark, -tinted), and the Dev icon the same with // the DEV band (assets/icons/dev-band.png: the red pill every Dev icon wears, x 261 to 762, y 834 to 946); // - the Play listing's 512 icon and the mark in its feature graphic's tile (assets/store/play//…/images); // - with --objects, the launch mark, light and dark, as `-object.png` / `-object-dark.png` (1024, clear // ground, at the icon's own proportion), for scripts/gen-launch-screens.py to lay on the launch screen and splash. // The Android launcher icon is drawn from that same mark by the build (apps/android/app/build.gradle.kts, // LaunchPictures), so it is the iPhone icon's twin. // Run it again whenever a drawing changes: the same drawing writes the same files. import fs from "node:fs"; import path from "node:path"; import { fileURLToPath } from "node:url"; import sharp from "sharp"; const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), ".."); const FLAVOURS = path.join(ROOT, "apps/cotton/App/Flavours"); const BAND = { left: 261, top: 834, file: path.join(ROOT, "assets/icons/dev-band.png") }; const svg = (ground, body) => `` + (ground ? `` : "") + body + ``; // Comms (assets/design/chat/DECISIONS.md "Icon"): the opening quote mark, drawn round as a hand writes it, two // 6-shaped marks side by side in Comms' terracotta on its warm ground; amber on its night ground. It reads as a // quotation mark and as two earbuds; neither reading is pushed further. function quote({ ink }) { const mark = (cx, cy) => `` + ``; return mark(382, 600) + mark(652, 600); } // Words (assets/design/notes/DECISIONS.md "Icon"): the wordmark "words" in Figtree ExtraBold, set tight, in Words' // ink, with a text cursor after it in Words' blue ink (#2B4A8F; owner, 22 Nov 2026: Words writes in blue). The letters are Figtree's own outlines (SIL OFL), // fixed here so the drawing never depends on a font being installed. It is the one picture at every size and in // every place, the home screen and the stores included: a "w|" small-size cut for the iPhone's small slots stood as // THE icon on the owner's iPhone and in App Store Connect in build 22 (22 Nov 2026), and is gone. const WORDS_LETTERS = "M213.10 600L174.69 600L132 474.45L171.92 474.45L195.02 547.77L218.13 474.45L256.79 474.45L279.14 546.01L302.74 474.45L342.67 474.45L299.73 600L261.31 600L237.21 521.41L213.10 600ZM405.44 603.01L405.44 603.01Q385.61 603.01 370.54 594.60Q355.47 586.19 346.81 571.38Q338.15 556.56 338.15 537.23L338.15 537.23Q338.15 517.89 346.56 503.08Q354.97 488.26 370.16 479.85Q385.35 471.44 404.69 471.44L404.69 471.44Q424.52 471.44 439.72 479.85Q454.91 488.26 463.32 503.08Q471.73 517.89 471.73 537.23L471.73 537.23Q471.73 556.56 463.32 571.38Q454.91 586.19 439.84 594.60Q424.78 603.01 405.44 603.01ZM405.44 566.86L405.44 566.86Q412.97 566.86 418.88 563.09Q424.78 559.32 428.17 552.67Q431.56 546.01 431.56 537.23L431.56 537.23Q431.56 528.44 428.17 521.78Q424.78 515.13 418.75 511.36Q412.72 507.60 404.94 507.60L404.94 507.60Q397.16 507.60 391.13 511.36Q385.10 515.13 381.71 521.78Q378.32 528.44 378.32 537.23L378.32 537.23Q378.32 546.01 381.71 552.67Q385.10 559.32 391.25 563.09Q397.41 566.86 405.44 566.86ZM521.20 600L482.03 600L482.03 474.45L521.20 474.45L521.20 497.80Q528.98 486.00 541.03 479.98Q553.09 473.95 565.64 473.95L565.64 473.95L565.64 512.12Q554.09 512.12 543.92 514.63Q533.75 517.14 527.47 522.29Q521.20 527.43 521.20 535.47L521.20 535.47L521.20 600ZM623.39 603.01L623.39 603.01Q605.82 603.01 593.13 595.10Q580.45 587.19 573.55 572.38Q566.64 557.57 566.64 537.23L566.64 537.23Q566.64 516.64 573.55 501.95Q580.45 487.26 593.13 479.35Q605.82 471.44 623.39 471.44L623.39 471.44Q635.19 471.44 644.11 476.08Q653.02 480.73 659.05 489.27L659.05 489.27L659.05 424.23L698.22 424.23L698.22 600L660.80 600L659.80 584.18Q654.03 593.22 644.73 598.12Q635.44 603.01 623.39 603.01ZM633.69 566.86L633.69 566.86Q640.72 566.86 646.12 563.59Q651.51 560.33 654.90 554.18Q658.29 548.02 659.05 540.49L659.05 540.49L659.05 533.96Q658.29 526.43 654.90 520.40Q651.51 514.38 645.99 510.99Q640.47 507.60 633.44 507.60L633.44 507.60Q625.90 507.60 620.00 511.36Q614.10 515.13 610.71 521.78Q607.32 528.44 607.32 537.23L607.32 537.23Q607.32 546.01 610.84 552.67Q614.35 559.32 620.25 563.09Q626.15 566.86 633.69 566.86ZM762.25 603.01L762.25 603.01Q749.94 603.01 739.27 599.37Q728.60 595.73 720.82 589.08Q713.03 582.42 709.27 572.88L709.27 572.88L741.41 559.32Q744.67 565.85 750.45 568.99Q756.22 572.13 762.25 572.13L762.25 572.13Q768.52 572.13 772.04 569.99Q775.55 567.86 775.55 564.09L775.55 564.09Q775.55 560.08 771.91 557.82Q768.27 555.56 761.49 553.80L761.49 553.80L750.70 551.04Q733.12 546.52 723.70 536.10Q714.29 525.68 714.29 511.87L714.29 511.87Q714.29 492.53 727.60 481.99Q740.90 471.44 764.51 471.44L764.51 471.44Q777.81 471.44 787.98 474.95Q798.15 478.47 805.06 484.87Q811.96 491.28 814.98 499.81L814.98 499.81L783.84 512.62Q782.08 507.60 776.68 504.96Q771.29 502.32 764.76 502.32L764.76 502.32Q759.23 502.32 756.22 504.71Q753.21 507.10 753.21 511.11L753.21 511.11Q753.21 514.13 756.85 516.26Q760.49 518.39 767.52 520.15L767.52 520.15L780.83 523.42Q792.63 526.43 800.66 532.58Q808.70 538.73 812.72 546.89Q816.73 555.05 816.73 564.34L816.73 564.34Q816.73 576.15 809.83 584.81Q802.92 593.47 790.62 598.24Q778.32 603.01 762.25 603.01Z"; const WORDS_CURSOR = [853.02, 414.32, 38.98, 225.86, 7.02]; const cursor = ([x, y, w, h, r], fill) => ``; const wordmark = ({ ink, accent }) => `` + cursor(WORDS_CURSOR, accent); // Secrets (assets/design/keys/DECISIONS.md "Icon and colour"; the owner chose Plum, 25 Nov 2026): the six-armed asterisk // that stands in for a hidden character, three round-ended strokes (secrets.html's `m-aster`, 64 units, times 16), in // plum on the lilac ground; lilac plum on the night ground. function aster({ ink }) { return ``; } // Contacts (assets/design/contacts/DECISIONS.md "Icon"; plain, for the owner to refine, 27 Nov 2026): one person, a // round head over round shoulders, solid, in Contacts' blue on its warm ground (ContactsApp.kt `Ink`); pale blue on // night. The same weight as Secrets' asterisk and Sites' slashes. function person({ ink }) { return `` + ``; } // Post (assets/design/mail/DECISIONS.md "Icon and colour"; the owner chose the Stamp, 25 Nov 2026): a postage stamp, // its edge perforated and an inner frame in the ground's colour (mail.html's `m-stamp`, 64 units, times 16), franking // green on sage; pale green on night. const STAMP_EDGE = "M13 9 H14.80 a2.4 2.4 0 0 0 4.8 0 H20.72 a2.4 2.4 0 0 0 4.8 0 H26.64 a2.4 2.4 0 0 0 4.8 0 H32.56 a2.4 2.4 0 0 0 4.8 0 H38.48 a2.4 2.4 0 0 0 4.8 0 H44.40 a2.4 2.4 0 0 0 4.8 0 H51 V10.80 a2.4 2.4 0 0 0 0 4.8 V17.07 a2.4 2.4 0 0 0 0 4.8 V23.33 a2.4 2.4 0 0 0 0 4.8 V29.60 a2.4 2.4 0 0 0 0 4.8 V35.87 a2.4 2.4 0 0 0 0 4.8 V42.13 a2.4 2.4 0 0 0 0 4.8 V48.40 a2.4 2.4 0 0 0 0 4.8 V55 H49.20 a2.4 2.4 0 0 0 -4.8 0 H43.28 a2.4 2.4 0 0 0 -4.8 0 H37.36 a2.4 2.4 0 0 0 -4.8 0 H31.44 a2.4 2.4 0 0 0 -4.8 0 H25.52 a2.4 2.4 0 0 0 -4.8 0 H19.60 a2.4 2.4 0 0 0 -4.8 0 H13 V53.20 a2.4 2.4 0 0 0 0 -4.8 V46.93 a2.4 2.4 0 0 0 0 -4.8 V40.67 a2.4 2.4 0 0 0 0 -4.8 V34.40 a2.4 2.4 0 0 0 0 -4.8 V28.13 a2.4 2.4 0 0 0 0 -4.8 V21.87 a2.4 2.4 0 0 0 0 -4.8 V15.60 a2.4 2.4 0 0 0 0 -4.8 Z"; function stamp({ ground, ink }) { // The frame is cut in the ground's colour; on a launch screen with no ground of its own it is the light paper's. const frame = ground ?? "#F1F3EE"; return `` + ``; } // Data (assets/design/data/DECISIONS.md "Icon"; the owner chose Ones and noughts, 25 Nov 2026, from // assets/design/shared/icons-fresh.html#data-a): two rows of binary, 10 over 01, each digit one ballpoint stroke and the // noughts drawn like the Days ring, in Days' blue on Days' pale; periwinkle on near-black at night. function binary({ ink }) { return ``; } // Sites (assets/design/sites/DECISIONS.md "Icon and colour"; the owner chose B, Double Slash, 25 Nov 2026, from // assets/design/shared/icons-fresh.html `sites-b`): the two slashes of every web address, two thick parallel strokes // that never touch, like two sign-ins to one site side by side. Round ends, 112 px, as Secrets' asterisk. Cranberry // on rose; pink on night. function slashes({ ink }) { return ``; } // Story (assets/design/story/DECISIONS.md "The icon"; the owner's final word, 25 Nov 2026): the full plot arc, one // smooth pen line through the inciting incident, the midpoint and the climax, round caps and joins, 54 wide on 1024. // The owner's line, its two dips eased a little apart (the curves' inner handles moved out by 7 to 22) so they stay // open at 29 px; the three rises are his. Story's ballpoint blue on its icon's paper; pale blue on its night navy. function arc({ ink }) { return ``; } // Albums (assets/design/albums/DECISIONS.md "Icon and colour", a suggestion until the owner chooses): a photo corner, // the paper mount that holds a print in an album: one flat triangle over the corner of a print drawn as a line. The // colour is a stand-in, saffron on cream and pale saffron on night, none of the family's taken inks. function corner({ ink }) { return `` + ``; } // Tinted: the mark in white on black; the system tints it by its lightness. const TINTED = { ground: "#000000", ink: "#FFFFFF", accent: "#FFFFFF" }; const APPS = { albums: { flavour: "albums", set: "Albums", store: "albums", light: { ground: "#F6F2EA", ink: "#A65A14" }, dark: { ground: "#1A1612", ink: "#E9A86A" }, mark: corner, }, story: { flavour: "story", set: "Story", store: "story", // The icon's paper as it was (#FAFAF7), in Story's Look default ink, ballpoint Blue (kits/look/look.json, Story's // inks: accent light and dark); the dark icon on Story's night navy, as before. light: { ground: "#FAFAF7", ink: "#1F3FE0" }, dark: { ground: "#15171F", ink: "#8EA2FF" }, mark: arc, // iPhone only (DECISIONS "Look": the icon follows the ink): one alternate set per ink but Blue. inks: { Red: { light: { ink: "#B3261E" }, dark: { ink: "#FF8C82" } }, Green: { light: { ink: "#1C7A44" }, dark: { ink: "#7ED6A1" } }, Black: { light: { ink: "#111111" }, dark: { ink: "#F0F0F0" } }, }, }, data: { flavour: "data", set: "Data", store: "data", // On iPhone too (26 Nov 2026): Android reads the iPhone's flavour folder, as for every app the iPhone builds. folder: path.join(ROOT, "apps/cotton/App/Flavours/data"), light: { ground: "#F1F2F6", ink: "#1D3FD8" }, dark: { ground: "#15171F", ink: "#8EA2FF" }, mark: binary, }, contacts: { flavour: "contacts", set: "Contacts", store: "contacts", // On iPhone too (28 Nov 2026): Android reads the iPhone's flavour folder, as for every app the iPhone builds. folder: path.join(ROOT, "apps/cotton/App/Flavours/contacts"), light: { ground: "#F4F2EE", ink: "#2F5D8A" }, dark: { ground: "#141311", ink: "#8DB4DC" }, mark: person, }, sites: { flavour: "sites", set: "Sites", store: "sites", // kits/look/look.json, Sites: Rose and Night, in Cranberry. light: { ground: "#F5F1F1", ink: "#9A2C4C" }, dark: { ground: "#171213", ink: "#E58AA6" }, mark: slashes, // iPhone only (DECISIONS "The look": the icon follows the ink): one alternate set per ink but Cranberry. inks: { Petrol: { light: { ink: "#0E6372" }, dark: { ink: "#7FC6CF" } }, Indigo: { light: { ink: "#3A4FC4" }, dark: { ink: "#A9B4F2" } }, Ochre: { light: { ink: "#8A6A12" }, dark: { ink: "#E2C46A" } }, Graphite: { light: { ink: "#2B3032" }, dark: { ink: "#D6DCDE" } }, }, }, post: { flavour: "mail", set: "Mail", store: "post", // kits/look/look.json, Post: Sage and Night, in Franking green. light: { ground: "#F1F3EE", ink: "#1E6B4A" }, dark: { ground: "#131915", ink: "#7CC9A0" }, mark: stamp, // iPhone only (DECISIONS "Look": the icon follows the ink): one alternate set per ink but Franking green. inks: { Teal: { light: { ink: "#0E6A70" }, dark: { ink: "#6CC4C8" } }, Oxblood: { light: { ink: "#8E2F3A" }, dark: { ink: "#E8909A" } }, InkBlue: { light: { ink: "#2F4A9A" }, dark: { ink: "#9DB0F0" } }, Graphite: { light: { ink: "#25302A" }, dark: { ink: "#D5DDD7" } }, }, }, secrets: { flavour: "keys", set: "Keys", store: "secrets", // kits/look/look.json, Secrets: Lilac and Night, in Plum. light: { ground: "#F1EEF3", ink: "#7A3C9E" }, dark: { ground: "#18131D", ink: "#C39BE3" }, mark: aster, // iPhone only (DECISIONS "Look": the icon follows the ink): one alternate set per ink but Plum, the asterisk in // that ink (kits/look/look.json, Secrets' inks: accent light and dark). inks: { Jade: { light: { ink: "#11785A" }, dark: { ink: "#5FCF9F" } }, Garnet: { light: { ink: "#B23A48" }, dark: { ink: "#F08A96" } }, Indigo: { light: { ink: "#3A4FC4" }, dark: { ink: "#9AA8FF" } }, Graphite: { light: { ink: "#2A2530" }, dark: { ink: "#DCD6E0" } }, }, }, comms: { flavour: "messages", set: "Messages", store: "comms", // messages/warm/Warm.kt: ground and accent, day and night. light: { ground: "#FAF7F2", ink: "#C8552D" }, dark: { ground: "#1A1714", ink: "#E0A243" }, mark: quote, // iPhone only (shared/DECISIONS.md "Look"): one alternate set per ink but Terracotta, the quote in that ink // (kits/look/look.json, Comms' inks: accent light and dark). inks: { Blue: { light: { ink: "#2F5BD3" }, dark: { ink: "#9DB2EA" } }, Green: { light: { ink: "#2F7D5B" }, dark: { ink: "#8CC3A3" } }, Black: { light: { ink: "#1F1F1F" }, dark: { ink: "#EFE9E1" } }, }, }, words: { flavour: "notes", set: "Notes", store: "words", // kits/notes/writing.json: Linen light (the icon, and the launch in a light phone), Linen dark (the dark icon). light: { ground: "#F8F6F1", ink: "#1E1C19", accent: "#2B4A8F" }, dark: { ground: "#1F1E1C", ink: "#F2EFE9", accent: "#93ABEB" }, // The launch in a dark phone lies on Slate's dark ground (Words' first dark screen), so its mark wears Slate's ink. launchDark: { ink: "#EEEFF1", accent: "#93ABEB" }, mark: wordmark, // iPhone only (owner, 23 Nov 2026; shared/DECISIONS.md "Look"): the icon follows the ink. One alternate set per ink // but the default (blue, the primary icon), its cursor in that ink, light and dark (kits/notes/writing.json `inks`). inks: { Red: { light: { accent: "#CF4A3C" }, dark: { accent: "#E6675A" } }, Green: { light: { accent: "#2E6A4F" }, dark: { accent: "#7DBF98" } }, Black: { light: { accent: "#2A2A2D" }, dark: { accent: "#E6E4DF" } }, }, }, }; const png = (s, px = 1024) => sharp(Buffer.from(s)).resize(px, px).png(); async function iconSet(dir, name, a, band) { fs.mkdirSync(dir, { recursive: true }); for (const f of fs.readdirSync(dir)) if (f.endsWith(".png")) fs.rmSync(path.join(dir, f)); const looks = [["", a.light], ["-dark", a.dark], ["-tinted", TINTED]]; const images = []; async function write(file, drawing, px) { let picture = png(drawing); if (band) picture = sharp(await picture.toBuffer()).composite([{ input: BAND.file, left: BAND.left, top: BAND.top }]).png(); // No alpha: the App Store refuses an icon with a transparent channel. const whole = await picture.removeAlpha().png().toBuffer(); await sharp(whole).resize(px, px).png().toFile(path.join(dir, file)); } const appearance = (suffix) => (suffix ? { appearances: [{ appearance: "luminosity", value: suffix.slice(1) }] } : {}); for (const [suffix, c] of looks) { // One 1024 per look: Xcode draws every size from it. const file = `${name}-1024${suffix}.png`; await write(file, svg(c.ground, a.mark(c)), 1024); images.push({ filename: file, idiom: "universal", platform: "ios", size: "1024x1024", ...appearance(suffix) }); } fs.writeFileSync(path.join(dir, "Contents.json"), JSON.stringify({ images, info: { author: "xcode", version: 1 } }, null, 2) + "\n"); } // The feature graphics (1024 by 500, 21 Nov 2026) all hold the icon as a rounded tile 296 px across at (100, 100) with a // soft shadow under it, the name to its right. const TILE = { left: 100, top: 100, side: 296 }; /** The feature graphic's tile: its place cleared to the ground (the old tile and its shadow), the new icon laid there. */ async function featureTile(file, a) { const { data, info } = await sharp(file).removeAlpha().raw().toBuffer({ resolveWithObject: true }); const ground = [0, 1, 2].map((k) => data[(2 * info.width + 2) * 3 + k]); const hex = "#" + ground.map((v) => v.toString(16).padStart(2, "0")).join(""); const { left, top, side } = TILE; const radius = Math.round(side * 0.2237); const rounded = (fill) => Buffer.from(``); const clear = await sharp({ create: { width: side + 60, height: side + 70, channels: 3, background: hex } }).png().toBuffer(); const pad = 24; const shadow = await sharp(Buffer.from(``)) .blur(8).png().toBuffer(); const tile = await sharp(await png(svg(a.light.ground, a.mark(a.light)), side).toBuffer()) .composite([{ input: rounded("#fff"), blend: "dest-in" }]).png().toBuffer(); const out = await sharp(file) .composite([ { input: clear, left: left - 30, top: top - 25 }, { input: shadow, left: left - pad, top: top - pad + 5 }, { input: tile, left, top }, ]) .png().toBuffer(); fs.writeFileSync(file, out); } // Days keeps its painted light icon (owner, 22 Nov 2026; Story's became the drawn arc, 25 Nov 2026); its dark and tinted looks are // recoloured from that painting, so the letters, the full stop and the pen ring keep every edge of the original. Each // pixel is read as the ground mixed with one of the painting's inks by some coverage, and laid again as the new ground // mixed with that ink's new colour by the same coverage. Both apps are light-only inside; the dark icon is for the // home screen in a dark phone. Their dark ground is Days' and Story's navy ink, deepened; the inks lightened to read on it. const PAINTED = { days: { flavour: "days", set: "Days", inks: ["#1F3FDC"], dark: { ground: "#15171F", inks: ["#8EA2FF"] }, byInk: { Red: ["#B3261E", "#FF8C82"], Green: ["#1C7A44", "#7ED6A1"], Black: ["#111111", "#F0F0F0"] }, }, }; const rgb = (hex) => [1, 3, 5].map((i) => parseInt(hex.slice(i, i + 2), 16)); async function recolour(file, inks, look) { const { data, info } = await sharp(file).removeAlpha().raw().toBuffer({ resolveWithObject: true }); const g = [data[0], data[1], data[2]]; const from = inks.map(rgb); const to = look.inks.map(rgb); const G = rgb(look.ground); const out = Buffer.alloc(data.length); for (let i = 0; i < data.length; i += 3) { const p = [data[i] - g[0], data[i + 1] - g[1], data[i + 2] - g[2]]; let best = 0, cover = 0, miss = Infinity; from.forEach((ink, k) => { const d = ink.map((v, j) => v - g[j]); const a = Math.min(1, Math.max(0, (p[0] * d[0] + p[1] * d[1] + p[2] * d[2]) / (d[0] * d[0] + d[1] * d[1] + d[2] * d[2]))); const r = p.reduce((sum, v, j) => sum + (v - a * d[j]) ** 2, 0); if (r < miss) { miss = r; best = k; cover = a; } }); for (let j = 0; j < 3; j++) out[i + j] = Math.round(G[j] * (1 - cover) + to[best][j] * cover); } return sharp(out, { raw: { width: info.width, height: info.height, channels: 3 } }).png().toBuffer(); } async function paintedLooks(a) { const catalogue = path.join(FLAVOURS, a.flavour, "Assets.xcassets"); const live = path.join(catalogue, `AppIcon${a.set}.appiconset`, `AppIcon${a.set}-1024.png`); const looks = { dark: a.dark, tinted: { ground: "#000000", inks: a.inks.map(() => "#FFFFFF") } }; for (const [set, band] of [[`AppIcon${a.set}`, false], [`AppIcon${a.set}Dev`, true]]) { const dir = path.join(catalogue, `${set}.appiconset`); const images = [{ filename: `${set}-1024.png`, idiom: "universal", platform: "ios", size: "1024x1024" }]; // The Dev light icon: the live painting with the DEV pill, as every Dev look and every other app's Dev icon. if (band) await sharp(live).composite([{ input: BAND.file, left: BAND.left, top: BAND.top }]).removeAlpha().png().toFile(path.join(dir, `${set}-1024.png`)); for (const [name, look] of Object.entries(looks)) { let picture = await recolour(live, a.inks, look); if (band) picture = await sharp(picture).composite([{ input: BAND.file, left: BAND.left, top: BAND.top }]).png().toBuffer(); const file = `${set}-1024-${name}.png`; await sharp(picture).removeAlpha().png().toFile(path.join(dir, file)); images.push({ filename: file, idiom: "universal", platform: "ios", size: "1024x1024", appearances: [{ appearance: "luminosity", value: name }] }); } fs.writeFileSync(path.join(dir, "Contents.json"), JSON.stringify({ images, info: { author: "xcode", version: 1 } }, null, 2) + "\n"); } } /** The ink icons of a painted app: its painting with the pen's blue (its last ink) recoloured, light, dark and tinted. */ async function paintedInks(a) { const catalogue = path.join(FLAVOURS, a.flavour, "Assets.xcassets"); const live = path.join(catalogue, `AppIcon${a.set}.appiconset`, `AppIcon${a.set}-1024.png`); const { data } = await sharp(live).removeAlpha().raw().toBuffer({ resolveWithObject: true }); const ground = "#" + [data[0], data[1], data[2]].map((v) => v.toString(16).padStart(2, "0")).join(""); for (const [ink, [light, dark]] of Object.entries(a.byInk ?? {})) { const swap = (inks, colour) => inks.map((one, i) => (i === inks.length - 1 ? colour : one)); const looks = [ ["", { ground, inks: swap(a.inks, light) }], ["-dark", { ground: a.dark.ground, inks: swap(a.dark.inks, dark) }], ["-tinted", { ground: "#000000", inks: a.inks.map(() => "#FFFFFF") }], ]; for (const [set, band] of [[`AppIcon${a.set}${ink}`, false], [`AppIcon${a.set}Dev${ink}`, true]]) { const dir = path.join(catalogue, `${set}.appiconset`); fs.mkdirSync(dir, { recursive: true }); const images = []; for (const [suffix, look] of looks) { let picture = await recolour(live, a.inks, look); if (band) picture = await sharp(picture).composite([{ input: BAND.file, left: BAND.left, top: BAND.top }]).png().toBuffer(); const file = `${set}-1024${suffix}.png`; await sharp(picture).removeAlpha().png().toFile(path.join(dir, file)); images.push({ filename: file, idiom: "universal", platform: "ios", size: "1024x1024", ...(suffix ? { appearances: [{ appearance: "luminosity", value: suffix.slice(1) }] } : {}) }); } fs.writeFileSync(path.join(dir, "Contents.json"), JSON.stringify({ images, info: { author: "xcode", version: 1 } }, null, 2) + "\n"); } } } async function main() { const [app, ...rest] = process.argv.slice(2); if (rest.includes("--inks-only") && PAINTED[app]) { await paintedInks(PAINTED[app]); console.log(`${app}: ink icons written`); return; } if (PAINTED[app]) { await paintedLooks(PAINTED[app]); await paintedInks(PAINTED[app]); console.log(`${app}: dark and tinted icons written`); return; } const a = APPS[app]; if (!a) throw new Error(`usage: node scripts/draw-app-icons.mjs <${[...Object.keys(APPS), ...Object.keys(PAINTED)].join("|")}> [--objects ]`); const catalogue = path.join(a.folder ?? path.join(FLAVOURS, a.flavour), "Assets.xcassets"); await iconSet(path.join(catalogue, `AppIcon${a.set}.appiconset`), `AppIcon${a.set}`, a, false); await iconSet(path.join(catalogue, `AppIcon${a.set}Dev.appiconset`), `AppIcon${a.set}Dev`, a, true); // The ink icons, `AppIcon` and `AppIconDev`: the app sets the one named after its primary and the ink. for (const [ink, c] of Object.entries(a.inks ?? {})) { const inked = { ...a, light: { ...a.light, ...c.light }, dark: { ...a.dark, ...c.dark } }; await iconSet(path.join(catalogue, `AppIcon${a.set}${ink}.appiconset`), `AppIcon${a.set}${ink}`, inked, false); await iconSet(path.join(catalogue, `AppIcon${a.set}Dev${ink}.appiconset`), `AppIcon${a.set}Dev${ink}`, inked, true); } // The Play listing's icon and feature tile, once the app has a listing in the tree (Secrets has none yet). const images = path.join(ROOT, `assets/store/play/${a.store}/metadata/en-US/images`); if (fs.existsSync(images)) { await png(svg(a.light.ground, a.mark(a.light)), 512).removeAlpha().toFile(path.join(images, "icon.png")); if (fs.existsSync(path.join(images, "featureGraphic.png"))) await featureTile(path.join(images, "featureGraphic.png"), a); } const k = rest.indexOf("--objects"); if (k >= 0) { const dir = rest[k + 1]; fs.mkdirSync(dir, { recursive: true }); await png(svg(null, a.mark(a.light))).toFile(path.join(dir, `${a.flavour}-object.png`)); await png(svg(null, a.mark({ ...a.dark, ...a.launchDark }))).toFile(path.join(dir, `${a.flavour}-object-dark.png`)); } console.log(`${app}: icons written`); } await main();