@@ -283,6 +283,7 @@ def board(board: Optional[chess.BaseBoard] = None, *,
283
283
inner_border = 1 if borders and coordinates else 0
284
284
outer_border = 1 if borders else 0
285
285
margin = 15 if coordinates else 0
286
+ board_offset = inner_border + margin + outer_border
286
287
full_size = 2 * outer_border + 2 * margin + 2 * inner_border + 8 * SQUARE_SIZE
287
288
svg = _svg (full_size , size )
288
289
@@ -351,12 +352,12 @@ def board(board: Optional[chess.BaseBoard] = None, *,
351
352
if coordinates :
352
353
coord_color , coord_opacity = _select_color (colors , "coord" )
353
354
for file_index , file_name in enumerate (chess .FILE_NAMES ):
354
- x = (file_index if orientation else 7 - file_index ) * SQUARE_SIZE + inner_border + margin + outer_border
355
+ x = (file_index if orientation else 7 - file_index ) * SQUARE_SIZE + board_offset
355
356
# Keep some padding here to separate the ascender from the border
356
357
svg .append (_coord (file_name , x , 1 , SQUARE_SIZE , margin , True , margin , color = coord_color , opacity = coord_opacity ))
357
358
svg .append (_coord (file_name , x , full_size - outer_border - margin , SQUARE_SIZE , margin , True , margin , color = coord_color , opacity = coord_opacity ))
358
359
for rank_index , rank_name in enumerate (chess .RANK_NAMES ):
359
- y = (7 - rank_index if orientation else rank_index ) * SQUARE_SIZE + inner_border + margin + outer_border
360
+ y = (7 - rank_index if orientation else rank_index ) * SQUARE_SIZE + board_offset
360
361
svg .append (_coord (rank_name , 0 , y , margin , SQUARE_SIZE , False , margin , color = coord_color , opacity = coord_opacity ))
361
362
svg .append (_coord (rank_name , full_size - outer_border - margin , y , margin , SQUARE_SIZE , False , margin , color = coord_color , opacity = coord_opacity ))
362
363
@@ -365,8 +366,8 @@ def board(board: Optional[chess.BaseBoard] = None, *,
365
366
file_index = chess .square_file (square )
366
367
rank_index = chess .square_rank (square )
367
368
368
- x = (file_index if orientation else 7 - file_index ) * SQUARE_SIZE + inner_border + margin + outer_border
369
- y = (7 - rank_index if orientation else rank_index ) * SQUARE_SIZE + inner_border + margin + outer_border
369
+ x = (file_index if orientation else 7 - file_index ) * SQUARE_SIZE + board_offset
370
+ y = (7 - rank_index if orientation else rank_index ) * SQUARE_SIZE + board_offset
370
371
371
372
cls = ["square" , "light" if chess .BB_LIGHT_SQUARES & bb else "dark" ]
372
373
if lastmove and square in [lastmove .from_square , lastmove .to_square ]:
@@ -406,8 +407,8 @@ def board(board: Optional[chess.BaseBoard] = None, *,
406
407
file_index = chess .square_file (check )
407
408
rank_index = chess .square_rank (check )
408
409
409
- x = (file_index if orientation else 7 - file_index ) * SQUARE_SIZE + margin
410
- y = (7 - rank_index if orientation else rank_index ) * SQUARE_SIZE + margin
410
+ x = (file_index if orientation else 7 - file_index ) * SQUARE_SIZE + board_offset
411
+ y = (7 - rank_index if orientation else rank_index ) * SQUARE_SIZE + board_offset
411
412
412
413
ET .SubElement (svg , "rect" , _attrs ({
413
414
"x" : x ,
@@ -423,8 +424,8 @@ def board(board: Optional[chess.BaseBoard] = None, *,
423
424
file_index = chess .square_file (square )
424
425
rank_index = chess .square_rank (square )
425
426
426
- x = (file_index if orientation else 7 - file_index ) * SQUARE_SIZE + margin
427
- y = (7 - rank_index if orientation else rank_index ) * SQUARE_SIZE + margin
427
+ x = (file_index if orientation else 7 - file_index ) * SQUARE_SIZE + board_offset
428
+ y = (7 - rank_index if orientation else rank_index ) * SQUARE_SIZE + board_offset
428
429
429
430
if board is not None :
430
431
piece = board .piece_at (square )
@@ -463,10 +464,10 @@ def board(board: Optional[chess.BaseBoard] = None, *,
463
464
head_file = chess .square_file (head )
464
465
head_rank = chess .square_rank (head )
465
466
466
- xtail = outer_border + margin + inner_border + (tail_file + 0.5 if orientation else 7.5 - tail_file ) * SQUARE_SIZE
467
- ytail = outer_border + margin + inner_border + (7.5 - tail_rank if orientation else tail_rank + 0.5 ) * SQUARE_SIZE
468
- xhead = outer_border + margin + inner_border + (head_file + 0.5 if orientation else 7.5 - head_file ) * SQUARE_SIZE
469
- yhead = outer_border + margin + inner_border + (7.5 - head_rank if orientation else head_rank + 0.5 ) * SQUARE_SIZE
467
+ xtail = board_offset + (tail_file + 0.5 if orientation else 7.5 - tail_file ) * SQUARE_SIZE
468
+ ytail = board_offset + (7.5 - tail_rank if orientation else tail_rank + 0.5 ) * SQUARE_SIZE
469
+ xhead = board_offset + (head_file + 0.5 if orientation else 7.5 - head_file ) * SQUARE_SIZE
470
+ yhead = board_offset + (7.5 - head_rank if orientation else head_rank + 0.5 ) * SQUARE_SIZE
470
471
471
472
if (head_file , head_rank ) == (tail_file , tail_rank ):
472
473
ET .SubElement (svg , "circle" , _attrs ({
0 commit comments