manim-chess 0.0.33__py3-none-any.whl → 0.0.34__py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- manim_chess/board.py +17 -18
- {manim_chess-0.0.33.dist-info → manim_chess-0.0.34.dist-info}/METADATA +1 -1
- {manim_chess-0.0.33.dist-info → manim_chess-0.0.34.dist-info}/RECORD +5 -5
- {manim_chess-0.0.33.dist-info → manim_chess-0.0.34.dist-info}/LICENSE.txt +0 -0
- {manim_chess-0.0.33.dist-info → manim_chess-0.0.34.dist-info}/WHEEL +0 -0
manim_chess/board.py
CHANGED
@@ -21,6 +21,10 @@ 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
|
24
28
|
|
25
29
|
Methods:
|
26
30
|
-------
|
@@ -66,11 +70,15 @@ class Board(Mobject):
|
|
66
70
|
Returns the piece at a given coordinate, if any.
|
67
71
|
"""
|
68
72
|
|
69
|
-
def __init__(self) -> None:
|
73
|
+
def __init__(self, color_dark='#769656', color_light='#eeeed2', color_highlight_light='#F7F769', color_highlight_dark='#BBCB2B') -> None:
|
70
74
|
"""
|
71
75
|
Initializes the Board object.
|
72
76
|
"""
|
73
77
|
super().__init__()
|
78
|
+
self.color_dark = ManimColor(color_dark)
|
79
|
+
self.color_light = ManimColor(color_light)
|
80
|
+
self.color_highlight_light = ManimColor(color_highlight_light)
|
81
|
+
self.color_highlight_dark = ManimColor(color_highlight_dark)
|
74
82
|
self.size_of_board = 8
|
75
83
|
self.cell_size = 0.8 # Size of each square in the board
|
76
84
|
self.squares = {} # squares[coordinate] = square
|
@@ -90,8 +98,8 @@ class Board(Mobject):
|
|
90
98
|
|
91
99
|
for row in range(self.size_of_board):
|
92
100
|
for col in range(self.size_of_board):
|
93
|
-
CHESS_GREEN =
|
94
|
-
CHESS_WHITE =
|
101
|
+
CHESS_GREEN = self.color_dark
|
102
|
+
CHESS_WHITE = self.color_light
|
95
103
|
color = CHESS_WHITE if (row + col) % 2 else CHESS_GREEN
|
96
104
|
# Create a square for each cell in the board
|
97
105
|
square = Square(side_length=self.cell_size)
|
@@ -123,12 +131,9 @@ class Board(Mobject):
|
|
123
131
|
number : str
|
124
132
|
The number to be displayed on the square.
|
125
133
|
"""
|
126
|
-
CHESS_GREEN = ManimColor('#769656')
|
127
|
-
CHESS_WHITE = ManimColor('#eeeed2')
|
128
|
-
|
129
134
|
offset = np.array([self.cell_size / 8, -self.cell_size / 6, 0])
|
130
135
|
|
131
|
-
number_color =
|
136
|
+
number_color = self.color_light if square.fill_color == self.color_dark else self.color_dark
|
132
137
|
number = Text(f'{number}', color=number_color, font_size=14 * self.cell_size, font="Arial")
|
133
138
|
square_top_left = square.get_center() + np.array([-self.cell_size / 2, self.cell_size / 2, 0])
|
134
139
|
number.move_to(square_top_left + offset)
|
@@ -145,12 +150,10 @@ class Board(Mobject):
|
|
145
150
|
letter : str
|
146
151
|
The letter to be displayed on the square.
|
147
152
|
"""
|
148
|
-
CHESS_GREEN = ManimColor('#769656')
|
149
|
-
CHESS_WHITE = ManimColor('#eeeed2')
|
150
153
|
|
151
154
|
offset = np.array([-self.cell_size / 8, self.cell_size / 6, 0])
|
152
155
|
|
153
|
-
letter_color =
|
156
|
+
letter_color = self.color_light if square.fill_color == self.color_dark else self.color_dark
|
154
157
|
letter = Text(f'{letter}', color=letter_color, font_size=14 * self.cell_size, font="Arial")
|
155
158
|
square_bot_right = square.get_center() + np.array([self.cell_size / 2, -self.cell_size / 2, 0])
|
156
159
|
letter.move_to(square_bot_right + offset)
|
@@ -326,13 +329,11 @@ class Board(Mobject):
|
|
326
329
|
coordinate : str
|
327
330
|
The coordinate of the square to be unmarked.
|
328
331
|
"""
|
329
|
-
CHESS_GREEN = ManimColor('#769656')
|
330
|
-
CHESS_WHITE = ManimColor('#eeeed2')
|
331
332
|
|
332
333
|
if self.is_light_square(coordinate):
|
333
|
-
self.squares[coordinate].set_fill(
|
334
|
+
self.squares[coordinate].set_fill(self.color_light)
|
334
335
|
else:
|
335
|
-
self.squares[coordinate].set_fill(
|
336
|
+
self.squares[coordinate].set_fill(self.color_dark)
|
336
337
|
|
337
338
|
# Add back text on square if needed
|
338
339
|
if coordinate[1] == '1':
|
@@ -349,13 +350,11 @@ class Board(Mobject):
|
|
349
350
|
coordinate : str
|
350
351
|
The coordinate of the square to be highlighted.
|
351
352
|
"""
|
352
|
-
LIGHT_HIGHLIGHT_COLOR = ManimColor('#F7F769')
|
353
|
-
DARK_HIGHLIGHT_COLOR = ManimColor('#BBCB2B')
|
354
353
|
|
355
354
|
if self.is_light_square(coordinate):
|
356
|
-
self.squares[coordinate].set_fill(
|
355
|
+
self.squares[coordinate].set_fill(self.color_highlight_light)
|
357
356
|
else:
|
358
|
-
self.squares[coordinate].set_fill(
|
357
|
+
self.squares[coordinate].set_fill(self.color_highlight_dark)
|
359
358
|
|
360
359
|
# Add back text on square if needed
|
361
360
|
if coordinate[1] == '1':
|
@@ -1,5 +1,5 @@
|
|
1
1
|
manim_chess/__init__.py,sha256=SEtbIVW1Lnh-ZF4_mMYWpI-UFQLOdnGkOD7W0iqK0uc,242
|
2
|
-
manim_chess/board.py,sha256=
|
2
|
+
manim_chess/board.py,sha256=NM-wJmnI-9PrJM8vwHsN9AFjUn7C53AplYea8c1IzBM,20162
|
3
3
|
manim_chess/evaluation_bar.py,sha256=ELjhyFPi5x_Q4Gw3U0FLVhQqN55k8rYCu-lpkru4nPo,3655
|
4
4
|
manim_chess/game_player.py,sha256=fESDu5eksZK9ic47CwQNgeq1rpkcMKt0O7_X7-E5lp0,31102
|
5
5
|
manim_chess/piece_svgs/bB.svg,sha256=d-nev6XLgFKglq_9SdXU2EIxPM1RlNWoXji4p4MYhb8,683
|
@@ -15,7 +15,7 @@ manim_chess/piece_svgs/wP.svg,sha256=BZa3zm9xUXgAtRA_SrA3DUeebWbmnBQR8nSQ0gdy6NY
|
|
15
15
|
manim_chess/piece_svgs/wQ.svg,sha256=3SCkD3QlZH7SwQ435sYe8uP3Dx9zy_xxdSy5_DbdwzU,1102
|
16
16
|
manim_chess/piece_svgs/wR.svg,sha256=6ela3ONk9djAPG3E2pqfhPVewWSyCRAtRvfm9Ycspcc,481
|
17
17
|
manim_chess/pieces.py,sha256=890HggU4vGv_PgLyUPnJj2p3ZdivoqG5BukjqsS6MeU,7634
|
18
|
-
manim_chess-0.0.
|
19
|
-
manim_chess-0.0.
|
20
|
-
manim_chess-0.0.
|
21
|
-
manim_chess-0.0.
|
18
|
+
manim_chess-0.0.34.dist-info/LICENSE.txt,sha256=B-V-3Tb7v93ub_E_3quknwdeUDtveYnceR0DcdAgolc,1067
|
19
|
+
manim_chess-0.0.34.dist-info/METADATA,sha256=hkO7aRsP8lGG-n5Ubi1K04YK8OmcMdwn4ZMCJ1fGLPs,7154
|
20
|
+
manim_chess-0.0.34.dist-info/WHEEL,sha256=RaoafKOydTQ7I_I3JTrPCg6kUmTgtm4BornzOqyEfJ8,88
|
21
|
+
manim_chess-0.0.34.dist-info/RECORD,,
|
File without changes
|
File without changes
|