Files
paseo/assets/brand/build.mjs
T

147 lines
17 KiB
JavaScript

// Generates the canonical Paseo and Paseo Hub brand marks and lockup SVGs.
//
// node assets/brand/build.mjs
//
// Marks are single-line stroked paths on a 700x700 viewBox (stroke-width 50,
// round caps and joins, centered to a 527-unit ink footprint). Lockups outline
// Plus Jakarta Sans SemiBold to SVG paths so every file is self-contained.
import { mkdirSync, writeFileSync } from "node:fs";
import path from "node:path";
import { fileURLToPath } from "node:url";
import { loadSync } from "opentype.js";
const root = path.dirname(fileURLToPath(import.meta.url));
const marksDir = path.join(root, "marks");
const lockupsDir = path.join(root, "lockups");
const fontPath = path.join(root, "fonts", "PlusJakartaSans-SemiBold.ttf");
const VIEWBOX = 700;
const STROKE = 50;
const FOOTPRINT = 527;
// Lockup proportions relative to the original website header (24px box, 12px gap, 18px text):
// - marks are 15% larger against text
// - ink-to-text gap is 20% tighter
// - butterfly is undersized by 6% in lockups so Paseo, Paseo Hub, and Hub read as one family
const MARK_SCALE = 1.15;
const GAP_SCALE = 0.8;
const BUTTERFLY_LOCKUP_SCALE = 0.94;
// Lockup coordinate system: flower ink spans 140 units with a 2-unit margin on all sides (height 144).
const LOCKUP_INK = 140;
const LOCKUP_PAD = 2;
const LOCKUP_HEIGHT = LOCKUP_INK + LOCKUP_PAD * 2;
const MARK_COLORS = [
{ name: "white", hex: "#FFFFFF" },
{ name: "black", hex: "#000000" },
{ name: "green", hex: "#20744A" },
];
const LOCKUP_COLORS = [
{ name: "white", hex: "#FFFFFF" },
{ name: "black", hex: "#000000" },
];
// Paseo butterfly mark (redraw B): smoothed centreline of the original mark, centered in 700x700.
const PASEO_MARK_PATH =
"M456.84 526.11C462.73 521.72 467.57 517.89 471.79 514.38C476.02 510.88 479.65 507.69 483.14 504.58C486.63 501.46 489.94 498.44 493.24 495.35C496.54 492.27 499.85 489.11 503.26 485.77C506.67 482.44 510.16 478.96 513.7 475.36C517.23 471.76 520.81 468.03 524.4 464.2C527.99 460.37 531.59 456.44 535.18 452.41C538.77 448.39 542.36 444.27 545.89 440.08C549.42 435.9 552.88 431.65 556.23 427.37C559.58 423.08 562.81 418.77 565.83 414.39C568.86 410.01 571.68 405.57 574.2 401.02C576.72 396.48 578.95 391.82 580.73 387C582.5 382.18 583.83 377.16 584.55 371.94C585.27 366.73 585.37 361.37 584.63 356.15C583.9 350.93 582.28 345.83 579.74 341.22C577.21 336.62 573.83 332.53 569.82 329.45C565.81 326.37 561.14 324.38 556.21 323.54C551.28 322.69 546.1 322.94 541.16 324.13C536.22 325.32 531.58 327.49 527.2 330.24C522.82 332.99 518.68 336.32 514.69 339.8C510.7 343.27 506.85 346.9 503.11 350.61C499.36 354.32 495.71 358.12 492.11 361.94C488.51 365.76 484.97 369.62 481.47 373.49C477.98 377.37 474.53 381.27 471.12 385.19C467.71 389.11 464.33 393.05 460.99 397C457.65 400.94 454.33 404.9 451.04 408.87C447.74 412.83 444.47 416.8 441.21 420.78C437.95 424.75 434.7 428.73 431.46 432.71C428.22 436.69 424.98 440.68 421.74 444.67C418.5 448.66 415.27 452.66 412.02 456.67C408.78 460.68 405.52 464.69 402.26 468.72C398.99 472.75 395.71 476.78 392.41 480.83C389.11 484.88 385.78 488.95 382.42 493.02C379.06 497.09 375.66 501.16 372.22 505.23C368.78 509.3 365.28 513.37 361.73 517.41C358.17 521.45 354.55 525.46 350.85 529.41C347.14 533.36 343.36 537.24 339.47 541.02C335.59 544.8 331.62 548.47 327.54 551.97C323.45 555.47 319.27 558.81 314.98 561.93C310.68 565.05 306.29 567.97 301.8 570.62C297.31 573.28 292.72 575.68 288.04 577.8C283.37 579.92 278.61 581.75 273.79 583.28C268.96 584.81 264.07 586.03 259.14 586.93C254.2 587.83 249.23 588.4 244.24 588.64C239.25 588.88 234.24 588.79 229.26 588.36C224.28 587.93 219.32 587.16 214.42 586.06C209.51 584.95 204.67 583.52 199.91 581.77C195.16 580.01 190.5 577.94 185.97 575.56C181.45 573.19 177.05 570.51 172.82 567.55C168.58 564.59 164.52 561.36 160.64 557.87C156.77 554.39 153.09 550.65 149.64 546.7C146.19 542.75 142.95 538.58 139.97 534.23C136.98 529.88 134.23 525.34 131.75 520.67C129.27 515.99 127.04 511.16 125.09 506.23C123.15 501.3 121.47 496.26 120.08 491.16C118.69 486.05 117.57 480.88 116.75 475.67C115.93 470.47 115.39 465.24 115.14 460.02C114.89 454.79 114.93 449.58 115.26 444.41C115.58 439.24 116.2 434.12 117.1 429.08C117.99 424.04 119.18 419.08 120.64 414.24C122.11 409.4 123.86 404.67 125.88 400.08C127.91 395.49 130.21 391.05 132.78 386.77C135.36 382.5 138.21 378.39 141.32 374.47C144.44 370.55 147.83 366.82 151.47 363.3C155.12 359.77 159.03 356.47 163.19 353.41C167.35 350.36 171.76 347.55 176.39 345.05C181.03 342.55 185.88 340.35 190.91 338.52C195.94 336.7 201.17 335.24 206.49 334.19C211.82 333.15 217.24 332.51 222.68 332.31C228.11 332.12 233.55 332.37 238.92 333.01C244.29 333.66 249.59 334.71 254.75 336.09C259.91 337.48 264.92 339.21 269.75 341.29C274.58 343.36 279.23 345.78 283.63 348.53C288.04 351.29 292.18 354.4 295.95 357.9C299.71 361.39 303.1 365.29 305.97 369.58C308.84 373.86 311.2 378.51 312.91 383.42C314.62 388.32 315.66 393.52 315.96 398.78C316.25 404.03 315.8 409.35 314.55 414.46C313.3 419.57 311.22 424.48 308.43 428.88C305.64 433.29 302.15 437.19 298.08 440.28C294.02 443.37 289.39 445.66 284.5 447.04C279.61 448.43 274.47 448.92 269.39 448.45C264.3 447.98 259.26 446.59 254.46 444.51C249.67 442.43 245.14 439.66 241.03 436.43C236.91 433.2 233.16 429.52 229.72 425.64C226.28 421.76 223.16 417.73 220.26 413.65C217.37 409.57 214.68 405.42 212.07 401.22C209.46 397.01 206.9 392.76 204.38 388.43C201.85 384.1 199.36 379.71 196.91 375.21C194.46 370.72 192.05 366.13 189.7 361.45C187.35 356.76 185.06 351.99 182.86 347.13C180.67 342.28 178.57 337.34 176.57 332.32C174.57 327.31 172.68 322.22 170.91 317.07C169.13 311.91 167.48 306.69 165.96 301.42C164.44 296.14 163.05 290.8 161.8 285.42C160.55 280.03 159.45 274.6 158.51 269.13C157.57 263.67 156.78 258.17 156.18 252.66C155.58 247.15 155.16 241.62 154.94 236.11C154.72 230.6 154.7 225.1 154.91 219.65C155.11 214.2 155.54 208.8 156.21 203.47C156.89 198.15 157.8 192.91 158.98 187.8C160.16 182.69 161.59 177.71 163.3 172.9C165.01 168.09 166.99 163.45 169.24 159.04C171.49 154.63 174.02 150.44 176.81 146.52C179.61 142.61 182.67 138.96 185.98 135.62C189.29 132.28 192.85 129.25 196.64 126.57C200.42 123.89 204.43 121.55 208.62 119.57C212.82 117.59 217.2 115.98 221.73 114.74C226.26 113.5 230.93 112.62 235.71 112.12C240.49 111.61 245.36 111.47 250.3 111.67C255.24 111.87 260.23 112.42 265.24 113.28C270.25 114.15 275.28 115.34 280.29 116.8C285.31 118.27 290.3 120.03 295.25 122.03C300.2 124.03 305.1 126.28 309.94 128.74C314.77 131.2 319.54 133.87 324.23 136.72C328.91 139.56 333.51 142.59 338.01 145.76C342.52 148.93 346.93 152.24 351.24 155.68C355.54 159.11 359.75 162.67 363.85 166.33C367.95 169.99 371.94 173.74 375.82 177.59C379.7 181.43 383.47 185.36 387.13 189.37C390.78 193.37 394.32 197.46 397.74 201.61C401.16 205.76 404.46 209.99 407.63 214.28C410.8 218.57 413.84 222.93 416.75 227.36C419.66 231.79 422.42 236.28 425.04 240.84C427.66 245.4 430.14 250.03 432.45 254.72C434.76 259.41 436.91 264.16 438.88 268.98C440.86 273.79 442.66 278.66 444.27 283.59C445.89 288.51 447.31 293.49 448.54 298.51C449.77 303.53 450.8 308.59 451.62 313.68C452.45 318.77 453.06 323.89 453.46 329.02C453.86 334.15 454.05 339.29 454.02 344.42C454 349.55 453.75 354.67 453.29 359.76C452.83 364.85 452.16 369.91 451.27 374.92C450.39 379.92 449.29 384.88 447.98 389.76C446.68 394.64 445.17 399.44 443.46 404.15C441.75 408.87 439.85 413.49 437.75 418C435.65 422.51 433.38 426.88 430.83 431.24C428.27 435.6 425.41 439.96 422.06 444.51C418.7 449.06 414.7 453.93 410.99 458.32C407.29 462.71 403.92 466.59 401.91 469.1";
// Paseo Hub flower mark (5-petal A, 12 deg clockwise lean): scaled to the butterfly's 527 footprint.
const PASEO_HUB_MARK_PATH =
"M389.47 112.65C383.85 111.46 377.9 111.12 371.85 111.7C365.8 112.28 359.66 113.78 353.67 116.15C347.7 118.52 341.89 121.77 336.47 125.79C331.07 129.81 326.07 134.6 321.7 139.98C317.32 145.37 313.55 151.35 310.53 157.69C307.52 164.02 305.25 170.72 303.79 177.54C302.32 184.35 301.67 191.27 301.77 198.07C301.87 204.87 302.75 211.54 304.28 217.89C305.8 224.25 307.98 230.28 310.66 235.86C313.33 241.46 316.5 246.6 319.96 251.26C323.43 255.92 327.19 260.09 331.07 263.82C334.95 267.53 338.95 270.81 342.89 273.74C346.84 276.67 350.75 279.26 354.51 281.62C358.27 283.98 361.88 286.13 365.3 288.2C368.7 290.29 371.92 292.29 374.95 294.34C377.98 296.38 380.81 298.49 383.54 300.73C386.26 302.97 388.87 305.36 391.48 307.96C394.08 310.55 396.69 313.35 399.42 316.37C402.14 319.4 404.99 322.65 408.09 326.09C411.18 329.51 414.51 333.14 418.18 336.89C421.83 340.63 425.82 344.49 430.16 348.36C434.5 352.22 439.2 356.09 444.25 359.82C449.31 363.56 454.71 367.15 460.41 370.46C466.11 373.77 472.11 376.79 478.3 379.39C484.49 381.98 490.9 384.15 497.37 385.76C503.83 387.38 510.38 388.43 516.83 388.85C523.28 389.26 529.64 389.03 535.73 388.12C541.83 387.2 547.65 385.6 553.03 383.33C558.4 381.05 563.31 378.09 567.59 374.55C571.88 370.99 575.53 366.83 578.41 362.22C581.28 357.6 583.38 352.5 584.59 347.13C585.79 341.76 586.13 336.1 585.52 330.39C584.92 324.69 583.4 318.92 580.98 313.34C578.55 307.78 575.24 302.4 571.14 297.43C567.03 292.48 562.15 287.96 556.66 284.06C551.16 280.16 545.05 276.89 538.59 274.39C532.11 271.89 525.27 270.15 518.3 269.24C511.34 268.33 504.27 268.24 497.34 268.96C490.4 269.67 483.61 271.19 477.18 273.38C470.75 275.58 464.67 278.47 459.11 281.9C453.53 285.31 448.47 289.25 443.98 293.52C439.49 297.79 435.58 302.39 432.22 307.12C428.86 311.86 426.05 316.73 423.71 321.56C421.37 326.41 419.49 331.22 417.92 335.88C416.36 340.55 415.11 345.06 414.03 349.37C412.93 353.67 412.01 357.78 411.09 361.66C410.16 365.55 409.26 369.22 408.24 372.73C407.23 376.24 406.11 379.59 404.82 382.87C403.52 386.16 402.06 389.38 400.4 392.66C398.73 395.94 396.87 399.28 394.84 402.81C392.81 406.34 390.6 410.05 388.29 414.05C385.98 418.06 383.56 422.36 381.13 426.99C378.7 431.63 376.26 436.6 373.93 441.93C371.59 447.26 369.37 452.92 367.38 458.88C365.4 464.83 363.64 471.09 362.26 477.53C360.86 483.98 359.84 490.61 359.29 497.31C358.73 504 358.66 510.76 359.12 517.41C359.58 524.06 360.6 530.6 362.2 536.87C363.81 543.13 365.99 549.12 368.74 554.63C371.49 560.14 374.82 565.19 378.64 569.59C382.47 574 386.78 577.76 391.49 580.73C396.2 583.71 401.28 585.9 406.55 587.21C411.84 588.51 417.33 588.93 422.82 588.42C428.3 587.91 433.78 586.48 439.02 584.14C444.26 581.81 449.28 578.57 453.82 574.54C458.38 570.53 462.47 565.7 465.92 560.28C469.36 554.84 472.16 548.79 474.17 542.37C476.18 535.93 477.4 529.12 477.78 522.19C478.16 515.26 477.69 508.22 476.41 501.32C475.13 494.41 473.02 487.66 470.2 481.29C467.38 474.91 463.85 468.93 459.76 463.49C455.68 458.04 451.05 453.17 446.08 448.92C441.11 444.68 435.8 441.08 430.35 438.14C424.9 435.18 419.32 432.88 413.78 431.15C408.24 429.41 402.74 428.25 397.41 427.52C392.08 426.79 386.92 426.48 382.01 426.44C377.09 426.4 372.41 426.6 367.98 426.9C363.55 427.2 359.36 427.58 355.38 427.9C351.41 428.23 347.63 428.5 343.97 428.62C340.32 428.74 336.8 428.72 333.27 428.5C329.75 428.29 326.23 427.89 322.59 427.32C318.96 426.75 315.2 426.01 311.23 425.17C307.24 424.32 303.03 423.38 298.51 422.42C293.98 421.45 289.15 420.48 283.99 419.61C278.84 418.72 273.35 417.94 267.56 417.37C261.78 416.79 255.7 416.43 249.41 416.38C243.14 416.33 236.65 416.6 230.09 417.26C223.53 417.94 216.9 419.01 210.37 420.56C203.83 422.1 197.38 424.11 191.19 426.61C185.02 429.11 179.11 432.1 173.64 435.56C168.18 439.01 163.16 442.94 158.77 447.26C154.38 451.58 150.61 456.29 147.61 461.3C144.6 466.3 142.35 471.57 140.98 476.96C139.59 482.36 139.08 487.87 139.48 493.29C139.86 498.73 141.16 504.07 143.34 509.13C145.52 514.19 148.57 518.96 152.42 523.22C156.27 527.49 160.89 531.25 166.12 534.34C171.35 537.43 177.19 539.83 183.43 541.42C189.66 543.02 196.27 543.81 203.01 543.73C209.75 543.66 216.6 542.72 223.32 540.94C230.02 539.16 236.58 536.53 242.75 533.18C248.92 529.83 254.69 525.74 259.87 521.09C265.06 516.43 269.67 511.22 273.58 505.66C277.49 500.1 280.71 494.19 283.2 488.15C285.7 482.11 287.49 475.95 288.6 469.85C289.72 463.76 290.19 457.74 290.13 451.93C290.06 446.13 289.47 440.54 288.52 435.25C287.57 429.96 286.26 424.96 284.79 420.27C283.32 415.58 281.66 411.19 280.02 407.07C278.36 402.94 276.71 399.09 275.16 395.4C273.63 391.72 272.21 388.2 270.96 384.77C269.72 381.34 268.65 377.96 267.77 374.55C266.88 371.13 266.17 367.66 265.59 364.03C265.01 360.4 264.55 356.61 264.12 352.56C263.69 348.51 263.29 344.21 262.81 339.61C262.32 335.01 261.77 330.11 261 324.94C260.24 319.76 259.28 314.29 258.05 308.62C256.8 302.93 255.28 297.05 253.38 291.05C251.48 285.07 249.23 278.98 246.56 272.95C243.9 266.92 240.83 260.95 237.34 255.21C233.85 249.46 229.94 243.95 225.66 238.85C221.37 233.74 216.7 229.04 211.72 224.92C206.75 220.79 201.47 217.23 196.01 214.39C190.54 211.55 184.89 209.42 179.2 208.1C173.52 206.79 167.81 206.29 162.25 206.64C156.7 207 151.3 208.21 146.25 210.26C141.22 212.31 136.52 215.19 132.38 218.84C128.25 222.47 124.66 226.85 121.79 231.82C118.92 236.8 116.77 242.35 115.45 248.28C114.13 254.22 113.66 260.52 114.07 266.94C114.47 273.36 115.77 279.9 117.91 286.28C120.07 292.66 123.08 298.89 126.85 304.73C130.61 310.55 135.14 315.98 140.23 320.81C145.33 325.63 151 329.86 157.03 333.36C163.06 336.86 169.44 339.62 175.94 341.63C182.44 343.63 189.04 344.85 195.57 345.37C202.08 345.87 208.49 345.67 214.62 344.85C220.77 344.04 226.65 342.61 232.15 340.76C237.65 338.9 242.77 336.61 247.52 334.08C252.26 331.53 256.61 328.75 260.62 325.9C264.61 323.05 268.28 320.12 271.69 317.28C275.11 314.43 278.27 311.67 281.3 309.06C284.33 306.46 287.22 304.02 290.1 301.77C292.99 299.53 295.85 297.48 298.83 295.59C301.81 293.68 304.89 291.94 308.17 290.27C311.44 288.59 314.91 286.98 318.63 285.31C322.35 283.66 326.31 281.95 330.53 280.07C334.76 278.19 339.24 276.14 343.93 273.82C348.62 271.49 353.52 268.9 358.54 265.97C363.56 263.02 368.68 259.75 373.8 256.09C378.91 252.44 384 248.42 388.91 244.02C393.82 239.62 398.55 234.85 402.93 229.76C407.32 224.67 411.35 219.25 414.88 213.6C418.41 207.94 421.44 202.05 423.83 196.05C426.21 190.03 427.96 183.92 428.97 177.84C429.99 171.76 430.26 165.73 429.76 159.92C429.25 154.11 427.97 148.52 425.91 143.34C423.86 138.18 421.05 133.42 417.53 129.25C414.03 125.09 409.83 121.52 405.09 118.71C400.35 115.9 395.08 113.84 389.47 112.65Z";
const round = (value) => Number(value.toFixed(2));
function transformPath(d, scale, offsetX, offsetY) {
let index = 0;
return d.replace(/-?\d+(?:\.\d+)?/g, (token) => {
const value = Number.parseFloat(token);
const out = index % 2 === 0 ? offsetX + value * scale : offsetY + value * scale;
index += 1;
return String(round(out));
});
}
function renderMarkSvg(d, color) {
return [
`<svg width="${VIEWBOX}" height="${VIEWBOX}" viewBox="0 0 ${VIEWBOX} ${VIEWBOX}" fill="none" xmlns="http://www.w3.org/2000/svg">`,
` <path d="${d}" stroke="${color}" stroke-width="${STROKE}" stroke-linecap="round" stroke-linejoin="round" />`,
"</svg>",
"",
].join("\n");
}
function renderLockupSvg({ font, markPath, markFactor, label, color }) {
const emptyShare = (VIEWBOX - FOOTPRINT) / 2 / VIEWBOX;
const headerBoxEm = (24 / 18) * MARK_SCALE;
const flowerInkEm = headerBoxEm * (FOOTPRINT / VIEWBOX);
const visibleGapEm = GAP_SCALE * (12 / 18 + (24 / 18) * emptyShare);
const fontSize = LOCKUP_INK / flowerInkEm;
const markCenter = LOCKUP_PAD + LOCKUP_INK / 2;
const unitScale = (LOCKUP_INK / FOOTPRINT) * markFactor;
const markOffset = markCenter - (VIEWBOX / 2) * unitScale;
const bakedMark = transformPath(markPath, unitScale, markOffset, markOffset);
const strokeWidth = round(STROKE * unitScale);
// Baseline matches CSS display:flex; align-items:center; line-height:1 for Plus Jakarta Sans.
const ascender = (font.ascender / font.unitsPerEm) * fontSize;
const descender = (font.descender / font.unitsPerEm) * fontSize;
const halfLeading = (fontSize - (ascender - descender)) / 2;
const baselineY = markCenter - fontSize / 2 + halfLeading + ascender;
const textOriginX = LOCKUP_PAD + LOCKUP_INK + visibleGapEm * fontSize;
const textPath = font.getPath(label, textOriginX, baselineY, fontSize);
const bounds = textPath.getBoundingBox();
const width = Math.ceil(bounds.x2 + LOCKUP_PAD);
return [
`<svg width="${width}" height="${LOCKUP_HEIGHT}" viewBox="0 0 ${width} ${LOCKUP_HEIGHT}" fill="none" xmlns="http://www.w3.org/2000/svg">`,
` <path d="${bakedMark}" stroke="${color}" stroke-width="${strokeWidth}" stroke-linecap="round" stroke-linejoin="round" />`,
` <path d="${textPath.toPathData(2)}" fill="${color}" />`,
"</svg>",
"",
].join("\n");
}
function build() {
mkdirSync(marksDir, { recursive: true });
mkdirSync(lockupsDir, { recursive: true });
const font = loadSync(fontPath);
const marks = [
{ slug: "paseo", d: PASEO_MARK_PATH },
{ slug: "paseo-hub", d: PASEO_HUB_MARK_PATH },
];
for (const mark of marks) {
for (const color of MARK_COLORS) {
const file = path.join(marksDir, `${mark.slug}-${color.name}.svg`);
writeFileSync(file, renderMarkSvg(mark.d, color.hex));
}
}
const lockups = [
{
slug: "paseo",
markPath: PASEO_MARK_PATH,
markFactor: BUTTERFLY_LOCKUP_SCALE,
label: "Paseo",
},
{ slug: "paseo-hub", markPath: PASEO_HUB_MARK_PATH, markFactor: 1, label: "Paseo Hub" },
{ slug: "hub", markPath: PASEO_HUB_MARK_PATH, markFactor: 1, label: "Hub" },
];
for (const lockup of lockups) {
for (const color of LOCKUP_COLORS) {
const file = path.join(lockupsDir, `${lockup.slug}-${color.name}.svg`);
writeFileSync(file, renderLockupSvg({ font, ...lockup, color: color.hex }));
}
}
}
build();