diff --git a/README.md b/README.md index 89f6e17..7f2b72c 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,18 @@ pnpm dev:docs # http://localhost:4322 `pnpm preview:site` and `pnpm preview:docs` serve the built output, which is what the review scripts below expect. +## The logo + +The mark is defined once, in `packages/brand/src/mark.mjs`: a tree between +two angle brackets on a 32-unit grid, with one 3-unit stroke. The wordmark +is "Parsec" in Geist Bold, outlined into paths, which the Open Font License +allows in a logo, so nothing that shows it needs the font. `pnpm --filter +@parsec/brand logos` runs `scripts/make-logos.mjs`, which draws the logo +files, favicons, org avatar, social cards and the animated README header +that parsec-html/parsec uses, and writes the wordmark's path data to +`src/wordmark.mjs` for `Logo.astro`. Edit the script and run it again +rather than editing those files. + ## Where the numbers come from Nothing on the site that can be measured is typed in by hand, with one diff --git a/apps/site/public/logo-full.svg b/apps/site/public/logo-full.svg index 7814ebd..a37c899 100644 --- a/apps/site/public/logo-full.svg +++ b/apps/site/public/logo-full.svg @@ -1,4 +1,4 @@ - - - + + + diff --git a/apps/site/public/logo-mark.svg b/apps/site/public/logo-mark.svg index 6e9b230..e0e884d 100644 --- a/apps/site/public/logo-mark.svg +++ b/apps/site/public/logo-mark.svg @@ -1,3 +1,3 @@ - + diff --git a/apps/site/public/logo-wordmark.svg b/apps/site/public/logo-wordmark.svg index e5573b2..12a6121 100644 --- a/apps/site/public/logo-wordmark.svg +++ b/apps/site/public/logo-wordmark.svg @@ -1,3 +1,3 @@ - - + + diff --git a/packages/brand/logos/apple-touch-icon.png b/packages/brand/logos/apple-touch-icon.png index 99d2a74..5c88655 100644 Binary files a/packages/brand/logos/apple-touch-icon.png and b/packages/brand/logos/apple-touch-icon.png differ diff --git a/packages/brand/logos/avatar.png b/packages/brand/logos/avatar.png new file mode 100644 index 0000000..2b28f0b Binary files /dev/null and b/packages/brand/logos/avatar.png differ diff --git a/packages/brand/logos/avatar.svg b/packages/brand/logos/avatar.svg new file mode 100644 index 0000000..e1a6559 --- /dev/null +++ b/packages/brand/logos/avatar.svg @@ -0,0 +1,4 @@ + + + + diff --git a/packages/brand/logos/favicon-32.png b/packages/brand/logos/favicon-32.png index 0b935c3..30334b6 100644 Binary files a/packages/brand/logos/favicon-32.png and b/packages/brand/logos/favicon-32.png differ diff --git a/packages/brand/logos/favicon.svg b/packages/brand/logos/favicon.svg index 913cc6f..4174201 100644 --- a/packages/brand/logos/favicon.svg +++ b/packages/brand/logos/favicon.svg @@ -1,4 +1,4 @@ - + - + diff --git a/packages/brand/logos/github-social-preview.png b/packages/brand/logos/github-social-preview.png index c854679..4c791e5 100644 Binary files a/packages/brand/logos/github-social-preview.png and b/packages/brand/logos/github-social-preview.png differ diff --git a/packages/brand/logos/logo-full.svg b/packages/brand/logos/logo-full.svg index 7814ebd..a37c899 100644 --- a/packages/brand/logos/logo-full.svg +++ b/packages/brand/logos/logo-full.svg @@ -1,4 +1,4 @@ - - - + + + diff --git a/packages/brand/logos/logo-mark.svg b/packages/brand/logos/logo-mark.svg index 6e9b230..e0e884d 100644 --- a/packages/brand/logos/logo-mark.svg +++ b/packages/brand/logos/logo-mark.svg @@ -1,3 +1,3 @@ - + diff --git a/packages/brand/logos/logo-wordmark.svg b/packages/brand/logos/logo-wordmark.svg index e5573b2..12a6121 100644 --- a/packages/brand/logos/logo-wordmark.svg +++ b/packages/brand/logos/logo-wordmark.svg @@ -1,3 +1,3 @@ - - + + diff --git a/packages/brand/logos/readme-header-dark.svg b/packages/brand/logos/readme-header-dark.svg new file mode 100644 index 0000000..71faa1b --- /dev/null +++ b/packages/brand/logos/readme-header-dark.svg @@ -0,0 +1,29 @@ + + + + + + + + diff --git a/packages/brand/logos/readme-header-light.svg b/packages/brand/logos/readme-header-light.svg new file mode 100644 index 0000000..f659c81 --- /dev/null +++ b/packages/brand/logos/readme-header-light.svg @@ -0,0 +1,29 @@ + + + + + + + + diff --git a/packages/brand/logos/social-card.png b/packages/brand/logos/social-card.png index 5ef63c8..be2ab6e 100644 Binary files a/packages/brand/logos/social-card.png and b/packages/brand/logos/social-card.png differ diff --git a/packages/brand/scripts/make-logos.mjs b/packages/brand/scripts/make-logos.mjs index b5f0bdf..2c14ce2 100644 --- a/packages/brand/scripts/make-logos.mjs +++ b/packages/brand/scripts/make-logos.mjs @@ -1,6 +1,7 @@ -// Draws the Parsec logo set: the mark, the wordmark, the two together and -// the favicons. Run `node scripts/make-logos.mjs` from packages/brand after -// changing anything here. +// Draws the Parsec logo set: the mark, the wordmark, the two together, the +// favicons, the org avatar, the social cards and the animated header the +// repository's README shows. Run `node scripts/make-logos.mjs` from +// packages/brand after changing anything here. import { Resvg } from '@resvg/resvg-js'; import opentype from 'opentype.js'; import { mkdirSync, writeFileSync } from 'node:fs'; @@ -8,56 +9,138 @@ import { join } from 'node:path'; import { fileURLToPath } from 'node:url'; import { geistDir as geist } from './copy-fonts.mjs'; import { renderSocialCard } from '../src/social.mjs'; -import { accent, ink, bg, markSvg } from '../src/mark.mjs'; +import { accent, ink, bg, markSvg, strokes, nodes, strokeWidth } from '../src/mark.mjs'; const out = fileURLToPath(new URL('../logos/', import.meta.url)); mkdirSync(out, { recursive: true }); -const markBody = (color) => markSvg(color); -const mark = ` - ${markBody(accent)} - -`; +const fontFile = (name) => opentype.loadSync(join(geist, `dist/fonts/geist-sans/${name}`)); +const bold = fontFile('Geist-Bold.ttf'); +const regular = fontFile('Geist-Regular.ttf'); -// The wordmark: "parsec" set in Geist SemiBold, converted to paths so the -// file renders the same everywhere. -const font = opentype.loadSync(join(geist, 'dist/fonts/geist-sans/Geist-SemiBold.ttf')); -const fontSize = 32; -const text = font.getPath('parsec', 0, 0, fontSize, { kerning: true, letterSpacing: -0.02 }); -const box = text.getBoundingBox(); -const pad = 2; -const w = +(box.x2 - box.x1 + pad * 2).toFixed(2); -const h = +(box.y2 - box.y1 + pad * 2).toFixed(2); -const d = text.toPathData(2); -const wordBody = (color, x = 0, y = 0) => - ``; -const wordmark = ` - ${wordBody(ink)} - -`; +/** Text as one outlined path, with its top-left corner at (0, 0). */ +function outline(font, text, size, tracking) { + const box = font.getPath(text, 0, 0, size, { kerning: true, letterSpacing: tracking }).getBoundingBox(); + const path = font.getPath(text, -box.x1, -box.y1, size, { kerning: true, letterSpacing: tracking }); + return { d: path.toPathData(2), width: +(box.x2 - box.x1).toFixed(2), height: +(box.y2 - box.y1).toFixed(2) }; +} -// Mark and wordmark together: the mark sits on the cap height of the word. -const gap = 10; -const markSize = 32; -const fullH = Math.max(markSize, h); -const fullW = +(markSize + gap + w).toFixed(2); -const wordY = (fullH - h) / 2; -const full = ` - ${markBody(accent)} - ${wordBody(ink, markSize + gap, wordY)} - -`; +// The wordmark: "Parsec" in Geist Bold, tracked in a little, as paths so it +// renders the same everywhere and needs no font. +const word = outline(bold, 'Parsec', 32, -0.03); -// Favicons: the mark on a dark rounded tile so it reads on light tabs too. -const tile = (size, radius, inset) => ` - - ${markBody(accent)} - -`; +// Mark and wordmark together, the word centred on the mark. +const gap = 9; +const wordX = 32 + gap; +const wordY = +((32 - word.height) / 2).toFixed(2); +const fullWidth = +(wordX + word.width).toFixed(2); + +// Logo.astro draws the same thing inline, from this. +writeFileSync( + fileURLToPath(new URL('../src/wordmark.mjs', import.meta.url)), + `// Written by scripts/make-logos.mjs; don't edit.\nexport const word = ${JSON.stringify({ ...word, x: wordX, y: wordY, fullWidth })};\n`, +); + +const wordPath = (color, x, y) => ``; +const svg = (w, h, body, label = 'Parsec') => + `\n ${body}\n\n`; + +const mark = svg(32, 32, markSvg(accent)); +const wordmark = svg(word.width, word.height, wordPath(ink, 0, 0)); +const full = svg(fullWidth, 32, `${markSvg(accent)}\n ${wordPath(ink, wordX, wordY)}`); + +// Favicons and the org avatar: the mark on a dark tile so it reads on light +// tabs and pages too. +const tile = (size, radius, inset) => + svg( + size, + size, + ` + ${markSvg(accent)}`, + ); const favicon = tile(32, 7, 3); const apple = tile(180, 0, 30); +const avatar = tile(500, 0, 90); + +// The README header: the mark assembling itself, the wordmark and the +// tagline, and a faint parse tree on the right growing node by node, then +// breathing. CSS animation runs in an SVG shown through , which is how +// GitHub and crates.io show it; scripts don't. +const tagline = outline(regular, 'The parsing foundation for the web', 30, 0); +const treeNodes = [ + [1040, 70], + [960, 150], + [1120, 150], + [1060, 230], + [1180, 230], +]; +const treeEdges = [ + [0, 1], + [0, 2], + [2, 3], + [2, 4], +]; +function header(theme) { + const dark = theme === 'dark'; + const page = dark ? bg : '#F5F7F9'; + const text = dark ? '#FFFFFF' : '#17191C'; + const muted = dark ? '#A19D93' : '#5B6068'; + const markScale = 3.5; + const markX = 96; + const markY = 160 - 16 * markScale; + const wScale = 2.6; + const wX = markX + 32 * markScale + 36; + // The word and the tagline under it, centred as one block on the mark. + const wY = 160 - (word.height * wScale + 22 + tagline.height) / 2; + const edges = treeEdges + .map(([a, b], i) => { + const [x1, y1] = treeNodes[a]; + const [x2, y2] = treeNodes[b]; + return ``; + }) + .join(''); + const dots = treeNodes + .map(([cx, cy], i) => ``) + .join(''); + const style = ``; + const markBody = `${nodes + .map(([cx, cy, r], i) => ``) + .join('')}`; + return svg( + 1280, + 320, + `${style} + + ${edges}${dots} + ${markBody} + + `, + 'Parsec: the parsing foundation for the web', + ); +} -const png = (svg, width) => new Resvg(svg, { fitTo: { mode: 'width', value: width } }).render().asPng(); +const png = (s, width) => new Resvg(s, { fitTo: { mode: 'width', value: width } }).render().asPng(); writeFileSync(join(out, 'logo-mark.svg'), mark); writeFileSync(join(out, 'logo-wordmark.svg'), wordmark); @@ -65,6 +148,10 @@ writeFileSync(join(out, 'logo-full.svg'), full); writeFileSync(join(out, 'favicon.svg'), favicon); writeFileSync(join(out, 'favicon-32.png'), png(favicon, 32)); writeFileSync(join(out, 'apple-touch-icon.png'), png(apple, 180)); +writeFileSync(join(out, 'avatar.svg'), avatar); +writeFileSync(join(out, 'avatar.png'), png(avatar, 500)); +writeFileSync(join(out, 'readme-header-dark.svg'), header('dark')); +writeFileSync(join(out, 'readme-header-light.svg'), header('light')); const card = { title: 'The parsing foundation for the web', subtitle: 'HTML, CSS, JavaScript, XML, URLs and encodings, parsed by spec in Rust.', @@ -73,4 +160,4 @@ const card = { writeFileSync(join(out, 'social-card.png'), await renderSocialCard(card)); // GitHub's repository social preview is 1280x640. writeFileSync(join(out, 'github-social-preview.png'), await renderSocialCard({ ...card, width: 1280, height: 640 })); -console.log(`wrote logos to ${out} (wordmark ${w}x${h}, full ${fullW}x${fullH})`); +console.log(`wrote logos to ${out} (wordmark ${word.width}x${word.height}, full ${fullWidth}x32)`); diff --git a/packages/brand/src/Logo.astro b/packages/brand/src/Logo.astro index b2c485e..d6dba20 100644 --- a/packages/brand/src/Logo.astro +++ b/packages/brand/src/Logo.astro @@ -1,46 +1,98 @@ --- -// The Parsec mark, inline so the brackets and tree take the accent and the -// wordmark takes the current text colour. `full` adds the wordmark. +// The Parsec logo, inline: the brackets and tree take the accent and the +// outlined wordmark takes the current text colour. `full` adds the +// wordmark. On load the brackets open and the tree's nodes pop in, once; +// with reduced motion it's drawn finished. import { strokes, nodes, strokeWidth } from './mark.mjs'; +import { word } from './wordmark.mjs'; interface Props { full?: boolean; - /** Mark height in pixels; the wordmark is scaled to match. */ + /** Logo height in pixels. */ size?: 28 | 26; class?: string; } const { full = true, size = 28, class: className } = Astro.props; +const width = full ? word.fullWidth : 32; --- - - - {full && parsec} - + diff --git a/packages/brand/src/mark.mjs b/packages/brand/src/mark.mjs index b38aa85..1a8aeff 100644 --- a/packages/brand/src/mark.mjs +++ b/packages/brand/src/mark.mjs @@ -5,15 +5,17 @@ export const accent = '#F2B33D'; export const ink = '#EBE8E1'; export const bg = '#15171A'; -/** Bracket strokes and tree edges, as SVG path data. */ -export const strokes = ['M8.5 8 3 16l5.5 8', 'M23.5 8l5.5 8-5.5 8', 'M16 11 12.5 20M16 11l3.5 9']; +/** The two brackets, then the tree's edges, as SVG path data, on whole + * units of the grid so every stroke lands on the same pixels at 32px. */ +export const strokes = ['M9 9 3 16l6 7', 'M23 9l6 7-6 7', 'M16 11 13 20M16 11l3 9']; /** Tree nodes: root, then the two children, as [cx, cy, r]. */ export const nodes = [ - [16, 10.5, 2.5], - [12.5, 21, 2.1], - [19.5, 21, 2.1], + [16, 10, 3], + [13, 21, 2.5], + [19, 21, 2.5], ]; -export const strokeWidth = 2.4; +/** One stroke width for brackets and edges alike. */ +export const strokeWidth = 3; /** The mark as an SVG fragment in one colour. @param {string} color */ export function markSvg(color) { diff --git a/packages/brand/src/social.mjs b/packages/brand/src/social.mjs index e79ea6e..1774e1a 100644 --- a/packages/brand/src/social.mjs +++ b/packages/brand/src/social.mjs @@ -51,6 +51,15 @@ function mark(size) { ); } +/** The wordmark, outlined. @param {{ d: string, width: number, height: number }} word @param {number} scale */ +function wordmark(word, scale) { + return h( + 'svg', + { width: word.width * scale, height: word.height * scale, viewBox: `0 0 ${word.width} ${word.height}` }, + h('path', { d: word.d, fill: '#FFFFFF' }), + ); +} + /** A parse tree drawn large and faint: a document, its head and body, a * paragraph with text and a bold child, the shape of `

