# HG changeset patch # User ark # Date 1792328914 -7200 # Node ID 3dd5b745fa0876cd88cf66b4aa9482044cd11474 # Parent 5492efd60e2c63bd351be86b8589aedf57aca97d updated art with inked drawings diff -r 5492efd60e2c -r 3dd5b745fa08 art/0418_261018145916_001.jpg Binary file art/0418_261018145916_001.jpg has changed diff -r 5492efd60e2c -r 3dd5b745fa08 art/b0.png Binary file art/b0.png has changed diff -r 5492efd60e2c -r 3dd5b745fa08 art/b1.png Binary file art/b1.png has changed diff -r 5492efd60e2c -r 3dd5b745fa08 art/b2.png Binary file art/b2.png has changed diff -r 5492efd60e2c -r 3dd5b745fa08 art/b3.png Binary file art/b3.png has changed diff -r 5492efd60e2c -r 3dd5b745fa08 art/hpb.png Binary file art/hpb.png has changed diff -r 5492efd60e2c -r 3dd5b745fa08 art/hpm.png Binary file art/hpm.png has changed diff -r 5492efd60e2c -r 3dd5b745fa08 art/m0.png Binary file art/m0.png has changed diff -r 5492efd60e2c -r 3dd5b745fa08 art/m1.png Binary file art/m1.png has changed diff -r 5492efd60e2c -r 3dd5b745fa08 art/m2.png Binary file art/m2.png has changed diff -r 5492efd60e2c -r 3dd5b745fa08 art/m3.png Binary file art/m3.png has changed diff -r 5492efd60e2c -r 3dd5b745fa08 art/m4.png Binary file art/m4.png has changed diff -r 5492efd60e2c -r 3dd5b745fa08 art/p0.png Binary file art/p0.png has changed diff -r 5492efd60e2c -r 3dd5b745fa08 art/p1.png Binary file art/p1.png has changed diff -r 5492efd60e2c -r 3dd5b745fa08 art/p2.png Binary file art/p2.png has changed diff -r 5492efd60e2c -r 3dd5b745fa08 art/p3.png Binary file art/p3.png has changed diff -r 5492efd60e2c -r 3dd5b745fa08 art/source_sheet_2.jpg Binary file art/source_sheet_2.jpg has changed diff -r 5492efd60e2c -r 3dd5b745fa08 art/t0.png Binary file art/t0.png has changed diff -r 5492efd60e2c -r 3dd5b745fa08 art/t0p.png Binary file art/t0p.png has changed diff -r 5492efd60e2c -r 3dd5b745fa08 art/t1.png Binary file art/t1.png has changed diff -r 5492efd60e2c -r 3dd5b745fa08 art/t1p.png Binary file art/t1p.png has changed diff -r 5492efd60e2c -r 3dd5b745fa08 art/t2.png Binary file art/t2.png has changed diff -r 5492efd60e2c -r 3dd5b745fa08 art/t2p.png Binary file art/t2p.png has changed diff -r 5492efd60e2c -r 3dd5b745fa08 art/t3.png Binary file art/t3.png has changed diff -r 5492efd60e2c -r 3dd5b745fa08 art/t3p.png Binary file art/t3p.png has changed diff -r 5492efd60e2c -r 3dd5b745fa08 config/game.toml --- a/config/game.toml Sun Oct 18 14:50:20 2026 +0200 +++ b/config/game.toml Sun Oct 18 15:08:34 2026 +0200 @@ -187,14 +187,15 @@ p3 = -45 # rotation point as a share of the trimmed image's width and height, for -# sprites that do not turn around their centre (art.md). proto, by eye from +# sprites that do not turn around their centre (art.md). proto, the centre of +# the base square measured on source_sheet_2 cutouts, checked in # temp/preview/towers.png. [art.pivot] -t1 = [0.36, 0.5] -t1_2 = [0.27, 0.55] -t1_3 = [0.31, 0.5] -t1_4 = [0.34, 0.5] -t1_5 = [0.26, 0.5] +t1 = [0.37, 0.5] +t1_2 = [0.30, 0.5] +t1_3 = [0.33, 0.5] +t1_4 = [0.35, 0.5] +t1_5 = [0.27, 0.5] # debug switches, all off by default diff -r 5492efd60e2c -r 3dd5b745fa08 doc/art.md --- a/doc/art.md Sun Oct 18 14:50:20 2026 +0200 +++ b/doc/art.md Sun Oct 18 15:08:34 2026 +0200 @@ -14,22 +14,27 @@ source_sheet.jpg: the original drawing sheet with all sprites, maps, damage values, monster and boss coins, and starting coins per map. map numbers on the sheet start at 1 (M1-M4 are map0-map3) +source_sheet_2.jpg: the same sheet with the sprite outlines inked in black, +and monster hp and tower costs added. m*, b*, t*, t*p, p* and the hp bars are +cut from it by tools/cut_sheet.py -files in art/ stay as supplied. the build (see architecture.md) writes -processed copies to game/assets/. +files in art/ stay as supplied, apart from the sprites cut from a sheet. the +build (see architecture.md) writes processed copies to game/assets/. state of the files ------------------ -- t0-t3, m0-m4, b0-b3, p0-p3, c0-c3, hpb: cut out, transparent outside, white - inside. ready to use after trimming -- hpm: no transparency, the whole rectangle is opaque. usable as a bar -- towers have 5 levels. t0-t3 are level 1, already processed -- t*p: pencil outlines of tower levels 2-5 side by side. transparent outside - and inside. the build splits them and fills the inside white -- the strip drawings are close in design to level 1, and the scan scale may - differ. to check when processing that the sizes follow on from level 1 +- t0-t3, m0-m4, b0-b3, p0-p3, hpm, hpb: cut from source_sheet_2.jpg at the + sheet's scale. black outlines, transparent outside. inside, the paper is + white and drawn colour is kept (bosses, hp bars) +- c0-c3: cut out by hand from the first sheet, transparent outside +- towers have 5 levels. t0-t3 are level 1 +- t*p: outlines of tower levels 2-5 side by side, cut from the same sheet as + level 1, so the sizes follow on. the build splits them and fills any + inside left transparent white +- on the sheet, the tower row runs t1, t0, t2, t3 and the projectile row + p1, p0, p2, p3 - t3 level 5 is a different design from levels 1-4 (square with a barrel instead of a triangle) - maps: scans with paper edges. map and mask of the same number line up pixel diff -r 5492efd60e2c -r 3dd5b745fa08 doc/roadmap.md --- a/doc/roadmap.md Sun Oct 18 14:50:20 2026 +0200 +++ b/doc/roadmap.md Sun Oct 18 15:08:34 2026 +0200 @@ -56,9 +56,15 @@ game.toml change; it keeps its result in temp/build/maps.json for the checks and previews - map images are written as jpeg, quality 88. the maps have no transparency -- tower strips are split at columns without pencil. pencil is anything darker +- tower strips are split at columns without ink. ink is anything darker than luminance 225. outline gaps of up to about 4 pixels are closed before the fill. the white paper edge outside the outline fades to transparent +- tools/cut_sheet.py cuts the sprites out of source_sheet_2.jpg into art/. it + is run by hand, not by the build. one hand-set box per drawing; in each box + the largest connected outline is the drawing and other ink is dropped. + outline ink is darker than luminance 150. sprites stay at the sheet's + scale, which is the scale the first cutouts had, so [scale] is unchanged. + coins and maps are not on the inked sheet and stay as they were - the empty part of the hp bars is a darkened copy made by the build (hpm_empty, hpb_empty) - sprite sizes go into config.js, so the game knows them before the images @@ -99,7 +105,8 @@ - added: hit_radius in [animation] (0.4 of the monster sprite's smaller side), min_weight in [route_preference] (the "at least 0.1" of the rule), [art.angle] and [art.pivot]. t1 turns around the middle of its box, not - the middle of the image; the pivots for levels 1-5 are set by eye + the middle of the image; the pivots for levels 1-5 are the centre of the + box measured on the cutouts. temp/preview/towers.png marks them - draft waves: monster counts per level from the coin shares. each level is spread over the waves by the coin budget still open, with wave n worth n shares. higher levels start later: m1 after 15 % of the waves, m2 35 %, m3 diff -r 5492efd60e2c -r 3dd5b745fa08 game/assets/b0.png Binary file game/assets/b0.png has changed diff -r 5492efd60e2c -r 3dd5b745fa08 game/assets/b1.png Binary file game/assets/b1.png has changed diff -r 5492efd60e2c -r 3dd5b745fa08 game/assets/b2.png Binary file game/assets/b2.png has changed diff -r 5492efd60e2c -r 3dd5b745fa08 game/assets/b3.png Binary file game/assets/b3.png has changed diff -r 5492efd60e2c -r 3dd5b745fa08 game/assets/hpb.png Binary file game/assets/hpb.png has changed diff -r 5492efd60e2c -r 3dd5b745fa08 game/assets/hpb_empty.png Binary file game/assets/hpb_empty.png has changed diff -r 5492efd60e2c -r 3dd5b745fa08 game/assets/hpm.png Binary file game/assets/hpm.png has changed diff -r 5492efd60e2c -r 3dd5b745fa08 game/assets/hpm_empty.png Binary file game/assets/hpm_empty.png has changed diff -r 5492efd60e2c -r 3dd5b745fa08 game/assets/m0.png Binary file game/assets/m0.png has changed diff -r 5492efd60e2c -r 3dd5b745fa08 game/assets/m1.png Binary file game/assets/m1.png has changed diff -r 5492efd60e2c -r 3dd5b745fa08 game/assets/m2.png Binary file game/assets/m2.png has changed diff -r 5492efd60e2c -r 3dd5b745fa08 game/assets/m3.png Binary file game/assets/m3.png has changed diff -r 5492efd60e2c -r 3dd5b745fa08 game/assets/m4.png Binary file game/assets/m4.png has changed diff -r 5492efd60e2c -r 3dd5b745fa08 game/assets/p0.png Binary file game/assets/p0.png has changed diff -r 5492efd60e2c -r 3dd5b745fa08 game/assets/p1.png Binary file game/assets/p1.png has changed diff -r 5492efd60e2c -r 3dd5b745fa08 game/assets/p2.png Binary file game/assets/p2.png has changed diff -r 5492efd60e2c -r 3dd5b745fa08 game/assets/p3.png Binary file game/assets/p3.png has changed diff -r 5492efd60e2c -r 3dd5b745fa08 game/assets/t0.png Binary file game/assets/t0.png has changed diff -r 5492efd60e2c -r 3dd5b745fa08 game/assets/t0_2.png Binary file game/assets/t0_2.png has changed diff -r 5492efd60e2c -r 3dd5b745fa08 game/assets/t0_3.png Binary file game/assets/t0_3.png has changed diff -r 5492efd60e2c -r 3dd5b745fa08 game/assets/t0_4.png Binary file game/assets/t0_4.png has changed diff -r 5492efd60e2c -r 3dd5b745fa08 game/assets/t0_5.png Binary file game/assets/t0_5.png has changed diff -r 5492efd60e2c -r 3dd5b745fa08 game/assets/t1.png Binary file game/assets/t1.png has changed diff -r 5492efd60e2c -r 3dd5b745fa08 game/assets/t1_2.png Binary file game/assets/t1_2.png has changed diff -r 5492efd60e2c -r 3dd5b745fa08 game/assets/t1_3.png Binary file game/assets/t1_3.png has changed diff -r 5492efd60e2c -r 3dd5b745fa08 game/assets/t1_4.png Binary file game/assets/t1_4.png has changed diff -r 5492efd60e2c -r 3dd5b745fa08 game/assets/t1_5.png Binary file game/assets/t1_5.png has changed diff -r 5492efd60e2c -r 3dd5b745fa08 game/assets/t2.png Binary file game/assets/t2.png has changed diff -r 5492efd60e2c -r 3dd5b745fa08 game/assets/t2_2.png Binary file game/assets/t2_2.png has changed diff -r 5492efd60e2c -r 3dd5b745fa08 game/assets/t2_3.png Binary file game/assets/t2_3.png has changed diff -r 5492efd60e2c -r 3dd5b745fa08 game/assets/t2_4.png Binary file game/assets/t2_4.png has changed diff -r 5492efd60e2c -r 3dd5b745fa08 game/assets/t2_5.png Binary file game/assets/t2_5.png has changed diff -r 5492efd60e2c -r 3dd5b745fa08 game/assets/t3.png Binary file game/assets/t3.png has changed diff -r 5492efd60e2c -r 3dd5b745fa08 game/assets/t3_2.png Binary file game/assets/t3_2.png has changed diff -r 5492efd60e2c -r 3dd5b745fa08 game/assets/t3_3.png Binary file game/assets/t3_3.png has changed diff -r 5492efd60e2c -r 3dd5b745fa08 game/assets/t3_4.png Binary file game/assets/t3_4.png has changed diff -r 5492efd60e2c -r 3dd5b745fa08 game/assets/t3_5.png Binary file game/assets/t3_5.png has changed diff -r 5492efd60e2c -r 3dd5b745fa08 game/data/config.js --- a/game/data/config.js Sun Oct 18 14:50:20 2026 +0200 +++ b/game/data/config.js Sun Oct 18 15:08:34 2026 +0200 @@ -218,23 +218,23 @@ }, "pivot": { "t1": [ - 0.36, + 0.37, 0.5 ], "t1_2": [ - 0.27, - 0.55 + 0.3, + 0.5 ], "t1_3": [ - 0.31, + 0.33, 0.5 ], "t1_4": [ - 0.34, + 0.35, 0.5 ], "t1_5": [ - 0.26, + 0.27, 0.5 ] } @@ -1357,20 +1357,20 @@ ], "sprites": { "b0": [ - 164, - 160 + 166, + 162 ], "b1": [ - 195, + 199, 160 ], "b2": [ - 127, - 176 + 125, + 188 ], "b3": [ - 144, - 183 + 135, + 175 ], "c0": [ 41, @@ -1389,136 +1389,136 @@ 53 ], "hpb": [ - 243, - 31 + 252, + 41 ], "hpb_empty": [ - 243, - 31 + 252, + 41 ], "hpm": [ - 117, - 28 + 127, + 40 ], "hpm_empty": [ - 117, - 28 + 127, + 40 ], "m0": [ - 130, - 113 + 134, + 118 ], "m1": [ - 128, - 112 + 125, + 111 ], "m2": [ 92, - 87 + 86 ], "m3": [ 97, - 104 + 102 ], "m4": [ - 111, - 110 + 108, + 109 ], "p0": [ - 34, - 88 + 35, + 90 ], "p1": [ - 46, - 32 + 50, + 36 ], "p2": [ - 51, + 52, 53 ], "p3": [ - 60, - 64 + 62, + 62 ], "t0": [ - 144, - 143 + 143, + 140 ], "t0_2": [ - 153, - 159 + 154, + 168 ], "t0_3": [ - 206, - 185 + 209, + 193 ], "t0_4": [ - 240, - 260 + 238, + 207 ], "t0_5": [ - 256, - 251 + 258, + 257 ], "t1": [ - 174, + 186, 120 ], "t1_2": [ - 203, - 184 + 211, + 126 ], "t1_3": [ - 239, - 152 + 243, + 154 ], "t1_4": [ - 216, - 135 + 222, + 143 ], "t1_5": [ - 359, - 146 + 361, + 143 ], "t2": [ - 124, - 149 + 116, + 142 ], "t2_2": [ - 115, - 154 + 117, + 156 ], "t2_3": [ - 101, - 159 + 97, + 156 ], "t2_4": [ - 132, - 177 + 127, + 179 ], "t2_5": [ - 132, + 129, 190 ], "t3": [ - 162, - 135 + 157, + 136 ], "t3_2": [ - 158, - 176 + 159, + 180 ], "t3_3": [ - 243, - 248 + 237, + 175 ], "t3_4": [ - 216, - 160 + 209, + 163 ], "t3_5": [ - 205, - 213 + 206, + 222 ] } }; diff -r 5492efd60e2c -r 3dd5b745fa08 tools/build.py --- a/tools/build.py Sun Oct 18 14:50:20 2026 +0200 +++ b/tools/build.py Sun Oct 18 15:08:34 2026 +0200 @@ -405,9 +405,10 @@ # 7. previews -def step_previews(maps, force, changed): +def step_previews(cfg, maps, force, changed): outputs = [PREVIEW / f"map{m}.png" for m in range(MAPS)] + [PREVIEW / "towers.png"] - if not changed and not stale([], outputs, force): + # the tower sheet shows the pivots from game.toml + if not changed and not stale([CONFIG / "game.toml"], outputs, force): print("previews: up to date") return PREVIEW.mkdir(parents=True, exist_ok=True) @@ -415,7 +416,7 @@ preview.map_preview(ART / f"map{m}.png", mp).save(PREVIEW / f"map{m}.png") if len(mp["routes"]) > 1: preview.route_sheet(ART / f"map{m}.png", mp).save(PREVIEW / f"map{m}_routes.png") - preview.tower_sheet(ASSETS).save(PREVIEW / "towers.png") + preview.tower_sheet(ASSETS, cfg["art"]["pivot"]).save(PREVIEW / "towers.png") print(f"previews: wrote {PREVIEW.relative_to(ROOT)}/") @@ -433,7 +434,7 @@ maps, masks_changed = step_masks(cfg, force) step_config(cfg, force, changed) step_checks(cfg, maps) - step_previews(maps, force, changed or masks_changed) + step_previews(cfg, maps, force, changed or masks_changed) print(f"\n{len(warnings)} warning(s)") return True diff -r 5492efd60e2c -r 3dd5b745fa08 tools/cut_sheet.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/cut_sheet.py Sun Oct 18 15:08:34 2026 +0200 @@ -0,0 +1,165 @@ +""" +cut the sprites out of a scanned drawing sheet and write them to art/. + + python3 tools/cut_sheet.py art/source_sheet_2.jpg + +the boxes below are set by hand for source_sheet_2.jpg, in sheet pixels, at +the sheet's own scale. each box holds one drawing with an inked outline. the +largest connected outline in a box is the drawing; other ink in the box, such +as a neighbour's edge, is dropped. the inside of the outline keeps the +scanned colour, the paper is whitened, the outside becomes transparent. + +the t*p strips are made of four boxes each, levels 2-5, laid out side by side +with empty columns between them, as the build expects (see images.py). + +coins and maps are not on the sheet in inked form and are not written. +""" + +import sys +from pathlib import Path + +from PIL import Image, ImageDraw, ImageFilter + +ART = Path(__file__).resolve().parent.parent / "art" + +# box padding, so the outline never touches the crop border +PAD = 12 +# outline ink is darker than this luminance +INK_LUM = 150 +# outside the outline, pixels fade from opaque at INK_LUM to transparent here +LUM_CLEAR = 245 +# paper is lighter than this and becomes white; darker colours are scaled +PAPER_LUM = 235 +# other outlines in a box are kept if they reach this share of the largest +# and do not touch the box border +KEEP_SHARE = 0.05 +# empty columns between the levels of a tower strip +STRIP_GAP = 40 + +SPRITES = { + "hpm": (284, 204, 424, 260), + "m0": (280, 280, 428, 412), + "m1": (496, 264, 628, 388), + "m2": (676, 276, 780, 376), + "m3": (804, 248, 916, 364), + "m4": (924, 244, 1040, 368), + "t1": (236, 564, 436, 696), + "t0": (476, 528, 632, 684), + "t2": (688, 512, 816, 668), + "t3": (872, 500, 1040, 652), + "hpb": (172, 730, 450, 785), + "b0": (200, 780, 440, 950), + "b1": (436, 760, 648, 950), + "b2": (688, 700, 828, 904), + "b3": (896, 712, 1040, 896), + "p1": (236, 1044, 300, 1096), + "p0": (520, 980, 568, 1080), + "p2": (720, 1008, 784, 1076), + "p3": (920, 976, 996, 1052), +} + +STRIPS = { + "t1p": [(1284, 464, 1508, 600), (1552, 424, 1808, 592), + (1816, 404, 2044, 560), (2080, 392, 2456, 548)], + "t0p": [(2544, 360, 2712, 540), (2736, 340, 2960, 548), + (2980, 300, 3226, 572), (3226, 290, 3500, 580)], + "t2p": [(1320, 672, 1452, 840), (1536, 656, 1648, 828), + (1720, 616, 1856, 812), (1920, 592, 2064, 796)], + "t3p": [(2120, 596, 2292, 788), (2312, 616, 2560, 804), + (2580, 620, 2800, 800), (2816, 552, 3036, 788)], +} + + +def outlines(walls): + """ + return the connected parts of a mask as (count, seed, touches border), + largest first. walls is an L image with 255 for ink. + """ + w, h = walls.size + work = walls.copy() + px = work.load() + parts = [] + for y in range(h): + for x in range(w): + if px[x, y] != 255: + continue + ImageDraw.floodfill(work, (x, y), 100) + part = work.point(lambda v: 255 if v == 100 else 0) + count = part.histogram()[255] + l, t, r, b = part.getbbox() + border = l == 0 or t == 0 or r == w or b == h + ImageDraw.floodfill(work, (x, y), 50) + px = work.load() + parts.append((count, (x, y), border)) + parts.sort(reverse=True) + return parts + + +def cut(sheet, box): + """cut one drawing out of the sheet. returns a trimmed RGBA image.""" + l, t, r, b = box + src = sheet.crop((max(0, l - PAD), max(0, t - PAD), + min(sheet.width, r + PAD), min(sheet.height, b + PAD))) + # pad with paper where the box reaches the sheet edge + im = Image.new("RGB", (r - l + 2 * PAD, b - t + 2 * PAD), (255, 255, 255)) + im.paste(src, (max(0, l - PAD) - (l - PAD), max(0, t - PAD) - (t - PAD))) + w, h = im.size + lum = im.convert("L") + + ink = lum.point(lambda v: 255 if v < INK_LUM else 0) + # close one pixel gaps in the outline + walls = ink.filter(ImageFilter.MaxFilter(3)) + + parts = outlines(walls) + largest = parts[0][0] + for i, (count, seed, border) in enumerate(parts): + if i == 0 or (count >= KEEP_SHARE * largest and not border): + ImageDraw.floodfill(walls, seed, 200) + kept = walls.point(lambda v: 255 if v == 200 else 0) + + # outside: flood fill from a corner, then grow back by the closed gap + ImageDraw.floodfill(kept, (0, 0), 128, thresh=0) + outside = kept.point(lambda v: 255 if v == 128 else 0) + drawing = outside.point(lambda v: 0 if v else 255) + outside = outside.filter(ImageFilter.MaxFilter(3)) + # only ink right next to the drawing counts as its edge + near = drawing.filter(ImageFilter.MaxFilter(5)) + + ramp = lum.point(lambda v: max(0, min(255, (LUM_CLEAR - v) * 255 // (LUM_CLEAR - INK_LUM)))) + alpha = Image.composite(ramp, Image.new("L", (w, h), 255), outside) + alpha = Image.composite(alpha, Image.new("L", (w, h), 0), near) + + rgb = im.point(lambda v: min(255, v * 255 // PAPER_LUM)) + out = rgb.convert("RGBA") + out.putalpha(alpha) + return out.crop(out.getbbox()) + + +def strip(levels): + """lay out level images side by side, centred vertically.""" + w = sum(im.width for im in levels) + STRIP_GAP * (len(levels) + 1) + h = max(im.height for im in levels) + 2 * STRIP_GAP + out = Image.new("RGBA", (w, h), (0, 0, 0, 0)) + x = STRIP_GAP + for im in levels: + out.paste(im, (x, (h - im.height) // 2)) + x += im.width + STRIP_GAP + return out + + +def main(path): + sheet = Image.open(path).convert("RGB") + for name, box in SPRITES.items(): + im = cut(sheet, box) + im.save(ART / f"{name}.png") + print(f"{name}: {im.width}x{im.height}") + for name, boxes in STRIPS.items(): + im = strip([cut(sheet, box) for box in boxes]) + im.save(ART / f"{name}.png") + print(f"{name}: {im.width}x{im.height}") + + +if __name__ == "__main__": + if len(sys.argv) != 2: + sys.exit("usage: cut_sheet.py SHEET") + main(sys.argv[1]) diff -r 5492efd60e2c -r 3dd5b745fa08 tools/preview.py --- a/tools/preview.py Sun Oct 18 14:50:20 2026 +0200 +++ b/tools/preview.py Sun Oct 18 15:08:34 2026 +0200 @@ -81,10 +81,10 @@ return sheet -def tower_sheet(assets): +def tower_sheet(assets, pivots): """ tower levels 1-5 per row: at full size on grey, so the white fill shows, - and at game scale next to each other. + and at game scale next to each other. a cross marks the rotation point. """ rows = [] for t in range(4): @@ -104,9 +104,10 @@ y = 20 + t * cell_h for lv, im in enumerate(r): x = lv * cell_w + pad // 2 - # cross at the image centre, the default rotation point sheet.alpha_composite(im, (x, y)) - cx, cy = x + im.width // 2, y + im.height // 2 + name = f"t{t}" if lv == 0 else f"t{t}_{lv + 1}" + px, py = pivots.get(name, (0.5, 0.5)) + cx, cy = x + round(im.width * px), y + round(im.height * py) draw.line((cx - 5, cy, cx + 5, cy), fill=(255, 0, 0)) draw.line((cx, cy - 5, cx, cy + 5), fill=(255, 0, 0)) small = im.resize((max(1, im.width // 4), max(1, im.height // 4)), Image.LANCZOS)