#!/usr/bin/env python3
"""CUPS Admin icon — old-school dot-matrix printer with green-bar fanfold paper."""
import cairosvg, os
BG = {
"graphite": ("#5b6470", "#2e343c"),
"slate": ("#6b7a8c", "#3a4655"),
"green": ("#2f8f5b", "#1b5a39"),
"cream": ("#e9e2cf", "#cbbf9f"),
}
def greenbar(x, y, w, h, bar=26, holes=True, rot=0, id_="gb"):
"""A sheet of green-bar paper: alternating pale green / white bands + tractor holes."""
out = [f'']
out.append(f'')
yy = y
i = 0
while yy < y + h:
if i % 2 == 0:
hh = min(bar, y + h - yy)
out.append(f'')
yy += bar; i += 1
if holes:
# tractor-feed strips
for hx in (x + 22, x + w - 22):
out.append(f'')
hy = y + 18
while hy < y + h - 8:
out.append(f'')
hy += 40
out.append('')
return "\n".join(out)
def svg(top, bottom, dark_glyph=False):
body_top, body_bot = ("#f4f6f8", "#d9dee5")
return f''''''
os.makedirs("out2", exist_ok=True)
for name, (top, bottom) in BG.items():
s = svg(top, bottom)
open(f"out2/icon-{name}.svg", "w").write(s)
cairosvg.svg2png(bytestring=s.encode(), write_to=f"out2/icon-{name}-1024.png", output_width=1024, output_height=1024)
cairosvg.svg2png(bytestring=s.encode(), write_to=f"out2/icon-{name}-256.png", output_width=256, output_height=256)
print("done")