From b61dc0efa8fd8304cd7ed0e1b449a1ee156397ad Mon Sep 17 00:00:00 2001 From: hkc Date: Thu, 4 Jul 2024 17:17:23 +0300 Subject: [PATCH] Added rectangle tool --- async-bot.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/async-bot.py b/async-bot.py index b64ba83..4b337be 100644 --- a/async-bot.py +++ b/async-bot.py @@ -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")