with canvas inside
This commit is contained in:
1 parent
b4f3415165
commit
d700dd52f0
2 files changed
+9
-8
No files matched your search
@@ -149,9 +149,9 @@ class BadukPanWidget(Widget):
|
||||
return
|
||||
katrain = self.katrain
|
||||
board_size_x, board_size_y = katrain.game.board_size
|
||||
max_board_size = max(board_size_x, board_size_y)
|
||||
self.canvas.before.clear()
|
||||
|
||||
with self.canvas.before:
|
||||
self.canvas.before.clear()
|
||||
# set up margins and grid lines
|
||||
grid_spaces_margin_x = [1.5, 0.75] # left, right
|
||||
grid_spaces_margin_y = [1.5, 0.75] # bottom, top
|
||||
@@ -226,8 +226,8 @@ class BadukPanWidget(Widget):
|
||||
board_size_x, board_size_y = katrain.game.board_size
|
||||
show_n_eval = self.trainer_config["eval_off_show_last"]
|
||||
|
||||
self.canvas.clear()
|
||||
with self.canvas:
|
||||
self.canvas.clear()
|
||||
# stones
|
||||
current_node = katrain.game.current_node
|
||||
game_ended = katrain.game.ended
|
||||
@@ -354,8 +354,8 @@ class BadukPanWidget(Widget):
|
||||
player, next_player = current_node.player, current_node.next_player
|
||||
stone_color = STONE_COLORS
|
||||
|
||||
self.canvas.after.clear()
|
||||
with self.canvas.after:
|
||||
self.canvas.after.clear()
|
||||
self.active_pv_moves = []
|
||||
|
||||
# children of current moves in undo / review
|
||||
|
||||
@@ -49,7 +49,7 @@ class MoveTreeCanvas(Widget):
|
||||
move_pos = {root: (0, 0)}
|
||||
stack = GameNode.order_children(root.children)[::-1]
|
||||
next_y_pos = defaultdict(int) # x pos -> max y pos
|
||||
|
||||
children = defaultdict(list) # since AI self-play etc may modify the tree between layout and draw!
|
||||
while stack:
|
||||
move = stack.pop()
|
||||
x = move.depth
|
||||
@@ -57,7 +57,8 @@ class MoveTreeCanvas(Widget):
|
||||
next_y_pos[x] = y + 1
|
||||
next_y_pos[x - 1] = max(next_y_pos[x], next_y_pos[x - 1])
|
||||
move_pos[move] = (x, y)
|
||||
for c in GameNode.order_children(move.children)[::-1]: # stack, so push top child last to process first
|
||||
children[move] = GameNode.order_children(move.children)
|
||||
for c in children[move][::-1]: # stack, so push top child last to process first
|
||||
stack.append(c)
|
||||
|
||||
def draw_stone(pos, player):
|
||||
@@ -76,8 +77,8 @@ class MoveTreeCanvas(Widget):
|
||||
|
||||
self.move_xy_pos = {n: xy_pos(x, y) for n, (x, y) in move_pos.items()}
|
||||
|
||||
self.canvas.clear()
|
||||
with self.canvas:
|
||||
self.canvas.clear()
|
||||
Color(*YELLOW)
|
||||
Rectangle(
|
||||
pos=[c - self.move_size / 2 - spacing / 2 for c in self.move_xy_pos[current_node]],
|
||||
@@ -85,7 +86,7 @@ class MoveTreeCanvas(Widget):
|
||||
)
|
||||
Color(*LIGHTGREY)
|
||||
for node, (x, y) in self.move_xy_pos.items():
|
||||
for ci, c in enumerate(GameNode.order_children(node.children)):
|
||||
for ci, c in enumerate(children[node]):
|
||||
cx, cy = self.move_xy_pos[c]
|
||||
Line(points=[x, y, x, cy, cx, cy], width=1)
|
||||
|
||||
|
||||
Reference in new issue
Block a user