Crates.io | c2g |
lib.rs | c2g |
version | 0.9.0 |
source | src |
created_at | 2022-03-20 23:57:07.674505 |
updated_at | 2024-05-09 21:39:31.90133 |
description | Turn your chess PGN files into GIFs! |
homepage | |
repository | https://github.com/tomasfarias/c2g |
max_upload_size | |
id | 553773 |
size | 3,167,837 |
♟️ Turn your chess PGNs to GIFs. c2g
also powers a Yew web application: c2g-yew.
Pass a size in pixels and an output file to c2g
:
cat example/example.pgn | ./c2g --size 640 --output example/chess.gif
Will output the following 640x640 GIF:
Bullet games are good candidates for real time delay using the --delay="real"
flag:
cat example/example_bullet.pgn | ./c2g --size 640 --delay="real" --output example/chess_bullet.gif
If you prefer a more cleaner look without any features, you can disable them:
cat example/example_no_clock.pgn | ./c2g --size 640 --no-player-bars --no-terminations --output example/chess_clean.gif
To install c2g you can download one of the binaries available from Releases. These binaries are compiled with the default features include-svgs
and include-fonts
, which means that the svgs and fonts avaible at svgs/
and fonts/
respectively come bundled with the binary, which makes it so it can be run without any extra dependencies from anywhere.
c2g may also be compiled from source by fetching the repository and building with cargo
:
git clone https://github.com/tomasfarias/c2g.git
cd c2g
cargo build --release
Building with the --release
flag is highly encouraged as the GIF rendering performance is very superior compared to debug builds.
The include-svgs
and include-fonts
features come enabled by default, these can be disabled by building with the --no-default-features
. If disabled, paths to fonts and svgs will need to be provided via CLI arguments. If you wish to use a different font or piece set, instead of compiling with --no-default-features
and relying on CLI arguments, consider adding them to the svgs/
and fonts/
directories and compiling with default features enabled.
If available, at the top and bottom of the GIF we include the player's username, elo, and turn clocks. This feature can be disabled by passing --no-player-bars
.
If the chess PGN contains %clk
comments, c2g will attempt to parse them into durations to try and estimate the time taken per move. The clock for each turn is included in the [player bars](#Player bars). Moreover, we can ask c2g to use the real duration as the delay between GIF frames, with the --delay="real"
option. This is particularly exciting for bullet games that usually last 1-2 minutes or less.
The last frame of the gif will draw a small circle over each king to show the result of the game. Some terminations have special circles to indicate the reason why the game ended. Since there are many possible reasons to terminate a chess game, we make use of the Termination PGN header to try to narrow down the cause. If the header is not available, or we cannot find any reason in it, we make the assumption that the losing side resigned for the purpose of choosing what circle to draw. For now, all possible draws are treated the same for the purpose of which circle will be drawn.
This feature can be disabled with --no-termination
.
Any file in this project that is not listed as an exception is licensed under the GNU General Public License 3.
The following (free) exceptions apply:
Files | Author(s) | License |
---|---|---|
svgs/cburnett/*.svg | Colin M.L. Burnett | GPLv2+ |
fonts/roboto.ttf | Christian Robertson | Apache 2.0 |
fonts/oswald.ttf | Vernon Adams, Kalapi Gajjar, Cyreal | Open Font License |