lumia-tiny / gen_icon.py
samcheng0's picture
Upload gen_icon.py with huggingface_hub
bcf4ea4 verified
Raw
History Blame Contribute Delete
3 kB
"""Generate project icon for Lumia Tiny."""
from PIL import Image, ImageDraw, ImageFont
import os, math
SIZE = 512
img = Image.new("RGB", (SIZE, SIZE), "#0d1117")
draw = ImageDraw.Draw(img)
# Background gradient circle
cx, cy = SIZE // 2, SIZE // 2
for y in range(SIZE):
for x in range(SIZE):
dx, dy = x - cx, y - cy
dist = math.sqrt(dx*dx + dy*dy)
if dist < 230:
t = dist / 230
r = int(15 + t * 30)
g = int(20 + t * 40)
b = int(35 + t * 50)
img.putpixel((x, y), (r, g, b))
# Outer ring
for angle in range(360):
rad = math.radians(angle)
for r in range(218, 225):
x = int(cx + r * math.cos(rad))
y = int(cy + r * math.sin(rad))
if 0 <= x < SIZE and 0 <= y < SIZE:
t = (angle % 60) / 60
cr = int(88 + t * 40)
cg = int(166 - t * 80)
cb = int(255 - t * 100)
img.putpixel((x, y), (cr, cg, cb))
# Inner glow circle
for angle in range(360):
rad = math.radians(angle)
for r in range(180, 185):
x = int(cx + r * math.cos(rad))
y = int(cy + r * math.sin(rad))
if 0 <= x < SIZE and 0 <= y < SIZE:
img.putpixel((x, y), (48, 54, 61))
# Neural network nodes (representing layers)
nodes = [
# Input layer (left)
(120, 160), (120, 220), (120, 280), (120, 340),
# Hidden layer 1
(220, 140), (220, 200), (220, 260), (220, 320), (220, 380),
# Hidden layer 2 (center)
(320, 120), (320, 190), (320, 260), (320, 330), (320, 400),
# Hidden layer 3
(420, 160), (420, 220), (420, 280), (420, 340),
]
# Draw connections
for i, (x1, y1) in enumerate(nodes):
for j, (x2, y2) in enumerate(nodes):
if abs(x2 - x1) == 100: # Only connect adjacent layers
alpha = 0.15
draw.line([(x1, y1), (x2, y2)], fill=(88, 166, 255, int(alpha * 255)), width=1)
# Draw nodes
for x, y in nodes:
# Glow
for r in range(18, 12, -1):
alpha = int(40 * (1 - (r - 12) / 6))
draw.ellipse([(x-r, y-r), (x+r, y+r)], fill=(88, 166, 255, alpha))
# Core
draw.ellipse([(x-10, y-10), (x+10, y+10)], fill="#58a6ff", outline="#79c0ff", width=2)
# "LT" text in center
try:
font = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf", 72)
except:
font = ImageFont.load_default()
# Text with shadow
draw.text((cx - 48, cy - 85), "LT", fill="#1f6feb", font=font)
draw.text((cx - 50, cy - 87), "LT", fill="#ffffff", font=font)
# Version badge
draw.rounded_rectangle([(340, 420), (470, 460)], radius=12, fill="#1f6feb")
try:
font_sm = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf", 20)
except:
font_sm = font
draw.text((355, 427), "V3 · 969K", fill="#ffffff", font=font_sm)
# Save
out_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), "hf_upload", "icon.png")
img.save(out_path, "PNG")
print(f"Saved: {out_path} ({os.path.getsize(out_path):,} bytes)")