Add PNGWriter

* png files are an available output in the CLI
* --svg-square-size is now --square-size
* output type of Writer.write is bytes instead of a string. Just use
  str.decode if string output is needed

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
2024-06-04 21:58:31 -07:00
parent 1758d477a8
commit 88ceb5e2ff
3 changed files with 145 additions and 52 deletions

View File

@@ -1,42 +1,42 @@
<svg width="256" height="160" xmlns="http://www.w3.org/2000/svg">
<rect x="0" y="0" width="32" height="32" fill="hsl(120.00,100.00%,93.33%)" />
<rect x="32" y="0" width="32" height="32" fill="hsl(120.00,100.00%,70.00%)" />
<rect x="64" y="0" width="32" height="32" fill="hsl(120.00,100.00%,53.33%)" />
<rect x="96" y="0" width="32" height="32" fill="hsl(120.00,100.00%,93.33%)" />
<rect x="128" y="0" width="32" height="32" fill="hsl(120.00,100.00%,83.33%)" />
<rect x="160" y="0" width="32" height="32" fill="hsl(120.00,100.00%,50.00%)" />
<rect x="192" y="0" width="32" height="32" fill="hsl(120.00,100.00%,56.67%)" />
<rect x="224" y="0" width="32" height="32" fill="hsl(120.00,100.00%,63.33%)" />
<rect x="0" y="32" width="32" height="32" fill="hsl(120.00,100.00%,90.00%)" />
<rect x="32" y="32" width="32" height="32" fill="hsl(120.00,100.00%,80.00%)" />
<rect x="64" y="32" width="32" height="32" fill="hsl(120.00,100.00%,63.33%)" />
<rect x="96" y="32" width="32" height="32" fill="hsl(120.00,100.00%,93.33%)" />
<rect x="128" y="32" width="32" height="32" fill="hsl(120.00,100.00%,86.67%)" />
<rect x="160" y="32" width="32" height="32" fill="hsl(120.00,100.00%,60.00%)" />
<rect x="192" y="32" width="32" height="32" fill="hsl(120.00,100.00%,96.67%)" />
<rect x="224" y="32" width="32" height="32" fill="hsl(120.00,100.00%,93.33%)" />
<rect x="0" y="64" width="32" height="32" fill="hsl(120.00,100.00%,56.67%)" />
<rect x="32" y="64" width="32" height="32" fill="hsl(120.00,100.00%,63.33%)" />
<rect x="64" y="64" width="32" height="32" fill="hsl(120.00,100.00%,80.00%)" />
<rect x="96" y="64" width="32" height="32" fill="hsl(120.00,100.00%,80.00%)" />
<rect x="128" y="64" width="32" height="32" fill="hsl(120.00,100.00%,56.67%)" />
<rect x="160" y="64" width="32" height="32" fill="hsl(120.00,100.00%,96.67%)" />
<rect x="192" y="64" width="32" height="32" fill="hsl(120.00,100.00%,73.33%)" />
<rect x="224" y="64" width="32" height="32" fill="hsl(120.00,100.00%,53.33%)" />
<rect x="0" y="96" width="32" height="32" fill="hsl(120.00,100.00%,86.67%)" />
<rect x="32" y="96" width="32" height="32" fill="hsl(120.00,100.00%,76.67%)" />
<rect x="64" y="96" width="32" height="32" fill="hsl(120.00,100.00%,90.00%)" />
<rect x="96" y="96" width="32" height="32" fill="hsl(120.00,100.00%,60.00%)" />
<rect x="128" y="96" width="32" height="32" fill="hsl(120.00,100.00%,93.33%)" />
<rect x="160" y="96" width="32" height="32" fill="hsl(120.00,100.00%,80.00%)" />
<rect x="192" y="96" width="32" height="32" fill="hsl(120.00,100.00%,80.00%)" />
<rect x="224" y="96" width="32" height="32" fill="hsl(120.00,100.00%,80.00%)" />
<rect x="0" y="128" width="32" height="32" fill="hsl(120.00,100.00%,100.00%)" />
<rect x="32" y="128" width="32" height="32" fill="hsl(120.00,100.00%,66.67%)" />
<rect x="64" y="128" width="32" height="32" fill="hsl(120.00,100.00%,70.00%)" />
<rect x="96" y="128" width="32" height="32" fill="hsl(120.00,100.00%,70.00%)" />
<rect x="128" y="128" width="32" height="32" fill="hsl(120.00,100.00%,66.67%)" />
<rect x="160" y="128" width="32" height="32" fill="hsl(120.00,100.00%,70.00%)" />
<rect x="192" y="128" width="32" height="32" fill="hsl(120.00,100.00%,83.33%)" />
<rect x="224" y="128" width="32" height="32" fill="hsl(120.00,100.00%,93.33%)" />
<rect x="0" y="0" width="32" height="32" fill="hsl(180.00,100.00%,53.33%)" />
<rect x="32" y="0" width="32" height="32" fill="hsl(180.00,100.00%,73.33%)" />
<rect x="64" y="0" width="32" height="32" fill="hsl(180.00,100.00%,66.67%)" />
<rect x="96" y="0" width="32" height="32" fill="hsl(180.00,100.00%,76.67%)" />
<rect x="128" y="0" width="32" height="32" fill="hsl(180.00,100.00%,93.33%)" />
<rect x="160" y="0" width="32" height="32" fill="hsl(180.00,100.00%,63.33%)" />
<rect x="192" y="0" width="32" height="32" fill="hsl(180.00,100.00%,73.33%)" />
<rect x="224" y="0" width="32" height="32" fill="hsl(180.00,100.00%,73.33%)" />
<rect x="0" y="32" width="32" height="32" fill="hsl(180.00,100.00%,83.33%)" />
<rect x="32" y="32" width="32" height="32" fill="hsl(180.00,100.00%,76.67%)" />
<rect x="64" y="32" width="32" height="32" fill="hsl(180.00,100.00%,66.67%)" />
<rect x="96" y="32" width="32" height="32" fill="hsl(180.00,100.00%,96.67%)" />
<rect x="128" y="32" width="32" height="32" fill="hsl(180.00,100.00%,73.33%)" />
<rect x="160" y="32" width="32" height="32" fill="hsl(180.00,100.00%,86.67%)" />
<rect x="192" y="32" width="32" height="32" fill="hsl(180.00,100.00%,83.33%)" />
<rect x="224" y="32" width="32" height="32" fill="hsl(180.00,100.00%,66.67%)" />
<rect x="0" y="64" width="32" height="32" fill="hsl(180.00,100.00%,66.67%)" />
<rect x="32" y="64" width="32" height="32" fill="hsl(180.00,100.00%,73.33%)" />
<rect x="64" y="64" width="32" height="32" fill="hsl(180.00,100.00%,66.67%)" />
<rect x="96" y="64" width="32" height="32" fill="hsl(180.00,100.00%,63.33%)" />
<rect x="128" y="64" width="32" height="32" fill="hsl(180.00,100.00%,80.00%)" />
<rect x="160" y="64" width="32" height="32" fill="hsl(180.00,100.00%,93.33%)" />
<rect x="192" y="64" width="32" height="32" fill="hsl(180.00,100.00%,60.00%)" />
<rect x="224" y="64" width="32" height="32" fill="hsl(180.00,100.00%,60.00%)" />
<rect x="0" y="96" width="32" height="32" fill="hsl(180.00,100.00%,90.00%)" />
<rect x="32" y="96" width="32" height="32" fill="hsl(180.00,100.00%,96.67%)" />
<rect x="64" y="96" width="32" height="32" fill="hsl(180.00,100.00%,83.33%)" />
<rect x="96" y="96" width="32" height="32" fill="hsl(180.00,100.00%,80.00%)" />
<rect x="128" y="96" width="32" height="32" fill="hsl(180.00,100.00%,83.33%)" />
<rect x="160" y="96" width="32" height="32" fill="hsl(180.00,100.00%,63.33%)" />
<rect x="192" y="96" width="32" height="32" fill="hsl(180.00,100.00%,73.33%)" />
<rect x="224" y="96" width="32" height="32" fill="hsl(180.00,100.00%,50.00%)" />
<rect x="0" y="128" width="32" height="32" fill="hsl(180.00,100.00%,70.00%)" />
<rect x="32" y="128" width="32" height="32" fill="hsl(180.00,100.00%,70.00%)" />
<rect x="64" y="128" width="32" height="32" fill="hsl(180.00,100.00%,90.00%)" />
<rect x="96" y="128" width="32" height="32" fill="hsl(180.00,100.00%,50.00%)" />
<rect x="128" y="128" width="32" height="32" fill="hsl(180.00,100.00%,53.33%)" />
<rect x="160" y="128" width="32" height="32" fill="hsl(180.00,100.00%,86.67%)" />
<rect x="192" y="128" width="32" height="32" fill="hsl(180.00,100.00%,60.00%)" />
<rect x="224" y="128" width="32" height="32" fill="hsl(180.00,100.00%,83.33%)" />
</svg>

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB