#!/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''' {greenbar(318, 250, 388, 200, rot=0)} {greenbar(300, 612, 424, 160, rot=0)} {"".join(f'' for y in (639, 651, 663) for x in range(364, 662, 12) if ((x-364)//12) % 7 != 6)} {"".join(f'' for y in (719, 731, 743) for x in range(364, 662, 12) if ((x-364)//12) % 7 != 6)} ''' 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")