@dloizides/poster-render 0.6.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/dist/index.d.mts +6 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.js +24 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +24 -13
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -198,6 +198,7 @@ var MAX_TOP = 600;
|
|
|
198
198
|
var MAX_LINE_GAP = 200;
|
|
199
199
|
var MIN_TITLE_SCALE = 0.3;
|
|
200
200
|
var MAX_TITLE_SCALE = 2.5;
|
|
201
|
+
var MIN_LABEL_SCALE = 0.3;
|
|
201
202
|
var num = (minimum, maximum) => ({ type: "number", minimum, maximum });
|
|
202
203
|
var icons = (maxItems) => ({ type: "array", items: { type: "string", enum: Object.values(RowIcon) }, minItems: 1, maxItems });
|
|
203
204
|
var rowsSchema = {
|
|
@@ -216,7 +217,9 @@ var rowsSchema = {
|
|
|
216
217
|
toPicture: { type: "boolean" },
|
|
217
218
|
reach: num(0, 1)
|
|
218
219
|
}
|
|
219
|
-
}
|
|
220
|
+
},
|
|
221
|
+
priceLabelScale: num(MIN_LABEL_SCALE, 1),
|
|
222
|
+
venue: { type: "object", additionalProperties: false, properties: { body: { type: "boolean" }, bare: { type: "boolean" } } }
|
|
220
223
|
}
|
|
221
224
|
};
|
|
222
225
|
var overlapSchema = {
|
|
@@ -817,6 +820,7 @@ var GAP = {
|
|
|
817
820
|
var makers = (p, u, sc) => ({
|
|
818
821
|
display: (text2, size, key) => styled({ text: text2, role: "display", weight: BOLD, size: size * u, color: p.title }, key, sc),
|
|
819
822
|
venue: (text2, size, key) => styled({ text: text2, role: "display", weight: MEDIUM, size: size * u, color: p.ink }, key, sc),
|
|
823
|
+
bodyVenue: (text2, size, key) => styled({ text: text2, role: "body", weight: BOLD, size: size * u, color: p.ink }, key, sc),
|
|
820
824
|
script: (text2, size, key) => styled({ text: text2, role: "script", weight: SCRIPT, size: size * u, color: p.script ?? p.accent }, key, sc),
|
|
821
825
|
strong: (text2, size, key) => styled({ text: text2, role: "body", weight: BOLD, size: size * u, color: p.ink }, key, sc),
|
|
822
826
|
accent: (text2, size, key) => styled({ text: text2, role: "body", weight: SEMI, size: size * u, color: p.accent }, key, sc),
|
|
@@ -881,7 +885,7 @@ function eventGroups(doc, l, u, options) {
|
|
|
881
885
|
groups.push({ lines, gapAfter: GAP.row * u, keepWithNext: i < schedule2.length - 1, ...options.marks(icons2?.schedule, i, i === lastRow) });
|
|
882
886
|
});
|
|
883
887
|
prices.forEach((row, i) => {
|
|
884
|
-
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`)];
|
|
888
|
+
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`)];
|
|
885
889
|
groups.push({ lines, gapAfter: GAP.row * u, keepWithNext: i < prices.length - 1, ...options.marks(icons2?.prices, i, schedule2.length + i === lastRow) });
|
|
886
890
|
});
|
|
887
891
|
return groups;
|
|
@@ -906,7 +910,9 @@ function bodyGroups(doc, p, u, options = {}) {
|
|
|
906
910
|
if (b.venue) {
|
|
907
911
|
const size = isList ? SIZE.listVenue : SIZE.venue;
|
|
908
912
|
const keepWithNext = !isList && (b.schedule?.length ?? 0) > 0;
|
|
909
|
-
|
|
913
|
+
const look = doc.rows?.venue;
|
|
914
|
+
const line = look?.body === true ? l.bodyVenue : l.venue;
|
|
915
|
+
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 });
|
|
910
916
|
}
|
|
911
917
|
groups.push(...isList ? listGroups(doc, l, u, options.dateScale ?? 1) : eventGroups(doc, l, u, { ...options, marks: rowMarks(doc, p, u) }));
|
|
912
918
|
if (b.includes) {
|
|
@@ -1023,7 +1029,7 @@ function placeIcon(group, box, out) {
|
|
|
1023
1029
|
return bottom2;
|
|
1024
1030
|
}
|
|
1025
1031
|
const textH = bottom2 - top;
|
|
1026
|
-
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 });
|
|
1032
|
+
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 });
|
|
1027
1033
|
return top + Math.max(textH, d);
|
|
1028
1034
|
}
|
|
1029
1035
|
function placeGroup(m, at, out) {
|
|
@@ -1414,18 +1420,23 @@ var PIN_TIP_Y = 0.28;
|
|
|
1414
1420
|
var PIN_HOLE = 0.42;
|
|
1415
1421
|
var ARC_START = 0.75;
|
|
1416
1422
|
var ARC_END = 2.25;
|
|
1417
|
-
|
|
1423
|
+
var BARE_SCALE = 1.6;
|
|
1424
|
+
function drawPin(ctx, r3, colors, bare = false) {
|
|
1425
|
+
const { color, glyph } = bare ? { color: colors.glyph, glyph: colors.color } : colors;
|
|
1426
|
+
const w = bare ? r3.w * BARE_SCALE : r3.w;
|
|
1418
1427
|
const cx = r3.x + r3.w / 2;
|
|
1419
1428
|
const cy = r3.y + r3.h / 2;
|
|
1420
|
-
const hy = cy -
|
|
1421
|
-
const rad =
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1429
|
+
const hy = cy - w * PIN_HEAD_Y;
|
|
1430
|
+
const rad = w * PIN_HEAD_R;
|
|
1431
|
+
if (!bare) {
|
|
1432
|
+
ctx.fillStyle = color;
|
|
1433
|
+
ctx.beginPath();
|
|
1434
|
+
ctx.arc(cx, cy, r3.w / 2, 0, Math.PI * 2);
|
|
1435
|
+
ctx.fill();
|
|
1436
|
+
}
|
|
1426
1437
|
ctx.fillStyle = glyph;
|
|
1427
1438
|
ctx.beginPath();
|
|
1428
|
-
ctx.moveTo(cx, cy +
|
|
1439
|
+
ctx.moveTo(cx, cy + w * PIN_TIP_Y);
|
|
1429
1440
|
ctx.arc(cx, hy, rad, Math.PI * ARC_START, Math.PI * ARC_END);
|
|
1430
1441
|
ctx.closePath();
|
|
1431
1442
|
ctx.fill();
|
|
@@ -1462,7 +1473,7 @@ function drawMarks(ctx, f, radius) {
|
|
|
1462
1473
|
ctx.arc(b.x, b.y, b.r, 0, Math.PI * 2);
|
|
1463
1474
|
ctx.fill();
|
|
1464
1475
|
});
|
|
1465
|
-
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 }));
|
|
1476
|
+
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 }));
|
|
1466
1477
|
ctx.textAlign = "left";
|
|
1467
1478
|
ctx.textBaseline = "top";
|
|
1468
1479
|
f.texts.forEach((t) => {
|