mirror of
https://git.checksum.fail/alec/svg2GR.git
synced 2026-05-26 05:38:37 +00:00
Operate on rects instead of pixels
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user