@dloizides/poster-render 0.2.6 → 0.2.7
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.js +16 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +16 -9
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -297,7 +297,7 @@ var flanksBeside = (pic, top, bottom2, m) => [
|
|
|
297
297
|
[pic[0] + pic[2] + m, top, 1 - pic[0] - pic[2] - 2 * m, bottom2 - top]
|
|
298
298
|
];
|
|
299
299
|
var ARCH_PIC = [0.22, 0.42, 0.56, 0.58];
|
|
300
|
-
var PHONE_ARCH_PIC = [0.2, 0.
|
|
300
|
+
var PHONE_ARCH_PIC = [0.2, 0.47, 0.6, 0.53];
|
|
301
301
|
var DESK_ARCH_PIC = [0.355, 0.07, 0.32, 0.93];
|
|
302
302
|
var ARCH_LANDSCAPE = {
|
|
303
303
|
header: [0.04, 0.06, 0.3, 0.5],
|
|
@@ -317,7 +317,7 @@ var LAYOUT_SPECS = {
|
|
|
317
317
|
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
318
|
},
|
|
319
319
|
["phone-arch" /* PhoneArch */]: {
|
|
320
|
-
portrait: { header: [0.045, 0.
|
|
320
|
+
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
321
|
landscape: { ...ARCH_LANDSCAPE, header: [0.04, 0.16, 0.3, 0.42], picture: [0.36, 0.16, 0.3, 0.84] }
|
|
322
322
|
},
|
|
323
323
|
["desktop-safe" /* DesktopSafe */]: {
|
|
@@ -550,7 +550,7 @@ function bodyGroups(doc, p, u, options = {}) {
|
|
|
550
550
|
groups.push(...isList ? listGroups(doc, l, u) : eventGroups(doc, l, u, options));
|
|
551
551
|
if (b.includes) {
|
|
552
552
|
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 });
|
|
553
|
+
groups.push({ lines, gapAfter: GAP.includes * u, uniform: true, keepWithNext: b.footer !== void 0, attachNext: b.footer !== void 0 });
|
|
554
554
|
}
|
|
555
555
|
if (b.footer) {
|
|
556
556
|
groups.push({ lines: wrapped(l.soft(b.footer, SIZE.small), options.wrap), gapAfter: 0 });
|
|
@@ -639,11 +639,15 @@ function placeGroup(m, at, out) {
|
|
|
639
639
|
function placeColumn(groups, at, out) {
|
|
640
640
|
const { k, col, spread = 0 } = at;
|
|
641
641
|
let h = 0;
|
|
642
|
-
|
|
643
|
-
h += placeGroup(g, { k, col, y0: col.y + h }, out)
|
|
644
|
-
|
|
645
|
-
|
|
642
|
+
groups.forEach((g, i) => {
|
|
643
|
+
h += placeGroup(g, { k, col, y0: col.y + h }, out);
|
|
644
|
+
if (i < groups.length - 1 && g.group.attachNext !== true) {
|
|
645
|
+
h += spread;
|
|
646
|
+
}
|
|
647
|
+
});
|
|
648
|
+
return h;
|
|
646
649
|
}
|
|
650
|
+
var spreadGaps = (groups) => groups.slice(0, -1).filter((g) => g.group.attachNext !== true).length;
|
|
647
651
|
var columnSum = (heights, from, to) => heights.slice(from, to).reduce((a, b) => a + b, 0);
|
|
648
652
|
var tallest = (heights, cut) => {
|
|
649
653
|
const left = heights.slice(0, cut).reduce((a, b) => a + b, 0);
|
|
@@ -723,7 +727,10 @@ function flow(ctx, groups, zone, fonts) {
|
|
|
723
727
|
const out = emptyFlow();
|
|
724
728
|
const heights = columns.map((c) => placeColumn(c.groups, { k: lo, col: c.col }, null));
|
|
725
729
|
const end = Math.max(...heights);
|
|
726
|
-
columns.forEach((c, i) =>
|
|
730
|
+
columns.forEach((c, i) => {
|
|
731
|
+
const gaps = spreadGaps(c.groups);
|
|
732
|
+
placeColumn(c.groups, { k: lo, col: c.col, spread: gaps > 0 && columns.length > 1 ? (end - (heights[i] ?? end)) / gaps : 0 }, out);
|
|
733
|
+
});
|
|
727
734
|
const lines = groups.flatMap((g) => g.lines);
|
|
728
735
|
out.texts.forEach((t, i) => {
|
|
729
736
|
const line = lines[i];
|
|
@@ -1028,7 +1035,7 @@ var LAYOUT_CATALOGUE = [
|
|
|
1028
1035
|
{ 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
1036
|
{ id: "list" /* List */, designId: "list", label: "Upcoming list", description: "Several dated events as a list beside the picture.", formats: POSTERS },
|
|
1030
1037
|
{ 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:
|
|
1038
|
+
{ 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
1039
|
{ 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
1040
|
{ 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
1041
|
];
|