Initial Renamr scaffold: Tauri (Rust core + React/TS UI), naming-expression engine ported+tested
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Generates Renamr's app icon set (placeholder branding, easy to swap later).
|
||||
|
||||
Produces the sizes Tauri's bundler expects in src-tauri/icons/.
|
||||
"""
|
||||
from PIL import Image, ImageDraw, ImageFont
|
||||
import os
|
||||
|
||||
OUT = os.path.join(os.path.dirname(__file__), "..", "src-tauri", "icons")
|
||||
os.makedirs(OUT, exist_ok=True)
|
||||
|
||||
SIZE = 1024
|
||||
BG_TOP = (91, 76, 245) # indigo
|
||||
BG_BOTTOM = (56, 189, 178) # teal
|
||||
FG = (255, 255, 255)
|
||||
|
||||
def make_master():
|
||||
img = Image.new("RGB", (SIZE, SIZE), BG_TOP)
|
||||
px = img.load()
|
||||
for y in range(SIZE):
|
||||
t = y / SIZE
|
||||
r = int(BG_TOP[0] * (1 - t) + BG_BOTTOM[0] * t)
|
||||
g = int(BG_TOP[1] * (1 - t) + BG_BOTTOM[1] * t)
|
||||
b = int(BG_TOP[2] * (1 - t) + BG_BOTTOM[2] * t)
|
||||
for x in range(SIZE):
|
||||
px[x, y] = (r, g, b)
|
||||
|
||||
# rounded-square mask
|
||||
mask = Image.new("L", (SIZE, SIZE), 0)
|
||||
ImageDraw.Draw(mask).rounded_rectangle([0, 0, SIZE - 1, SIZE - 1], radius=SIZE // 5, fill=255)
|
||||
canvas = Image.new("RGBA", (SIZE, SIZE), (0, 0, 0, 0))
|
||||
canvas.paste(img, (0, 0), mask)
|
||||
|
||||
draw = ImageDraw.Draw(canvas)
|
||||
font = ImageFont.truetype("/usr/share/fonts/truetype/google-fonts/Poppins-Bold.ttf", int(SIZE * 0.56))
|
||||
text = "R"
|
||||
bbox = draw.textbbox((0, 0), text, font=font)
|
||||
tw, th = bbox[2] - bbox[0], bbox[3] - bbox[1]
|
||||
draw.text(((SIZE - tw) / 2 - bbox[0], (SIZE - th) / 2 - bbox[1] - SIZE * 0.02), text, font=font, fill=FG)
|
||||
|
||||
return canvas
|
||||
|
||||
master = make_master()
|
||||
master.save(os.path.join(OUT, "icon-master.png"))
|
||||
|
||||
sizes = [32, 128, 256, 512, 1024]
|
||||
for s in sizes:
|
||||
master.resize((s, s), Image.LANCZOS).save(os.path.join(OUT, f"{s}x{s}.png"))
|
||||
|
||||
# Tauri's expected filenames
|
||||
master.resize((32, 32), Image.LANCZOS).save(os.path.join(OUT, "32x32.png"))
|
||||
master.resize((128, 128), Image.LANCZOS).save(os.path.join(OUT, "128x128.png"))
|
||||
master.resize((256, 256), Image.LANCZOS).save(os.path.join(OUT, "[email protected]"))
|
||||
|
||||
# Windows .ico (multi-resolution)
|
||||
ico_sizes = [(16, 16), (24, 24), (32, 32), (48, 48), (64, 64), (128, 128), (256, 256)]
|
||||
master.save(os.path.join(OUT, "icon.ico"), sizes=ico_sizes)
|
||||
|
||||
# macOS .icns
|
||||
try:
|
||||
master.save(os.path.join(OUT, "icon.icns"), format="ICNS")
|
||||
except Exception as e:
|
||||
print(f"WARN: could not write icon.icns via Pillow ({e}); leaving it out")
|
||||
|
||||
print("done:", os.listdir(OUT))
|
||||
Reference in New Issue
Block a user