manim-chess 0.0.33__py3-none-any.whl → 0.0.35__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 CHANGED
@@ -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 = ManimColor('#769656')
94
- CHESS_WHITE = ManimColor('#eeeed2')
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 = CHESS_WHITE if square.fill_color == CHESS_GREEN else CHESS_GREEN
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 = CHESS_WHITE if square.fill_color == CHESS_GREEN else CHESS_GREEN
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(CHESS_WHITE)
338
+ self.squares[coordinate].set_fill(self.color_light)
334
339
  else:
335
- self.squares[coordinate].set_fill(CHESS_GREEN)
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(LIGHT_HIGHLIGHT_COLOR)
359
+ self.squares[coordinate].set_fill(self.color_highlight_light)
357
360
  else:
358
- self.squares[coordinate].set_fill(DARK_HIGHLIGHT_COLOR)
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]-tip_buffer, end_position[1], 0]), tip_position + buffer_y])
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
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: manim-chess
3
- Version: 0.0.33
3
+ Version: 0.0.35
4
4
  Summary: A plugin for animating chessboards. Includes additional features such as PGN conversion, arrows, etc.
5
5
  Author: swoyer2
6
6
  Author-email: swoyer.logan@gmail.com
@@ -1,5 +1,5 @@
1
1
  manim_chess/__init__.py,sha256=SEtbIVW1Lnh-ZF4_mMYWpI-UFQLOdnGkOD7W0iqK0uc,242
2
- manim_chess/board.py,sha256=jOA4fvU9zDD67uDdRhrBvpyfk9afJBDMLDu4aMCj_RI,20003
2
+ manim_chess/board.py,sha256=Ljq_9AS8GKejOuvtCHdXdN6hZ2BTMMAwCmpKJRLA67Y,20219
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.33.dist-info/LICENSE.txt,sha256=B-V-3Tb7v93ub_E_3quknwdeUDtveYnceR0DcdAgolc,1067
19
- manim_chess-0.0.33.dist-info/METADATA,sha256=S2ryW_FLYh6nLN58xy-EYrcUe9iry4Jb6sKEllPCKV0,7154
20
- manim_chess-0.0.33.dist-info/WHEEL,sha256=RaoafKOydTQ7I_I3JTrPCg6kUmTgtm4BornzOqyEfJ8,88
21
- manim_chess-0.0.33.dist-info/RECORD,,
18
+ manim_chess-0.0.35.dist-info/LICENSE.txt,sha256=B-V-3Tb7v93ub_E_3quknwdeUDtveYnceR0DcdAgolc,1067
19
+ manim_chess-0.0.35.dist-info/METADATA,sha256=0YyaH5DPxrg6CUMHXeJj0qGtKckaC5sq3j31cUaMaPY,7154
20
+ manim_chess-0.0.35.dist-info/WHEEL,sha256=RaoafKOydTQ7I_I3JTrPCg6kUmTgtm4BornzOqyEfJ8,88
21
+ manim_chess-0.0.35.dist-info/RECORD,,