Added rectangle tool

This commit is contained in:
Casey 2024-07-04 17:17:23 +03:00
parent 7889d58170
commit b61dc0efa8
Signed by: hkc
GPG Key ID: F0F6CFE11CDB0960
1 changed files with 7 additions and 0 deletions

View File

@ -39,6 +39,9 @@ class AsyncBotManager:
if a:
self.put_index(index, l > 0)
def put_pixel(self, x: int, y: int, val: bool):
self.put_index(x + y * 1000, val)
def put_index(self, index: int, value: bool):
if not index in self.avoid:
self.difference[index] = value
@ -186,6 +189,10 @@ async def amain():
mgr.put_index(
ndx_start + i, ((color >> i) & 1) > 0
)
elif elem["type"] == "rect":
for y in range(elem["y"], elem["y"] + elem["h"]):
for x in range(elem["x"], elem["x"] + elem["w"]):
mgr.put_pixel(x, y, elem["fill"])
mgr.get_difference_image().save("result.png")
mgr.get_avoid_image().save("avoid.png")