Sgf Render

Continuous integration

Cho Chikun Elementary, Problem 45.

CLI to generate SVG or PNG diagrams of Go games from SGF format game records.

SVG output is clean and well labeled for easy re-styling or modification.

Supports numbered moves, markup, and several customizable styles.

Installation

Check the releases page on GitHub for pre-built binaries.

If you have cargo installed, you can also install the package from crates.io:

$ cargo install sgf-render

Building

If you have git and cargo installed you can also build from source:

$ git clone https://julianandrews/sgf-render $ cd sgf-render $ cargo build --release $ ./target/release/sgf-render -h

Usage

``` Usage: sgf-render [FILE] [options]

Options: -o, --outfile FILE Output file. SVG and PNG formats supported. -n, --node NUM Node to render (default 0) or 'last' to render the last node. Note that SGFs may have nodes without moves. -w, --width WIDTH Width of the output image in pixels (default 800) -s, --shrink-wrap Draw only enough of the board to hold all the stones (with 1 space padding) -r, --range RANGE Range to draw as a pair of corners (e.g. 'cc-ff') --style STYLE Style to use. One of 'simple', 'fancy' or 'minimalist' --custom-style FILE Custom style to use. Overrides '--style'. See the README for details. --move-numbers Draw move numbers (disables other markup). --first-move-number NUM First move number to draw if using --move-numbers --board-labels Sides to draw board labels on (any of nesw). --no-board-labels Don't draw position labels. --no-marks Don't draw SGF marks. --no-triangles Don't draw SGF triangles. --no-circles Don't draw SGF circles. --no-squares Don't draw SGF squares. --no-selected Don't draw SGF selected. --no-dimmed Don't draw SGF dimmmed. --no-labels Don't draw SGF labels. --no-lines Don't draw SGF lines. --no-arrows Don't draw SGF arrows. -h, --help Display this help and exit ```

If FILE isn't provided, sgf-render will read from stdin. If --outfile isn't provided sgf-render will print the resulting SVG to stdout.

Custom styles

You can use the --custom-style flag to specify a file with custom style configuration in TOML format. As an example here's the style config for the simple style:

line_color = "black" line_width = 0.03 hoshi_radius = 0.09 background_fill = "#cfa87e" label_color = "#6e5840" black_stone_fill = "black" white_stone_fill = "white" black_stone_stroke = "black" white_stone_stroke = "black" markup_stroke_width = 0.1 black_stone_markup_color = "white" white_stone_markup_color = "black" empty_markup_color = "black" black_stone_selected_color = "blue" white_stone_selected_color = "blue" empty_selected_color = "blue"

You can see a couple other examples in the source code package under resources/styles/

Contributing

Pull requests are welcome! For major changes, please open an issue first to discuss what you would like to change.

Feature requests are also welcome! The goal is to make this a general purpose sgf diagram generation tool. Just open an issue at GitHub.