Update labels
This commit is contained in:
1 parent
6db0286fc1
commit
e6a0750cb9
4 files changed
+30
-9
No files matched your search
+14
@@ -0,0 +1,14 @@
|
||||
python3 make_label.py assets/food_apple_01/food_apple_01_1k.blend \
|
||||
--texture assets/face_crop.png \
|
||||
--project \
|
||||
--output test.png \
|
||||
--azimuth 15 \
|
||||
--elevation -5 \
|
||||
--margin 0.9 \
|
||||
--transparent \
|
||||
--project-size 1.35 \
|
||||
--project-offset-y 0.05 \
|
||||
--project-offset-x -0.05 \
|
||||
--blend-mode VALUE \
|
||||
--light-strength 1.5 \
|
||||
--blend-factor 1.5
|
||||
+16
-9
@@ -39,6 +39,7 @@ def parse_args():
|
||||
p.add_argument("--save-render", help="also keep the apple render at this path")
|
||||
p.add_argument("--title", default="jider")
|
||||
p.add_argument("--subtitle", default="alc 5.5% · mostly maggot-free")
|
||||
p.add_argument("--tagline", default='"better dead than med!"', help="'' to omit")
|
||||
p.add_argument("--labels-per-sheet", type=int, default=4,
|
||||
help="labels stacked vertically on the A4 page")
|
||||
p.add_argument("--page-margin", type=float, default=10.0,
|
||||
@@ -49,6 +50,7 @@ def parse_args():
|
||||
help="fraction of the width given to the apple panel")
|
||||
p.add_argument("--label-background", default="#ffffff", help="label colour")
|
||||
p.add_argument("--label-ink", default="#7a1f12", help="text and border colour")
|
||||
p.add_argument("--label-tagline-ink", default="#000000", help="tagline colour")
|
||||
p.add_argument("--label-font", default=os.path.join(HERE, "assets/fonts/comic.ttf"),
|
||||
help="subtitle font")
|
||||
p.add_argument("--label-title-font", default=os.path.join(HERE, "assets/fonts/comicbd.ttf"),
|
||||
@@ -139,17 +141,22 @@ def compose_label(args, apple, W, H):
|
||||
label.alpha_composite(shadow.filter(ImageFilter.GaussianBlur(H / 60)))
|
||||
label.alpha_composite(apple, (ax, ay))
|
||||
|
||||
# Right panel: big title over the subtitle, the pair centred vertically.
|
||||
# Right panel: big title, tagline, then subtitle, the stack centred vertically.
|
||||
text_l, text_r = panel_w, W - 1.5 * pad
|
||||
text_w, cx = text_r - text_l, (text_l + text_r) / 2
|
||||
title_font = fit_font(args.label_title_font, args.title, text_w, H * 0.5)
|
||||
sub_font = fit_font(args.label_font, args.subtitle, text_w, H * 0.09)
|
||||
_, tt, _, tb = title_font.getbbox(args.title)
|
||||
_, st, _, sb = sub_font.getbbox(args.subtitle)
|
||||
gap = H * 0.06
|
||||
top = (H - ((tb - tt) + gap + (sb - st))) / 2
|
||||
draw_centered(draw, title_font, args.title, cx, top, ink)
|
||||
draw_centered(draw, sub_font, args.subtitle, cx, top + (tb - tt) + gap, ink)
|
||||
lines = [ # (text, font, colour, gap above as a fraction of H)
|
||||
(args.title, fit_font(args.label_title_font, args.title, text_w, H * 0.46), ink, 0),
|
||||
(args.tagline, fit_font(args.label_font, args.tagline, text_w * 0.8, H * 0.08),
|
||||
args.label_tagline_ink, 0.05),
|
||||
(args.subtitle, fit_font(args.label_font, args.subtitle, text_w, H * 0.09), ink, 0.08),
|
||||
]
|
||||
lines = [line for line in lines if line[0]]
|
||||
heights = [font.getbbox(text)[3] - font.getbbox(text)[1] for text, font, _, _ in lines]
|
||||
y = (H - sum(heights) - sum(gap * H for *_, gap in lines)) / 2
|
||||
for (text, font, colour, gap), height in zip(lines, heights):
|
||||
y += gap * H
|
||||
draw_centered(draw, font, text, cx, y, colour)
|
||||
y += height
|
||||
|
||||
return label.convert("RGB")
|
||||
|
||||
|
||||
Binary file not shown.
Reference in new issue
Block a user