- Expo SDK 57 / React Native 0.86 / TypeScript strict - ESLint (expo config), Prettier, jest-expo setup - app identifiers org.giteanative.app, deep-link scheme giteanative - original git-branch app icons generated from scratch (scripts/generate-icons.py) - MIT licence for the Gitea Native contributors (unofficial project)
75 lines
2.1 KiB
Python
75 lines
2.1 KiB
Python
#!/usr/bin/env python3
|
|
"""Generate Gitea Native's original app icons.
|
|
|
|
The mark is a simple git-branch glyph (trunk + branch + three nodes) drawn on
|
|
the brand green. Everything here is generated from scratch — no template assets.
|
|
"""
|
|
|
|
from PIL import Image, ImageDraw
|
|
|
|
GREEN = (96, 153, 38, 255)
|
|
WHITE = (255, 255, 255, 255)
|
|
TRANSPARENT = (0, 0, 0, 0)
|
|
|
|
OUT = "assets/images"
|
|
|
|
|
|
def mark_layer(size: int, color, margin: float, width_ratio: float = 0.10) -> Image.Image:
|
|
img = Image.new("RGBA", (size, size), TRANSPARENT)
|
|
d = ImageDraw.Draw(img)
|
|
m = size * margin
|
|
box = size - 2 * m
|
|
|
|
def p(x, y):
|
|
return (m + x * box, m + y * box)
|
|
|
|
lw = max(2, int(box * width_ratio))
|
|
trunk_top = p(0.36, 0.18)
|
|
trunk_bottom = p(0.36, 0.82)
|
|
branch_top = p(0.66, 0.18)
|
|
branch_mid = p(0.66, 0.50)
|
|
branch_join = p(0.36, 0.62)
|
|
|
|
d.line([trunk_top, trunk_bottom], fill=color, width=lw)
|
|
d.line([branch_top, branch_mid, branch_join], fill=color, width=lw, joint="curve")
|
|
|
|
r = box * 0.085
|
|
for cx, cy in [(0.36, 0.18), (0.66, 0.18), (0.36, 0.82)]:
|
|
x, y = p(cx, cy)
|
|
d.ellipse([x - r, y - r, x + r, y + r], fill=color)
|
|
|
|
return img
|
|
|
|
|
|
def solid(size: int, color) -> Image.Image:
|
|
return Image.new("RGBA", (size, size), color)
|
|
|
|
|
|
def save(img: Image.Image, name: str):
|
|
img.save(f"{OUT}/{name}", "PNG")
|
|
print("wrote", f"{OUT}/{name}", img.size)
|
|
|
|
|
|
def main():
|
|
# Full-bleed marketing / iOS / favicon icon: white glyph on green.
|
|
icon = solid(1024, GREEN)
|
|
icon.alpha_composite(mark_layer(1024, WHITE, margin=0.24))
|
|
save(icon, "icon.png")
|
|
|
|
# Android adaptive icon layers.
|
|
save(mark_layer(1024, WHITE, margin=0.30), "android-icon-foreground.png")
|
|
save(solid(1024, GREEN), "android-icon-background.png")
|
|
save(mark_layer(1024, WHITE, margin=0.30), "android-icon-monochrome.png")
|
|
|
|
# Splash: green glyph on the dark splash background.
|
|
save(mark_layer(512, GREEN, margin=0.14), "splash-icon.png")
|
|
|
|
# Web favicon: white glyph on green.
|
|
favicon = solid(64, GREEN)
|
|
favicon.alpha_composite(mark_layer(64, WHITE, margin=0.24))
|
|
save(favicon, "favicon.png")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|