@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 CHANGED
@@ -129,7 +129,7 @@ interface PictureOverlap {
129
129
  dx: number;
130
130
  dy: number;
131
131
  }
132
- /** Row icon discs and divider rules; a short icon list repeats its last icon; px at a 1080 short edge. */
132
+ /** Row icon discs, divider rules, price label scale and venue face/pin; a short icon list repeats its last icon; px at a 1080 short edge. */
133
133
  interface RowTheme {
134
134
  icons?: {
135
135
  schedule?: RowIcon[];
@@ -143,6 +143,11 @@ interface RowTheme {
143
143
  toPicture?: boolean;
144
144
  reach?: number;
145
145
  };
146
+ priceLabelScale?: number;
147
+ venue?: {
148
+ body?: boolean;
149
+ bare?: boolean;
150
+ };
146
151
  }
147
152
  interface LogoSlot {
148
153
  imageId: string;
package/dist/index.d.ts CHANGED
@@ -129,7 +129,7 @@ interface PictureOverlap {
129
129
  dx: number;
130
130
  dy: number;
131
131
  }
132
- /** Row icon discs and divider rules; a short icon list repeats its last icon; px at a 1080 short edge. */
132
+ /** Row icon discs, divider rules, price label scale and venue face/pin; a short icon list repeats its last icon; px at a 1080 short edge. */
133
133
  interface RowTheme {
134
134
  icons?: {
135
135
  schedule?: RowIcon[];
@@ -143,6 +143,11 @@ interface RowTheme {
143
143
  toPicture?: boolean;
144
144
  reach?: number;
145
145
  };
146
+ priceLabelScale?: number;
147
+ venue?: {
148
+ body?: boolean;
149
+ bare?: boolean;
150
+ };
146
151
  }
147
152
  interface LogoSlot {
148
153
  imageId: string;
package/dist/index.js CHANGED
@@ -200,6 +200,7 @@ var MAX_TOP = 600;
200
200
  var MAX_LINE_GAP = 200;
201
201
  var MIN_TITLE_SCALE = 0.3;
202
202
  var MAX_TITLE_SCALE = 2.5;
203
+ var MIN_LABEL_SCALE = 0.3;
203
204
  var num = (minimum, maximum) => ({ type: "number", minimum, maximum });
204
205
  var icons = (maxItems) => ({ type: "array", items: { type: "string", enum: Object.values(RowIcon) }, minItems: 1, maxItems });
205
206
  var rowsSchema = {
@@ -218,7 +219,9 @@ var rowsSchema = {
218
219
  toPicture: { type: "boolean" },
219
220
  reach: num(0, 1)
220
221
  }
221
- }
222
+ },
223
+ priceLabelScale: num(MIN_LABEL_SCALE, 1),
224
+ venue: { type: "object", additionalProperties: false, properties: { body: { type: "boolean" }, bare: { type: "boolean" } } }
222
225
  }
223
226
  };
224
227
  var overlapSchema = {
@@ -819,6 +822,7 @@ var GAP = {
819
822
  var makers = (p, u, sc) => ({
820
823
  display: (text2, size, key) => styled({ text: text2, role: "display", weight: BOLD, size: size * u, color: p.title }, key, sc),
821
824
  venue: (text2, size, key) => styled({ text: text2, role: "display", weight: MEDIUM, size: size * u, color: p.ink }, key, sc),
825
+ bodyVenue: (text2, size, key) => styled({ text: text2, role: "body", weight: BOLD, size: size * u, color: p.ink }, key, sc),
822
826
  script: (text2, size, key) => styled({ text: text2, role: "script", weight: SCRIPT, size: size * u, color: p.script ?? p.accent }, key, sc),
823
827
  strong: (text2, size, key) => styled({ text: text2, role: "body", weight: BOLD, size: size * u, color: p.ink }, key, sc),
824
828
  accent: (text2, size, key) => styled({ text: text2, role: "body", weight: SEMI, size: size * u, color: p.accent }, key, sc),
@@ -883,7 +887,7 @@ function eventGroups(doc, l, u, options) {
883
887
  groups.push({ lines, gapAfter: GAP.row * u, keepWithNext: i < schedule2.length - 1, ...options.marks(icons2?.schedule, i, i === lastRow) });
884
888
  });
885
889
  prices.forEach((row, i) => {
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`)];
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`)];
887
891
  groups.push({ lines, gapAfter: GAP.row * u, keepWithNext: i < prices.length - 1, ...options.marks(icons2?.prices, i, schedule2.length + i === lastRow) });
888
892
  });
889
893
  return groups;
@@ -908,7 +912,9 @@ function bodyGroups(doc, p, u, options = {}) {
908
912
  if (b.venue) {
909
913
  const size = isList ? SIZE.listVenue : SIZE.venue;
910
914
  const keepWithNext = !isList && (b.schedule?.length ?? 0) > 0;
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 });
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 });
912
918
  }
913
919
  groups.push(...isList ? listGroups(doc, l, u, options.dateScale ?? 1) : eventGroups(doc, l, u, { ...options, marks: rowMarks(doc, p, u) }));
914
920
  if (b.includes) {
@@ -1025,7 +1031,7 @@ function placeIcon(group, box, out) {
1025
1031
  return bottom2;
1026
1032
  }
1027
1033
  const textH = bottom2 - top;
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 });
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 });
1029
1035
  return top + Math.max(textH, d);
1030
1036
  }
1031
1037
  function placeGroup(m, at, out) {
@@ -1416,18 +1422,23 @@ var PIN_TIP_Y = 0.28;
1416
1422
  var PIN_HOLE = 0.42;
1417
1423
  var ARC_START = 0.75;
1418
1424
  var ARC_END = 2.25;
1419
- function drawPin(ctx, r3, color, glyph) {
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;
1420
1429
  const cx = r3.x + r3.w / 2;
1421
1430
  const cy = r3.y + r3.h / 2;
1422
- const hy = cy - r3.w * PIN_HEAD_Y;
1423
- const rad = r3.w * PIN_HEAD_R;
1424
- ctx.fillStyle = color;
1425
- ctx.beginPath();
1426
- ctx.arc(cx, cy, r3.w / 2, 0, Math.PI * 2);
1427
- ctx.fill();
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
+ }
1428
1439
  ctx.fillStyle = glyph;
1429
1440
  ctx.beginPath();
1430
- ctx.moveTo(cx, cy + r3.w * PIN_TIP_Y);
1441
+ ctx.moveTo(cx, cy + w * PIN_TIP_Y);
1431
1442
  ctx.arc(cx, hy, rad, Math.PI * ARC_START, Math.PI * ARC_END);
1432
1443
  ctx.closePath();
1433
1444
  ctx.fill();
@@ -1464,7 +1475,7 @@ function drawMarks(ctx, f, radius) {
1464
1475
  ctx.arc(b.x, b.y, b.r, 0, Math.PI * 2);
1465
1476
  ctx.fill();
1466
1477
  });
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 }));
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 }));
1468
1479
  ctx.textAlign = "left";
1469
1480
  ctx.textBaseline = "top";
1470
1481
  f.texts.forEach((t) => {