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:
BIN
Assets/Art/UI/logo_grasscutter.png
(Stored with Git LFS)
BIN
Assets/Art/UI/logo_grasscutter.png
(Stored with Git LFS)
Binary file not shown.
BIN
Docs/Steam/capsules/event_cover_800x450.png
(Stored with Git LFS)
BIN
Docs/Steam/capsules/event_cover_800x450.png
(Stored with Git LFS)
Binary file not shown.
BIN
Docs/Steam/capsules/event_header_1920x622.png
(Stored with Git LFS)
BIN
Docs/Steam/capsules/event_header_1920x622.png
(Stored with Git LFS)
Binary file not shown.
BIN
Docs/Steam/capsules/header_capsule_920x430.png
(Stored with Git LFS)
BIN
Docs/Steam/capsules/header_capsule_920x430.png
(Stored with Git LFS)
Binary file not shown.
BIN
Docs/Steam/capsules/library_capsule_600x900.png
(Stored with Git LFS)
BIN
Docs/Steam/capsules/library_capsule_600x900.png
(Stored with Git LFS)
Binary file not shown.
BIN
Docs/Steam/capsules/library_header_920x430.png
(Stored with Git LFS)
BIN
Docs/Steam/capsules/library_header_920x430.png
(Stored with Git LFS)
Binary file not shown.
BIN
Docs/Steam/capsules/library_logo_1280w.png
(Stored with Git LFS)
BIN
Docs/Steam/capsules/library_logo_1280w.png
(Stored with Git LFS)
Binary file not shown.
BIN
Docs/Steam/capsules/main_capsule_1232x706.png
(Stored with Git LFS)
BIN
Docs/Steam/capsules/main_capsule_1232x706.png
(Stored with Git LFS)
Binary file not shown.
BIN
Docs/Steam/capsules/small_capsule_462x174.png
(Stored with Git LFS)
BIN
Docs/Steam/capsules/small_capsule_462x174.png
(Stored with Git LFS)
Binary file not shown.
BIN
Docs/Steam/capsules/vertical_capsule_748x896.png
(Stored with Git LFS)
BIN
Docs/Steam/capsules/vertical_capsule_748x896.png
(Stored with Git LFS)
Binary file not shown.
BIN
Docs/Steam/demo/capsules/header_capsule_920x430.png
(Stored with Git LFS)
BIN
Docs/Steam/demo/capsules/header_capsule_920x430.png
(Stored with Git LFS)
Binary file not shown.
BIN
Docs/Steam/demo/capsules/library_capsule_600x900.png
(Stored with Git LFS)
BIN
Docs/Steam/demo/capsules/library_capsule_600x900.png
(Stored with Git LFS)
Binary file not shown.
BIN
Docs/Steam/demo/capsules/library_header_920x430.png
(Stored with Git LFS)
BIN
Docs/Steam/demo/capsules/library_header_920x430.png
(Stored with Git LFS)
Binary file not shown.
BIN
Docs/Steam/demo/capsules/library_logo_1280w.png
(Stored with Git LFS)
BIN
Docs/Steam/demo/capsules/library_logo_1280w.png
(Stored with Git LFS)
Binary file not shown.
BIN
Docs/Steam/demo/capsules/main_capsule_1232x706.png
(Stored with Git LFS)
BIN
Docs/Steam/demo/capsules/main_capsule_1232x706.png
(Stored with Git LFS)
Binary file not shown.
BIN
Docs/Steam/demo/capsules/small_capsule_462x174.png
(Stored with Git LFS)
BIN
Docs/Steam/demo/capsules/small_capsule_462x174.png
(Stored with Git LFS)
Binary file not shown.
BIN
Docs/Steam/demo/capsules/vertical_capsule_748x896.png
(Stored with Git LFS)
BIN
Docs/Steam/demo/capsules/vertical_capsule_748x896.png
(Stored with Git LFS)
Binary file not shown.
BIN
Docs/Steam/source/logo_clean.png
(Stored with Git LFS)
BIN
Docs/Steam/source/logo_clean.png
(Stored with Git LFS)
Binary file not shown.
@ -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
|
||||
rest of the logo's, and the scythe pixels (orange handle, grey head, pale blade) are cleared or blacked in.
|
||||
The originals are the scythe versions in git before 88c1ee9: Assets/Art/UI/logo_grasscutter.png and Docs/Steam/source/logo_clean.png.
|
||||
|
||||
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 numpy as np
|
||||
@ -11,87 +14,97 @@ from PIL import Image
|
||||
from scipy import ndimage as nd
|
||||
|
||||
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]
|
||||
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)
|
||||
solid = a > 128
|
||||
white = solid & (mn > 200) & (mx - mn < 30)
|
||||
dark = solid & (mx < 90)
|
||||
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)
|
||||
objs = nd.find_objects(lab)
|
||||
sizes = nd.sum(white, lab, range(1, n + 1))
|
||||
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
|
||||
letters = []
|
||||
for i, sl in enumerate(objs):
|
||||
if sizes[i] < 0.002 * H * W:
|
||||
continue
|
||||
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]
|
||||
row = sorted((sl[1].start, i + 1, sl[1].stop, sl[0].start, sl[0].stop) for i, sl in enumerate(objs)
|
||||
if sizes[i] >= 0.002 * H * W and sl[0].start < row_mid < sl[0].stop)
|
||||
right = [l for l in row if l[0] > hx0]
|
||||
u = [l for l in row if l[2] < hx0 + 5][-1]
|
||||
t2, e = right[0], right[1]
|
||||
u = left[-1]
|
||||
# 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})")
|
||||
print("U", u[0], u[2], "T2", t2[0], t2[2], "E", e[0], e[2])
|
||||
|
||||
t2mask = lab == t2[1]
|
||||
newT = np.zeros_like(t2mask)
|
||||
if dx < 0:
|
||||
newT[:, :W + dx] = t2mask[:, -dx:]
|
||||
# outline thickness: distance from the T2 white to the transparent outside, measured across its stem's left side
|
||||
dist_out = nd.distance_transform_edt(~solid)
|
||||
outline = int(np.percentile(nd.distance_transform_edt(~t2mask)[(solid) & (~white) & (nd.binary_dilation(t2mask, iterations=40)) & (~nd.binary_dilation(t2mask, iterations=3))], 95))
|
||||
outline = max(8, min(outline, 60))
|
||||
print("outline px", outline)
|
||||
# every letter of the logo, minus the scythe's pale blade (a white blob sitting between U and T2)
|
||||
letters = np.zeros_like(white)
|
||||
for i, sl in enumerate(objs):
|
||||
if sizes[i] < 0.0005 * H * W:
|
||||
continue
|
||||
x0, x1 = sl[1].start, sl[1].stop
|
||||
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]):
|
||||
continue
|
||||
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
|
||||
box = np.zeros_like(solid)
|
||||
box[max(0, hy0 - 15):hy1 + 15, u[2] - 10:t2[0] + 30] = True
|
||||
scythe = box & solid & ~dark & ~np.isin(lab, [u[1], t2[1]])
|
||||
scythe = nd.binary_dilation(scythe, iterations=3) & solid & box & ~np.isin(lab, [u[1], t2[1]])
|
||||
big = np.isin(lab, [l[1] for l in letters])
|
||||
# outline thickness: how far the dark band reaches past the letters on the logo's outer edge, away from the scythe
|
||||
d_let = nd.distance_transform_edt(~letters)
|
||||
edge = solid & ~nd.binary_erosion(solid)
|
||||
far = np.ones_like(solid)
|
||||
far[:, u[0]:e[2]] = False
|
||||
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()
|
||||
# what the outline of everything else covers stays dark, the rest of the scythe goes transparent
|
||||
keep_dark = nd.distance_transform_edt(~(white & ~scythe)) <= outline + 1
|
||||
ring = nd.distance_transform_edt(~newT) <= outline
|
||||
dark_col = np.median(im[dark & ~scythe][:, :3], axis=0).astype(np.int32)
|
||||
clear = scythe & ~keep_dark & ~ring
|
||||
out[clear] = 0
|
||||
# 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 = box & (a < 250) & nd.binary_fill_holes(solid | ring)
|
||||
# inside the box every solid pixel off the letters (and their soft edges) becomes plain outline: no ghost of the handle's edge
|
||||
letters_soft = nd.binary_dilation(np.isin(lab, [u[1], t2[1]]), iterations=1) | nd.binary_dilation(newT, iterations=2)
|
||||
fill = (scythe & (keep_dark | ring)) | (ring & ~solid) | pocket | (box & (solid | ring) & ~letters_soft & (keep_dark | ring))
|
||||
out[fill, :3] = dark_col
|
||||
out[fill, 3] = 255
|
||||
# the letter itself: the T2 pixels copied across with their shading
|
||||
for c in range(4):
|
||||
plane = out[..., c]
|
||||
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)
|
||||
band = R & ~nd.binary_dilation(keep, iterations=2)
|
||||
cov = np.clip(outline + 0.5 - d, 0.0, 1.0) # outline coverage with a soft 1 px outer edge
|
||||
out[band, :3] = dark_col
|
||||
# never less than the logo already covered there (rows close together share one dark mass)
|
||||
out[band, 3] = np.maximum(cov[band] * 255, a[band])
|
||||
# a pocket the old handle left between the two stems, now walled in: fill it
|
||||
pocket = band & nd.binary_fill_holes(out[..., 3] > 128) & (out[..., 3] < 255)
|
||||
out[pocket, 3] = 255
|
||||
for mask, pix in ((sym, px), (newT, newpx)):
|
||||
soft = nd.binary_dilation(mask, iterations=2) & R
|
||||
al = pix[soft, 3:4] / 255.0
|
||||
# the copied pixels carry their own anti-aliased edge over the dark outline
|
||||
out[soft, :3] = pix[soft, :3] * al + dark_col * (1 - al)
|
||||
out[soft, 3] = 255
|
||||
res = Image.fromarray(out.clip(0, 255).astype(np.uint8))
|
||||
res.save(dst)
|
||||
if len(sys.argv) > 3:
|
||||
prev = Image.new("RGBA", (W, H), (40, 60, 80, 255))
|
||||
prev.alpha_composite(Image.fromarray(out.clip(0, 255).astype(np.uint8)))
|
||||
prev = Image.new("RGBA", (W, H), (90, 160, 60, 255))
|
||||
prev.alpha_composite(res)
|
||||
prev.convert("RGB").save(sys.argv[3])
|
||||
print("saved", dst)
|
||||
|
||||
Reference in New Issue
Block a user