@dloizides/poster-render 0.5.0 → 0.6.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.js CHANGED
@@ -5,6 +5,7 @@ var BackgroundStyle = /* @__PURE__ */ ((BackgroundStyle2) => {
5
5
  BackgroundStyle2["Solid"] = "solid";
6
6
  BackgroundStyle2["Tint"] = "tint";
7
7
  BackgroundStyle2["Horizon"] = "horizon";
8
+ BackgroundStyle2["Brush"] = "brush";
8
9
  return BackgroundStyle2;
9
10
  })(BackgroundStyle || {});
10
11
 
@@ -14,6 +15,7 @@ var FontSetId = /* @__PURE__ */ ((FontSetId2) => {
14
15
  FontSetId2["Modern"] = "modern";
15
16
  FontSetId2["Elegant"] = "elegant";
16
17
  FontSetId2["Coastal"] = "coastal";
18
+ FontSetId2["KizombaSample"] = "kizomba-sample";
17
19
  return FontSetId2;
18
20
  })(FontSetId || {});
19
21
 
@@ -48,6 +50,7 @@ var PaletteId = /* @__PURE__ */ ((PaletteId2) => {
48
50
  PaletteId2["Sea"] = "sea";
49
51
  PaletteId2["Rose"] = "rose";
50
52
  PaletteId2["GoldenHorizon"] = "golden-horizon";
53
+ PaletteId2["KizombaSample"] = "kizomba-sample";
51
54
  return PaletteId2;
52
55
  })(PaletteId || {});
53
56
 
@@ -74,6 +77,14 @@ var LineTieKind = /* @__PURE__ */ ((LineTieKind2) => {
74
77
  return LineTieKind2;
75
78
  })(LineTieKind || {});
76
79
 
80
+ // src/enums/RowIcon.ts
81
+ var RowIcon = /* @__PURE__ */ ((RowIcon2) => {
82
+ RowIcon2["Person"] = "person";
83
+ RowIcon2["People"] = "people";
84
+ RowIcon2["Ticket"] = "ticket";
85
+ return RowIcon2;
86
+ })(RowIcon || {});
87
+
77
88
  // src/schema/lineStyleSchema.ts
78
89
  var LINE_KEY_PATTERN = "^(title|titleBottom|script|footer|includes[.]heading|includes[.]items[.][0-5]|venue[.][0-2]|schedule[.][0-5][.](label|time)|prices[.][0-3][.](amount|label)|items[.][0-7][.](date|price|schedule[.][0-5]))$";
79
90
  var MAX_FONT = 40;
@@ -149,6 +160,20 @@ var PALETTES = {
149
160
  arch: "#c7d4d6",
150
161
  sky: [[0, "#bfd3d8"], [0.55, "#d4dddd"], [1, "#eadccb"]]
151
162
  },
163
+ ["kizomba-sample" /* KizombaSample */]: {
164
+ background: "#fefefe",
165
+ tint: "#f3eee9",
166
+ title: "#6d645d",
167
+ accent: "#ad8164",
168
+ ink: "#45372f",
169
+ soft: "#9c8f84",
170
+ card: "#ffffff",
171
+ arch: "#efe8e1",
172
+ script: "#e5bb97",
173
+ icon: "#cca383",
174
+ rule: "#d5bca8",
175
+ brush: ["#cdc3b9", "#96918b", "#daae81"]
176
+ },
152
177
  ["rose" /* Rose */]: { background: "#f8efec", tint: "#f1e2dd", title: "#9b6b63", accent: "#c9846f", ink: "#4a3934", soft: "#b39a92", card: "#ffffff", arch: "#f1e5e1" }
153
178
  };
154
179
 
@@ -157,15 +182,65 @@ var FONT_SETS = {
157
182
  ["classic" /* Classic */]: { display: '"Oswald", "Arial Narrow", sans-serif', script: '"Sacramento", cursive', body: '"Fredoka", sans-serif' },
158
183
  ["modern" /* Modern */]: { display: '"Bebas Neue", "Arial Narrow", sans-serif', script: '"Great Vibes", cursive', body: '"Montserrat", sans-serif' },
159
184
  ["elegant" /* Elegant */]: { display: '"Playfair Display", serif', script: '"Allura", cursive', body: '"Lato", sans-serif' },
185
+ ["kizomba-sample" /* KizombaSample */]: { display: '"Anton", "Oswald", "Arial Narrow", sans-serif', script: '"Sacramento", cursive', body: '"Barlow Semi Condensed", "Fredoka", sans-serif' },
160
186
  ["coastal" /* Coastal */]: { display: '"Fraunces", Georgia, serif', script: '"Allura", cursive', body: '"Jost", sans-serif' }
161
187
  };
162
188
 
