Operate on rects instead of pixels

This commit is contained in:
Alec Murphy
2026-04-12 15:57:51 -04:00
parent 92bc4ee529
commit d5218865fb
2 changed files with 10 additions and 5 deletions
+1 -1
View File
@@ -4,7 +4,7 @@ Converts .svg files generated by Aseprite to TempleOS GR format, preserving pale
# Notes
Tested w/ Aseprite v1.2.33-x64
Tested w/ Aseprite v1.3.17-x64
# Usage
+9 -4
View File
@@ -26,20 +26,25 @@ def main():
height = int(get_attr(svg_rows[1], "height"))
width_internal = (width + 7) & (-8);
x = 0
y = 0
color = 0
buffer = bytearray([255]) * (height * width_internal)
i = 2
while i < len(svg_rows) - 1:
x = int(get_attr(svg_rows[i], "x"))
y = int(get_attr(svg_rows[i], "y"))
rw = int(get_attr(svg_rows[i], "width"))
rh = int(get_attr(svg_rows[i], "height"))
if "opacity" in svg_rows[i]:
color = 255
else:
color = color_lookup[get_attr(svg_rows[i], "fill")]
buffer[(y * width_internal) + x] = color
iy = y;
while iy < y + rh:
ix = x
while ix < x + rw:
buffer[(iy * width_internal) + ix] = color
ix += 1
iy += 1
i += 1
f = open(svg_file.replace(".svg",".GR"), "wb")