add color to put block

This commit is contained in:
2026-03-30 15:47:39 +02:00
parent 56ebb2823a
commit b2aa93e04d
+13 -6
View File
@@ -81,9 +81,16 @@ class MazeMLX:
for y in range(min(sy, ey), max(sy, ey) + 1): for y in range(min(sy, ey), max(sy, ey) + 1):
self.put_pixel(sx, y, color) self.put_pixel(sx, y, color)
def put_block(self, ul: tuple[int, int], dr: tuple[int, int]) -> None: def put_block(
self,
ul: tuple[int, int],
dr: tuple[int, int],
color: list | None = None,
) -> None:
for y in range(min(ul[1], dr[1]), max(dr[1], ul[1])): for y in range(min(ul[1], dr[1]), max(dr[1], ul[1])):
self.put_line((min(ul[0], dr[0]), y), (max(ul[0], dr[0]), y)) self.put_line(
(min(ul[0], dr[0]), y), (max(ul[0], dr[0]), y), color
)
@staticmethod @staticmethod
def random_color_ft() -> Any: def random_color_ft() -> Any:
@@ -217,12 +224,12 @@ class MazeMLX:
margin_y = (self.height - maze_height) // 2 margin_y = (self.height - maze_height) // 2
ul = ( ul = (
(entry[0]) * line_len + margin_x + 3, (entry[0] - 1) * line_len + margin_x + 3,
(entry[1]) * line_len + 3 + margin_y, (entry[1] - 1) * line_len + 3 + margin_y,
) )
dr = ( dr = (
(entry[0]) * line_len + line_len + margin_x - 3, (entry[0] - 1) * line_len + line_len + margin_x - 3,
(entry[1]) * line_len + line_len - 3 + margin_y, (entry[1] - 1) * line_len + line_len - 3 + margin_y,
) )
print(f"ul: {ul}; dr: {dr}") print(f"ul: {ul}; dr: {dr}")
self.put_block(ul, dr) self.put_block(ul, dr)