189
+ // src/schema/rowsSchema.ts
190
+ var MAX_ROWS = 6;
191
+ var MAX_PRICES = 4;
192
+ var MIN_ICON = 16;
193
+ var MAX_ICON = 300;
194
+ var MIN_THICKNESS = 0.5;
195
+ var MAX_THICKNESS = 20;
196
+ var MAX_GAP = 120;
197
+ var MAX_OVERLAP = 1.5;
198
+ var MAX_SHIFT = 0.5;
199
+ var MAX_TOP = 600;
200
+ var MAX_LINE_GAP = 200;
201
+ var MIN_TITLE_SCALE = 0.3;
202
+ var MAX_TITLE_SCALE = 2.5;
203
+ var num = (minimum, maximum) => ({ type: "number", minimum, maximum });
204
+ var icons = (maxItems) => ({ type: "array", items: { type: "string", enum: Object.values(RowIcon) }, minItems: 1, maxItems });
205
+ var rowsSchema = {
206
+ type: "object",
207
+ additionalProperties: false,
208
+ properties: {
209
+ icons: { type: "object", additionalProperties: false, properties: { schedule: icons(MAX_ROWS), prices: icons(MAX_PRICES), size: num(MIN_ICON, MAX_ICON) } },
210
+ dividers: {
211
+ type: "object",
212
+ required: ["thickness"],
213
+ additionalProperties: false,
214
+ properties: {
215
+ thickness: num(MIN_THICKNESS, MAX_THICKNESS),
216
+ color: { type: "string", pattern: "^#[0-9a-fA-F]{6}$" },
217
+ gap: num(0, MAX_GAP),
218
+ toPicture: { type: "boolean" },
219
+ reach: num(0, 1)
220
+ }
221
+ }
222
+ }
223
+ };
224
+ var overlapSchema = {
225
+ type: "object",
226
+ required: ["scale", "dx", "dy"],
227
+ additionalProperties: false,
228
+ properties: { scale: num(1, MAX_OVERLAP), dx: num(-MAX_SHIFT, MAX_SHIFT), dy: num(-MAX_SHIFT, MAX_SHIFT) }
229
+ };
230
+ var headerTuningSchema = {
231
+ headerTop: num(0, MAX_TOP),
232
+ titleScriptGap: num(-MAX_LINE_GAP, MAX_LINE_GAP),
233
+ scriptTitleGap: num(-MAX_LINE_GAP, MAX_LINE_GAP),
234
+ titleScale: num(MIN_TITLE_SCALE, MAX_TITLE_SCALE),
235
+ titleBottomScale: num(MIN_TITLE_SCALE, MAX_TITLE_SCALE)
236
+ };
237
+
163
238
  // src/schema/flierDocSchema.ts
164
239
  var SHORT = 60;
165
240
  var LINE = 120;
166
- var MAX_ROWS = 6;
241
+ var MAX_ROWS2 = 6;
167
242
  var MAX_ITEMS = 8;
168
- var MAX_PRICES = 4;
243
+ var MAX_PRICES2 = 4;
169
244
  var MAX_VENUE = 3;
170
245
  var MIN_SCALE = 0.3;
171
246
  var MAX_HEADER_GAP = 200;
@@ -178,7 +253,7 @@ var scheduleRow = {
178
253
  additionalProperties: false,
179
254
  properties: { label: text(SHORT), time: text(SHORT) }
180
255
  };
