@dloizides/poster-render 0.5.0 → 0.7.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/CHANGELOG.md +11 -0
- package/dist/index.d.mts +51 -4
- package/dist/index.d.ts +51 -4
- package/dist/index.js +369 -52
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +369 -53
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
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,68 @@ 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 MIN_LABEL_SCALE = 0.3;
|
|
204
|
+
var num = (minimum, maximum) => ({ type: "number", minimum, maximum });
|
|
205
|
+
var icons = (maxItems) => ({ type: "array", items: { type: "string", enum: Object.values(RowIcon) }, minItems: 1, maxItems });
|
|
206
|
+
var rowsSchema = {
|
|
207
|
+
type: "object",
|
|
208
|
+
additionalProperties: false,
|
|
209
|
+
properties: {
|
|
210
|
+
icons: { type: "object", additionalProperties: false, properties: { schedule: icons(MAX_ROWS), prices: icons(MAX_PRICES), size: num(MIN_ICON, MAX_ICON) } },
|
|
211
|
+
dividers: {
|
|
212
|
+
type: "object",
|
|
213
|
+
required: ["thickness"],
|
|
214
|
+
additionalProperties: false,
|
|
215
|
+
properties: {
|
|
216
|
+
thickness: num(MIN_THICKNESS, MAX_THICKNESS),
|
|
217
|
+
color: { type: "string", pattern: "^#[0-9a-fA-F]{6}$" },
|
|
218
|
+
gap: num(0, MAX_GAP),
|
|
219
|
+
toPicture: { type: "boolean" },
|
|
220
|
+
reach: num(0, 1)
|
|
221
|
+
}
|
|
222
|
+
},
|
|
223
|
+
priceLabelScale: num(MIN_LABEL_SCALE, 1),
|
|
224
|
+
venue: { type: "object", additionalProperties: false, properties: { body: { type: "boolean" }, bare: { type: "boolean" } } }
|
|
225
|
+
}
|
|
226
|
+
};
|
|
227
|
+
var overlapSchema = {
|
|
228
|
+
type: "object",
|
|
229
|
+
required: ["scale", "dx", "dy"],
|
|
230
|
+
additionalProperties: false,
|
|
231
|
+
properties: { scale: num(1, MAX_OVERLAP), dx: num(-MAX_SHIFT, MAX_SHIFT), dy: num(-MAX_SHIFT, MAX_SHIFT) }
|
|
232
|
+
};
|
|
233
|
+
var headerTuningSchema = {
|
|
234
|
+
headerTop: num(0, MAX_TOP),
|
|
235
|
+
titleScriptGap: num(-MAX_LINE_GAP, MAX_LINE_GAP),
|
|
236
|
+
scriptTitleGap: num(-MAX_LINE_GAP, MAX_LINE_GAP),
|
|
237
|
+
titleScale: num(MIN_TITLE_SCALE, MAX_TITLE_SCALE),
|
|
238
|
+
titleBottomScale: num(MIN_TITLE_SCALE, MAX_TITLE_SCALE)
|
|
239
|
+
};
|
|
240
|
+
|
|
163
241
|
// src/schema/flierDocSchema.ts
|
|
164
242
|
var SHORT = 60;
|
|
165
243
|
var LINE = 120;
|
|
166
|
-
var
|
|
244
|
+
var MAX_ROWS2 = 6;
|
|
167
245
|
var MAX_ITEMS = 8;
|
|
168
|
-
var
|
|
246
|
+
var MAX_PRICES2 = 4;
|
|
169
247
|
var MAX_VENUE = 3;
|
|
170
248
|
var MIN_SCALE = 0.3;
|
|
171
249
|
var MAX_HEADER_GAP = 200;
|
|
@@ -178,7 +256,7 @@ var scheduleRow = {
|
|
|
178
256
|
additionalProperties: false,
|
|
179
257
|
properties: { label: text(SHORT), time: text(SHORT) }
|
|
180
258
|
};
|
|
181
|
-
var scheduleList = { type: "array", items: scheduleRow, minItems: 1, maxItems:
|
|
259
|
+
var scheduleList = { type: "array", items: scheduleRow, minItems: 1, maxItems: MAX_ROWS2 };
|
|
182
260
|
var blocks = {
|
|
183
261
|
type: "object",
|
|
184
262
|
required: ["title"],
|
|
@@ -192,7 +270,7 @@ var blocks = {
|
|
|
192
270
|
prices: {
|
|
193
271
|
type: "array",
|
|
194
272
|
minItems: 1,
|
|
195
|
-
maxItems:
|
|
273
|
+
maxItems: MAX_PRICES2,
|
|
196
274
|
items: {
|
|
197
275
|
type: "object",
|
|
198
276
|
required: ["amount", "label"],
|
|
@@ -204,7 +282,7 @@ var blocks = {
|
|
|
204
282
|
type: "object",
|
|
205
283
|
required: ["heading", "items"],
|
|
206
284
|
additionalProperties: false,
|
|
207
|
-
properties: { heading: text(SHORT), items: { type: "array", items: text(LINE), minItems: 1, maxItems:
|
|
285
|
+
properties: { heading: text(SHORT), items: { type: "array", items: text(LINE), minItems: 1, maxItems: MAX_ROWS2 } }
|
|
208
286
|
},
|
|
209
287
|
footer: text(LINE)
|
|
210
288
|
}
|
|
@@ -231,7 +309,8 @@ var flierDocSchema = {
|
|
|
231
309
|
properties: {
|
|
232
310
|
imageId: text(SHORT),
|
|
233
311
|
anchor: { type: "string", enum: Object.values(PictureAnchor) },
|
|
234
|
-
scale: { type: "number", minimum: MIN_SCALE, maximum: 1 }
|
|
312
|
+
scale: { type: "number", minimum: MIN_SCALE, maximum: 1 },
|
|
313
|
+
overlap: overlapSchema
|
|
235
314
|
}
|
|
236
315
|
},
|
|
237
316
|
logo: { type: "object", required: ["imageId"], additionalProperties: false, properties: { imageId: text(SHORT) } },
|
|
@@ -241,11 +320,13 @@ var flierDocSchema = {
|
|
|
241
320
|
additionalProperties: false,
|
|
242
321
|
properties: {
|
|
243
322
|
headerGap: { type: "number", minimum: 0, maximum: MAX_HEADER_GAP },
|
|
244
|
-
itemDateScale: { type: "number", minimum: MIN_DATE_SCALE, maximum: MAX_DATE_SCALE }
|
|
323
|
+
itemDateScale: { type: "number", minimum: MIN_DATE_SCALE, maximum: MAX_DATE_SCALE },
|
|
324
|
+
...headerTuningSchema
|
|
245
325
|
}
|
|
246
326
|
},
|
|
247
327
|
lineStyles: lineStylesSchema,
|
|
248
328
|
lineTies: lineTiesSchema,
|
|
329
|
+
rows: rowsSchema,
|
|
249
330
|
items: {
|
|
250
331
|
type: "array",
|
|
251
332
|
minItems: 1,
|
|
@@ -405,6 +486,92 @@ function missingAssets(doc, assets) {
|
|
|
405
486
|
return errors;
|
|
406
487
|
}
|
|
407
488
|
|
|
489
|
+
// src/render/shapes.ts
|
|
490
|
+
function polygon(ctx, pts) {
|
|
491
|
+
const first = pts[0];
|
|
492
|
+
if (!first) {
|
|
493
|
+
return;
|
|
494
|
+
}
|
|
495
|
+
ctx.beginPath();
|
|
496
|
+
ctx.moveTo(first[0], first[1]);
|
|
497
|
+
pts.slice(1).forEach((p, i) => {
|
|
498
|
+
const next = pts[i + 2] ?? first;
|
|
499
|
+
ctx.arcTo(p[0], p[1], next[0], next[1], 0);
|
|
500
|
+
});
|
|
501
|
+
ctx.closePath();
|
|
502
|
+
ctx.fill();
|
|
503
|
+
}
|
|
504
|
+
function disc(ctx, c, r3, color) {
|
|
505
|
+
ctx.fillStyle = color;
|
|
506
|
+
ctx.beginPath();
|
|
507
|
+
ctx.arc(c[0], c[1], Math.max(0, r3), 0, Math.PI * 2);
|
|
508
|
+
ctx.fill();
|
|
509
|
+
}
|
|
510
|
+
function turnedRect(c, size, angle) {
|
|
511
|
+
const cos = Math.cos(angle);
|
|
512
|
+
const sin = Math.sin(angle);
|
|
513
|
+
const hw = size.w / 2;
|
|
514
|
+
const hh = size.h / 2;
|
|
515
|
+
const corners = [[-hw, -hh], [hw, -hh], [hw, hh], [-hw, hh]];
|
|
516
|
+
return corners.map(([px, py]) => [c[0] + px * cos - py * sin, c[1] + px * sin + py * cos]);
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
// src/render/brush.ts
|
|
520
|
+
var CLUSTERS = [
|
|
521
|
+
{ x: -0.14, y: 0.13, w: 0.42, h: 0.35, tone: 0 },
|
|
522
|
+
{ x: -0.16, y: 0.78, w: 0.36, h: 0.22, tone: 1 },
|
|
523
|
+
{ x: 0.78, y: 0.63, w: 0.3, h: 0.3, tone: 2 }
|
|
524
|
+
];
|
|
525
|
+
var STROKES = 7;
|
|
526
|
+
var ALPHA = 0.55;
|
|
527
|
+
var SLANT = -0.3;
|
|
528
|
+
var TAPER = 0.3;
|
|
529
|
+
var SEED = 42;
|
|
530
|
+
var PM_A = 16807;
|
|
531
|
+
var PM_M = 2147483647;
|
|
532
|
+
var JITTER = 0.3;
|
|
533
|
+
var MIN_LENGTH = 0.7;
|
|
534
|
+
var MIN_THICK = 0.6;
|
|
535
|
+
var THICK_RANGE = 0.8;
|
|
536
|
+
var HALF = 0.5;
|
|
537
|
+
function random(seed) {
|
|
538
|
+
let s = seed;
|
|
539
|
+
return () => {
|
|
540
|
+
s = s * PM_A % PM_M;
|
|
541
|
+
return s / PM_M;
|
|
542
|
+
};
|
|
543
|
+
}
|
|
544
|
+
function stroke(ctx, c, length, thick) {
|
|
545
|
+
const dx = Math.cos(SLANT) * length / 2;
|
|
546
|
+
const dy = Math.sin(SLANT) * length / 2;
|
|
547
|
+
const nx = -Math.sin(SLANT);
|
|
548
|
+
const ny = Math.cos(SLANT);
|
|
549
|
+
const a = thick / 2;
|
|
550
|
+
const b = thick * TAPER / 2;
|
|
551
|
+
polygon(ctx, [
|
|
552
|
+
[c[0] - dx + nx * a, c[1] - dy + ny * a],
|
|
553
|
+
[c[0] + dx + nx * b, c[1] + dy + ny * b],
|
|
554
|
+
[c[0] + dx - nx * b, c[1] + dy - ny * b],
|
|
555
|
+
[c[0] - dx - nx * a, c[1] - dy - ny * a]
|
|
556
|
+
]);
|
|
557
|
+
}
|
|
558
|
+
function paintBrush(ctx, picture, colors) {
|
|
559
|
+
if (colors.length === 0) {
|
|
560
|
+
return;
|
|
561
|
+
}
|
|
562
|
+
const next = random(SEED);
|
|
563
|
+
ctx.globalAlpha = ALPHA;
|
|
564
|
+
CLUSTERS.forEach((cl) => {
|
|
565
|
+
ctx.fillStyle = colors[cl.tone % colors.length] ?? colors[0] ?? "";
|
|
566
|
+
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 };
|
|
567
|
+
for (let i = 0; i < STROKES; i++) {
|
|
568
|
+
const c = [box.x + box.w * (HALF + (next() - HALF) * JITTER), box.y + box.h * (i + HALF) / STROKES];
|
|
569
|
+
stroke(ctx, c, box.w * (MIN_LENGTH + (1 - MIN_LENGTH) * next()), box.h / STROKES * (MIN_THICK + THICK_RANGE * next()));
|
|
570
|
+
}
|
|
571
|
+
});
|
|
572
|
+
ctx.globalAlpha = 1;
|
|
573
|
+
}
|
|
574
|
+
|
|
408
575
|
// src/render/background.ts
|
|
409
576
|
function paintGround(ctx, style, palette, size) {
|
|
410
577
|
ctx.fillStyle = palette.background;
|
|
@@ -416,6 +583,17 @@ function paintGround(ctx, style, palette, size) {
|
|
|
416
583
|
}
|
|
417
584
|
ctx.fillRect(0, 0, size.width, size.height);
|
|
418
585
|
}
|
|
586
|
+
function paintPage(ctx, doc, palette, page) {
|
|
587
|
+
ctx.globalAlpha = 1;
|
|
588
|
+
paintGround(ctx, doc.background, palette, page);
|
|
589
|
+
if (doc.background === "tint" /* Tint */) {
|
|
590
|
+
ctx.fillStyle = palette.tint;
|
|
591
|
+
[page.geo.header, page.geo.body].forEach((r3) => ctx.fillRect(r3.x, r3.y, r3.w, r3.h));
|
|
592
|
+
}
|
|
593
|
+
if (doc.background === "brush" /* Brush */ && page.picture) {
|
|
594
|
+
paintBrush(ctx, page.picture, palette.brush ?? [palette.tint, palette.arch]);
|
|
595
|
+
}
|
|
596
|
+
}
|
|
419
597
|
|
|
420
598
|
// src/layout/layoutSpecs.ts
|
|
421
599
|
var flanksBeside = (pic, top, bottom2, m) => [
|
|
@@ -638,12 +816,14 @@ var GAP = {
|
|
|
638
816
|
row: 30,
|
|
639
817
|
venue: 40,
|
|
640
818
|
includes: 24,
|
|
641
|
-
rule: 8
|
|
819
|
+
rule: 8,
|
|
820
|
+
divider: 24
|
|
642
821
|
};
|
|
643
822
|
var makers = (p, u, sc) => ({
|
|
644
823
|
display: (text2, size, key) => styled({ text: text2, role: "display", weight: BOLD, size: size * u, color: p.title }, key, sc),
|
|
645
824
|
venue: (text2, size, key) => styled({ text: text2, role: "display", weight: MEDIUM, size: size * u, color: p.ink }, key, sc),
|
|
646
|
-
|
|
825
|
+
bodyVenue: (text2, size, key) => styled({ text: text2, role: "body", weight: BOLD, size: size * u, color: p.ink }, key, sc),
|
|
826
|
+
script: (text2, size, key) => styled({ text: text2, role: "script", weight: SCRIPT, size: size * u, color: p.script ?? p.accent }, key, sc),
|
|
647
827
|
strong: (text2, size, key) => styled({ text: text2, role: "body", weight: BOLD, size: size * u, color: p.ink }, key, sc),
|
|
648
828
|
accent: (text2, size, key) => styled({ text: text2, role: "body", weight: SEMI, size: size * u, color: p.accent }, key, sc),
|
|
649
829
|
item: (text2, size, key) => styled({ text: text2, role: "body", weight: SEMI, size: size * u, color: p.ink, bullet: p.accent }, key, sc),
|
|
@@ -652,7 +832,11 @@ var makers = (p, u, sc) => ({
|
|
|
652
832
|
function headerGroups(doc, p, u) {
|
|
653
833
|
const l = makers(p, u, styleContext(doc));
|
|
654
834
|
const b = doc.blocks;
|
|
655
|
-
const
|
|
835
|
+
const t = doc.tuning;
|
|
836
|
+
const gap = (line, after) => after === void 0 ? line : { ...line, gapAfter: after * u };
|
|
837
|
+
const title = gap(l.display(b.title, SIZE.title * (t?.titleScale ?? 1), "title"), b.script ?? b.titleBottom ? t?.titleScriptGap : void 0);
|
|
838
|
+
const script = b.script ? gap(l.script(b.script, SIZE.headerScript, "script"), b.titleBottom ? t?.scriptTitleGap : void 0) : void 0;
|
|
839
|
+
const lines = [title, script, b.titleBottom ? l.display(b.titleBottom, SIZE.title * (t?.titleBottomScale ?? 1), "titleBottom") : void 0];
|
|
656
840
|
return [{ lines: lines.filter((x) => x !== void 0), gapAfter: 0 }];
|
|
657
841
|
}
|
|
658
842
|
function itemGroup(item, n, l, scale) {
|
|
@@ -665,6 +849,19 @@ function itemGroup(item, n, l, scale) {
|
|
|
665
849
|
return { lines, gapAfter: GAP.item * u };
|
|
666
850
|
}
|
|
667
851
|
var WRAP_FROM = 14;
|
|
852
|
+
function dividerOf(doc, p, u) {
|
|
853
|
+
const d = doc.rows?.dividers;
|
|
854
|
+
return d === void 0 ? void 0 : { color: d.color ?? p.rule ?? p.accent, height: d.thickness * u, gap: (d.gap ?? GAP.divider) * u };
|
|
855
|
+
}
|
|
856
|
+
function rowMarks(doc, p, u) {
|
|
857
|
+
const divider = dividerOf(doc, p, u);
|
|
858
|
+
const size = doc.rows?.icons?.size;
|
|
859
|
+
return (icons2, i, last) => {
|
|
860
|
+
const kind = icons2 === void 0 || icons2.length === 0 ? void 0 : icons2[Math.min(i, icons2.length - 1)];
|
|
861
|
+
const icon = kind === void 0 ? {} : { icon: { color: p.icon ?? p.accent, glyph: p.background, kind, size: size === void 0 ? void 0 : size * u } };
|
|
862
|
+
return { ...icon, ...divider === void 0 || last ? {} : { rule: divider, ruleBelow: true, ruleAbove: false } };
|
|
863
|
+
};
|
|
864
|
+
}
|
|
668
865
|
function halves(text2) {
|
|
669
866
|
const mid = text2.length / 2;
|
|
670
867
|
const spaces = [...text2].flatMap((c, i) => c === " " ? [i] : []);
|
|
@@ -682,14 +879,16 @@ function eventGroups(doc, l, u, options) {
|
|
|
682
879
|
const b = doc.blocks;
|
|
683
880
|
const groups = [];
|
|
684
881
|
const schedule2 = b.schedule ?? [];
|
|
882
|
+
const prices = (options.withPrices === false ? void 0 : b.prices) ?? [];
|
|
883
|
+
const lastRow = schedule2.length + prices.length - 1;
|
|
884
|
+
const icons2 = doc.rows?.icons;
|
|
685
885
|
schedule2.forEach((row, i) => {
|
|
686
886
|
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 });
|
|
887
|
+
groups.push({ lines, gapAfter: GAP.row * u, keepWithNext: i < schedule2.length - 1, ...options.marks(icons2?.schedule, i, i === lastRow) });
|
|
688
888
|
});
|
|
689
|
-
const prices = (options.withPrices === false ? void 0 : b.prices) ?? [];
|
|
690
889
|
prices.forEach((row, i) => {
|
|
691
|
-
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 });
|
|
890
|
+
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 * (doc.rows?.priceLabelScale ?? 1), `prices.${i}.label`)];
|
|
891
|
+
groups.push({ lines, gapAfter: GAP.row * u, keepWithNext: i < prices.length - 1, ...options.marks(icons2?.prices, i, schedule2.length + i === lastRow) });
|
|
693
892
|
});
|
|
694
893
|
return groups;
|
|
695
894
|
}
|
|
@@ -713,9 +912,11 @@ function bodyGroups(doc, p, u, options = {}) {
|
|
|
713
912
|
if (b.venue) {
|
|
714
913
|
const size = isList ? SIZE.listVenue : SIZE.venue;
|
|
715
914
|
const keepWithNext = !isList && (b.schedule?.length ?? 0) > 0;
|
|
716
|
-
|
|
915
|
+
const look = doc.rows?.venue;
|
|
916
|
+
const line = look?.body === true ? l.bodyVenue : l.venue;
|
|
917
|
+
groups.push({ lines: b.venue.map((v, i) => line(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, bare: look?.bare }, keepWithNext });
|
|
717
918
|
}
|
|
718
|
-
groups.push(...isList ? listGroups(doc, l, u, options.dateScale ?? 1) : eventGroups(doc, l, u, options));
|
|
919
|
+
groups.push(...isList ? listGroups(doc, l, u, options.dateScale ?? 1) : eventGroups(doc, l, u, { ...options, marks: rowMarks(doc, p, u) }));
|
|
719
920
|
if (b.includes) {
|
|
720
921
|
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
922
|
groups.push({ lines, gapAfter: GAP.includes * u, uniform: true, keepWithNext: b.footer !== void 0, attachNext: b.footer !== void 0 });
|
|
@@ -735,6 +936,9 @@ var indented = (line) => line.bullet !== void 0 || line.hang === true;
|
|
|
735
936
|
var bulletIndent = (line, k) => indented(line) ? line.size * k * BULLET_INDENT : 0;
|
|
736
937
|
var iconSize = (group, k) => {
|
|
737
938
|
const first = group.lines[0];
|
|
939
|
+
if (group.icon?.size !== void 0) {
|
|
940
|
+
return group.icon.size * k;
|
|
941
|
+
}
|
|
738
942
|
return group.icon && first ? first.size * k * LINE_HEIGHT * ICON_SCALE : 0;
|
|
739
943
|
};
|
|
740
944
|
function groupBox(group, k, colW) {
|
|
@@ -827,16 +1031,16 @@ function placeIcon(group, box, out) {
|
|
|
827
1031
|
return bottom2;
|
|
828
1032
|
}
|
|
829
1033
|
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 });
|
|
1034
|
+
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, bare: group.icon.bare });
|
|
831
1035
|
return top + Math.max(textH, d);
|
|
832
1036
|
}
|
|
833
1037
|
function placeGroup(m, at, out) {
|
|
834
1038
|
const { k, col, y0, sizes } = at;
|
|
835
1039
|
const { group } = m;
|
|
836
1040
|
let y = y0;
|
|
837
|
-
if (group.rule) {
|
|
1041
|
+
if (group.rule && group.ruleAbove !== false) {
|
|
838
1042
|
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;
|
|
1043
|
+
y += group.rule.gap === void 0 ? group.rule.height * k * RULE_GAP : (group.rule.height + group.rule.gap) * k;
|
|
840
1044
|
}
|
|
841
1045
|
const { pad, d, iconIndent } = groupBox(group, k, col.w);
|
|
842
1046
|
const top = y;
|
|
@@ -850,12 +1054,12 @@ function placeGroup(m, at, out) {
|
|
|
850
1054
|
if (line.bullet && out) {
|
|
851
1055
|
out.bullets.push({ x: col.x + pad + size * BULLET_RADIUS, y: y + size * LINE_HEIGHT / 2, r: size * BULLET_RADIUS, color: line.bullet });
|
|
852
1056
|
}
|
|
853
|
-
y += size * LINE_HEIGHT;
|
|
1057
|
+
y += size * LINE_HEIGHT + (line.gapAfter ?? 0) * k;
|
|
854
1058
|
});
|
|
855
1059
|
y = placeIcon(group, { d, x: col.x + pad, top: top + pad, bottom: y }, out);
|
|
856
1060
|
y += pad;
|
|
857
1061
|
if (group.rule && group.ruleBelow) {
|
|
858
|
-
y += group.rule.height * k * (RULE_GAP - 1);
|
|
1062
|
+
y += group.rule.gap === void 0 ? group.rule.height * k * (RULE_GAP - 1) : group.rule.gap * k;
|
|
859
1063
|
out?.rules.push({ rect: { x: col.x, y, w: col.w * RULE_WIDTH, h: group.rule.height * k }, color: group.rule.color });
|
|
860
1064
|
y += group.rule.height * k;
|
|
861
1065
|
}
|
|
@@ -1033,6 +1237,13 @@ function splitHeader(header, hasLogo) {
|
|
|
1033
1237
|
const logoW = hasLogo ? Math.round(header.w * LOGO_SHARE) : 0;
|
|
1034
1238
|
return { text: { ...header, w: header.w - logoW * 1.1 }, logo: { ...header, x: header.x + header.w - logoW, w: logoW } };
|
|
1035
1239
|
}
|
|
1240
|
+
function headerAt(zones, top, u) {
|
|
1241
|
+
if (top === void 0) {
|
|
1242
|
+
return zones;
|
|
1243
|
+
}
|
|
1244
|
+
const y = Math.round(top * u);
|
|
1245
|
+
return { ...zones, text: { ...zones.text, y, h: Math.max(1, zones.text.y + zones.text.h - y) } };
|
|
1246
|
+
}
|
|
1036
1247
|
function closeHeaderGap(geo, head, gap, u) {
|
|
1037
1248
|
const { header, body } = geo;
|
|
1038
1249
|
const stacked = header.y + header.h <= body.y && header.x < body.x + body.w && body.x < header.x + header.w;
|
|
@@ -1045,7 +1256,7 @@ function closeHeaderGap(geo, head, gap, u) {
|
|
|
1045
1256
|
function flowAll(ctx, input, geo, reflow) {
|
|
1046
1257
|
const { doc, palette, fonts } = input;
|
|
1047
1258
|
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);
|
|
1259
|
+
const zones = headerAt(geo.logo ? { text: geo.header, logo: geo.logo } : splitHeader(geo.header, doc.logo !== void 0), doc.tuning?.headerTop, u);
|
|
1049
1260
|
const head = flow(ctx, headerGroups(doc, palette, u), zones.text, fonts);
|
|
1050
1261
|
const flanks = geo.flanks ?? [];
|
|
1051
1262
|
const tight = closeHeaderGap(geo, head, doc.tuning?.headerGap, u);
|
|
@@ -1119,6 +1330,87 @@ function fitToFloor(ctx, input) {
|
|
|
1119
1330
|
return best ?? flowAll(ctx, input, base2, { compact: false, wrap: false});
|
|
1120
1331
|
}
|
|
1121
1332
|
|
|
1333
|
+
// src/render/overlap.ts
|
|
1334
|
+
var clamp = (v, lo, hi) => Math.min(Math.max(v, lo), hi);
|
|
1335
|
+
function placePicture(image, region, slot, fit) {
|
|
1336
|
+
const base2 = placeContain(image, region, { anchor: slot.anchor, alignX: fit.alignX, scale: slot.scale });
|
|
1337
|
+
const o = slot.overlap;
|
|
1338
|
+
if (o === void 0) {
|
|
1339
|
+
return base2;
|
|
1340
|
+
}
|
|
1341
|
+
const { width, height } = fit.frame;
|
|
1342
|
+
const s = Math.min(o.scale, width / Math.max(base2.w, 1), height / Math.max(base2.h, 1));
|
|
1343
|
+
const w = Math.floor(base2.w * s);
|
|
1344
|
+
const h = Math.floor(base2.h * s);
|
|
1345
|
+
const x = base2.x + (base2.w - w) * fit.alignX + o.dx * width;
|
|
1346
|
+
const y = base2.y + (base2.h - h) * ANCHOR_Y[slot.anchor] + o.dy * height;
|
|
1347
|
+
return { x: Math.round(clamp(x, 0, width - w)), y: Math.round(clamp(y, 0, height - h)), w, h };
|
|
1348
|
+
}
|
|
1349
|
+
function reachPicture(rules, picture, reach) {
|
|
1350
|
+
const end = picture.x + picture.w * reach;
|
|
1351
|
+
rules.filter((r3) => r3.rect.y >= picture.y && r3.rect.y <= picture.y + picture.h).forEach((r3) => {
|
|
1352
|
+
r3.rect.w = Math.max(0, end - r3.rect.x);
|
|
1353
|
+
});
|
|
1354
|
+
}
|
|
1355
|
+
|
|
1356
|
+
// src/render/rowIcons.ts
|
|
1357
|
+
var LINE2 = 0.03;
|
|
1358
|
+
var HEAD_Y = -0.15;
|
|
1359
|
+
var HEAD_R = 0.1;
|
|
1360
|
+
var BODY_Y = 0.25;
|
|
1361
|
+
var BODY_R = 0.2;
|
|
1362
|
+
var BACK_DX = 0.12;
|
|
1363
|
+
var BACK_DY = -0.04;
|
|
1364
|
+
var FRONT_DX = -0.08;
|
|
1365
|
+
var PAIR_SCALE = 0.85;
|
|
1366
|
+
var TICKET_W = 0.52;
|
|
1367
|
+
var TICKET_H = 0.3;
|
|
1368
|
+
var TICKET_TURN = -Math.PI / 4;
|
|
1369
|
+
var PERFORATION = 0.14;
|
|
1370
|
+
var DOTS = [-0.3, 0, 0.3];
|
|
1371
|
+
var DOT = 0.035;
|
|
1372
|
+
function halfDisc(ctx, c, r3, color) {
|
|
1373
|
+
ctx.fillStyle = color;
|
|
1374
|
+
ctx.beginPath();
|
|
1375
|
+
ctx.arc(c[0], c[1], Math.max(0, r3), Math.PI, Math.PI * 2);
|
|
1376
|
+
ctx.closePath();
|
|
1377
|
+
ctx.fill();
|
|
1378
|
+
}
|
|
1379
|
+
function person(ctx, c, d, colors) {
|
|
1380
|
+
const w = d * LINE2;
|
|
1381
|
+
const head = [c[0], c[1] + d * HEAD_Y];
|
|
1382
|
+
disc(ctx, head, d * HEAD_R, colors.glyph);
|
|
1383
|
+
disc(ctx, head, d * HEAD_R - w, colors.fill);
|
|
1384
|
+
halfDisc(ctx, [c[0], c[1] + d * BODY_Y], d * BODY_R, colors.glyph);
|
|
1385
|
+
halfDisc(ctx, [c[0], c[1] + d * BODY_Y - w], d * BODY_R - 2 * w, colors.fill);
|
|
1386
|
+
}
|
|
1387
|
+
function people(ctx, c, d, colors) {
|
|
1388
|
+
const s = d * PAIR_SCALE;
|
|
1389
|
+
person(ctx, [c[0] + d * BACK_DX, c[1] + d * BACK_DY], s, colors);
|
|
1390
|
+
person(ctx, [c[0] + d * FRONT_DX, c[1]], s, colors);
|
|
1391
|
+
}
|
|
1392
|
+
function ticket(ctx, c, d, colors) {
|
|
1393
|
+
const w = d * LINE2;
|
|
1394
|
+
ctx.fillStyle = colors.glyph;
|
|
1395
|
+
polygon(ctx, turnedRect(c, { w: d * TICKET_W, h: d * TICKET_H }, TICKET_TURN));
|
|
1396
|
+
ctx.fillStyle = colors.fill;
|
|
1397
|
+
polygon(ctx, turnedRect(c, { w: d * TICKET_W - 2 * w, h: d * TICKET_H - 2 * w }, TICKET_TURN));
|
|
1398
|
+
const along = [Math.cos(TICKET_TURN), Math.sin(TICKET_TURN)];
|
|
1399
|
+
const across = [-along[1], along[0]];
|
|
1400
|
+
const x = d * PERFORATION;
|
|
1401
|
+
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));
|
|
1402
|
+
}
|
|
1403
|
+
var GLYPHS = {
|
|
1404
|
+
["person" /* Person */]: person,
|
|
1405
|
+
["people" /* People */]: people,
|
|
1406
|
+
["ticket" /* Ticket */]: ticket
|
|
1407
|
+
};
|
|
1408
|
+
function drawRowIcon(ctx, r3, kind, colors) {
|
|
1409
|
+
const c = [r3.x + r3.w / 2, r3.y + r3.h / 2];
|
|
1410
|
+
disc(ctx, c, r3.w / 2, colors.fill);
|
|
1411
|
+
GLYPHS[kind](ctx, c, r3.w, colors);
|
|
1412
|
+
}
|
|
1413
|
+
|
|
1122
1414
|
// src/render/render.ts
|
|
1123
1415
|
var BASE2 = 1080;
|
|
1124
1416
|
var NO_SPACING2 = "0px";
|
|
@@ -1130,18 +1422,23 @@ var PIN_TIP_Y = 0.28;
|
|
|
1130
1422
|
var PIN_HOLE = 0.42;
|
|
1131
1423
|
var ARC_START = 0.75;
|
|
1132
1424
|
var ARC_END = 2.25;
|
|
1133
|
-
|
|
1425
|
+
var BARE_SCALE = 1.6;
|
|
1426
|
+
function drawPin(ctx, r3, colors, bare = false) {
|
|
1427
|
+
const { color, glyph } = bare ? { color: colors.glyph, glyph: colors.color } : colors;
|
|
1428
|
+
const w = bare ? r3.w * BARE_SCALE : r3.w;
|
|
1134
1429
|
const cx = r3.x + r3.w / 2;
|
|
1135
1430
|
const cy = r3.y + r3.h / 2;
|
|
1136
|
-
const hy = cy -
|
|
1137
|
-
const rad =
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1431
|
+
const hy = cy - w * PIN_HEAD_Y;
|
|
1432
|
+
const rad = w * PIN_HEAD_R;
|
|
1433
|
+
if (!bare) {
|
|
1434
|
+
ctx.fillStyle = color;
|
|
1435
|
+
ctx.beginPath();
|
|
1436
|
+
ctx.arc(cx, cy, r3.w / 2, 0, Math.PI * 2);
|
|
1437
|
+
ctx.fill();
|
|
1438
|
+
}
|
|
1142
1439
|
ctx.fillStyle = glyph;
|
|
1143
1440
|
ctx.beginPath();
|
|
1144
|
-
ctx.moveTo(cx, cy +
|
|
1441
|
+
ctx.moveTo(cx, cy + w * PIN_TIP_Y);
|
|
1145
1442
|
ctx.arc(cx, hy, rad, Math.PI * ARC_START, Math.PI * ARC_END);
|
|
1146
1443
|
ctx.closePath();
|
|
1147
1444
|
ctx.fill();
|
|
@@ -1161,11 +1458,13 @@ function roundRect(ctx, r3, radius) {
|
|
|
1161
1458
|
ctx.closePath();
|
|
1162
1459
|
ctx.fill();
|
|
1163
1460
|
}
|
|
1164
|
-
function
|
|
1461
|
+
function drawRules(ctx, f) {
|
|
1165
1462
|
f.rules.forEach((r3) => {
|
|
1166
1463
|
ctx.fillStyle = r3.color;
|
|
1167
1464
|
ctx.fillRect(r3.rect.x, r3.rect.y, r3.rect.w, r3.rect.h);
|
|
1168
1465
|
});
|
|
1466
|
+
}
|
|
1467
|
+
function drawMarks(ctx, f, radius) {
|
|
1169
1468
|
f.cards.forEach((c) => {
|
|
1170
1469
|
ctx.fillStyle = c.color;
|
|
1171
1470
|
roundRect(ctx, c.rect, radius);
|
|
@@ -1176,7 +1475,7 @@ function drawFlow(ctx, f, radius) {
|
|
|
1176
1475
|
ctx.arc(b.x, b.y, b.r, 0, Math.PI * 2);
|
|
1177
1476
|
ctx.fill();
|
|
1178
1477
|
});
|
|
1179
|
-
f.icons.forEach((i) => drawPin(ctx, i.rect, i.color, i.glyph));
|
|
1478
|
+
f.icons.forEach((i) => i.kind === void 0 ? drawPin(ctx, i.rect, { color: i.color, glyph: i.glyph }, i.bare) : drawRowIcon(ctx, i.rect, i.kind, { fill: i.color, glyph: i.glyph }));
|
|
1180
1479
|
ctx.textAlign = "left";
|
|
1181
1480
|
ctx.textBaseline = "top";
|
|
1182
1481
|
f.texts.forEach((t) => {
|
|
@@ -1191,6 +1490,10 @@ function drawFlow(ctx, f, radius) {
|
|
|
1191
1490
|
}
|
|
1192
1491
|
});
|
|
1193
1492
|
}
|
|
1493
|
+
function drawFlow(ctx, f, radius) {
|
|
1494
|
+
drawRules(ctx, f);
|
|
1495
|
+
drawMarks(ctx, f, radius);
|
|
1496
|
+
}
|
|
1194
1497
|
function checked(input, assets) {
|
|
1195
1498
|
const result = validateFlierDoc(input);
|
|
1196
1499
|
if (!result.ok) {
|
|
@@ -1222,6 +1525,25 @@ function capAligned(zone, head) {
|
|
|
1222
1525
|
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
1526
|
return { ...zone, y: zone.y + shift, h: zone.h - shift };
|
|
1224
1527
|
}
|
|
1528
|
+
function placeOnPage(doc, assets, fitted, frame) {
|
|
1529
|
+
const image = doc.picture ? assets[doc.picture.imageId] : void 0;
|
|
1530
|
+
const region = pictureRegion(doc.layout, fitted.geo, fitted.body, frame);
|
|
1531
|
+
const picture = image && doc.picture ? placePicture(image, region, doc.picture, { alignX: fitted.geo.alignX, frame }) : null;
|
|
1532
|
+
const dividers = doc.rows?.dividers;
|
|
1533
|
+
if (picture && dividers?.toPicture === true) {
|
|
1534
|
+
reachPicture(fitted.body.rules, picture, dividers.reach ?? 0);
|
|
1535
|
+
}
|
|
1536
|
+
return { image, region, picture };
|
|
1537
|
+
}
|
|
1538
|
+
function drawLogo(ctx, doc, assets, fitted) {
|
|
1539
|
+
const logoImage = doc.logo ? assets[doc.logo.imageId] : void 0;
|
|
1540
|
+
const zone = fitted.geo.logo ? fitted.zones.logo : capAligned(fitted.zones.logo, fitted.head);
|
|
1541
|
+
const logo = logoImage ? placeContain(logoImage, zone, { anchor: "top" /* Top */, alignX: 1, scale: 1 }) : null;
|
|
1542
|
+
if (logoImage && logo) {
|
|
1543
|
+
ctx.drawImage(logoImage, logo.x, logo.y, logo.w, logo.h);
|
|
1544
|
+
}
|
|
1545
|
+
return logo;
|
|
1546
|
+
}
|
|
1225
1547
|
function render(input, assets, canvas) {
|
|
1226
1548
|
const doc = checked(input, assets);
|
|
1227
1549
|
const { width, height } = FORMAT_SIZES[doc.format];
|
|
@@ -1232,40 +1554,34 @@ function render(input, assets, canvas) {
|
|
|
1232
1554
|
throw new Error("poster-render: the canvas has no 2d context");
|
|
1233
1555
|
}
|
|
1234
1556
|
const palette = PALETTES[doc.palette];
|
|
1235
|
-
const
|
|
1236
|
-
const
|
|
1237
|
-
const {
|
|
1238
|
-
ctx
|
|
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
|
-
}
|
|
1557
|
+
const fitted = fitToFloor(ctx, { doc, palette, fonts: FONT_SETS[doc.fonts], width, height });
|
|
1558
|
+
const { geo, head, body, sides } = fitted;
|
|
1559
|
+
const { image, region, picture } = placeOnPage(doc, assets, fitted, { width, height, u: Math.min(width, height) / BASE2 });
|
|
1560
|
+
paintPage(ctx, doc, palette, { geo, width, height, picture });
|
|
1244
1561
|
const radius = Math.min(width, height) * CARD_RADIUS;
|
|
1245
|
-
[head, body, ...sides]
|
|
1246
|
-
const
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
ctx.drawImage(logoImage, logo.x, logo.y, logo.w, logo.h);
|
|
1250
|
-
}
|
|
1251
|
-
const image = doc.picture ? assets[doc.picture.imageId] : void 0;
|
|
1562
|
+
const flows = [head, body, ...sides];
|
|
1563
|
+
const layered = doc.picture?.overlap !== void 0;
|
|
1564
|
+
flows.forEach((f) => layered ? drawRules(ctx, f) : drawFlow(ctx, f, radius));
|
|
1565
|
+
const logo = drawLogo(ctx, doc, assets, fitted);
|
|
1252
1566
|
const backdrop = image ? archRect(geo) : null;
|
|
1253
1567
|
if (backdrop) {
|
|
1254
1568
|
drawArch(ctx, backdrop, palette.arch);
|
|
1255
1569
|
}
|
|
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
1570
|
if (image && picture) {
|
|
1259
1571
|
ctx.drawImage(image, picture.x, picture.y, picture.w, picture.h);
|
|
1260
1572
|
}
|
|
1573
|
+
if (layered) {
|
|
1574
|
+
flows.forEach((f) => drawMarks(ctx, f, radius));
|
|
1575
|
+
}
|
|
1261
1576
|
return {
|
|
1262
1577
|
width,
|
|
1263
1578
|
height,
|
|
1264
1579
|
picture,
|
|
1265
1580
|
pictureRegion: region,
|
|
1266
|
-
textBoxes:
|
|
1581
|
+
textBoxes: flows.flatMap((f) => f.texts.map((t) => t.box)),
|
|
1267
1582
|
cardBoxes: body.cards.map((c) => c.rect),
|
|
1268
|
-
iconBoxes:
|
|
1583
|
+
iconBoxes: flows.flatMap((f) => f.icons.map((i) => i.rect)),
|
|
1584
|
+
ruleBoxes: flows.flatMap((f) => f.rules.map((r3) => r3.rect)),
|
|
1269
1585
|
logo,
|
|
1270
1586
|
backdrop
|
|
1271
1587
|
};
|
|
@@ -1375,6 +1691,7 @@ exports.LineTieKind = LineTieKind;
|
|
|
1375
1691
|
exports.PALETTES = PALETTES;
|
|
1376
1692
|
exports.PaletteId = PaletteId;
|
|
1377
1693
|
exports.PictureAnchor = PictureAnchor;
|
|
1694
|
+
exports.RowIcon = RowIcon;
|
|
1378
1695
|
exports.defaultLayoutFor = defaultLayoutFor;
|
|
1379
1696
|
exports.exportPng = exportPng;
|
|
1380
1697
|
exports.flierDocSchema = flierDocSchema;
|