manim-chess 0.0.33__tar.gz → 0.0.35__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- {manim_chess-0.0.33 → manim_chess-0.0.35}/PKG-INFO +1 -1
- {manim_chess-0.0.33 → manim_chess-0.0.35}/manim_chess/board.py +22 -21
- {manim_chess-0.0.33 → manim_chess-0.0.35}/pyproject.toml +1 -1
- {manim_chess-0.0.33 → manim_chess-0.0.35}/LICENSE.txt +0 -0
- {manim_chess-0.0.33 → manim_chess-0.0.35}/README.md +0 -0
- {manim_chess-0.0.33 → manim_chess-0.0.35}/manim_chess/__init__.py +0 -0
- {manim_chess-0.0.33 → manim_chess-0.0.35}/manim_chess/evaluation_bar.py +0 -0
- {manim_chess-0.0.33 → manim_chess-0.0.35}/manim_chess/game_player.py +0 -0
- {manim_chess-0.0.33 → manim_chess-0.0.35}/manim_chess/piece_svgs/bB.svg +0 -0
- {manim_chess-0.0.33 → manim_chess-0.0.35}/manim_chess/piece_svgs/bK.svg +0 -0
- {manim_chess-0.0.33 → manim_chess-0.0.35}/manim_chess/piece_svgs/bN.svg +0 -0
- {manim_chess-0.0.33 → manim_chess-0.0.35}/manim_chess/piece_svgs/bP.svg +0 -0
- {manim_chess-0.0.33 → manim_chess-0.0.35}/manim_chess/piece_svgs/bQ.svg +0 -0
- {manim_chess-0.0.33 → manim_chess-0.0.35}/manim_chess/piece_svgs/bR.svg +0 -0
- {manim_chess-0.0.33 → manim_chess-0.0.35}/manim_chess/piece_svgs/wB.svg +0 -0
- {manim_chess-0.0.33 → manim_chess-0.0.35}/manim_chess/piece_svgs/wK.svg +0 -0
- {manim_chess-0.0.33 → manim_chess-0.0.35}/manim_chess/piece_svgs/wN.svg +0 -0
- {manim_chess-0.0.33 → manim_chess-0.0.35}/manim_chess/piece_svgs/wP.svg +0 -0
- {manim_chess-0.0.33 → manim_chess-0.0.35}/manim_chess/piece_svgs/wQ.svg +0 -0
- {manim_chess-0.0.33 → manim_chess-0.0.35}/manim_chess/piece_svgs/wR.svg +0 -0
- {manim_chess-0.0.33 → manim_chess-0.0.35}/manim_chess/pieces.py +0 -0
@@ -21,6 +21,14 @@ class Board(Mobject):
|
|
21
21
|
A list of coordinates of squares that are currently highlighted.
|
22
22
|
arrows : list
|
23
23
|
A list of arrow objects currently drawn on the board.
|
24
|
+
color_dark : ManimColor
|
25
|
+
The manim color of the dark squares
|
26
|
+
color_light : ManimColor
|
27
|
+
The manim color of the light squares
|
28
|
+
color_highlight_light : ManimColor
|
29
|
+
The manim color of the highlight on dark squares
|
30
|
+
color_highlight_dark : ManimColor
|
31
|
+
The manim color of the highlight on light squares
|
24
32
|
|
25
33
|
Methods:
|
26
34
|
-------
|
@@ -66,11 +74,15 @@ class Board(Mobject):
|
|
66
74
|
Returns the piece at a given coordinate, if any.
|
67
75
|
"""
|
68
76
|
|
69
|
-
def __init__(self) -> None:
|
77
|
+
def __init__(self, color_dark='#769656', color_light='#eeeed2', color_highlight_light='#F7F769', color_highlight_dark='#BBCB2B') -> None:
|
70
78
|
"""
|
71
79
|
Initializes the Board object.
|
72
80
|
"""
|
73
81
|
super().__init__()
|
82
|
+
self.color_dark = ManimColor(color_dark)
|
83
|
+
self.color_light = ManimColor(color_light)
|
84
|
+
self.color_highlight_light = ManimColor(color_highlight_light)
|
85
|
+
self.color_highlight_dark = ManimColor(color_highlight_dark)
|
74
86
|
self.size_of_board = 8
|
75
87
|
self.cell_size = 0.8 # Size of each square in the board
|
76
88
|
self.squares = {} # squares[coordinate] = square
|
@@ -90,8 +102,8 @@ class Board(Mobject):
|
|
90
102
|
|
91
103
|
for row in range(self.size_of_board):
|
92
104
|
for col in range(self.size_of_board):
|
93
|
-
CHESS_GREEN =
|
94
|
-
CHESS_WHITE =
|
105
|
+
CHESS_GREEN = self.color_dark
|
106
|
+
CHESS_WHITE = self.color_light
|
95
107
|
color = CHESS_WHITE if (row + col) % 2 else CHESS_GREEN
|
96
108
|
# Create a square for each cell in the board
|
97
109
|
square = Square(side_length=self.cell_size)
|
@@ -123,12 +135,9 @@ class Board(Mobject):
|
|
123
135
|
number : str
|
124
136
|
The number to be displayed on the square.
|
125
137
|
"""
|
126
|
-
CHESS_GREEN = ManimColor('#769656')
|
127
|
-
CHESS_WHITE = ManimColor('#eeeed2')
|
128
|
-
|
129
138
|
offset = np.array([self.cell_size / 8, -self.cell_size / 6, 0])
|
130
139
|
|
131
|
-
number_color =
|
140
|
+
number_color = self.color_light if square.fill_color == self.color_dark else self.color_dark
|
132
141
|
number = Text(f'{number}', color=number_color, font_size=14 * self.cell_size, font="Arial")
|
133
142
|
square_top_left = square.get_center() + np.array([-self.cell_size / 2, self.cell_size / 2, 0])
|
134
143
|
number.move_to(square_top_left + offset)
|
@@ -145,12 +154,10 @@ class Board(Mobject):
|
|
145
154
|
letter : str
|
146
155
|
The letter to be displayed on the square.
|
147
156
|
"""
|
148
|
-
CHESS_GREEN = ManimColor('#769656')
|
149
|
-
CHESS_WHITE = ManimColor('#eeeed2')
|
150
157
|
|
151
158
|
offset = np.array([-self.cell_size / 8, self.cell_size / 6, 0])
|
152
159
|
|
153
|
-
letter_color =
|
160
|
+
letter_color = self.color_light if square.fill_color == self.color_dark else self.color_dark
|
154
161
|
letter = Text(f'{letter}', color=letter_color, font_size=14 * self.cell_size, font="Arial")
|
155
162
|
square_bot_right = square.get_center() + np.array([self.cell_size / 2, -self.cell_size / 2, 0])
|
156
163
|
letter.move_to(square_bot_right + offset)
|
@@ -326,13 +333,11 @@ class Board(Mobject):
|
|
326
333
|
coordinate : str
|
327
334
|
The coordinate of the square to be unmarked.
|
328
335
|
"""
|
329
|
-
CHESS_GREEN = ManimColor('#769656')
|
330
|
-
CHESS_WHITE = ManimColor('#eeeed2')
|
331
336
|
|
332
337
|
if self.is_light_square(coordinate):
|
333
|
-
self.squares[coordinate].set_fill(
|
338
|
+
self.squares[coordinate].set_fill(self.color_light)
|
334
339
|
else:
|
335
|
-
self.squares[coordinate].set_fill(
|
340
|
+
self.squares[coordinate].set_fill(self.color_dark)
|
336
341
|
|
337
342
|
# Add back text on square if needed
|
338
343
|
if coordinate[1] == '1':
|
@@ -349,13 +354,11 @@ class Board(Mobject):
|
|
349
354
|
coordinate : str
|
350
355
|
The coordinate of the square to be highlighted.
|
351
356
|
"""
|
352
|
-
LIGHT_HIGHLIGHT_COLOR = ManimColor('#F7F769')
|
353
|
-
DARK_HIGHLIGHT_COLOR = ManimColor('#BBCB2B')
|
354
357
|
|
355
358
|
if self.is_light_square(coordinate):
|
356
|
-
self.squares[coordinate].set_fill(
|
359
|
+
self.squares[coordinate].set_fill(self.color_highlight_light)
|
357
360
|
else:
|
358
|
-
self.squares[coordinate].set_fill(
|
361
|
+
self.squares[coordinate].set_fill(self.color_highlight_dark)
|
359
362
|
|
360
363
|
# Add back text on square if needed
|
361
364
|
if coordinate[1] == '1':
|
@@ -425,9 +428,7 @@ class Board(Mobject):
|
|
425
428
|
self.add(finished_arrow)
|
426
429
|
else:
|
427
430
|
arrow0 = Line(stroke_width=15, stroke_opacity=.8, fill_color=ARROW_COLOR, stroke_color=ARROW_COLOR)
|
428
|
-
arrow0.reset_endpoints_based_on_tip = lambda *args: None
|
429
431
|
arrow1 = Line(stroke_width=15, stroke_opacity=.8, fill_color=ARROW_COLOR, stroke_color=ARROW_COLOR)
|
430
|
-
arrow1.reset_endpoints_based_on_tip = lambda *args: None
|
431
432
|
|
432
433
|
if dir_y > 0:
|
433
434
|
buffer_y = np.array([0, 0.25, 0])
|
@@ -448,7 +449,7 @@ class Board(Mobject):
|
|
448
449
|
tip.move_to(tip_position + buffer_x)
|
449
450
|
else:
|
450
451
|
arrow0.set_points_as_corners([end_position - buffer_x, np.array([tip_position[0], end_position[1], 0])])
|
451
|
-
arrow1.set_points_as_corners([np.array([tip_position[0]
|
452
|
+
arrow1.set_points_as_corners([np.array([tip_position[0], end_position[1]+tip_buffer, 0]), tip_position + buffer_y])
|
452
453
|
tip = arrow1.create_tip()
|
453
454
|
tip.move_to(tip_position + buffer_y)
|
454
455
|
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|