181
- var scheduleList = { type: "array", items: scheduleRow, minItems: 1, maxItems: MAX_ROWS };
256
+ var scheduleList = { type: "array", items: scheduleRow, minItems: 1, maxItems: MAX_ROWS2 };
182
257
  var blocks = {
183
258
  type: "object",
184
259
  required: ["title"],
@@ -192,7 +267,7 @@ var blocks = {
192
267
  prices: {
193
268
  type: "array",
194
269
  minItems: 1,
195
- maxItems: MAX_PRICES,
270
+ maxItems: MAX_PRICES2,
196
271
  items: {
197
272
  type: "object",
198
273
  required: ["amount", "label"],
@@ -204,7 +279,7 @@ var blocks = {
204
279
  type: "object",
205
280
  required: ["heading", "items"],
206
281
  additionalProperties: false,
207
- properties: { heading: text(SHORT), items: { type: "array", items: text(LINE), minItems: 1, maxItems: MAX_ROWS } }
282
+ properties: { heading: text(SHORT), items: { type: "array", items: text(LINE), minItems: 1, maxItems: MAX_ROWS2 } }
208
283
  },
209
284
  footer: text(LINE)
210
285
  }
@@ -231,7 +306,8 @@ var flierDocSchema = {
231
306
  properties: {
232
307
  imageId: text(SHORT),
233
308
  anchor: { type: "string", enum: Object.values(PictureAnchor) },
234
- scale: { type: "number", minimum: MIN_SCALE, maximum: 1 }
309
+ scale: { type: "number", minimum: MIN_SCALE, maximum: 1 },
310
+ overlap: overlapSchema
235
311
  }
236
312
  },
237
313
  logo: { type: "object", required: ["imageId"], additionalProperties: false, properties: { imageId: text(SHORT) } },
@@ -241,11 +317,13 @@ var flierDocSchema = {
241
317
  additionalProperties: false,
242
318
  properties: {
243
319
  headerGap: { type: "number", minimum: 0, maximum: MAX_HEADER_GAP },
244
- itemDateScale: { type: "number", minimum: MIN_DATE_SCALE, maximum: MAX_DATE_SCALE }
320
+ itemDateScale: { type: "number", minimum: MIN_DATE_SCALE, maximum: MAX_DATE_SCALE },
321
+ ...headerTuningSchema
245
322
  }
246
323
  },
247
324
  lineStyles: lineStylesSchema,
248
325
  lineTies: lineTiesSchema,
326
+ rows: rowsSchema,
249
327
  items: {
250
328
  type: "array",
251
329
  minItems: 1,
@@ -405,6 +483,92 @@ function missingAssets(doc, assets) {
405
483
  return errors;
406
484
  }
407
485
 
486
+ // src/render/shapes.ts
487
+ function polygon(ctx, pts) {
488
+ const first = pts[0];
489
+ if (!first) {
490
+ return;
491
+ }
492
+ ctx.beginPath();
493
+ ctx.moveTo(first[0], first[1]);
494
+ pts.slice(1).forEach((p, i) => {
495
+ const next = pts[i + 2] ?? first;
496
+ ctx.arcTo(p[0], p[1], next[0], next[1], 0);
497
+ });
498
+ ctx.closePath();
499
+ ctx.fill();
500
+ }
501
+ function disc(ctx, c, r3, color) {
502
+ ctx.fillStyle = color;
503
+ ctx.beginPath();
504
+ ctx.arc(c[0], c[1], Math.max(0, r3), 0, Math.PI * 2);
505
+ ctx.fill();
506
+ }
507
+ function turnedRect(c, size, angle) {
508
+ const cos = Math.cos(angle);
509
+ const sin = Math.sin(angle);
510
+ const hw = size.w / 2;
511
+ const hh = size.h / 2;
512
+ const corners = [[-hw, -hh], [hw, -hh], [hw, hh], [-hw, hh]];
513
+ return corners.map(([px, py]) => [c[0] + px * cos - py * sin, c[1] + px * sin + py * cos]);
514
+ }
515
+
516
+ // src/render/brush.ts
517
+ var CLUSTERS = [
518
+ { x: -0.14, y: 0.13, w: 0.42, h: 0.35, tone: 0 },
519
+ { x: -0.16, y: 0.78, w: 0.36, h: 0.22, tone: 1 },
520
+ { x: 0.78, y: 0.63, w: 0.3, h: 0.3, tone: 2 }
521
+ ];
522
+ var STROKES = 7;
523
+ var ALPHA = 0.55;
524
+ var SLANT = -0.3;
525
+ var TAPER = 0.3;
526
+ var SEED = 42;
527
+ var PM_A = 16807;
528
+ var PM_M = 2147483647;
529
+ var JITTER = 0.3;
530
+ var MIN_LENGTH = 0.7;
531
+ var MIN_THICK = 0.6;
532
+ var THICK_RANGE = 0.8;
533
+ var HALF = 0.5;
534
+ function random(seed) {
535
+ let s = seed;
536
+ return () => {
537
+ s = s * PM_A % PM_M;
538
+ return s / PM_M;
539
+ };
540
+ }
541
+ function stroke(ctx, c, length, thick) {
542
+ const dx = Math.cos(SLANT) * length / 2;
543
+ const dy = Math.sin(SLANT) * length / 2;
544
+ const nx = -Math.sin(SLANT);
545
+ const ny = Math.cos(SLANT);
546
+ const a = thick / 2;
547
+ const b = thick * TAPER / 2;
548
+ polygon(ctx, [
549
+ [c[0] - dx + nx * a, c[1] - dy + ny * a],
550
+ [c[0] + dx + nx * b, c[1] + dy + ny * b],
551
+ [c[0] + dx - nx * b, c[1] + dy - ny * b],
552
+ [c[0] - dx - nx * a, c[1] - dy - ny * a]
553
+ ]);
554
+ }
555
+ function paintBrush(ctx, picture, colors) {
556
+ if (colors.length === 0) {
557
+ return;
558
+ }
559
+ const next = random(SEED);
560
+ ctx.globalAlpha = ALPHA;
561
+ CLUSTERS.forEach((cl) => {
562
+ ctx.fillStyle = colors[cl.tone % colors.length] ?? colors[0] ?? "";
563
+ const box = { x: picture.x + picture.w * cl.x, y: picture.y + picture.h * cl.y, w: picture.w * cl.w, h: picture.h * cl.h };
564
+ for (let i = 0; i < STROKES; i++) {
565
+ const c = [box.x + box.w * (HALF + (next() - HALF) * JITTER), box.y + box.h * (i + HALF) / STROKES];
566
+ stroke(ctx, c, box.w * (MIN_LENGTH + (1 - MIN_LENGTH) * next()), box.h / STROKES * (MIN_THICK + THICK_RANGE * next()));
567
+ }
568
+ });
569
+ ctx.globalAlpha = 1;
570
+ }
571
+
408
572
  // src/render/background.ts
409
573
  function paintGround(ctx, style, palette, size) {
410
574
  ctx.fillStyle = palette.background;
@@ -416,6 +580,17 @@ function paintGround(ctx, style, palette, size) {
416
580
  }
417
581
  ctx.fillRect(0, 0, size.width, size.height);
418
582
  }
583
+ function paintPage(ctx, doc, palette, page) {
584
+ ctx.globalAlpha = 1;
585
+ paintGround(ctx, doc.background, palette, page);
586
+ if (doc.background === "tint" /* Tint */) {
587
+ ctx.fillStyle = palette.tint;
588
+ [page.geo.header, page.geo.body].forEach((r3) => ctx.fillRect(r3.x, r3.y, r3.w, r3.h));
589
+ }
590
+ if (doc.background === "brush" /* Brush */ && page.picture) {
591
+ paintBrush(ctx, page.picture, palette.brush ?? [palette.tint, palette.arch]);
592
+ }
593
+ }
419
594
 
420
595
  // src/layout/layoutSpecs.ts
421
596
  var flanksBeside = (pic, top, bottom2, m) => [
@@ -638,12 +813,13 @@ var GAP = {
638
813
  row: 30,
639
814
  venue: 40,
640
815
  includes: 24,
641
- rule: 8
816
+ rule: 8,
817
+ divider: 24
642
818
  };
643
819
  var makers = (p, u, sc) => ({
644
820
  display: (text2, size, key) => styled({ text: text2, role: "display", weight: BOLD, size: size * u, color: p.title }, key, sc),
645
821
  venue: (text2, size, key) => styled({ text: text2, role: "display", weight: MEDIUM, size: size * u, color: p.ink }, key, sc),
646
- script: (text2, size, key) => styled({ text: text2, role: "script", weight: SCRIPT, size: size * u, color: p.accent }, key, sc),
822
+ script: (text2, size, key) => styled({ text: text2, role: "script", weight: SCRIPT, size: size * u, color: p.script ?? p.accent }, key, sc),
647
823
  strong: (text2, size, key) => styled({ text: text2, role: "body", weight: BOLD, size: size * u, color: p.ink }, key, sc),
648
824
  accent: (text2, size, key) => styled({ text: text2, role: "body", weight: SEMI, size: size * u, color: p.accent }, key, sc),
649
825
  item: (text2, size, key) => styled({ text: text2, role: "body", weight: SEMI, size: size * u, color: p.ink, bullet: p.accent }, key, sc),
@@ -652,7 +828,11 @@ var makers = (p, u, sc) => ({
652
828
  function headerGroups(doc, p, u) {
653
829
  const l = makers(p, u, styleContext(doc));
654
830
  const b = doc.blocks;
655
- const lines = [l.display(b.title, SIZE.title, "title"), b.script ? l.script(b.script, SIZE.headerScript, "script") : void 0, b.titleBottom ? l.display(b.titleBottom, SIZE.title, "titleBottom") : void 0];
831
+ const t = doc.tuning;
832
+ const gap = (line, after) => after === void 0 ? line : { ...line, gapAfter: after * u };
833
+ const title = gap(l.display(b.title, SIZE.title * (t?.titleScale ?? 1), "title"), b.script ?? b.titleBottom ? t?.titleScriptGap : void 0);
834
+ const script = b.script ? gap(l.script(b.script, SIZE.headerScript, "script"), b.titleBottom ? t?.scriptTitleGap : void 0) : void 0;
835
+ const lines = [title, script, b.titleBottom ? l.display(b.titleBottom, SIZE.title * (t?.titleBottomScale ?? 1), "titleBottom") : void 0];
656
836
  return [{ lines: lines.filter((x) => x !== void 0), gapAfter: 0 }];
657
837
  }
658
838
  function itemGroup(item, n, l, scale) {
@@ -665,6 +845,19 @@ function itemGroup(item, n, l, scale) {
665
845
  return { lines, gapAfter: GAP.item * u };
666
846
  }
667
847
  var WRAP_FROM = 14;
848
+ function dividerOf(doc, p, u) {
849
+ const d = doc.rows?.dividers;
850
+ return d === void 0 ? void 0 : { color: d.color ?? p.rule ?? p.accent, height: d.thickness * u, gap: (d.gap ?? GAP.divider) * u };
851
+ }
852
+ function rowMarks(doc, p, u) {
853
+ const divider = dividerOf(doc, p, u);
854
+ const size = doc.rows?.icons?.size;
855
+ return (icons2, i, last) => {
856
+ const kind = icons2 === void 0 || icons2.length === 0 ? void 0 : icons2[Math.min(i, icons2.length - 1)];
857
+ const icon = kind === void 0 ? {} : { icon: { color: p.icon ?? p.accent, glyph: p.background, kind, size: size === void 0 ? void 0 : size * u } };
858
+ return { ...icon, ...divider === void 0 || last ? {} : { rule: divider, ruleBelow: true, ruleAbove: false } };
859
+ };
860
+ }
668
861
  function halves(text2) {
669
862
  const mid = text2.length / 2;
670
863
  const spaces = [...text2].flatMap((c, i) => c === " " ? [i] : []);
@@ -682,14 +875,16 @@ function eventGroups(doc, l, u, options) {
682
875
  const b = doc.blocks;
683
876
  const groups = [];
684
877
  const schedule2 = b.schedule ?? [];
878
+ const prices = (options.withPrices === false ? void 0 : b.prices) ?? [];
879
+ const lastRow = schedule2.length + prices.length - 1;
880
+ const icons2 = doc.rows?.icons;
685
881
  schedule2.forEach((row, i) => {
686
882
  const lines = options.compact ? [l.strong(`${row.label} ${row.time}`, SIZE.scheduleLabel, `schedule.${i}.label`)] : [l.strong(row.label, SIZE.scheduleLabel, `schedule.${i}.label`), l.accent(row.time, SIZE.scheduleTime, `schedule.${i}.time`)];
687
- groups.push({ lines, gapAfter: GAP.row * u, keepWithNext: i < schedule2.length - 1 });
883
+ groups.push({ lines, gapAfter: GAP.row * u, keepWithNext: i < schedule2.length - 1, ...options.marks(icons2?.schedule, i, i === lastRow) });
688
884
  });
689
- const prices = (options.withPrices === false ? void 0 : b.prices) ?? [];
690
885
  prices.forEach((row, i) => {
691
886
  const lines = options.compact ? [l.strong(`${row.amount} ${row.label}`, SIZE.priceAmount, `prices.${i}.amount`)] : [l.strong(row.amount, SIZE.priceAmount, `prices.${i}.amount`), l.accent(row.label, SIZE.priceLabel, `prices.${i}.label`)];
692
- groups.push({ lines, gapAfter: GAP.row * u, keepWithNext: i < prices.length - 1 });
887
+ groups.push({ lines, gapAfter: GAP.row * u, keepWithNext: i < prices.length - 1, ...options.marks(icons2?.prices, i, schedule2.length + i === lastRow) });
693
888
  });
694
889
  return groups;
695
890
  }
@@ -713,9 +908,9 @@ function bodyGroups(doc, p, u, options = {}) {
713
908
  if (b.venue) {
714
909
  const size = isList ? SIZE.listVenue : SIZE.venue;
715
910
  const keepWithNext = !isList && (b.schedule?.length ?? 0) > 0;
716
- groups.push({ lines: b.venue.map((v, i) => l.venue(v, size, `venue.${i}`)), gapAfter: GAP.venue * u, rule: { color: p.accent, height: GAP.rule * u }, ruleBelow: true, icon: { color: p.accent, glyph: p.background }, keepWithNext });
911
+ groups.push({ lines: b.venue.map((v, i) => l.venue(v, size, `venue.${i}`)), gapAfter: GAP.venue * u, rule: dividerOf(doc, p, u) ?? { color: p.accent, height: GAP.rule * u }, ruleBelow: true, icon: { color: p.icon ?? p.accent, glyph: p.background }, keepWithNext });
717
912
  }
718
- groups.push(...isList ? listGroups(doc, l, u, options.dateScale ?? 1) : eventGroups(doc, l, u, options));
913
+ groups.push(...isList ? listGroups(doc, l, u, options.dateScale ?? 1) : eventGroups(doc, l, u, { ...options, marks: rowMarks(doc, p, u) }));
719
914
  if (b.includes) {
720
915
  const lines = [l.accent(b.includes.heading, SIZE.small, "includes.heading"), ...b.includes.items.map((item, i) => l.item(item, SIZE.small, `includes.items.${i}`))].flatMap((line) => wrapped(line, options.wrap));
721
916
  groups.push({ lines, gapAfter: GAP.includes * u, uniform: true, keepWithNext: b.footer !== void 0, attachNext: b.footer !== void 0 });
@@ -735,6 +930,9 @@ var indented = (line) => line.bullet !== void 0 || line.hang === true;
735
930
  var bulletIndent = (line, k) => indented(line) ? line.size * k * BULLET_INDENT : 0;
736
931
  var iconSize = (group, k) => {
737
932
  const first = group.lines[0];
933
+ if (group.icon?.size !== void 0) {
934
+ return group.icon.size * k;
935
+ }
738
936
  return group.icon && first ? first.size * k * LINE_HEIGHT * ICON_SCALE : 0;
739
937
  };
740
938
  function groupBox(group, k, colW) {
@@ -827,16 +1025,16 @@ function placeIcon(group, box, out) {
827
1025
  return bottom2;
828
1026
  }
829
1027
  const textH = bottom2 - top;
830
- out?.icons.push({ rect: { x, y: top + Math.max(0, (textH - d) / 2), w: d, h: d }, color: group.icon.color, glyph: group.icon.glyph });
1028
+ out?.icons.push({ rect: { x, y: top + Math.max(0, (textH - d) / 2), w: d, h: d }, color: group.icon.color, glyph: group.icon.glyph, kind: group.icon.kind });
831
1029
  return top + Math.max(textH, d);
832
1030
  }
833
1031
  function placeGroup(m, at, out) {
834
1032
  const { k, col, y0, sizes } = at;
835
1033
  const { group } = m;
836
1034
  let y = y0;
837
- if (group.rule) {
1035
+ if (group.rule && group.ruleAbove !== false) {
838
1036
  out?.rules.push({ rect: { x: col.x, y, w: col.w * RULE_WIDTH, h: group.rule.height * k }, color: group.rule.color });
839
- y += group.rule.height * k * RULE_GAP;
1037
+ y += group.rule.gap === void 0 ? group.rule.height * k * RULE_GAP : (group.rule.height + group.rule.gap) * k;
840
1038
  }
841
1039
  const { pad, d, iconIndent } = groupBox(group, k, col.w);
842
1040
  const top = y;
@@ -850,12 +1048,12 @@ function placeGroup(m, at, out) {
850
1048
  if (line.bullet && out) {
851
1049
  out.bullets.push({ x: col.x + pad + size * BULLET_RADIUS, y: y + size * LINE_HEIGHT / 2, r: size * BULLET_RADIUS, color: line.bullet });
852
1050
  }
853
- y += size * LINE_HEIGHT;
1051
+ y += size * LINE_HEIGHT + (line.gapAfter ?? 0) * k;
854
1052
  });
855
1053
  y = placeIcon(group, { d, x: col.x + pad, top: top + pad, bottom: y }, out);
856
1054
  y += pad;
857
1055
  if (group.rule && group.ruleBelow) {
858
- y += group.rule.height * k * (RULE_GAP - 1);
1056
+ y += group.rule.gap === void 0 ? group.rule.height * k * (RULE_GAP - 1) : group.rule.gap * k;
859
1057
  out?.rules.push({ rect: { x: col.x, y, w: col.w * RULE_WIDTH, h: group.rule.height * k }, color: group.rule.color });
860
1058
  y += group.rule.height * k;
861
1059
  }
@@ -1033,6 +1231,13 @@ function splitHeader(header, hasLogo) {
1033
1231
  const logoW = hasLogo ? Math.round(header.w * LOGO_SHARE) : 0;
1034
1232
  return { text: { ...header, w: header.w - logoW * 1.1 }, logo: { ...header, x: header.x + header.w - logoW, w: logoW } };
1035
1233
  }
1234
+ function headerAt(zones, top, u) {
1235
+ if (top === void 0) {
1236
+ return zones;
1237
+ }
1238
+ const y = Math.round(top * u);
1239
+ return { ...zones, text: { ...zones.text, y, h: Math.max(1, zones.text.y + zones.text.h - y) } };
1240
+ }
1036
1241
  function closeHeaderGap(geo, head, gap, u) {
1037
1242
  const { header, body } = geo;
1038
1243
  const stacked = header.y + header.h <= body.y && header.x < body.x + body.w && body.x < header.x + header.w;
@@ -1045,7 +1250,7 @@ function closeHeaderGap(geo, head, gap, u) {
1045
1250
  function flowAll(ctx, input, geo, reflow) {
1046
1251
  const { doc, palette, fonts } = input;
1047
1252
  const u = Math.min(input.width, input.height) / BASE;
1048
- const zones = geo.logo ? { text: geo.header, logo: geo.logo } : splitHeader(geo.header, doc.logo !== void 0);
1253
+ const zones = headerAt(geo.logo ? { text: geo.header, logo: geo.logo } : splitHeader(geo.header, doc.logo !== void 0), doc.tuning?.headerTop, u);
1049
1254
  const head = flow(ctx, headerGroups(doc, palette, u), zones.text, fonts);
1050
1255
  const flanks = geo.flanks ?? [];
1051
1256
  const tight = closeHeaderGap(geo, head, doc.tuning?.headerGap, u);
@@ -1119,6 +1324,87 @@ function fitToFloor(ctx, input) {
1119
1324
  return best ?? flowAll(ctx, input, base2, { compact: false, wrap: false});
1120
1325
  }
1121
1326
 
1327
+ // src/render/overlap.ts
1328
+ var clamp = (v, lo, hi) => Math.min(Math.max(v, lo), hi);
1329
+ function placePicture(image, region, slot, fit) {
1330
+ const base2 = placeContain(image, region, { anchor: slot.anchor, alignX: fit.alignX, scale: slot.scale });
1331
+ const o = slot.overlap;
1332
+ if (o === void 0) {
1333
+ return base2;
1334
+ }
1335
+ const { width, height } = fit.frame;
1336
+ const s = Math.min(o.scale, width / Math.max(base2.w, 1), height / Math.max(base2.h, 1));
1337
+ const w = Math.floor(base2.w * s);
1338
+ const h = Math.floor(base2.h * s);
1339
+ const x = base2.x + (base2.w - w) * fit.alignX + o.dx * width;
1340
+ const y = base2.y + (base2.h - h) * ANCHOR_Y[slot.anchor] + o.dy * height;
1341
+ return { x: Math.round(clamp(x, 0, width - w)), y: Math.round(clamp(y, 0, height - h)), w, h };
1342
+ }
1343
+ function reachPicture(rules, picture, reach) {
1344
+ const end = picture.x + picture.w * reach;
1345
+ rules.filter((r3) => r3.rect.y >= picture.y && r3.rect.y <= picture.y + picture.h).forEach((r3) => {
1346
+ r3.rect.w = Math.max(0, end - r3.rect.x);
1347
+ });
1348
+ }
1349
+
1350
+ // src/render/rowIcons.ts
1351
+ var LINE2 = 0.03;
1352
+ var HEAD_Y = -0.15;
1353
+ var HEAD_R = 0.1;
1354
+ var BODY_Y = 0.25;
1355
+ var BODY_R = 0.2;
1356
+ var BACK_DX = 0.12;
1357
+ var BACK_DY = -0.04;
1358
+ var FRONT_DX = -0.08;
1359
+ var PAIR_SCALE = 0.85;
1360
+ var TICKET_W = 0.52;
1361
+ var TICKET_H = 0.3;
1362
+ var TICKET_TURN = -Math.PI / 4;
1363
+ var PERFORATION = 0.14;
1364
+ var DOTS = [-0.3, 0, 0.3];
1365
+ var DOT = 0.035;
1366
+ function halfDisc(ctx, c, r3, color) {
1367
+ ctx.fillStyle = color;
1368
+ ctx.beginPath();
1369
+ ctx.arc(c[0], c[1], Math.max(0, r3), Math.PI, Math.PI * 2);
1370
+ ctx.closePath();
1371
+ ctx.fill();
1372
+ }
1373
+ function person(ctx, c, d, colors) {
1374
+ const w = d * LINE2;
1375
+ const head = [c[0], c[1] + d * HEAD_Y];
1376
+ disc(ctx, head, d * HEAD_R, colors.glyph);
1377
+ disc(ctx, head, d * HEAD_R - w, colors.fill);
1378
+ halfDisc(ctx, [c[0], c[1] + d * BODY_Y], d * BODY_R, colors.glyph);
1379
+ halfDisc(ctx, [c[0], c[1] + d * BODY_Y - w], d * BODY_R - 2 * w, colors.fill);
1380
+ }
1381
+ function people(ctx, c, d, colors) {
1382
+ const s = d * PAIR_SCALE;
1383
+ person(ctx, [c[0] + d * BACK_DX, c[1] + d * BACK_DY], s, colors);
1384
+ person(ctx, [c[0] + d * FRONT_DX, c[1]], s, colors);
1385
+ }
1386
+ function ticket(ctx, c, d, colors) {
1387
+ const w = d * LINE2;
1388
+ ctx.fillStyle = colors.glyph;
1389
+ polygon(ctx, turnedRect(c, { w: d * TICKET_W, h: d * TICKET_H }, TICKET_TURN));
1390
+ ctx.fillStyle = colors.fill;
1391
+ polygon(ctx, turnedRect(c, { w: d * TICKET_W - 2 * w, h: d * TICKET_H - 2 * w }, TICKET_TURN));
1392
+ const along = [Math.cos(TICKET_TURN), Math.sin(TICKET_TURN)];
1393
+ const across = [-along[1], along[0]];
1394
+ const x = d * PERFORATION;
1395
+ DOTS.forEach((t) => disc(ctx, [c[0] + along[0] * x + across[0] * t * d * TICKET_H, c[1] + along[1] * x + across[1] * t * d * TICKET_H], d * DOT, colors.glyph));
1396
+ }
1397
+ var GLYPHS = {
1398
+ ["person" /* Person */]: person,
1399
+ ["people" /* People */]: people,
1400
+ ["ticket" /* Ticket */]: ticket
1401
+ };
1402
+ function drawRowIcon(ctx, r3, kind, colors) {
1403
+ const c = [r3.x + r3.w / 2, r3.y + r3.h / 2];
1404
+ disc(ctx, c, r3.w / 2, colors.fill);
1405
+ GLYPHS[kind](ctx, c, r3.w, colors);
1406
+ }
1407
+
1122
1408
  // src/render/render.ts
1123
1409
  var BASE2 = 1080;
1124
1410
  var NO_SPACING2 = "0px";
@@ -1161,11 +1447,13 @@ function roundRect(ctx, r3, radius) {
1161
1447
  ctx.closePath();
1162
1448
  ctx.fill();
1163
1449
  }
1164
- function drawFlow(ctx, f, radius) {
1450
+ function drawRules(ctx, f) {
1165
1451
  f.rules.forEach((r3) => {
1166
1452
  ctx.fillStyle = r3.color;
1167
1453
  ctx.fillRect(r3.rect.x, r3.rect.y, r3.rect.w, r3.rect.h);
1168
1454
  });
1455
+ }
1456
+ function drawMarks(ctx, f, radius) {
1169
1457
  f.cards.forEach((c) => {
1170
1458
  ctx.fillStyle = c.color;
1171
1459
  roundRect(ctx, c.rect, radius);
@@ -1176,7 +1464,7 @@ function drawFlow(ctx, f, radius) {
1176
1464
  ctx.arc(b.x, b.y, b.r, 0, Math.PI * 2);
1177
1465
  ctx.fill();
1178
1466
  });
1179
- f.icons.forEach((i) => drawPin(ctx, i.rect, i.color, i.glyph));
1467
+ f.icons.forEach((i) => i.kind === void 0 ? drawPin(ctx, i.rect, i.color, i.glyph) : drawRowIcon(ctx, i.rect, i.kind, { fill: i.color, glyph: i.glyph }));
1180
1468
  ctx.textAlign = "left";
1181
1469
  ctx.textBaseline = "top";
1182
1470
  f.texts.forEach((t) => {
@@ -1191,6 +1479,10 @@ function drawFlow(ctx, f, radius) {
1191
1479
  }
1192
1480
  });
1193
1481
  }
1482
+ function drawFlow(ctx, f, radius) {
1483
+ drawRules(ctx, f);
1484
+ drawMarks(ctx, f, radius);
1485
+ }
1194
1486
  function checked(input, assets) {
1195
1487
  const result = validateFlierDoc(input);
1196
1488
  if (!result.ok) {
@@ -1222,6 +1514,25 @@ function capAligned(zone, head) {
1222
1514
  const shift = first ? Math.min(Math.max(0, Math.round(first.y + first.h * CAP_TOP) - zone.y), Math.round(zone.h / 2)) : 0;
1223
1515
  return { ...zone, y: zone.y + shift, h: zone.h - shift };
1224
1516
  }
1517
+ function placeOnPage(doc, assets, fitted, frame) {
1518
+ const image = doc.picture ? assets[doc.picture.imageId] : void 0;
1519
+ const region = pictureRegion(doc.layout, fitted.geo, fitted.body, frame);
1520
+ const picture = image && doc.picture ? placePicture(image, region, doc.picture, { alignX: fitted.geo.alignX, frame }) : null;
1521
+ const dividers = doc.rows?.dividers;
1522
+ if (picture && dividers?.toPicture === true) {
1523
+ reachPicture(fitted.body.rules, picture, dividers.reach ?? 0);
1524
+ }
1525
+ return { image, region, picture };
1526
+ }
1527
+ function drawLogo(ctx, doc, assets, fitted) {
1528
+ const logoImage = doc.logo ? assets[doc.logo.imageId] : void 0;
1529
+ const zone = fitted.geo.logo ? fitted.zones.logo : capAligned(fitted.zones.logo, fitted.head);
1530
+ const logo = logoImage ? placeContain(logoImage, zone, { anchor: "top" /* Top */, alignX: 1, scale: 1 }) : null;
1531
+ if (logoImage && logo) {
1532
+ ctx.drawImage(logoImage, logo.x, logo.y, logo.w, logo.h);
1533
+ }
1534
+ return logo;
1535
+ }
1225
1536
  function render(input, assets, canvas) {
1226
1537
  const doc = checked(input, assets);
1227
1538
  const { width, height } = FORMAT_SIZES[doc.format];
@@ -1232,40 +1543,34 @@ function render(input, assets, canvas) {
1232
1543
  throw new Error("poster-render: the canvas has no 2d context");
1233
1544
  }
1234
1545
  const palette = PALETTES[doc.palette];
1235
- const fonts = FONT_SETS[doc.fonts];
1236
- const u = Math.min(width, height) / BASE2;
1237
- const { geo, zones, head, body, sides } = fitToFloor(ctx, { doc, palette, fonts, width, height });
1238
- ctx.globalAlpha = 1;
1239
- paintGround(ctx, doc.background, palette, { width, height });
1240
- if (doc.background === "tint" /* Tint */) {
1241
- ctx.fillStyle = palette.tint;
1242
- [geo.header, geo.body].forEach((r3) => ctx.fillRect(r3.x, r3.y, r3.w, r3.h));
1243
- }
1546
+ const fitted = fitToFloor(ctx, { doc, palette, fonts: FONT_SETS[doc.fonts], width, height });
1547
+ const { geo, head, body, sides } = fitted;
1548
+ const { image, region, picture } = placeOnPage(doc, assets, fitted, { width, height, u: Math.min(width, height) / BASE2 });
1549
+ paintPage(ctx, doc, palette, { geo, width, height, picture });
1244
1550
  const radius = Math.min(width, height) * CARD_RADIUS;
1245
- [head, body, ...sides].forEach((f) => drawFlow(ctx, f, radius));
1246
- const logoImage = doc.logo ? assets[doc.logo.imageId] : void 0;
1247
- const logo = logoImage ? placeContain(logoImage, geo.logo ? zones.logo : capAligned(zones.logo, head), { anchor: "top" /* Top */, alignX: 1, scale: 1 }) : null;
1248
- if (logoImage && logo) {
1249
- ctx.drawImage(logoImage, logo.x, logo.y, logo.w, logo.h);
1250
- }
1251
- const image = doc.picture ? assets[doc.picture.imageId] : void 0;
1551
+ const flows = [head, body, ...sides];
1552
+ const layered = doc.picture?.overlap !== void 0;
1553
+ flows.forEach((f) => layered ? drawRules(ctx, f) : drawFlow(ctx, f, radius));
1554
+ const logo = drawLogo(ctx, doc, assets, fitted);
1252
1555
  const backdrop = image ? archRect(geo) : null;
1253
1556
  if (backdrop) {
1254
1557
  drawArch(ctx, backdrop, palette.arch);
1255
1558
  }
1256
- const region = pictureRegion(doc.layout, geo, body, { height, u });
1257
- const picture = image && doc.picture ? placeContain(image, region, { anchor: doc.picture.anchor, alignX: geo.alignX, scale: doc.picture.scale }) : null;
1258
1559
  if (image && picture) {
1259
1560
  ctx.drawImage(image, picture.x, picture.y, picture.w, picture.h);
1260
1561
  }
1562
+ if (layered) {
1563
+ flows.forEach((f) => drawMarks(ctx, f, radius));
1564
+ }
1261
1565
  return {
1262
1566
  width,
1263
1567
  height,
1264
1568
  picture,
1265
1569
  pictureRegion: region,
1266
- textBoxes: [head, body, ...sides].flatMap((f) => f.texts.map((t) => t.box)),
1570
+ textBoxes: flows.flatMap((f) => f.texts.map((t) => t.box)),
1267
1571
  cardBoxes: body.cards.map((c) => c.rect),
1268
- iconBoxes: [head, body, ...sides].flatMap((f) => f.icons.map((i) => i.rect)),
1572
+ iconBoxes: flows.flatMap((f) => f.icons.map((i) => i.rect)),
1573
+ ruleBoxes: flows.flatMap((f) => f.rules.map((r3) => r3.rect)),
1269
1574
  logo,
1270
1575
  backdrop
1271
1576
  };
@@ -1375,6 +1680,7 @@ exports.LineTieKind = LineTieKind;
1375
1680
  exports.PALETTES = PALETTES;
1376
1681
  exports.PaletteId = PaletteId;
1377
1682
  exports.PictureAnchor = PictureAnchor;
1683
+ exports.RowIcon = RowIcon;
1378
1684
  exports.defaultLayoutFor = defaultLayoutFor;
1379
1685
  exports.exportPng = exportPng;
1380
1686
  exports.flierDocSchema = flierDocSchema;