Upload gen_icon.py with huggingface_hub
Browse files- gen_icon.py +93 -0
gen_icon.py
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Generate project icon for Lumia Tiny."""
|
| 2 |
+
from PIL import Image, ImageDraw, ImageFont
|
| 3 |
+
import os, math
|
| 4 |
+
|
| 5 |
+
SIZE = 512
|
| 6 |
+
img = Image.new("RGB", (SIZE, SIZE), "#0d1117")
|
| 7 |
+
draw = ImageDraw.Draw(img)
|
| 8 |
+
|
| 9 |
+
# Background gradient circle
|
| 10 |
+
cx, cy = SIZE // 2, SIZE // 2
|
| 11 |
+
for y in range(SIZE):
|
| 12 |
+
for x in range(SIZE):
|
| 13 |
+
dx, dy = x - cx, y - cy
|
| 14 |
+
dist = math.sqrt(dx*dx + dy*dy)
|
| 15 |
+
if dist < 230:
|
| 16 |
+
t = dist / 230
|
| 17 |
+
r = int(15 + t * 30)
|
| 18 |
+
g = int(20 + t * 40)
|
| 19 |
+
b = int(35 + t * 50)
|
| 20 |
+
img.putpixel((x, y), (r, g, b))
|
| 21 |
+
|
| 22 |
+
# Outer ring
|
| 23 |
+
for angle in range(360):
|
| 24 |
+
rad = math.radians(angle)
|
| 25 |
+
for r in range(218, 225):
|
| 26 |
+
x = int(cx + r * math.cos(rad))
|
| 27 |
+
y = int(cy + r * math.sin(rad))
|
| 28 |
+
if 0 <= x < SIZE and 0 <= y < SIZE:
|
| 29 |
+
t = (angle % 60) / 60
|
| 30 |
+
cr = int(88 + t * 40)
|
| 31 |
+
cg = int(166 - t * 80)
|
| 32 |
+
cb = int(255 - t * 100)
|
| 33 |
+
img.putpixel((x, y), (cr, cg, cb))
|
| 34 |
+
|
| 35 |
+
# Inner glow circle
|
| 36 |
+
for angle in range(360):
|
| 37 |
+
rad = math.radians(angle)
|
| 38 |
+
for r in range(180, 185):
|
| 39 |
+
x = int(cx + r * math.cos(rad))
|
| 40 |
+
y = int(cy + r * math.sin(rad))
|
| 41 |
+
if 0 <= x < SIZE and 0 <= y < SIZE:
|
| 42 |
+
img.putpixel((x, y), (48, 54, 61))
|
| 43 |
+
|
| 44 |
+
# Neural network nodes (representing layers)
|
| 45 |
+
nodes = [
|
| 46 |
+
# Input layer (left)
|
| 47 |
+
(120, 160), (120, 220), (120, 280), (120, 340),
|
| 48 |
+
# Hidden layer 1
|
| 49 |
+
(220, 140), (220, 200), (220, 260), (220, 320), (220, 380),
|
| 50 |
+
# Hidden layer 2 (center)
|
| 51 |
+
(320, 120), (320, 190), (320, 260), (320, 330), (320, 400),
|
| 52 |
+
# Hidden layer 3
|
| 53 |
+
(420, 160), (420, 220), (420, 280), (420, 340),
|
| 54 |
+
]
|
| 55 |
+
|
| 56 |
+
# Draw connections
|
| 57 |
+
for i, (x1, y1) in enumerate(nodes):
|
| 58 |
+
for j, (x2, y2) in enumerate(nodes):
|
| 59 |
+
if abs(x2 - x1) == 100: # Only connect adjacent layers
|
| 60 |
+
alpha = 0.15
|
| 61 |
+
draw.line([(x1, y1), (x2, y2)], fill=(88, 166, 255, int(alpha * 255)), width=1)
|
| 62 |
+
|
| 63 |
+
# Draw nodes
|
| 64 |
+
for x, y in nodes:
|
| 65 |
+
# Glow
|
| 66 |
+
for r in range(18, 12, -1):
|
| 67 |
+
alpha = int(40 * (1 - (r - 12) / 6))
|
| 68 |
+
draw.ellipse([(x-r, y-r), (x+r, y+r)], fill=(88, 166, 255, alpha))
|
| 69 |
+
# Core
|
| 70 |
+
draw.ellipse([(x-10, y-10), (x+10, y+10)], fill="#58a6ff", outline="#79c0ff", width=2)
|
| 71 |
+
|
| 72 |
+
# "LT" text in center
|
| 73 |
+
try:
|
| 74 |
+
font = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf", 72)
|
| 75 |
+
except:
|
| 76 |
+
font = ImageFont.load_default()
|
| 77 |
+
|
| 78 |
+
# Text with shadow
|
| 79 |
+
draw.text((cx - 48, cy - 85), "LT", fill="#1f6feb", font=font)
|
| 80 |
+
draw.text((cx - 50, cy - 87), "LT", fill="#ffffff", font=font)
|
| 81 |
+
|
| 82 |
+
# Version badge
|
| 83 |
+
draw.rounded_rectangle([(340, 420), (470, 460)], radius=12, fill="#1f6feb")
|
| 84 |
+
try:
|
| 85 |
+
font_sm = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf", 20)
|
| 86 |
+
except:
|
| 87 |
+
font_sm = font
|
| 88 |
+
draw.text((355, 427), "V3 · 969K", fill="#ffffff", font=font_sm)
|
| 89 |
+
|
| 90 |
+
# Save
|
| 91 |
+
out_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), "hf_upload", "icon.png")
|
| 92 |
+
img.save(out_path, "PNG")
|
| 93 |
+
print(f"Saved: {out_path} ({os.path.getsize(out_path):,} bytes)")
|