Hello world`. */ function tree() { @@ -102,6 +111,8 @@ function titleSize(title) { */ export async function renderSocialCard(card) { fonts ??= loadFonts(); + // make-logos.mjs writes this before it draws the cards. + const { word } = await import('./wordmark.mjs'); const width = card.width ?? 1200; const height = card.height ?? 630; const layout = h( @@ -123,7 +134,7 @@ export async function renderSocialCard(card) { 'div', { style: { position: 'absolute', left: 72, top: 72, display: 'flex', alignItems: 'center', gap: 16 } }, mark(48), - h('div', { style: { fontSize: 40, fontWeight: 600, letterSpacing: -1.2, color: '#FFFFFF' } }, 'parsec'), + wordmark(word, 1.3), ), h( 'div', diff --git a/packages/brand/src/wordmark.mjs b/packages/brand/src/wordmark.mjs new file mode 100644 index 0000000..f2bab19 --- /dev/null +++ b/packages/brand/src/wordmark.mjs @@ -0,0 +1,2 @@ +// Written by scripts/make-logos.mjs; don't edit. +export const word = {"d":"M4.86 22.72L0 22.72L0 0L9.09 0Q13.18 0 15.50 1.98Q17.82 3.97 17.82 7.42L17.82 7.42Q17.82 10.88 15.50 12.88Q13.18 14.88 9.09 14.88L9.09 14.88L4.86 14.88L4.86 22.72ZM4.86 4.10L4.86 10.78L8.80 10.78Q10.72 10.78 11.78 9.94Q12.83 9.09 12.83 7.42L12.83 7.42Q12.83 5.76 11.78 4.93Q10.72 4.10 8.80 4.10L8.80 4.10L4.86 4.10ZM24.67 23.10L24.67 23.10Q21.98 23.10 20.32 21.87Q18.66 20.64 18.66 18.43L18.66 18.43Q18.66 16.16 20.08 14.93Q21.50 13.70 24.29 13.12L24.29 13.12L29.82 12.03Q29.82 8.67 26.91 8.67L26.91 8.67Q24.26 8.67 23.78 11.14L23.78 11.14L18.94 10.91Q19.42 8.10 21.49 6.64Q23.55 5.18 26.91 5.18L26.91 5.18Q30.75 5.18 32.69 7.02Q34.62 8.86 34.62 12.35L34.62 12.35L34.62 18.21Q34.62 18.94 34.86 19.18Q35.10 19.42 35.58 19.42L35.58 19.42L36.06 19.42L36.06 22.72Q35.84 22.78 35.34 22.85Q34.85 22.91 34.37 22.91L34.37 22.91Q33.06 22.91 32.02 22.35Q30.98 21.79 30.66 20.26L30.66 20.26L30.59 20.10Q29.95 21.47 28.42 22.29Q26.88 23.10 24.67 23.10ZM25.82 19.81L25.82 19.81Q27.62 19.81 28.72 18.75Q29.82 17.70 29.82 15.87L29.82 15.87L29.82 15.04L25.92 15.87Q23.58 16.32 23.58 17.98L23.58 17.98Q23.58 19.81 25.82 19.81ZM42.43 22.72L37.63 22.72L37.63 5.57L42.18 5.57L42.30 8.99Q42.82 7.20 43.81 6.38Q44.80 5.57 46.37 5.57L46.37 5.57L47.94 5.57L47.94 9.54L46.37 9.54Q44.35 9.54 43.39 10.35Q42.43 11.17 42.43 13.09L42.43 13.09L42.43 22.72ZM56.32 23.10L56.32 23.10Q52.16 23.10 50.21 21.47Q48.26 19.84 48.06 17.31L48.06 17.31L52.93 17.15Q53.15 18.37 53.92 19.04Q54.69 19.71 56.32 19.71L56.32 19.71Q58.98 19.71 58.98 17.98L58.98 17.98Q58.98 17.44 58.72 17.09Q58.46 16.74 57.73 16.46Q56.99 16.19 55.55 15.97L55.55 15.97Q52.86 15.49 51.34 14.83Q49.82 14.18 49.20 13.17Q48.58 12.16 48.58 10.69L48.58 10.69Q48.58 8.22 50.50 6.70Q52.42 5.18 56.22 5.18L56.22 5.18Q58.78 5.18 60.45 5.95Q62.11 6.72 62.96 8.06Q63.81 9.41 63.94 11.07L63.94 11.07L59.14 11.26Q59.07 10.08 58.35 9.33Q57.63 8.58 56.16 8.58L56.16 8.58Q54.88 8.58 54.21 9.10Q53.54 9.63 53.54 10.50L53.54 10.50Q53.54 11.42 54.19 11.89Q54.85 12.35 56.61 12.61L56.61 12.61Q59.33 13.02 60.93 13.70Q62.53 14.37 63.22 15.39Q63.90 16.42 63.90 17.92L63.90 17.92Q63.90 20.42 61.86 21.76Q59.81 23.10 56.32 23.10ZM73.66 23.10L73.66 23.10Q71.04 23.10 69.10 21.98Q67.17 20.86 66.10 18.86Q65.02 16.86 65.02 14.14L65.02 14.14Q65.02 11.46 66.08 9.44Q67.14 7.42 69.07 6.30Q71.01 5.18 73.63 5.18L73.63 5.18Q76.19 5.18 78.08 6.30Q79.97 7.42 81.01 9.50Q82.05 11.58 82.05 14.46L82.05 14.46L82.05 15.42L69.98 15.42Q70.08 17.47 71.09 18.46Q72.10 19.46 73.76 19.46L73.76 19.46Q76.26 19.46 76.96 17.38L76.96 17.38L81.79 17.66Q81.09 20.22 78.93 21.66Q76.77 23.10 73.66 23.10ZM69.98 12.48L69.98 12.48L77.12 12.48Q77.02 10.59 76.08 9.66Q75.14 8.74 73.63 8.74L73.63 8.74Q72.13 8.74 71.15 9.71Q70.18 10.69 69.98 12.48ZM91.81 23.10L91.81 23.10Q89.18 23.10 87.22 21.98Q85.25 20.86 84.18 18.86Q83.10 16.86 83.10 14.14L83.10 14.14Q83.10 11.46 84.18 9.44Q85.25 7.42 87.22 6.30Q89.18 5.18 91.81 5.18L91.81 5.18Q94.08 5.18 95.89 5.98Q97.70 6.78 98.82 8.29Q99.94 9.79 100.19 11.90L100.19 11.90L95.23 12.13Q95.01 10.53 94.10 9.71Q93.18 8.90 91.81 8.90L91.81 8.90Q90.02 8.90 89.02 10.27Q88.03 11.65 88.03 14.14L88.03 14.14Q88.03 16.64 89.02 18.03Q90.02 19.42 91.81 19.42L91.81 19.42Q93.18 19.42 94.11 18.58Q95.04 17.73 95.23 16L95.23 16L100.19 16.19Q99.97 18.30 98.86 19.86Q97.76 21.41 95.95 22.26Q94.14 23.10 91.81 23.10Z","width":100.19,"height":23.1,"x":41,"y":4.45,"fullWidth":141.19};