@dloizides/poster-render 0.2.6 → 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/CHANGELOG.md +5 -0
- package/dist/index.d.mts +15 -5
- package/dist/index.d.ts +15 -5
- package/dist/index.js +45 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +45 -12
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
var BackgroundStyle = /* @__PURE__ */ ((BackgroundStyle2) => {
|
|
3
3
|
BackgroundStyle2["Solid"] = "solid";
|
|
4
4
|
BackgroundStyle2["Tint"] = "tint";
|
|
5
|
+
BackgroundStyle2["Horizon"] = "horizon";
|
|
5
6
|
return BackgroundStyle2;
|
|
6
7
|
})(BackgroundStyle || {});
|
|
7
8
|
|
|
@@ -10,6 +11,7 @@ var FontSetId = /* @__PURE__ */ ((FontSetId2) => {
|
|
|
10
11
|
FontSetId2["Classic"] = "classic";
|
|
11
12
|
FontSetId2["Modern"] = "modern";
|
|
12
13
|
FontSetId2["Elegant"] = "elegant";
|
|
14
|
+
FontSetId2["Coastal"] = "coastal";
|
|
13
15
|
return FontSetId2;
|
|
14
16
|
})(FontSetId || {});
|
|
15
17
|
|
|
@@ -43,6 +45,7 @@ var PaletteId = /* @__PURE__ */ ((PaletteId2) => {
|
|
|
43
45
|
PaletteId2["Night"] = "night";
|
|
44
46
|
PaletteId2["Sea"] = "sea";
|
|
45
47
|
PaletteId2["Rose"] = "rose";
|
|
48
|
+
PaletteId2["GoldenHorizon"] = "golden-horizon";
|
|
46
49
|
return PaletteId2;
|
|
47
50
|
})(PaletteId || {});
|
|
48
51
|
|
|
@@ -68,6 +71,17 @@ var PALETTES = {
|
|
|
68
71
|
["sand" /* Sand */]: { background: "#f5f4f2", tint: "#ece8e3", title: "#958a80", accent: "#e9b47f", ink: "#5f564f", soft: "#b3a89e", card: "#ffffff", arch: "#ede8e2" },
|
|
69
72
|
["night" /* Night */]: { background: "#1c1a17", tint: "#25221e", title: "#e8dccb", accent: "#e9b47f", ink: "#f4efe8", soft: "#9c9284", card: "#2c2824", arch: "#25221f" },
|
|
70
73
|
["sea" /* Sea */]: { background: "#eef4f3", tint: "#e1ecea", title: "#4f7d7a", accent: "#e07a5f", ink: "#2f3e46", soft: "#8aa3a1", card: "#ffffff", arch: "#e4ecea" },
|
|
74
|
+
["golden-horizon" /* GoldenHorizon */]: {
|
|
75
|
+
background: "#dce5e7",
|
|
76
|
+
tint: "#d3dee1",
|
|
77
|
+
title: "#2f566f",
|
|
78
|
+
accent: "#8a4325",
|
|
79
|
+
ink: "#1f2d36",
|
|
80
|
+
soft: "#46606f",
|
|
81
|
+
card: "#f4f1ec",
|
|
82
|
+
arch: "#c7d4d6",
|
|
83
|
+
sky: [[0, "#bfd3d8"], [0.55, "#d4dddd"], [1, "#eadccb"]]
|
|
84
|
+
},
|
|
71
85
|
["rose" /* Rose */]: { background: "#f8efec", tint: "#f1e2dd", title: "#9b6b63", accent: "#c9846f", ink: "#4a3934", soft: "#b39a92", card: "#ffffff", arch: "#f1e5e1" }
|
|
72
86
|
};
|
|
73
87
|
|
|
@@ -75,7 +89,8 @@ var PALETTES = {
|
|
|
75
89
|
var FONT_SETS = {
|
|
76
90
|
["classic" /* Classic */]: { display: '"Oswald", "Arial Narrow", sans-serif', script: '"Sacramento", cursive', body: '"Fredoka", sans-serif' },
|
|
77
91
|
["modern" /* Modern */]: { display: '"Bebas Neue", "Arial Narrow", sans-serif', script: '"Great Vibes", cursive', body: '"Montserrat", sans-serif' },
|
|
78
|
-
["elegant" /* Elegant */]: { display: '"Playfair Display", serif', script: '"Allura", cursive', body: '"Lato", sans-serif' }
|
|
92
|
+
["elegant" /* Elegant */]: { display: '"Playfair Display", serif', script: '"Allura", cursive', body: '"Lato", sans-serif' },
|
|
93
|
+
["coastal" /* Coastal */]: { display: '"Fraunces", Georgia, serif', script: '"Allura", cursive', body: '"Jost", sans-serif' }
|
|
79
94
|
};
|
|
80
95
|
|
|
81
96
|
// src/schema/flierDocSchema.ts
|
|
@@ -291,13 +306,25 @@ function missingAssets(doc, assets) {
|
|
|
291
306
|
return errors;
|
|
292
307
|
}
|
|
293
308
|
|
|
309
|
+
// src/render/background.ts
|
|
310
|
+
function paintGround(ctx, style, palette, size) {
|
|
311
|
+
ctx.fillStyle = palette.background;
|
|
312
|
+
if (style === "horizon" /* Horizon */) {
|
|
313
|
+
const stops = palette.sky ?? [[0, palette.background], [1, palette.tint]];
|
|
314
|
+
const sky = ctx.createLinearGradient(0, 0, 0, size.height);
|
|
315
|
+
stops.forEach(([offset, color]) => sky.addColorStop(offset, color));
|
|
316
|
+
ctx.fillStyle = sky;
|
|
317
|
+
}
|
|
318
|
+
ctx.fillRect(0, 0, size.width, size.height);
|
|
319
|
+
}
|
|
320
|
+
|
|
294
321
|
// src/layout/layoutSpecs.ts
|
|
295
322
|
var flanksBeside = (pic, top, bottom2, m) => [
|
|
296
323
|
[m, top, pic[0] - 2 * m, bottom2 - top],
|
|
297
324
|
[pic[0] + pic[2] + m, top, 1 - pic[0] - pic[2] - 2 * m, bottom2 - top]
|
|
298
325
|
];
|
|
299
326
|
var ARCH_PIC = [0.22, 0.42, 0.56, 0.58];
|
|
300
|
-
var PHONE_ARCH_PIC = [0.2, 0.
|
|
327
|
+
var PHONE_ARCH_PIC = [0.2, 0.47, 0.6, 0.53];
|
|
301
328
|
var DESK_ARCH_PIC = [0.355, 0.07, 0.32, 0.93];
|
|
302
329
|
var ARCH_LANDSCAPE = {
|
|
303
330
|
header: [0.04, 0.06, 0.3, 0.5],
|
|
@@ -317,7 +344,7 @@ var LAYOUT_SPECS = {
|
|
|
317
344
|
landscape: { header: [0.04, 0.2, 0.52, 0.3], body: [0.04, 0.52, 0.52, 0.42], picture: [0.6, 0.12, 0.4, 0.88], alignX: 1 }
|
|
318
345
|
},
|
|
319
346
|
["phone-arch" /* PhoneArch */]: {
|
|
320
|
-
portrait: { header: [0.045, 0.
|
|
347
|
+
portrait: { header: [0.045, 0.05, 0.91, 0.16], body: [0.045, 0.22, 0.91, 0.21], picture: PHONE_ARCH_PIC, alignX: 0.5, flanks: flanksBeside(PHONE_ARCH_PIC, 0.5, 0.94, 0.03), arch: 0.08 },
|
|
321
348
|
landscape: { ...ARCH_LANDSCAPE, header: [0.04, 0.16, 0.3, 0.42], picture: [0.36, 0.16, 0.3, 0.84] }
|
|
322
349
|
},
|
|
323
350
|
["desktop-safe" /* DesktopSafe */]: {
|
|
@@ -550,7 +577,7 @@ function bodyGroups(doc, p, u, options = {}) {
|
|
|
550
577
|
groups.push(...isList ? listGroups(doc, l, u) : eventGroups(doc, l, u, options));
|
|
551
578
|
if (b.includes) {
|
|
552
579
|
const lines = [l.accent(b.includes.heading, SIZE.small), ...b.includes.items.map((i) => l.item(i, SIZE.small))].flatMap((line) => wrapped(line, options.wrap));
|
|
553
|
-
groups.push({ lines, gapAfter: GAP.includes * u, uniform: true });
|
|
580
|
+
groups.push({ lines, gapAfter: GAP.includes * u, uniform: true, keepWithNext: b.footer !== void 0, attachNext: b.footer !== void 0 });
|
|
554
581
|
}
|
|
555
582
|
if (b.footer) {
|
|
556
583
|
groups.push({ lines: wrapped(l.soft(b.footer, SIZE.small), options.wrap), gapAfter: 0 });
|
|
@@ -639,11 +666,15 @@ function placeGroup(m, at, out) {
|
|
|
639
666
|
function placeColumn(groups, at, out) {
|
|
640
667
|
const { k, col, spread = 0 } = at;
|
|
641
668
|
let h = 0;
|
|
642
|
-
|
|
643
|
-
h += placeGroup(g, { k, col, y0: col.y + h }, out)
|
|
644
|
-
|
|
645
|
-
|
|
669
|
+
groups.forEach((g, i) => {
|
|
670
|
+
h += placeGroup(g, { k, col, y0: col.y + h }, out);
|
|
671
|
+
if (i < groups.length - 1 && g.group.attachNext !== true) {
|
|
672
|
+
h += spread;
|
|
673
|
+
}
|
|
674
|
+
});
|
|
675
|
+
return h;
|
|
646
676
|
}
|
|
677
|
+
var spreadGaps = (groups) => groups.slice(0, -1).filter((g) => g.group.attachNext !== true).length;
|
|
647
678
|
var columnSum = (heights, from, to) => heights.slice(from, to).reduce((a, b) => a + b, 0);
|
|
648
679
|
var tallest = (heights, cut) => {
|
|
649
680
|
const left = heights.slice(0, cut).reduce((a, b) => a + b, 0);
|
|
@@ -723,7 +754,10 @@ function flow(ctx, groups, zone, fonts) {
|
|
|
723
754
|
const out = emptyFlow();
|
|
724
755
|
const heights = columns.map((c) => placeColumn(c.groups, { k: lo, col: c.col }, null));
|
|
725
756
|
const end = Math.max(...heights);
|
|
726
|
-
columns.forEach((c, i) =>
|
|
757
|
+
columns.forEach((c, i) => {
|
|
758
|
+
const gaps = spreadGaps(c.groups);
|
|
759
|
+
placeColumn(c.groups, { k: lo, col: c.col, spread: gaps > 0 && columns.length > 1 ? (end - (heights[i] ?? end)) / gaps : 0 }, out);
|
|
760
|
+
});
|
|
727
761
|
const lines = groups.flatMap((g) => g.lines);
|
|
728
762
|
out.texts.forEach((t, i) => {
|
|
729
763
|
const line = lines[i];
|
|
@@ -968,8 +1002,7 @@ function render(input, assets, canvas) {
|
|
|
968
1002
|
const u = Math.min(width, height) / BASE2;
|
|
969
1003
|
const { geo, zones, head, body, sides } = fitToFloor(ctx, { doc, palette, fonts, width, height });
|
|
970
1004
|
ctx.globalAlpha = 1;
|
|
971
|
-
ctx.
|
|
972
|
-
ctx.fillRect(0, 0, width, height);
|
|
1005
|
+
paintGround(ctx, doc.background, palette, { width, height });
|
|
973
1006
|
if (doc.background === "tint" /* Tint */) {
|
|
974
1007
|
ctx.fillStyle = palette.tint;
|
|
975
1008
|
[geo.header, geo.body].forEach((r3) => ctx.fillRect(r3.x, r3.y, r3.w, r3.h));
|
|
@@ -1028,7 +1061,7 @@ var LAYOUT_CATALOGUE = [
|
|
|
1028
1061
|
{ id: "picture-bottom" /* PictureBottom */, designId: "picture-bottom", label: "Picture bottom", description: "Titles and details on top, the picture across the bottom half.", formats: POSTERS },
|
|
1029
1062
|
{ id: "list" /* List */, designId: "list", label: "Upcoming list", description: "Several dated events as a list beside the picture.", formats: POSTERS },
|
|
1030
1063
|
{ id: "phone-clock-safe" /* PhoneClockSafe */, designId: "P-A", label: "Phone, clock clear", description: "Lock-screen wallpaper: top kept clear for the clock, details on the left, picture on the right.", formats: ["phone" /* Phone */] },
|
|
1031
|
-
{ id: "phone-arch" /* PhoneArch */, designId: "P-B", label: "Phone arch", description: "Lock-screen wallpaper:
|
|
1064
|
+
{ id: "phone-arch" /* PhoneArch */, designId: "P-B", label: "Phone arch", description: "Lock-screen wallpaper: titles at the top, details under them, the picture in an arch at the bottom.", formats: ["phone" /* Phone */] },
|
|
1032
1065
|
{ id: "desktop-safe" /* DesktopSafe */, designId: "D-A", label: "Desktop, icons clear", description: "Desktop wallpaper: text on the left clear of desktop icons and the taskbar, the picture on the right.", formats: ["desktop" /* Desktop */] },
|
|
1033
1066
|
{ id: "desktop-arch" /* DesktopArch */, designId: "D-B", label: "Desktop arch", description: "Desktop wallpaper: titles left, the picture in a centred arch, details right.", formats: ["desktop" /* Desktop */] }
|
|
1034
1067
|
];
|