@dloizides/logo-kit 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -67,9 +67,17 @@ interface MotionBeat {
67
67
  width?: number;
68
68
  colour?: string;
69
69
  }
70
+ interface WordmarkMotionConfig {
71
+ recipe: string;
72
+ startMs: number;
73
+ }
70
74
  interface MotionConfig {
71
75
  intro: MotionBeat[];
72
76
  micro: MotionBeat[];
77
+ wordmark?: WordmarkMotionConfig;
78
+ idle?: {
79
+ recipe: string;
80
+ };
73
81
  allowLongIntro?: string;
74
82
  recipeErrors?: string[];
75
83
  }
@@ -176,6 +184,11 @@ declare function microRecipe(name: string, ctx: RecipeContext): MotionBeat[] | n
176
184
  interface RawMotion {
177
185
  intro?: MotionBeat[] | string;
178
186
  micro?: MotionBeat[] | string;
187
+ wordmark?: string | {
188
+ recipe: string;
189
+ startMs?: number;
190
+ };
191
+ idle?: string;
179
192
  roles?: Partial<MotionRoles>;
180
193
  allowLongIntro?: string;
181
194
  }
@@ -320,7 +333,8 @@ declare const enum IntroRecipe {
320
333
  SpinAssemble = "spin-assemble",
321
334
  DropBounce = "drop-bounce",
322
335
  FlipFaces = "flip-faces",
323
- SlamShake = "slam-shake"
336
+ SlamShake = "slam-shake",
337
+ GrowSettle = "grow-settle"
324
338
  }
325
339
  declare const INTRO_RECIPES: readonly IntroRecipe[];
326
340
 
@@ -332,6 +346,56 @@ declare const enum MicroRecipe {
332
346
  }
333
347
  declare const MICRO_RECIPES: readonly MicroRecipe[];
334
348
 
