Logo: a clean symmetric T, outline redrawn (no remnants of the scythe, G of TOGETHER intact)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
NiemandKG
2026-12-01 18:13:52 +06:00
parent 88c1ee9202
commit f3f96ae6b4
19 changed files with 118 additions and 105 deletions

BIN
Assets/Art/UI/logo_grasscutter.png (Stored with Git LFS)

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
Docs/Steam/capsules/library_logo_1280w.png (Stored with Git LFS)

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
Docs/Steam/source/logo_clean.png (Stored with Git LFS)

Binary file not shown.

View File

@ -1,9 +1,12 @@
"""Replace the scythe standing in for the first T of CUTTERS with a copy of the second T. """Replace the scythe standing in for the first T of CUTTERS with a plain T.
py -I Tools/ui/logo_t.py in.png out.png [preview.png] py -I Tools/ui/logo_t.py original.png out.png [preview.png]
The second T (white letter) is copied left by the letter pitch of the word, given a dark outline as thick as the The originals are the scythe versions in git before 88c1ee9: Assets/Art/UI/logo_grasscutter.png and Docs/Steam/source/logo_clean.png.
rest of the logo's, and the scythe pixels (orange handle, grey head, pale blade) are cleared or blacked in.
Works from the ORIGINAL logo (the one with the scythe). The second T had its top-left corner cut away where the
scythe blade lay over it, so the T is rebuilt symmetric (its right half mirrored onto the left), used for both Ts,
and the dark outline between U and E is drawn again from scratch at the logo's own thickness.
""" """
import sys import sys
import numpy as np import numpy as np
@ -11,87 +14,97 @@ from PIL import Image
from scipy import ndimage as nd from scipy import ndimage as nd
src, dst = sys.argv[1], sys.argv[2] src, dst = sys.argv[1], sys.argv[2]
im = np.array(Image.open(src).convert("RGBA")).astype(np.int32) im = np.array(Image.open(src).convert("RGBA")).astype(np.float64)
H, W = im.shape[:2] H, W = im.shape[:2]
r, g, b, a = im[..., 0], im[..., 1], im[..., 2], im[..., 3] r, g, b, a = (im[..., i] for i in range(4))
mx, mn = np.maximum(np.maximum(r, g), b), np.minimum(np.minimum(r, g), b) mx, mn = np.maximum(np.maximum(r, g), b), np.minimum(np.minimum(r, g), b)
solid = a > 128 solid = a > 128
white = solid & (mn > 200) & (mx - mn < 30) white = solid & (mn > 200) & (mx - mn < 30)
dark = solid & (mx < 90) dark = solid & (mx < 90)
orange = solid & (r > 150) & (r - b > 80) & (g < 200) orange = solid & (r > 150) & (r - b > 80) & (g < 200)
grey = solid & (mx - mn < 35) & (mn > 100) & (mn <= 215)
# letters: big white components. The middle row (CUTTERS) is the band holding the orange handle.
lab, n = nd.label(white) lab, n = nd.label(white)
objs = nd.find_objects(lab) objs = nd.find_objects(lab)
sizes = nd.sum(white, lab, range(1, n + 1)) sizes = nd.sum(white, lab, range(1, n + 1))
ys, xs = np.nonzero(orange) ys, xs = np.nonzero(orange)
hx0, hx1, hy0, hy1 = xs.min(), xs.max(), ys.min(), ys.max() hx0, hy0, hy1 = xs.min(), ys.min(), ys.max()
row_mid = (hy0 + hy1) / 2 row_mid = (hy0 + hy1) / 2
letters = [] row = sorted((sl[1].start, i + 1, sl[1].stop, sl[0].start, sl[0].stop) for i, sl in enumerate(objs)
for i, sl in enumerate(objs): if sizes[i] >= 0.002 * H * W and sl[0].start < row_mid < sl[0].stop)
if sizes[i] < 0.002 * H * W: right = [l for l in row if l[0] > hx0]
continue u = [l for l in row if l[2] < hx0 + 5][-1]
y0, y1, x0, x1 = sl[0].start, sl[0].stop, sl[1].start, sl[1].stop
if y0 < row_mid < y1:
letters.append((x0, i + 1, x1, y0, y1))
letters.sort()
print("row letters (x0..x1):", [(l[0], l[2]) for l in letters])
# the first letter right of the handle is the second T, the one after it is E; the one left of it is U
right = [l for l in letters if l[0] > hx0]
left = [l for l in letters if l[2] < hx0 + 5]
t2, e = right[0], right[1] t2, e = right[0], right[1]
u = left[-1] print("U", u[0], u[2], "T2", t2[0], t2[2], "E", e[0], e[2])
# T1 goes halfway between U and T2 so both gaps match
gap_te = e[0] - t2[2]
w_t = t2[2] - t2[0]
x_new = int(round((u[2] + t2[0] - w_t) / 2))
dx = x_new - t2[0]
print(f"U ends {u[2]}, T2 {t2[0]}..{t2[2]}, E starts {e[0]}; new T at {x_new} (dx {dx})")
t2mask = lab == t2[1] # every letter of the logo, minus the scythe's pale blade (a white blob sitting between U and T2)
newT = np.zeros_like(t2mask) letters = np.zeros_like(white)
if dx < 0: for i, sl in enumerate(objs):
newT[:, :W + dx] = t2mask[:, -dx:] if sizes[i] < 0.0005 * H * W:
# outline thickness: distance from the T2 white to the transparent outside, measured across its stem's left side continue
dist_out = nd.distance_transform_edt(~solid) x0, x1 = sl[1].start, sl[1].stop
outline = int(np.percentile(nd.distance_transform_edt(~t2mask)[(solid) & (~white) & (nd.binary_dilation(t2mask, iterations=40)) & (~nd.binary_dilation(t2mask, iterations=3))], 95)) if x0 >= u[2] - 2 and x1 <= t2[0] + 40 and sl[0].stop <= t2[4] + 5 and (i + 1) not in (u[1], t2[1]):
outline = max(8, min(outline, 60)) continue
print("outline px", outline) letters |= lab == i + 1
# the scythe: everything light or coloured between U and T2, from the top of the handle to its foot, that is not one of the letters # outline thickness: how far the dark band reaches past the letters on the logo's outer edge, away from the scythe
box = np.zeros_like(solid) d_let = nd.distance_transform_edt(~letters)
box[max(0, hy0 - 15):hy1 + 15, u[2] - 10:t2[0] + 30] = True edge = solid & ~nd.binary_erosion(solid)
scythe = box & solid & ~dark & ~np.isin(lab, [u[1], t2[1]]) far = np.ones_like(solid)
scythe = nd.binary_dilation(scythe, iterations=3) & solid & box & ~np.isin(lab, [u[1], t2[1]]) far[:, u[0]:e[2]] = False
big = np.isin(lab, [l[1] for l in letters]) outline = float(np.median(d_let[edge & far]))
print("outline", outline)
# the T, symmetric about its stem
t2m = lab == t2[1]
y0, y1 = t2[3], t2[4]
low = range(y0 + int((y1 - y0) * 0.6), y1 - 4)
cx = int(round(np.mean([np.nonzero(t2m[y])[0].mean() for y in low if t2m[y].any()])))
half = t2[2] - cx + 3
sym = np.zeros_like(t2m)
px = np.zeros_like(im)
for x in range(cx, cx + half):
m = 2 * cx - x
sym[:, x] = t2m[:, x]
sym[:, m] = t2m[:, x]
px[:, x] = im[:, x]
px[:, m] = im[:, x]
# the new T halfway between U and T2 (same gap on both sides)
gap = (cx - half - u[2] - 2 * half) / 2
dx = int(round(u[2] + gap + half - cx))
newT = np.zeros_like(sym)
newpx = np.zeros_like(px)
newT[:, cx + dx - half:cx + dx + half] = sym[:, cx - half:cx + half]
newpx[:, cx + dx - half:cx + dx + half] = px[:, cx - half:cx + half]
print("stem", cx, "half", half, "new T stem", cx + dx)
# redraw the band from U's right edge to halfway into the T2-E gap
x_lo, x_hi = u[2] + 1, (t2[2] + e[0]) // 2
y_lo, y_hi = max(0, t2[3] - int(outline) - 30), min(H, t2[4] + int(outline) + 30)
R = np.zeros_like(solid)
R[y_lo:y_hi, x_lo:x_hi] = True
keep = letters & ~t2m # other letters' whites (GRASS bottoms, TOGETHER tops, U's edge) as they were
new_white = keep | sym | newT
d = nd.distance_transform_edt(~new_white)
dark_col = np.median(im[dark][:, :3], axis=0)
out = im.copy() out = im.copy()
# what the outline of everything else covers stays dark, the rest of the scythe goes transparent band = R & ~nd.binary_dilation(keep, iterations=2)
keep_dark = nd.distance_transform_edt(~(white & ~scythe)) <= outline + 1 cov = np.clip(outline + 0.5 - d, 0.0, 1.0) # outline coverage with a soft 1 px outer edge
ring = nd.distance_transform_edt(~newT) <= outline out[band, :3] = dark_col
dark_col = np.median(im[dark & ~scythe][:, :3], axis=0).astype(np.int32) # never less than the logo already covered there (rows close together share one dark mass)
clear = scythe & ~keep_dark & ~ring out[band, 3] = np.maximum(cov[band] * 255, a[band])
out[clear] = 0 # a pocket the old handle left between the two stems, now walled in: fill it
# gaps the handle left inside the word (between it and T2) are closed up: transparent pockets in the box that the filled silhouette surrounds pocket = band & nd.binary_fill_holes(out[..., 3] > 128) & (out[..., 3] < 255)
pocket = box & (a < 250) & nd.binary_fill_holes(solid | ring) out[pocket, 3] = 255
# inside the box every solid pixel off the letters (and their soft edges) becomes plain outline: no ghost of the handle's edge for mask, pix in ((sym, px), (newT, newpx)):
letters_soft = nd.binary_dilation(np.isin(lab, [u[1], t2[1]]), iterations=1) | nd.binary_dilation(newT, iterations=2) soft = nd.binary_dilation(mask, iterations=2) & R
fill = (scythe & (keep_dark | ring)) | (ring & ~solid) | pocket | (box & (solid | ring) & ~letters_soft & (keep_dark | ring)) al = pix[soft, 3:4] / 255.0
out[fill, :3] = dark_col # the copied pixels carry their own anti-aliased edge over the dark outline
out[fill, 3] = 255 out[soft, :3] = pix[soft, :3] * al + dark_col * (1 - al)
# the letter itself: the T2 pixels copied across with their shading out[soft, 3] = 255
for c in range(4): res = Image.fromarray(out.clip(0, 255).astype(np.uint8))
plane = out[..., c] res.save(dst)
shifted = np.zeros_like(plane)
shifted[:, :W + dx] = im[:, -dx:, c]
soft = nd.binary_dilation(newT, iterations=2)
plane[soft] = shifted[soft]
# soften the outer edge of the new outline a touch
edge = ring & ~nd.binary_erosion(ring, iterations=1) & ~solid
out[edge, 3] = 200
Image.fromarray(out.clip(0, 255).astype(np.uint8)).save(dst)
if len(sys.argv) > 3: if len(sys.argv) > 3:
prev = Image.new("RGBA", (W, H), (40, 60, 80, 255)) prev = Image.new("RGBA", (W, H), (90, 160, 60, 255))
prev.alpha_composite(Image.fromarray(out.clip(0, 255).astype(np.uint8))) prev.alpha_composite(res)
prev.convert("RGB").save(sys.argv[3]) prev.convert("RGB").save(sys.argv[3])
print("saved", dst) print("saved", dst)