Collapse portal under src/, unify pnpm workspace/scripts, thin VIP topic re-exports, drop orphan vip scaffolds and one-shot scripts, ignore xhs/release, document root commands. Co-authored-by: Cursor <cursoragent@cursor.com>
91 lines
3.0 KiB
Python
91 lines
3.0 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""Generate solid-red nomadro store icons (WeChat / Douyin / XHS)."""
|
|
from pathlib import Path
|
|
from PIL import Image, ImageDraw
|
|
|
|
OUT = Path(__file__).resolve().parent
|
|
RED = (225, 29, 46) # #e11d2e
|
|
RED_SOFT = (255, 70, 70)
|
|
BG = (12, 12, 15) # #0c0c0f
|
|
|
|
|
|
def make_icon(size: int = 1024) -> Image.Image:
|
|
img = Image.new("RGB", (size, size), BG)
|
|
d = ImageDraw.Draw(img)
|
|
cx = cy = size / 2
|
|
|
|
for r in range(int(size * 0.42), int(size * 0.18), -3):
|
|
t = (r - size * 0.18) / (size * 0.24)
|
|
a = int(28 * t)
|
|
col = (BG[0] + a, BG[1], BG[2] + a // 4)
|
|
d.ellipse([cx - r, cy - r, cx + r, cy + r], fill=col)
|
|
|
|
ring_w = max(10, size // 22)
|
|
r_out = size * 0.38
|
|
d.ellipse([cx - r_out, cy - r_out, cx + r_out, cy + r_out], outline=RED, width=ring_w)
|
|
|
|
stroke = max(8, size // 28)
|
|
|
|
def pt(ux: float, uy: float):
|
|
return (cx + ux * r_out * 0.72, cy + uy * r_out * 0.72)
|
|
|
|
# stylized trail / abstract "n" — matches in-app red mark
|
|
pts = [
|
|
pt(-0.55, 0.45),
|
|
pt(-0.50, -0.15),
|
|
pt(-0.35, -0.45),
|
|
pt(-0.05, -0.35),
|
|
pt(0.15, 0.05),
|
|
pt(0.35, 0.40),
|
|
pt(0.55, 0.20),
|
|
pt(0.58, -0.25),
|
|
]
|
|
for i in range(len(pts) - 1):
|
|
x0, y0 = pts[i]
|
|
x1, y1 = pts[i + 1]
|
|
for s in range(25):
|
|
t = s / 24
|
|
x = x0 + (x1 - x0) * t
|
|
y = y0 + (y1 - y0) * t
|
|
rr = stroke / 2
|
|
d.ellipse([x - rr, y - rr, x + rr, y + rr], fill=RED)
|
|
|
|
sat = max(8, size // 20)
|
|
sx = cx + r_out * 0.72
|
|
sy = cy - r_out * 0.55
|
|
d.ellipse([sx - sat, sy - sat, sx + sat, sy + sat], fill=RED_SOFT)
|
|
return img
|
|
|
|
|
|
def main() -> None:
|
|
icon = make_icon(1024)
|
|
icon.save(OUT / "icon-1024.png", "PNG", optimize=True)
|
|
for s in (512, 256, 144):
|
|
icon.resize((s, s), Image.Resampling.LANCZOS).save(OUT / f"icon-{s}.png", "PNG", optimize=True)
|
|
icon.save(OUT / "icon-1024.jpg", "JPEG", quality=94, optimize=True)
|
|
icon.resize((512, 512), Image.Resampling.LANCZOS).save(OUT / "icon-512.jpg", "JPEG", quality=94, optimize=True)
|
|
icon.resize((192, 192), Image.Resampling.LANCZOS).save(OUT / "icon-192.webp", "WEBP", quality=90)
|
|
|
|
(OUT / "icon-nomadro-red.svg").write_text(
|
|
"""<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" fill="none">
|
|
<rect width="1024" height="1024" fill="#0c0c0f"/>
|
|
<circle cx="512" cy="512" r="389" stroke="#e11d2e" stroke-width="46"/>
|
|
<path d="M300 650 C320 420 380 280 470 320 C540 350 580 480 650 620 C700 540 720 400 740 360"
|
|
stroke="#e11d2e" stroke-width="40" stroke-linecap="round" stroke-linejoin="round" fill="none"/>
|
|
<circle cx="790" cy="300" r="42" fill="#ff4646"/>
|
|
</svg>
|
|
""",
|
|
encoding="utf-8",
|
|
)
|
|
|
|
for p in sorted(OUT.glob("icon-*")):
|
|
if p.suffix == ".svg":
|
|
print(p.name, p.stat().st_size)
|
|
else:
|
|
im = Image.open(p)
|
|
print(f"{p.name}\t{im.size}\t{p.stat().st_size}")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|