349
+ declare const enum WordmarkRecipe {
350
+ LetterStagger = "letter-stagger",
351
+ SlideFromMark = "slide-from-mark",
352
+ Typewriter = "typewriter",
353
+ MaskWipe = "mask-wipe",
354
+ TrackingSettle = "tracking-settle"
355
+ }
356
+ declare const WORDMARK_RECIPES: readonly WordmarkRecipe[];
357
+
358
+ interface WordmarkOptions {
359
+ advances: readonly number[];
360
+ startMs?: number;
361
+ prefix?: string;
362
+ fontSize?: number;
363
+ }
364
+ interface WordmarkMotion {
365
+ recipe: WordmarkRecipe;
366
+ startMs: number;
367
+ durationMs: number;
368
+ classes: string[];
369
+ css: string;
370
+ }
371
+ /** Returns the reveal CSS for letters classed `<prefix>-l<i>`, or null for an unknown recipe. */
372
+ declare function wordmarkReveal(name: string, options: WordmarkOptions): WordmarkMotion | null;
373
+
374
+ declare const enum IdleRecipe {
375
+ RimGlint = "rim-glint",
376
+ FacesPart = "faces-part",
377
+ Breath = "breath",
378
+ OrbitSpark = "orbit-spark"
379
+ }
380
+ declare const IDLE_RECIPES: readonly IdleRecipe[];
381
+ declare const IDLE_CAP_MS = 600;
382
+
383
+ interface IdleContext {
384
+ mark: Mark;
385
+ roles?: Partial<MotionRoles>;
386
+ prefix?: string;
387
+ trigger?: string;
388
+ colour?: string;
389
+ }
390
+ interface IdleMotion {
391
+ recipe: IdleRecipe;
392
+ durationMs: number;
393
+ css: string;
394
+ overlay: string;
395
+ }
396
+ /** Returns the CSS and SVG overlay of an idle recipe, played while the trigger class is on, or null for an unknown name. */
397
+ declare function idleRecipe(name: string, ctx: IdleContext): IdleMotion | null;
398
+
335
399
  interface MotionSvgOptions {
336
400
  label: string;
337
401
  size?: number;
@@ -414,4 +478,4 @@ type Out = (line: string) => void;
414
478
  /** Runs the logo-kit command line and returns its exit code. */
415
479
  declare function runCli(args: readonly string[], out?: Out): number;
416
480
 
417
- export { type AnimationTiming, BOLD_PRESETS, type Bitmap, type Brand, CVD_KINDS, type CheckResult, type ChecksReport, CvdKind, type ExportedFile, INTRO_CAP_MS, INTRO_PRESETS, INTRO_RECIPES, IntroRecipe, LOOKALIKE_THRESHOLD, type LayerPaint, MICRO_CAP_MS, MICRO_DEFAULTS, MICRO_PRESETS, MICRO_RECIPES, MODES, type Mark, type MarkLayer, MicroRecipe, Mode, type MotionBeat, type MotionConfig, MotionPreset, type MotionRoles, PRESET_DEFAULTS, PRIMITIVES, type PaintItem, type Palette, type PickSpec, type Pt, type RawMotion, type RecipeContext, SYMBOLS, type TimingMap, type Variant, alphaMask, animatedSvg, buildPickPage, buildPickSpec, checkVariants, contrast, deltaE, exportBrand, fitBeat, flattenPath, generateVariants, generatorPalette, geometryModule, introRecipe, introSvg, loadBrand, markSvg, microRecipe, microSvg, paletteVariants, parseBrand, parseTiming, pixelDiff, pngSize, primitiveMark, renderPng, renderSvg, resolveMotion, resolveToken, runChecks, runCli, schedule, simulateCvd, symbolMatches, symbolScores, totalMs, validateMotion };
481
+ export { type AnimationTiming, BOLD_PRESETS, type Bitmap, type Brand, CVD_KINDS, type CheckResult, type ChecksReport, CvdKind, type ExportedFile, IDLE_CAP_MS, IDLE_RECIPES, INTRO_CAP_MS, INTRO_PRESETS, INTRO_RECIPES, type IdleContext, type IdleMotion, IdleRecipe, IntroRecipe, LOOKALIKE_THRESHOLD, type LayerPaint, MICRO_CAP_MS, MICRO_DEFAULTS, MICRO_PRESETS, MICRO_RECIPES, MODES, type Mark, type MarkLayer, MicroRecipe, Mode, type MotionBeat, type MotionConfig, MotionPreset, type MotionRoles, PRESET_DEFAULTS, PRIMITIVES, type PaintItem, type Palette, type PickSpec, type Pt, type RawMotion, type RecipeContext, SYMBOLS, type TimingMap, type Variant, WORDMARK_RECIPES, type WordmarkMotion, type WordmarkMotionConfig, type WordmarkOptions, WordmarkRecipe, alphaMask, animatedSvg, buildPickPage, buildPickSpec, checkVariants, contrast, deltaE, exportBrand, fitBeat, flattenPath, generateVariants, generatorPalette, geometryModule, idleRecipe, introRecipe, introSvg, loadBrand, markSvg, microRecipe, microSvg, paletteVariants, parseBrand, parseTiming, pixelDiff, pngSize, primitiveMark, renderPng, renderSvg, resolveMotion, resolveToken, runChecks, runCli, schedule, simulateCvd, symbolMatches, symbolScores, totalMs, validateMotion, wordmarkReveal };
package/dist/index.js CHANGED
@@ -464,6 +464,17 @@ var DEFAULT_MOTION_CONFIG = {
464
464
  micro: [{ preset: "spread" /* Spread */, durationMs: 300, distance: 1.6, easing: EASE }]
465
465
  };
466
466
 
467
+ // src/motion/IdleRecipe.ts
468
+ var IdleRecipe = /* @__PURE__ */ ((IdleRecipe2) => {
469
+ IdleRecipe2["RimGlint"] = "rim-glint";
470
+ IdleRecipe2["FacesPart"] = "faces-part";
471
+ IdleRecipe2["Breath"] = "breath";
472
+ IdleRecipe2["OrbitSpark"] = "orbit-spark";
473
+ return IdleRecipe2;
474
+ })(IdleRecipe || {});
475
+ var IDLE_RECIPES = ["rim-glint" /* RimGlint */, "faces-part" /* FacesPart */, "breath" /* Breath */, "orbit-spark" /* OrbitSpark */];
476
+ var IDLE_CAP_MS = 600;
477
+
467
478
  // src/motion/IntroRecipe.ts
468
479
  var IntroRecipe = /* @__PURE__ */ ((IntroRecipe2) => {
469
480
  IntroRecipe2["RimThenInk"] = "rim-then-ink";
@@ -476,6 +487,7 @@ var IntroRecipe = /* @__PURE__ */ ((IntroRecipe2) => {
476
487
  IntroRecipe2["DropBounce"] = "drop-bounce";
477
488
  IntroRecipe2["FlipFaces"] = "flip-faces";
478
489
  IntroRecipe2["SlamShake"] = "slam-shake";
490
+ IntroRecipe2["GrowSettle"] = "grow-settle";
479
491
  return IntroRecipe2;
480
492
  })(IntroRecipe || {});
481
493
  var INTRO_RECIPES = [
@@ -488,7 +500,8 @@ var INTRO_RECIPES = [
488
500
  "spin-assemble" /* SpinAssemble */,
489
501
  "drop-bounce" /* DropBounce */,
490
502
  "flip-faces" /* FlipFaces */,
491
- "slam-shake" /* SlamShake */
503
+ "slam-shake" /* SlamShake */,
504
+ "grow-settle" /* GrowSettle */
492
505
  ];
493
506
 
494
507
  // src/motion/MicroRecipe.ts
@@ -506,7 +519,7 @@ function targetsOf(beat, layerNames) {
506
519
  if (!beat.layers) {
507
520
  return [...layerNames];
508
521
  }
509
- return beat.layers.includes(MARK_TARGET) ? [MARK_TARGET] : layerNames.filter((n) => beat.layers?.includes(n));
522
+ return beat.layers.includes(MARK_TARGET) ? [MARK_TARGET] : layerNames.filter((n2) => beat.layers?.includes(n2));
510
523
  }
511
524
  function schedule(beat, layerNames) {
512
525
  return targetsOf(beat, layerNames).map((target, k) => ({ target, delayMs: (beat.delayMs ?? 0) + k * (beat.stepMs ?? 0), durationMs: beat.durationMs }));
@@ -514,9 +527,9 @@ function schedule(beat, layerNames) {
514
527
  function totalMs(beats, layerNames) {
515
528
  return Math.max(0, ...beats.flatMap((b) => schedule(b, layerNames).map((s) => s.delayMs + s.durationMs)));
516
529
  }
517
- function fitBeat(beat, n, capMs) {
530
+ function fitBeat(beat, n2, capMs) {
518
531
  const room = capMs - (beat.delayMs ?? 0) - beat.durationMs;
519
- const step2 = n > 1 ? Math.min(beat.stepMs ?? 0, Math.max(0, Math.floor(room / (n - 1)))) : beat.stepMs ?? 0;
532
+ const step2 = n2 > 1 ? Math.min(beat.stepMs ?? 0, Math.max(0, Math.floor(room / (n2 - 1)))) : beat.stepMs ?? 0;
520
533
  return { ...beat, stepMs: step2 };
521
534
  }
522
535
  function morphClashes(beats, layerNames) {
@@ -550,6 +563,7 @@ function validateMotion(config, layerNames) {
550
563
 
551
564
  // src/motion/recipes.ts
552
565
  var REFERENCE_SIZE = 64;
566
+ var SETTLE_EASE = "cubic-bezier(0.23,1,0.32,1)";
553
567
  var fit = (beat) => fitBeat(beat, beat.layers?.length ?? 1, INTRO_CAP_MS);
554
568
  var all = (ctx) => [...ctx.roles.base, ...ctx.roles.parts];
555
569
  var INTROS = {
@@ -581,7 +595,12 @@ var INTROS = {
581
595
  { preset: "flood" /* Flood */, layers: ctx.roles.base, durationMs: 400, easing: EASE_IN_FIRST },
582
596
  fit({ preset: "flip" /* Flip */, layers: ctx.roles.parts, durationMs: 700, delayMs: 250, stepMs: 100 })
583
597
  ],
584
- ["slam-shake" /* SlamShake */]: () => [{ preset: "slam-shake" /* SlamShake */, layers: [MARK_TARGET], durationMs: 800 }]
598
+ ["slam-shake" /* SlamShake */]: () => [{ preset: "slam-shake" /* SlamShake */, layers: [MARK_TARGET], durationMs: 800 }],
599
+ ["grow-settle" /* GrowSettle */]: (ctx) => [
600
+ { preset: "flood" /* Flood */, layers: ctx.roles.base, durationMs: 360, easing: EASE_IN_FIRST },
601
+ { preset: "morph-from-circle" /* MorphFromCircle */, layers: ctx.roles.parts, durationMs: 700, delayMs: 240, stops: [0, 40, 100], fadeIn: ctx.roles.parts, easing: EASE_IN_FIRST, settleEasing: SETTLE_EASE },
602
+ { preset: "pulse" /* Pulse */, layers: [MARK_TARGET], durationMs: 260, delayMs: 920, scale: 1.04, easing: SETTLE_EASE }
603
+ ]
585
604
  };
586
605
  var spread = (ctx, k) => ({ preset: "spread" /* Spread */, layers: ctx.roles.parts, durationMs: 300, distance: 1.6 * k, easing: EASE });
587
606
  var glint = (ctx, k) => ({ preset: "sweep" /* Sweep */, layers: ctx.roles.base, durationMs: 300, share: 0.2, width: 1.5 * k, colour: "text", easing: EASE });
@@ -602,6 +621,23 @@ function microRecipe(name, ctx) {
602
621
  return run(MICROS, name, ctx);
603
622
  }
604
623
 
624
+ // src/motion/WordmarkRecipe.ts
625
+ var WordmarkRecipe = /* @__PURE__ */ ((WordmarkRecipe2) => {
626
+ WordmarkRecipe2["LetterStagger"] = "letter-stagger";
627
+ WordmarkRecipe2["SlideFromMark"] = "slide-from-mark";
628
+ WordmarkRecipe2["Typewriter"] = "typewriter";
629
+ WordmarkRecipe2["MaskWipe"] = "mask-wipe";
630
+ WordmarkRecipe2["TrackingSettle"] = "tracking-settle";
631
+ return WordmarkRecipe2;
632
+ })(WordmarkRecipe || {});
633
+ var WORDMARK_RECIPES = [
634
+ "letter-stagger" /* LetterStagger */,
635
+ "slide-from-mark" /* SlideFromMark */,
636
+ "typewriter" /* Typewriter */,
637
+ "mask-wipe" /* MaskWipe */,
638
+ "tracking-settle" /* TrackingSettle */
639
+ ];
640
+
605
641
  // src/motion/resolveMotion.ts
606
642
  var KINDS = {
607
643
  intro: { recipe: introRecipe, fallback: DEFAULT_MOTION_CONFIG.intro },
@@ -615,18 +651,30 @@ function resolve(kind, value, ctx) {
615
651
  const beats = recipe(value, ctx);
616
652
  return beats !== null ? { beats } : { beats: [], error: `unknown ${kind} recipe "${value}"` };
617
653
  }
654
+ function toWordmark(raw) {
655
+ if (raw === void 0) {
656
+ return void 0;
657
+ }
658
+ return typeof raw === "string" ? { recipe: raw, startMs: 0 } : { recipe: raw.recipe, startMs: raw.startMs ?? 0 };
659
+ }
660
+ var known = (list, kind, name) => name === void 0 || list.includes(name) ? [] : [`unknown ${kind} recipe "${name}"`];
618
661
  function resolveMotion(raw, layerNames, size) {
619
662
  const roles = { base: raw?.roles?.base ?? layerNames.slice(0, 1), parts: raw?.roles?.parts ?? layerNames.slice(1) };
620
663
  const ctx = { roles, size };
621
664
  const intro = resolve("intro", raw?.intro, ctx);
622
665
  const micro = resolve("micro", raw?.micro, ctx);
666
+ const wordmark = toWordmark(raw?.wordmark);
623
667
  const errors = [
624
- ...[...roles.base, ...roles.parts].filter((n) => !layerNames.includes(n)).map((n) => `motion.roles names unknown layer "${n}"`),
625
- ...[intro.error, micro.error].filter((e) => e !== void 0)
668
+ ...[...roles.base, ...roles.parts].filter((n2) => !layerNames.includes(n2)).map((n2) => `motion.roles names unknown layer "${n2}"`),
669
+ ...[intro.error, micro.error].filter((e) => e !== void 0),
670
+ ...known(WORDMARK_RECIPES, "wordmark", wordmark?.recipe),
671
+ ...known(IDLE_RECIPES, "idle", raw?.idle)
626
672
  ];
627
673
  return {
628
674
  intro: intro.beats,
629
675
  micro: micro.beats,
676
+ ...wordmark !== void 0 ? { wordmark } : {},
677
+ ...raw?.idle !== void 0 ? { idle: { recipe: raw.idle } } : {},
630
678
  ...raw?.allowLongIntro !== void 0 ? { allowLongIntro: raw.allowLongIntro } : {},
631
679
  ...errors.length > 0 ? { recipeErrors: errors } : {}
632
680
  };
@@ -720,7 +768,7 @@ function polygonsToD(polys) {
720
768
  const ring = (poly) => poly.map(point).join("L");
721
769
  return polys.map((poly) => `M${ring(poly)}Z`).join("");
722
770
  }
723
- function resample(poly, n) {
771
+ function resample(poly, n2) {
724
772
  const first = poly[0] ?? { x: 0, y: 0 };
725
773
  const closed = [...poly, first];
726
774
  const lengths = closed.slice(1).map((p, k) => Math.hypot(p.x - (closed[k]?.x ?? 0), p.y - (closed[k]?.y ?? 0)));
@@ -728,8 +776,8 @@ function resample(poly, n) {
728
776
  const out = [];
729
777
  let seg = 0;
730
778
  let walked = 0;
731
- for (let k = 0; k < n; k++) {
732
- const target = total * k / n;
779
+ for (let k = 0; k < n2; k++) {
780
+ const target = total * k / n2;
733
781
  while (seg < lengths.length - 1 && walked + (lengths[seg] ?? 0) < target) {
734
782
  walked += lengths[seg] ?? 0;
735
783
  seg++;
@@ -742,15 +790,15 @@ function resample(poly, n) {
742
790
  }
743
791
  return out;
744
792
  }
745
- function circlePoints(c, r, n) {
746
- return Array.from({ length: n }, (_, k) => {
747
- const t = -Math.PI / 2 + 2 * Math.PI * k / n;
793
+ function circlePoints(c, r, n2) {
794
+ return Array.from({ length: n2 }, (_, k) => {
795
+ const t = -Math.PI / 2 + 2 * Math.PI * k / n2;
748
796
  return { x: c.x + r * Math.cos(t), y: c.y + r * Math.sin(t) };
749
797
  });
750
798
  }
751
799
  function centroid(pts) {
752
- const n = Math.max(1, pts.length);
753
- return { x: pts.reduce((s, p) => s + p.x, 0) / n, y: pts.reduce((s, p) => s + p.y, 0) / n };
800
+ const n2 = Math.max(1, pts.length);
801
+ return { x: pts.reduce((s, p) => s + p.x, 0) / n2, y: pts.reduce((s, p) => s + p.y, 0) / n2 };
754
802
  }
755
803
 
756
804
  // src/generate/shapes.ts
@@ -758,12 +806,12 @@ var CIRCLE_N = 48;
758
806
  var ORIGIN = { x: 0, y: 0 };
759
807
  var SQRT3_2 = Math.sqrt(3) / 2;
760
808
  var FACE_SHRINK = 0.9;
761
- var ngon = (n, r, start = -Math.PI / 2) => Array.from({ length: n }, (_, k) => ({ x: r * Math.cos(start + 2 * Math.PI * k / n), y: r * Math.sin(start + 2 * Math.PI * k / n) }));
809
+ var ngon = (n2, r, start = -Math.PI / 2) => Array.from({ length: n2 }, (_, k) => ({ x: r * Math.cos(start + 2 * Math.PI * k / n2), y: r * Math.sin(start + 2 * Math.PI * k / n2) }));
762
810
  var shrink = (poly, s) => {
763
811
  const c = poly.reduce((a, p) => ({ x: a.x + p.x / poly.length, y: a.y + p.y / poly.length }), ORIGIN);
764
812
  return poly.map((p) => ({ x: c.x + (p.x - c.x) * s, y: c.y + (p.y - c.y) * s }));
765
813
  };
766
- var arcPts = (r, from, to, n) => Array.from({ length: n + 1 }, (_, k) => ({ x: r * Math.cos(from + (to - from) * k / n), y: r * Math.sin(from + (to - from) * k / n) }));
814
+ var arcPts = (r, from, to, n2) => Array.from({ length: n2 + 1 }, (_, k) => ({ x: r * Math.cos(from + (to - from) * k / n2), y: r * Math.sin(from + (to - from) * k / n2) }));
767
815
  function crescent(dx = 0.36, r = 0.83) {
768
816
  const ix = (1 - r * r + dx * dx) / (2 * dx);
769
817
  const theta = Math.acos(Math.min(1, ix));
@@ -780,7 +828,7 @@ function cubeFaces() {
780
828
  }
781
829
  var band = (outer, inner, start, end) => [[...arcPts(outer, start, end, CIRCLE_N), ...arcPts(inner, end, start, CIRCLE_N)]];
782
830
  var rect = (x, y, w, h) => [{ x, y }, { x: x + w, y }, { x: x + w, y: y + h }, { x, y: y + h }];
783
- var star = (n, inner) => ngon(2 * n, 1).map((p, k) => k % 2 === 1 ? { x: p.x * inner, y: p.y * inner } : p);
831
+ var star = (n2, inner) => ngon(2 * n2, 1).map((p, k) => k % 2 === 1 ? { x: p.x * inner, y: p.y * inner } : p);
784
832
  var wave = () => {
785
833
  const xs = Array.from({ length: 25 }, (_, k) => -1 + k / 12);
786
834
  const back = [...xs];
@@ -840,9 +888,9 @@ var COMBINATORS = {
840
888
  return [...parts(a, 0.72, 0, 0, "a"), ...parts(b, 0.24, 0.82 * Math.cos(t), 0.82 * Math.sin(t), "b")];
841
889
  },
842
890
  repeat: (r, a) => {
843
- const n = pick(r, [3, 4, 5, 6]);
844
- return Array.from({ length: n }, (_, k) => {
845
- const t = -Math.PI / 2 + 2 * Math.PI * k / n;
891
+ const n2 = pick(r, [3, 4, 5, 6]);
892
+ return Array.from({ length: n2 }, (_, k) => {
893
+ const t = -Math.PI / 2 + 2 * Math.PI * k / n2;
846
894
  return parts(a, 0.34, 0.6 * Math.cos(t), 0.6 * Math.sin(t), k % 2 === 0 ? "a" : "b").map((p) => ({ ...p, name: `${p.name}-${k}` }));
847
895
  }).flat();
848
896
  },
@@ -972,9 +1020,9 @@ function normalise(mask, w, h) {
972
1020
  for (let gx = 0; gx < GRID; gx++) {
973
1021
  let hits = 0;
974
1022
  for (let s = 0; s < SAMPLES * SAMPLES; s++) {
975
- const px2 = Math.floor(ox + (gx + (s % SAMPLES + 0.5) / SAMPLES) * side / GRID);
1023
+ const px3 = Math.floor(ox + (gx + (s % SAMPLES + 0.5) / SAMPLES) * side / GRID);
976
1024
  const py = Math.floor(oy + (gy + (Math.floor(s / SAMPLES) + 0.5) / SAMPLES) * side / GRID);
977
- hits += px2 >= 0 && py >= 0 && px2 < w && py < h ? mask[py * w + px2] ?? 0 : 0;
1025
+ hits += px3 >= 0 && py >= 0 && px3 < w && py < h ? mask[py * w + px3] ?? 0 : 0;
978
1026
  }
979
1027
  out[gy * GRID + gx] = hits >= MAJORITY ? 1 : 0;
980
1028
  }
@@ -1032,8 +1080,8 @@ function visibleShare(tile, ink2) {
1032
1080
  // src/checks/symbols.ts
1033
1081
  var svg = (body) => `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100">${body}</svg>`;
1034
1082
  var crescentBody = (dx, r) => `<mask id="c"><rect width="100" height="100" fill="#fff"/><circle cx="${50 + dx}" cy="50" r="${r}" fill="#000"/></mask><circle cx="50" cy="50" r="40" mask="url(#c)"/>`;
1035
- var starPoints = (cx, cy, r, n, inner) => Array.from({ length: 2 * n }, (_, k) => {
1036
- const t = -Math.PI / 2 + Math.PI * k / n;
1083
+ var starPoints = (cx, cy, r, n2, inner) => Array.from({ length: 2 * n2 }, (_, k) => {
1084
+ const t = -Math.PI / 2 + Math.PI * k / n2;
1037
1085
  const rr = k % 2 === 0 ? r : r * inner;
1038
1086
  return `${(cx + rr * Math.cos(t)).toFixed(2)},${(cy + rr * Math.sin(t)).toFixed(2)}`;
1039
1087
  }).join(" ");
@@ -1135,9 +1183,9 @@ function legibility(mark, size) {
1135
1183
  out.push(`legible${size}: ink covers ${(cover * 100).toFixed(0)}% of the ${size} px tile`);
1136
1184
  }
1137
1185
  mark.layers.forEach((layer, i) => {
1138
- const px2 = ink(alphaMask(renderSvg(inkSvg(mark, i), size)));
1139
- if (px2 < (MIN_LAYER_PX[size] ?? 1)) {
1140
- out.push(`legible${size}: layer "${layer.name}" is ${px2} px, lost at ${size} px`);
1186
+ const px3 = ink(alphaMask(renderSvg(inkSvg(mark, i), size)));
1187
+ if (px3 < (MIN_LAYER_PX[size] ?? 1)) {
1188
+ out.push(`legible${size}: layer "${layer.name}" is ${px3} px, lost at ${size} px`);
1141
1189
  }
1142
1190
  });
1143
1191
  return out;
@@ -1239,9 +1287,143 @@ function generatorPalette(tokensId) {
1239
1287
  };
1240
1288
  }
1241
1289
 
1290
+ // src/motion/cssAnim.ts
1291
+ var SETTLE_OUT = "cubic-bezier(0.23,1,0.32,1)";
1292
+ var IN_OUT = "cubic-bezier(0.77,0,0.175,1)";
1293
+ var pct = (p) => `${Number.isInteger(p) ? p : p.toFixed(2)}%`;
1294
+ function cssAnim(name, selector, frames2, timing) {
1295
+ const body = frames2.map(([p, v]) => `${pct(p)}{${v}}`).join("");
1296
+ const run2 = `${name} ${Math.round(timing.durationMs)}ms ${timing.easing} ${Math.round(timing.delayMs ?? 0)}ms 1 both`;
1297
+ return `@keyframes ${name}{${body}}${selector}{animation:${run2}}`;
1298
+ }
1299
+
1300
+ // src/motion/wordmark.ts
1301
+ var REFERENCE_FONT = 17;
1302
+ var TYPE_SHARE = 0.7;
1303
+ var TYPE_STEP = 16;
1304
+ var STAGGER_STEP = 12;
1305
+ var STAGGER_MS = 240;
1306
+ var px = (v) => `${Number(v.toFixed(1))}px`;
1307
+ var letterCss = (c, frames2, durationMs, step2, easing) => c.xs.map((_, i) => cssAnim(`${c.p}-l${i}`, `.${c.p}-l${i}`, frames2(i), { durationMs, delayMs: c.at + i * step2, easing })).join("");
1308
+ function stagger(c) {
1309
+ const rise = px(7 * c.k);
1310
+ const css = letterCss(c, () => [[0, `opacity:0;transform:translateY(${rise})`], [100, "opacity:1;transform:none"]], STAGGER_MS, STAGGER_STEP, SETTLE_OUT);
1311
+ return { durationMs: (c.n - 1) * STAGGER_STEP + STAGGER_MS, letters: true, shown: [], hidden: [], css };
1312
+ }
1313
+ function slide(c) {
1314
+ const frames2 = [[0, `opacity:0;transform:translateX(${px(-56 * c.k)})`], [35, "opacity:1"], [100, "opacity:1;transform:none"]];
1315
+ const css = cssAnim(`${c.p}-g`, `.${c.p}-g`, frames2, { durationMs: 420, delayMs: c.at, easing: SETTLE_OUT });
1316
+ return { durationMs: 420, letters: false, shown: [`${c.p}-g`], hidden: [], css };
1317
+ }
1318
+ function typewriter(c) {
1319
+ const durationMs = Math.round(c.n * TYPE_STEP / TYPE_SHARE);
1320
+ const end = px(c.width);
1321
+ const steps = c.xs.map((x, i) => [i / c.n * TYPE_SHARE * 100, `transform:translateX(${px(x)});opacity:1`]);
1322
+ const caret = [[0, "transform:translateX(0);opacity:1"], ...steps, [TYPE_SHARE * 100, `transform:translateX(${end});opacity:1`], [100, `transform:translateX(${end});opacity:0`]];
1323
+ const letters = letterCss(c, () => [[0, "opacity:0"], [100, "opacity:1"]], 1, TYPE_STEP, "linear");
1324
+ const css = letters + cssAnim(`${c.p}-k`, `.${c.p}-k`, caret, { durationMs, delayMs: c.at, easing: "step-end" });
1325
+ return { durationMs, letters: true, shown: [], hidden: [`${c.p}-k`], css };
1326
+ }
1327
+ function wipe(c) {
1328
+ const end = px(c.width);
1329
+ const rect2 = cssAnim(`${c.p}-r`, `.${c.p}-r`, [[0, "transform:scaleX(0)"], [100, "transform:scaleX(1)"]], { durationMs: 380, delayMs: c.at, easing: SETTLE_OUT });
1330
+ const edgeFrames = [[0, "transform:translateX(0);opacity:1"], [73, `transform:translateX(${end});opacity:1`], [100, `transform:translateX(${end});opacity:0`]];
1331
+ const edge = cssAnim(`${c.p}-e`, `.${c.p}-e`, edgeFrames, { durationMs: 520, delayMs: c.at, easing: SETTLE_OUT });
1332
+ return { durationMs: 520, letters: false, shown: [`${c.p}-r`], hidden: [`${c.p}-e`], css: rect2 + edge };
1333
+ }
1334
+ function tracking(c) {
1335
+ const css = letterCss(c, (i) => [[0, `opacity:0;transform:translateX(${px(i * 2.2 * c.k)})`], [100, "opacity:1;transform:none"]], 440, 0, SETTLE_OUT);
1336
+ return { durationMs: 440, letters: true, shown: [], hidden: [], css };
1337
+ }
1338
+ var RECIPES = {
1339
+ ["letter-stagger" /* LetterStagger */]: stagger,
1340
+ ["slide-from-mark" /* SlideFromMark */]: slide,
1341
+ ["typewriter" /* Typewriter */]: typewriter,
1342
+ ["mask-wipe" /* MaskWipe */]: wipe,
1343
+ ["tracking-settle" /* TrackingSettle */]: tracking
1344
+ };
1345
+ function reduced(c, b) {
1346
+ const shown = [...b.letters ? c.xs.map((_, i) => `${c.p}-l${i}`) : [], ...b.shown].map((s) => `.${s}`).join(",");
1347
+ const hidden = b.hidden.map((s) => `.${s}`).join(",");
1348
+ const show = shown !== "" ? `${shown}{animation:none!important;opacity:1!important;transform:none!important}` : "";
1349
+ const hide = hidden !== "" ? `${hidden}{animation:none!important;opacity:0!important}` : "";
1350
+ return `@media (prefers-reduced-motion:reduce){${show}${hide}}`;
1351
+ }
1352
+ var offsets = (advances) => advances.map((_, i) => advances.slice(0, i).reduce((s, a) => s + a, 0));
1353
+ function wordmarkReveal(name, options2) {
1354
+ const build = RECIPES[name];
1355
+ if (!build) {
1356
+ return null;
1357
+ }
1358
+ const startMs = options2.startMs ?? 0;
1359
+ const width = options2.advances.reduce((s, a) => s + a, 0);
1360
+ const k = (options2.fontSize ?? REFERENCE_FONT) / REFERENCE_FONT;
1361
+ const c = { p: options2.prefix ?? "lkw", at: startMs, k, n: options2.advances.length, xs: offsets(options2.advances), width };
1362
+ const b = build(c);
1363
+ return { recipe: name, startMs, durationMs: b.durationMs, classes: [...b.shown, ...b.hidden], css: b.css + reduced(c, b) };
1364
+ }
1365
+
1366
+ // src/motion/idle.ts
1367
+ var REFERENCE_SIZE2 = 64;
1368
+ var RIM_SHARE = 0.425;
1369
+ var PART_STEP = 1.2;
1370
+ var n = (v) => String(Number(v.toFixed(2)));
1371
+ function rimGlint(c) {
1372
+ const overlay = `<circle class="${c.p}-s" cx="${n(c.cx)}" cy="${n(c.cy)}" r="${n(RIM_SHARE * c.size)}" fill="none" stroke="${c.colour}" stroke-width="${n(1.6 * c.k)}" stroke-linecap="round" pathLength="100" stroke-dasharray="14 86" style="opacity:0"/>`;
1373
+ const frames2 = [[0, "stroke-dashoffset:100;opacity:0"], [20, "opacity:0.9"], [80, "opacity:0.9"], [100, "stroke-dashoffset:0;opacity:0"]];
1374
+ return { durationMs: 520, css: cssAnim(`${c.p}-s`, `.${c.on} .${c.p}-s`, frames2, { durationMs: 520, easing: SETTLE_OUT }), overlay };
1375
+ }
1376
+ function facesPart(c) {
1377
+ const one = (part, i) => {
1378
+ const frames2 = [[0, "transform:none"], [45, `transform:translate(${part.dx.toFixed(2)}px,${part.dy.toFixed(2)}px)`], [100, "transform:none"]];
1379
+ return cssAnim(`${c.p}-p${i}`, `.${c.on} #mark-${part.name}`, frames2, { durationMs: 420, easing: IN_OUT });
1380
+ };
1381
+ return { durationMs: 420, css: c.parts.map(one).join(""), overlay: "" };
1382
+ }
1383
+ function breath(c) {
1384
+ const origin = `.${c.on} #mark{transform-box:view-box;transform-origin:${n(c.cx)}px ${n(c.cy)}px}`;
1385
+ const frames2 = [[0, "transform:none"], [50, "transform:scale(1.05)"], [100, "transform:none"]];
1386
+ return { durationMs: 600, css: cssAnim(`${c.p}-b`, `.${c.on} #mark`, frames2, { durationMs: 600, easing: IN_OUT }) + origin, overlay: "" };
1387
+ }
1388
+ function orbitSpark(c) {
1389
+ const spark = `<circle cx="${n(c.cx)}" cy="${n(c.top + 1.6 * c.k)}" r="${n(1.8 * c.k)}" fill="${c.colour}"/>`;
1390
+ const overlay = `<g class="${c.p}-o" style="transform-box:view-box;transform-origin:${n(c.cx)}px ${n(c.cy)}px;opacity:0">${spark}</g>`;
1391
+ const frames2 = [[0, "transform:rotate(0deg);opacity:0"], [12, "opacity:1"], [85, "opacity:1"], [100, "transform:rotate(360deg);opacity:0"]];
1392
+ return { durationMs: 600, css: cssAnim(`${c.p}-o`, `.${c.on} .${c.p}-o`, frames2, { durationMs: 600, easing: "cubic-bezier(0.45,0,0.55,1)" }), overlay };
1393
+ }
1394
+ var RECIPES2 = {
1395
+ ["rim-glint" /* RimGlint */]: rimGlint,
1396
+ ["faces-part" /* FacesPart */]: facesPart,
1397
+ ["breath" /* Breath */]: breath,
1398
+ ["orbit-spark" /* OrbitSpark */]: orbitSpark
1399
+ };
1400
+ function context(ctx) {
1401
+ const vb = viewBoxOf(ctx.mark);
1402
+ const size = markSizeOf(ctx.mark);
1403
+ const k = size / REFERENCE_SIZE2;
1404
+ const cx = vb.x + vb.w / 2;
1405
+ const cy = vb.y + vb.h / 2;
1406
+ const names = ctx.roles?.parts ?? ctx.mark.layers.slice(1).map((l) => l.name);
1407
+ const parts2 = ctx.mark.layers.filter((l) => names.includes(l.name)).map((l) => {
1408
+ const c = centroid(flattenPath(l.d).flat());
1409
+ const len = Math.hypot(c.x - cx, c.y - cy) || 1;
1410
+ return { name: l.name, dx: (c.x - cx) / len * PART_STEP * k, dy: (c.y - cy) / len * PART_STEP * k };
1411
+ });
1412
+ return { p: ctx.prefix ?? "lki", on: ctx.trigger ?? "lk-idle", colour: ctx.colour ?? "currentColor", cx, cy, top: vb.y, size, k, parts: parts2 };
1413
+ }
1414
+ function idleRecipe(name, ctx) {
1415
+ const build = RECIPES2[name];
1416
+ if (!build) {
1417
+ return null;
1418
+ }
1419
+ const c = context(ctx);
1420
+ const b = build(c);
1421
+ return { recipe: name, durationMs: b.durationMs, overlay: b.overlay, css: `${b.css}@media (prefers-reduced-motion:reduce){.${c.on} *{animation:none!important}}` };
1422
+ }
1423
+
1242
1424
  // src/motion/boldPresets.ts
1243
1425
  var fillBox = "transform-box:fill-box;transform-origin:center";
1244
- var px = (n) => `${n.toFixed(2)}px`;
1426
+ var px2 = (n2) => `${n2.toFixed(2)}px`;
1245
1427
  var frames = (stops) => stops.map(([at, body]) => `${at}%{${body}}`).join("");
1246
1428
  function outward(ctx) {
1247
1429
  const pts = ctx.layer ? flattenPath(ctx.layer.d).flat() : [];
@@ -1254,7 +1436,7 @@ function outward(ctx) {
1254
1436
  function flyIn(beat, ctx) {
1255
1437
  const u = outward(ctx);
1256
1438
  const d = beat.distance ?? ctx.markSize * 0.5;
1257
- const at = (k) => `transform:translate(${px(u.x * d * k)},${px(u.y * d * k)})`;
1439
+ const at = (k) => `transform:translate(${px2(u.x * d * k)},${px2(u.y * d * k)})`;
1258
1440
  const keyframes = frames([[0, `opacity:0;${at(1)}`], [60, `opacity:1;${at(-0.08)}`], [80, `opacity:1;${at(0.03)}`], [100, `opacity:1;${at(0)}`]]);
1259
1441
  return { keyframes, timing: beat.easing ?? EASE };
1260
1442
  }
@@ -1264,7 +1446,7 @@ function spinAssemble(beat) {
1264
1446
  }
1265
1447
  function dropBounce(beat, ctx) {
1266
1448
  const h = beat.distance ?? ctx.markSize * 0.6;
1267
- const y = (k) => `transform:translateY(${px(-h * k)})`;
1449
+ const y = (k) => `transform:translateY(${px2(-h * k)})`;
1268
1450
  const keyframes = frames([[0, `opacity:0;${y(1)}`], [45, `opacity:1;${y(0)}`], [60, `opacity:1;${y(0.18)}`], [75, `opacity:1;${y(0)}`], [87, `opacity:1;${y(0.05)}`], [100, `opacity:1;${y(0)}`]]);
1269
1451
  return { keyframes, timing: beat.easing ?? "ease-in-out" };
1270
1452
  }
@@ -1274,7 +1456,7 @@ function flip(beat) {
1274
1456
  }
1275
1457
  function slamShake(beat, ctx) {
1276
1458
  const s = beat.distance ?? ctx.markSize * 0.04;
1277
- const at = (k, scale) => `transform:translate(${px(s * k)},0px) scale(${scale})`;
1459
+ const at = (k, scale) => `transform:translate(${px2(s * k)},0px) scale(${scale})`;
1278
1460
  const keyframes = frames([
1279
1461
  [0, `opacity:0;${at(0, beat.scale ?? 2.4)}`],
1280
1462
  [40, `opacity:1;${at(0, 0.94)}`],
@@ -1735,10 +1917,10 @@ function colourStep(brand, mark, outDir) {
1735
1917
  function motionStep(mark, palette, outDir) {
1736
1918
  const still = frame(outDir, "motion-still", mark, palette);
1737
1919
  fs2.mkdirSync(path3.join(outDir, "motion"), { recursive: true });
1738
- const n = mark.layers.length;
1920
+ const n2 = mark.layers.length;
1739
1921
  const options2 = MOTION_OPTIONS.map((preset) => {
1740
1922
  const base = PRESET_DEFAULTS[preset] ?? { preset, durationMs: 600 };
1741
- const beat = preset === "morph-from-circle" /* MorphFromCircle */ ? { ...base, fadeIn: mark.layers.slice(1).map((l) => l.name) } : fitBeat(base, n, INTRO_CAP_MS);
1923
+ const beat = preset === "morph-from-circle" /* MorphFromCircle */ ? { ...base, fadeIn: mark.layers.slice(1).map((l) => l.name) } : fitBeat(base, n2, INTRO_CAP_MS);
1742
1924
  const rel = `motion/${preset}.svg`;
1743
1925
  fs2.writeFileSync(path3.join(outDir, rel), frameSvg(mark, palette, [beat]));
1744
1926
  return option(preset, `The ${preset} intro, ${beat.durationMs} ms per layer, ends on the still.`, still, { motion: rel, targetBox: void 0 });
@@ -1842,6 +2024,6 @@ function runCli(args, out = (line) => process.stdout.write(`${line}
1842
2024
  return 2;
1843
2025
  }
1844
2026
 
1845
- export { BOLD_PRESETS, CVD_KINDS, CvdKind, INTRO_CAP_MS, INTRO_PRESETS, INTRO_RECIPES, IntroRecipe, LOOKALIKE_THRESHOLD, MICRO_CAP_MS, MICRO_DEFAULTS, MICRO_PRESETS, MICRO_RECIPES, MODES, MicroRecipe, Mode, MotionPreset, PRESET_DEFAULTS, PRIMITIVES, SYMBOLS, alphaMask, animatedSvg, buildPickPage, buildPickSpec, checkVariants, contrast, deltaE, exportBrand, fitBeat, flattenPath, generateVariants, generatorPalette, geometryModule, introRecipe, introSvg, loadBrand, markSvg, microRecipe, microSvg, paletteVariants, parseBrand, parseTiming, pixelDiff, pngSize, primitiveMark, renderPng, renderSvg, resolveMotion, resolveToken, runChecks, runCli, schedule, simulateCvd, symbolMatches, symbolScores, totalMs, validateMotion };
2027
+ export { BOLD_PRESETS, CVD_KINDS, CvdKind, IDLE_CAP_MS, IDLE_RECIPES, INTRO_CAP_MS, INTRO_PRESETS, INTRO_RECIPES, IdleRecipe, IntroRecipe, LOOKALIKE_THRESHOLD, MICRO_CAP_MS, MICRO_DEFAULTS, MICRO_PRESETS, MICRO_RECIPES, MODES, MicroRecipe, Mode, MotionPreset, PRESET_DEFAULTS, PRIMITIVES, SYMBOLS, WORDMARK_RECIPES, WordmarkRecipe, alphaMask, animatedSvg, buildPickPage, buildPickSpec, checkVariants, contrast, deltaE, exportBrand, fitBeat, flattenPath, generateVariants, generatorPalette, geometryModule, idleRecipe, introRecipe, introSvg, loadBrand, markSvg, microRecipe, microSvg, paletteVariants, parseBrand, parseTiming, pixelDiff, pngSize, primitiveMark, renderPng, renderSvg, resolveMotion, resolveToken, runChecks, runCli, schedule, simulateCvd, symbolMatches, symbolScores, totalMs, validateMotion, wordmarkReveal };
1846
2028
  //# sourceMappingURL=index.js.map
1847
2029
  //# sourceMappingURL=index.js.map