Files
pipelines/app/tool/app_icon/make_icon.py
T
alan d300fdc5a5 New app icon: a pipeline graph instead of the P
One stage forks into two parallel stages that rejoin in a finished ring, in
the app's palette on the dark background. Updates the Android adaptive,
themed and legacy launcher icons, the status-bar icon, the iOS icon set and
the web favicon and PWA icons, and adds the generator under tool/app_icon.
2026-11-01 18:02:34 +00:00

78 lines
3.9 KiB
Python

"""Generates the Pipelines mark as SVG variants and the Android vector drawables."""
import sys, os
OUT = sys.argv[1]
def graph(color=True, mono='#FFFFFF'):
c = (lambda v: v) if color else (lambda v: mono)
return f'''<g fill="none" stroke-width="3.6" stroke-linecap="round">
<path d="M17 32 C24 32 24 21 31 21" stroke="{c('#8FA8FF')}"/>
<path d="M17 32 C24 32 24 43 31 43" stroke="{c('#8FA8FF')}"/>
<path d="M33 21 C39.5 21 39.5 32 43.6 32" stroke="{c('#5FD3B8')}"/>
<path d="M33 43 C39.5 43 39.5 32 43.6 32" stroke="{c('#C59BFF')}"/>
</g>
<circle cx="15" cy="32" r="6" fill="{c('#8FA8FF')}"/>
<circle cx="32" cy="21" r="5.2" fill="{c('#5FD3B8')}"/>
<circle cx="32" cy="43" r="5.2" fill="{c('#C59BFF')}"/>
<circle cx="49" cy="32" r="4.3" fill="none" stroke="{c('#7BE39B')}" stroke-width="3.4"/>'''
def svg(scale=1.12, rounded=True, background=True, color=True):
bg = ''
if background:
rx = ' rx="14"' if rounded else ''
bg = f'''<defs><linearGradient id="bg" x1="0" y1="0" x2="1" y2="1"><stop offset="0" stop-color="#1B1B24"/><stop offset="1" stop-color="#0E0E12"/></linearGradient></defs>
<rect width="64" height="64"{rx} fill="url(#bg)"/>'''
t = f'translate(32 32) scale({scale}) translate(-32 -32)'
return f'''<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" role="img" aria-label="Pipelines">
{bg}
<g transform="{t}">
{graph(color)}
</g>
</svg>
'''
variants = {
'rounded.svg': svg(), # favicon, web icons, legacy Android
'square.svg': svg(rounded=False), # iOS (the OS masks corners)
'maskable.svg': svg(scale=0.92, rounded=False), # PWA maskable: inside the 80% safe circle
}
for name, body in variants.items():
open(os.path.join(OUT, name), 'w').write(body)
# Android vectors share one path set. The 64-unit graph is placed in the 108dp
# adaptive canvas inside the 66dp safe zone (scale 66/64*0.92 about the centre).
def vector(color=True, size=108, scale=None, comment=''):
s = scale if scale is not None else (66 / 64) * 1.12
tx = size / 2 - 32 * s
def col(v): return v if color else '#FFFFFFFF'
def stroke(d, colr, w=3.6):
return f''' <path android:pathData="{d}" android:fillColor="#00000000" android:strokeColor="{col(colr)}" android:strokeWidth="{w}" android:strokeLineCap="round"/>'''
def dot(cx, cy, r, colr):
d = f'M{cx - r},{cy}a{r},{r} 0,1 0,{2 * r},0a{r},{r} 0,1 0,{-2 * r},0'
return f''' <path android:pathData="{d}" android:fillColor="{col(colr)}"/>'''
ring = 'M49,32m-4.3,0a4.3,4.3 0,1 0,8.6,0a4.3,4.3 0,1 0,-8.6,0'
return f'''<?xml version="1.0" encoding="utf-8"?>
<!-- {comment} Generated from the Pipelines mark (64-unit grid). -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="{size}dp"
android:height="{size}dp"
android:viewportWidth="{size}"
android:viewportHeight="{size}">
<group android:scaleX="{s:.4f}" android:scaleY="{s:.4f}" android:translateX="{tx:.3f}" android:translateY="{tx:.3f}">
{stroke('M17,32 C24,32 24,21 31,21', '#FF8FA8FF')}
{stroke('M17,32 C24,32 24,43 31,43', '#FF8FA8FF')}
{stroke('M33,21 C39.5,21 39.5,32 43.6,32', '#FF5FD3B8')}
{stroke('M33,43 C39.5,43 39.5,32 43.6,32', '#FFC59BFF')}
{dot(15, 32, 6, '#FF8FA8FF')}
{dot(32, 21, 5.2, '#FF5FD3B8')}
{dot(32, 43, 5.2, '#FFC59BFF')}
{stroke(ring, '#FF7BE39B', 3.4)}
</group>
</vector>
'''
open(os.path.join(OUT, 'ic_launcher_foreground.xml'), 'w').write(vector(comment='Adaptive icon foreground: the graph in the 66dp safe zone.'))
open(os.path.join(OUT, 'ic_launcher_monochrome.xml'), 'w').write(vector(color=False, comment='Themed (monochrome) icon: the same graph in one colour.'))
# Notification small icon: 24dp, white, the graph filling most of the canvas.
open(os.path.join(OUT, 'ic_stat_pipelines.xml'), 'w').write(vector(color=False, size=24, scale=24 / 64 * 1.12, comment='Status bar icon (white; Android tints it).'))
print('ok')