Package for visualising chess games
Project description
Chessplot
Introduction
chessplot
is a library for producing visualisations of chess games
by parsing and plotting .pgn
files (Portable Game Notation).
It can produce either an animated .gif
of a game,
a .pdf
with a single page per move, or .png
files of individual moves.
Installation
Using PyPi:
The easiest way to install chessplot
is using Pypi.
To do this, first ensure that you have pip
installed then run:
pip install chessplot
Usage:
The core of chessplot
is the ChessPlot
class. A ChessPlot
can be created using a valid path to a
.pgn
file of a chess game. The game can then be visualised by calling the to_gif
, to_pdf
, or to_png
methods
of the ChessPlot
class.
For example:
from chessplot import ChessPlot
plot = ChessPlot(pgn="mypgnfile.pgn")
plot.to_gif(save_path="mynewgif.gif")
This code will read and parse the given .pgn
file mypgnfile.pgn
,
create a visualisation of the game, and then save the output as a
.gif
to the file mynewgif.gif
.
If a save_path
is not provided, a path will be generated using the path of the inputted .pgn
file.
For example, creating an instance of ChessPlot
with the file mypgnfile.pgn
and calling the to_gif
method
would cause a file to be saved to the path mypgnfile.gif
.
Customising plots
Plots can be customised in a number of ways using the following settings:
plot_size
: This determines the width of the generated plot in millimetersboard_only
: Toggles the plot header to allow for plots of just the boarddisplay_notation
: Toggles move notation on plotsflip_perspective
: Toggles the perspective of the board from white to black
In addition, when generating .gif
or .pdf
files, the start and end
frames can be specified using the start_frame
and end_frame
parameters.
For example:
from chessplot import ChessPlot
plot = ChessPlot(pgn="myfile.pgn")
plot.to_gif(
plot_size=1000,
board_only=True,
display_notation=True,
flip_perspective=True,
start_frame=10,
end_frame=15
)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file chessplot-1.5.tar.gz
.
File metadata
- Download URL: chessplot-1.5.tar.gz
- Upload date:
- Size: 15.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.7.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7a817e1e8ba6f9be534ca32c10b31744c5b5548511968edc768be140e19f312c |
|
MD5 | 192622251166b443626492af621f5df5 |
|
BLAKE2b-256 | 1e5d185672cfe70b242b2c7281b84e141d068df1bdcd2ab30a409f9369ea7b86 |