from pathlib import Path
out=Path('generated-svg-fixtures');out.mkdir(exist_ok=True)
def save(n,s): (out/n).write_text(s+'\n',encoding='utf8',newline='\n')
def svg(attrs,body): return '<svg xmlns="http://www.w3.org/2000/svg" '+attrs+'>'+body+'</svg>'
art='<rect width="100" height="100" fill="#38b2a0"/><circle cx="50" cy="50" r="30" fill="#ffbd8d"/>'
save('letterbox-meet.svg',svg('width="320" height="200" viewBox="0 0 100 100"',art))
save('letterbox-none.svg',svg('width="320" height="200" viewBox="0 0 100 100" preserveAspectRatio="none"',art))
bands='<rect x="80" width="80" height="120" fill="#2864a8" fill-opacity="0.5"/><rect x="160" width="80" height="120" fill="#2864a8"/>'
save('alpha-bands.svg',svg('width="240" height="120" viewBox="0 0 240 120"',bands))
save('painted-white.svg',svg('width="240" height="120" viewBox="0 0 240 120"','<rect width="240" height="120" fill="white"/>'+bands))
save('viewbox-only.svg',svg('viewBox="0 0 301 199"','<rect width="301" height="199" fill="#38b2a0"/><path d="M0 0L301 199M301 0L0 199" stroke="#ffbd8d" stroke-width="7"/>'))
save('gradient-lines.svg',svg('width="400" height="160" viewBox="0 0 400 160"','<defs><linearGradient id="g"><stop stop-color="#163a6b"/><stop offset="1" stop-color="#38b2a0"/></linearGradient></defs><rect width="400" height="160" fill="url(#g)"/>'+''.join(f'<path d="M{x} 20V140" stroke="#ffbd8d" stroke-width="1"/>' for x in range(30,381,10))))
save('style-rejected.svg',svg('width="20" height="20"','<rect width="20" height="20" style="fill:red"/>'))
save('linked-image.svg',svg('width="20" height="20"','<image href="https://example.invalid/image.png" width="20" height="20"/>'))
save('malformed.svg','<svg xmlns="http://www.w3.org/2000/svg"><rect></svg>')
save('over-dimension.svg',svg('width="4097" height="1"','<rect width="4097" height="1" fill="red"/>'))
print('Generated',len(list(out.iterdir())),'original SVG inputs; no external images/fonts.')
