|
1 |
| -from algorithm_visualizer import Tracer |
| 1 | +from typing import List |
| 2 | + |
| 3 | +from algorithm_visualizer import Tracer, _Serializable |
2 | 4 |
|
3 | 5 | class Array2DTracer(Tracer):
|
4 |
| - pass |
| 6 | + def set(self, array2d: List[List[_Serializable]] = None): |
| 7 | + if array2d is None: |
| 8 | + array2d = [] |
| 9 | + self.command("set", array2d) |
| 10 | + |
| 11 | + def patch(self, x: int, y: int, v: _Serializable = None): |
| 12 | + self.command("patch", x, y, v) |
| 13 | + |
| 14 | + def depatch(self, x: int, y: int): |
| 15 | + self.command("depatch", x, y) |
| 16 | + |
| 17 | + def select(self, sx: int, sy: int, ex: int = None, ey: int = None): |
| 18 | + if ex is None: |
| 19 | + ex = sx |
| 20 | + if ey is None: |
| 21 | + ey = sy |
| 22 | + self.command("select", sx, sy, ex, ey) |
| 23 | + |
| 24 | + def selectRow(self, x: int, sy: int, ey: int): |
| 25 | + self.command("selectRow", x, sy, ey) |
| 26 | + |
| 27 | + def selectCol(self, y: int, sx: int, ex: int): |
| 28 | + self.command("selectCol", y, sx, ex) |
| 29 | + |
| 30 | + def deselect(self, sx: int, sy: int, ex: int = None, ey: int = None): |
| 31 | + if ex is None: |
| 32 | + ex = sx |
| 33 | + if ey is None: |
| 34 | + ey = sy |
| 35 | + self.command("deselect", sx, sy, ex, ey) |
| 36 | + |
| 37 | + def deselectRow(self, x: int, sy: int, ey: int): |
| 38 | + self.command("deselectRow", x, sy, ey) |
| 39 | + |
| 40 | + def deselectCol(self, y: int, sx: int, ex: int): |
| 41 | + self.command("deselectCol", y, sx, ex) |
0 commit comments