[](https://github.com/pre-commit/pre-commit)
[](https://github.com/hartwork/xiangqi-setup/actions/workflows/smoke_test.yml)
# xiangqi-setup (and xiangqi-board)
## Overview
**xiangqi-setup** is a command line tool using [svgutils](https://pypi.org/project/svgutils/) 0.3.4 to
render [Xiangqi](https://en.wikipedia.org/wiki/Xiangqi) (Chinese chess) board setups from WXF/FEN/[annoFEN](https://github.com/hartwork/xiangqi-setup/blob/master/doc/file_formats.md#annofen)/[XAY](https://github.com/hartwork/xiangqi-setup/blob/master/doc/file_formats.md#xay) files to SVG images.
With WXF files that contain move history, **xiangqi-setup** can replay these moves on top of the initial setup —
all of them, none, or any custom number of moves (using the `--moves COUNT` argument).
With [XAY](https://github.com/hartwork/xiangqi-setup/blob/master/doc/file_formats.md#xay)/[annoFEN](https://github.com/hartwork/xiangqi-setup/blob/master/doc/file_formats.md#annofen) files
it can also draw [arrows](https://github.com/hartwork/xiangqi-setup/blob/master/doc/file_formats.md#arrows), mark a field as "good", "bad" or involved in a move —
it can add [annotations](https://github.com/hartwork/xiangqi-setup/blob/master/doc/file_formats.md#annotations).
The most simple way to render a given setup is:
```console
# xiangqi-setup input.wxf output.svg
```
For file [doc/demo.wxf](https://github.com/hartwork/xiangqi-setup/blob/master/doc/demo.wxf), the result is:
[](https://github.com/hartwork/xiangqi-setup/blob/master/doc/demo_retro_simple.svg)
[](https://github.com/hartwork/xiangqi-setup/blob/master/doc/demo_euro_xiangqi_js.svg)
(left: default board, default pieces — right: default board, `euro_xiangqi_js` pieces)
There are a number of themes to pick from for board and pieces (independently).
The `--help` listing below also includes the list of all themes
and their license information.
The [default board theme `clean_alpha`](https://github.com/hartwork/xiangqi-setup/blob/master/xiangqi_setup/themes/board/clean_alpha/board.svg)
has been generated with command line tool `xiangqi-board`
that is included with the **xiangqi-setup** package. It can be used to create
variations of the detault theme, e.g. to create a version with reduced spacing
in crosses you would run:
```console
# xiangqi-board --cross-gap-px 2 board.{svg,ini}
```
# Installation
You can install the latest release using pip like so:
```console
# pip install xiangqi-setup
```
If you would rather run the latest pre-release code off Git `master` in a virtualenv, you could do:
```console
# git clone --depth 1 https://github.com/hartwork/xiangqi-setup
# cd xiangqi-setup/
# python3 -m venv venv
# source venv/bin/activate
# pip install -e .
```
# Writing a Book
For a demo of how to use **xiangqi-setup** in writing a book
please see https://github.com/hartwork/xiangqi-book-example .
# Usage in Detail
## `xiangqi-setup` — Renders WXF/FEN/annoFEN/XAY Files to SVG Images
```console
# xiangqi-setup --help
usage: xiangqi-setup [OPTIONS] INPUT_FILE OUTPUT_FILE
xiangqi-setup --help
xiangqi-setup --version
Generate razor-sharp Xiangqi (Chinese chess) setup graphics
positional arguments:
INPUT_FILE location of WXF/FEN/annoFEN/XAY file to render
OUTPUT_FILE location of SVG output file to write
optional arguments:
-h, --help show this help message and exit
--debug enable debugging (e.g. mark corners of the board)
--version show program's version number and exit
theme selection:
--board THEME name of board theme to use (default: "clean_alpha");
please check the list of available themes below
--pieces THEME name of piece theme to use (default: "retro_simple");
please check the list of available themes below
--annotations THEME name of annotation theme to use (default:
"colors_alpha"); please check the list of available
themes below
scaling:
--width-px PIXEL width of the output in pixels (default: ~248.03, i.e. 7.0cm at 90.0dpi)
--width-cm CENTIMETER
width of the output in centimeters (default: 7.0)
--dpi FLOAT resolution of the output in dots per inch (default: 90.0)
--scale-pieces FACTOR
factor to scale pieces by (0.0 to 1.2, default: 0.9)
--scale-annotations FACTOR
factor to scale annotations by (0.0 to 1.2, default: 0.9)
WXF format arguments:
--moves COUNT how many moves to play (for a file with moves history),
e.g. "3" would play the first move of red, the first
move of black and the second move of red and then skip
any remaining moves, "all" would play all moves, "-1"
all moves but the last, "-2" all but the last two
(default: "0")
--annotate-last-move Add annotations "blank_move" and "piece_move" to the
source and target locations of the last move
board themes (16 available, in alphabetic order):
a4_blank_2cm_margin (license: CC0-1.0)
cambaluc_remake_nolegend (license: CC0-1.0)
cambaluc_remake_nolegend_nogap (license: CC0-1.0)
ccbridge_3_0_beta4_default_preview_remake (license: CC0-1.0)
clean_alpha (license: CC0-1.0)
clean_beta (license: CC0-1.0)
commons_xiangqi_board_2008 (license: public-domain)
commons_xiangqi_board_2008_bw_thin (license: public-domain)
dhtmlxq_2014_remake (license: CC0-1.0)
latex_xq_remake (license: CC0-1.0)
minimal (license: CC0-1.0)
minimal_chinese (license: CC0-1.0)
minimal_chinese_arabic (license: CC0-1.0)
playok_2014_remake (license: CC0-1.0)
western_red_wine (license: CC0-1.0)
xiexie_2_5_0_remake_minimal (license: CC0-1.0)
piece themes (10 available, in alphabetic order):
ccbridge_3_0_beta4_default_preview_remake (license: CC0-1.0)
commons_xiangqi_pieces_print_2010 (license: FDL-1.2+ / CC-BY-SA-4.0)
commons_xiangqi_pieces_print_2010_bw_heavy (license: FDL-1.2+ / CC-BY-SA-4.0)
euro_xiangqi_js (license: CC-BY-4.0)
euro_xiangqi_js_tricolor (license: CC-BY-4.0)
latex_xqlarge_2006_chinese_autotrace (license: non-commercial)
latex_xqlarge_2006_chinese_potrace (license: non-commercial)
playok_2014_chinese (license: CC0-1.0)
playok_2014_chinese_noshadow (license: CC0-1.0)
retro_simple (license: CC0-1.0)
annotation themes (2 available, in alphabetic order):
colors_alpha (license: CC0-1.0)
gray_alpha (license: CC0-1.0)
```
## `xiangqi-board` — Creates Custom Board Themes
```console
# xiangqi-board --help
usage: xiangqi-board [-h] [--line-thickness-px FLOAT] [--field-width-px FLOAT]
[--field-height-px FLOAT] [--border-thickness-px FLOAT]
[--border-gap-width-px FLOAT]
[--border-gap-height-px FLOAT] [--cross-width-px FLOAT]
[--cross-thickness-px FLOAT] [--cross-gap-px FLOAT]
SVG_FILE INI_FILE
positional arguments:
SVG_FILE
INI_FILE
optional arguments:
-h, --help show this help message and exit
--line-thickness-px FLOAT
Line thickness of square fields in pixel (default: 1)
--field-width-px FLOAT
Width of fields in pixel (default: 53)
--field-height-px FLOAT
Height of fields in pixel (default: 53)
--border-thickness-px FLOAT
Line thickness of border in pixel (default: 2)
--border-gap-width-px FLOAT
Widtn of gap to border in pixel (default: 40)
--border-gap-height-px FLOAT
Height of gap to border in pixel (default: 40)
--cross-width-px FLOAT
Width of starting position cross segments in pixel
(default: 10)
--cross-thickness-px FLOAT
Line thickness of starting position cross in pixel
(default: 1)
--cross-gap-px FLOAT Gap to starting position cross in pixel (default: 4)
```
Raw data
{
"_id": null,
"home_page": "https://github.com/hartwork/xiangqi-setup",
"name": "xiangqi-setup",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": "",
"keywords": "",
"author": "Sebastian Pipping",
"author_email": "sebastian@pipping.org",
"download_url": "https://files.pythonhosted.org/packages/32/ba/73e89d481002f5bc04e2857ed7764fcb873e048b105a3323dfcbdd0f9e36/xiangqi-setup-2.2.0.tar.gz",
"platform": null,
"description": "[](https://github.com/pre-commit/pre-commit)\n[](https://github.com/hartwork/xiangqi-setup/actions/workflows/smoke_test.yml)\n\n\n# xiangqi-setup (and xiangqi-board)\n\n## Overview\n\n**xiangqi-setup** is a command line tool using [svgutils](https://pypi.org/project/svgutils/) 0.3.4 to\nrender [Xiangqi](https://en.wikipedia.org/wiki/Xiangqi) (Chinese chess) board setups from WXF/FEN/[annoFEN](https://github.com/hartwork/xiangqi-setup/blob/master/doc/file_formats.md#annofen)/[XAY](https://github.com/hartwork/xiangqi-setup/blob/master/doc/file_formats.md#xay) files to SVG images.\nWith WXF files that contain move history, **xiangqi-setup** can replay these moves on top of the initial setup \u2014\nall of them, none, or any custom number of moves (using the `--moves COUNT` argument).\nWith [XAY](https://github.com/hartwork/xiangqi-setup/blob/master/doc/file_formats.md#xay)/[annoFEN](https://github.com/hartwork/xiangqi-setup/blob/master/doc/file_formats.md#annofen) files\nit can also draw [arrows](https://github.com/hartwork/xiangqi-setup/blob/master/doc/file_formats.md#arrows), mark a field as \"good\", \"bad\" or involved in a move \u2014\nit can add [annotations](https://github.com/hartwork/xiangqi-setup/blob/master/doc/file_formats.md#annotations).\n\nThe most simple way to render a given setup is:\n\n```console\n# xiangqi-setup input.wxf output.svg\n```\n\nFor file [doc/demo.wxf](https://github.com/hartwork/xiangqi-setup/blob/master/doc/demo.wxf), the result is:\n\n[](https://github.com/hartwork/xiangqi-setup/blob/master/doc/demo_retro_simple.svg)\n[](https://github.com/hartwork/xiangqi-setup/blob/master/doc/demo_euro_xiangqi_js.svg)\n\n(left: default board, default pieces \u2014 right: default board, `euro_xiangqi_js` pieces)\n\nThere are a number of themes to pick from for board and pieces (independently).\nThe `--help` listing below also includes the list of all themes\nand their license information.\n\nThe [default board theme `clean_alpha`](https://github.com/hartwork/xiangqi-setup/blob/master/xiangqi_setup/themes/board/clean_alpha/board.svg)\nhas been generated with command line tool `xiangqi-board`\nthat is included with the **xiangqi-setup** package. It can be used to create\nvariations of the detault theme, e.g. to create a version with reduced spacing\nin crosses you would run:\n\n```console\n# xiangqi-board --cross-gap-px 2 board.{svg,ini}\n```\n\n\n# Installation\n\nYou can install the latest release using pip like so:\n\n```console\n# pip install xiangqi-setup\n```\n\nIf you would rather run the latest pre-release code off Git `master` in a virtualenv, you could do:\n\n```console\n# git clone --depth 1 https://github.com/hartwork/xiangqi-setup\n# cd xiangqi-setup/\n# python3 -m venv venv\n# source venv/bin/activate\n# pip install -e .\n```\n\n\n# Writing a Book\n\nFor a demo of how to use **xiangqi-setup** in writing a book\nplease see https://github.com/hartwork/xiangqi-book-example .\n\n\n# Usage in Detail\n\n## `xiangqi-setup` \u2014 Renders WXF/FEN/annoFEN/XAY Files to SVG Images\n\n```console\n# xiangqi-setup --help\nusage: xiangqi-setup [OPTIONS] INPUT_FILE OUTPUT_FILE\n xiangqi-setup --help\n xiangqi-setup --version\n\nGenerate razor-sharp Xiangqi (Chinese chess) setup graphics\n\npositional arguments:\n INPUT_FILE location of WXF/FEN/annoFEN/XAY file to render\n OUTPUT_FILE location of SVG output file to write\n\noptional arguments:\n -h, --help show this help message and exit\n --debug enable debugging (e.g. mark corners of the board)\n --version show program's version number and exit\n\ntheme selection:\n --board THEME name of board theme to use (default: \"clean_alpha\");\n please check the list of available themes below\n --pieces THEME name of piece theme to use (default: \"retro_simple\");\n please check the list of available themes below\n --annotations THEME name of annotation theme to use (default:\n \"colors_alpha\"); please check the list of available\n themes below\n\nscaling:\n --width-px PIXEL width of the output in pixels (default: ~248.03, i.e. 7.0cm at 90.0dpi)\n --width-cm CENTIMETER\n width of the output in centimeters (default: 7.0)\n --dpi FLOAT resolution of the output in dots per inch (default: 90.0)\n --scale-pieces FACTOR\n factor to scale pieces by (0.0 to 1.2, default: 0.9)\n --scale-annotations FACTOR\n factor to scale annotations by (0.0 to 1.2, default: 0.9)\n\nWXF format arguments:\n --moves COUNT how many moves to play (for a file with moves history),\n e.g. \"3\" would play the first move of red, the first\n move of black and the second move of red and then skip\n any remaining moves, \"all\" would play all moves, \"-1\"\n all moves but the last, \"-2\" all but the last two\n (default: \"0\")\n --annotate-last-move Add annotations \"blank_move\" and \"piece_move\" to the\n source and target locations of the last move\n\nboard themes (16 available, in alphabetic order):\n a4_blank_2cm_margin (license: CC0-1.0)\n cambaluc_remake_nolegend (license: CC0-1.0)\n cambaluc_remake_nolegend_nogap (license: CC0-1.0)\n ccbridge_3_0_beta4_default_preview_remake (license: CC0-1.0)\n clean_alpha (license: CC0-1.0)\n clean_beta (license: CC0-1.0)\n commons_xiangqi_board_2008 (license: public-domain)\n commons_xiangqi_board_2008_bw_thin (license: public-domain)\n dhtmlxq_2014_remake (license: CC0-1.0)\n latex_xq_remake (license: CC0-1.0)\n minimal (license: CC0-1.0)\n minimal_chinese (license: CC0-1.0)\n minimal_chinese_arabic (license: CC0-1.0)\n playok_2014_remake (license: CC0-1.0)\n western_red_wine (license: CC0-1.0)\n xiexie_2_5_0_remake_minimal (license: CC0-1.0)\n\npiece themes (10 available, in alphabetic order):\n ccbridge_3_0_beta4_default_preview_remake (license: CC0-1.0)\n commons_xiangqi_pieces_print_2010 (license: FDL-1.2+ / CC-BY-SA-4.0)\n commons_xiangqi_pieces_print_2010_bw_heavy (license: FDL-1.2+ / CC-BY-SA-4.0)\n euro_xiangqi_js (license: CC-BY-4.0)\n euro_xiangqi_js_tricolor (license: CC-BY-4.0)\n latex_xqlarge_2006_chinese_autotrace (license: non-commercial)\n latex_xqlarge_2006_chinese_potrace (license: non-commercial)\n playok_2014_chinese (license: CC0-1.0)\n playok_2014_chinese_noshadow (license: CC0-1.0)\n retro_simple (license: CC0-1.0)\n\nannotation themes (2 available, in alphabetic order):\n colors_alpha (license: CC0-1.0)\n gray_alpha (license: CC0-1.0)\n```\n\n\n## `xiangqi-board` \u2014 Creates Custom Board Themes\n\n```console\n# xiangqi-board --help\nusage: xiangqi-board [-h] [--line-thickness-px FLOAT] [--field-width-px FLOAT]\n [--field-height-px FLOAT] [--border-thickness-px FLOAT]\n [--border-gap-width-px FLOAT]\n [--border-gap-height-px FLOAT] [--cross-width-px FLOAT]\n [--cross-thickness-px FLOAT] [--cross-gap-px FLOAT]\n SVG_FILE INI_FILE\n\npositional arguments:\n SVG_FILE\n INI_FILE\n\noptional arguments:\n -h, --help show this help message and exit\n --line-thickness-px FLOAT\n Line thickness of square fields in pixel (default: 1)\n --field-width-px FLOAT\n Width of fields in pixel (default: 53)\n --field-height-px FLOAT\n Height of fields in pixel (default: 53)\n --border-thickness-px FLOAT\n Line thickness of border in pixel (default: 2)\n --border-gap-width-px FLOAT\n Widtn of gap to border in pixel (default: 40)\n --border-gap-height-px FLOAT\n Height of gap to border in pixel (default: 40)\n --cross-width-px FLOAT\n Width of starting position cross segments in pixel\n (default: 10)\n --cross-thickness-px FLOAT\n Line thickness of starting position cross in pixel\n (default: 1)\n --cross-gap-px FLOAT Gap to starting position cross in pixel (default: 4)\n```\n",
"bugtrack_url": null,
"license": "GNU Affero General Public License version 3.0 or later",
"summary": "Command line tool to generate razor-sharp Xiangqi (Chinese chess) setup graphics",
"version": "2.2.0",
"project_urls": {
"Download": "https://github.com/hartwork/xiangqi-setup/archive/2.2.0.tar.gz",
"Homepage": "https://github.com/hartwork/xiangqi-setup"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "dba3e883c52ae2dcaa353d472e0d0f14b007b53e6e30239d8c295fb01aedc20f",
"md5": "8381b65d0fb934e2b390841eb11566d1",
"sha256": "b2b914594047de65d858a6d0da15bed00d8f1dfd5a9e35c9888df2dcf2eb44a6"
},
"downloads": -1,
"filename": "xiangqi_setup-2.2.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "8381b65d0fb934e2b390841eb11566d1",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 1225441,
"upload_time": "2023-07-26T16:50:29",
"upload_time_iso_8601": "2023-07-26T16:50:29.804425Z",
"url": "https://files.pythonhosted.org/packages/db/a3/e883c52ae2dcaa353d472e0d0f14b007b53e6e30239d8c295fb01aedc20f/xiangqi_setup-2.2.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "32ba73e89d481002f5bc04e2857ed7764fcb873e048b105a3323dfcbdd0f9e36",
"md5": "969342d093339cd17ccec71f0b794d5d",
"sha256": "8e4e72785ec08ab17815b90f794aa557b4ea1809c5aeb00a8bb4378cb4be7492"
},
"downloads": -1,
"filename": "xiangqi-setup-2.2.0.tar.gz",
"has_sig": false,
"md5_digest": "969342d093339cd17ccec71f0b794d5d",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 1406743,
"upload_time": "2023-07-26T16:50:32",
"upload_time_iso_8601": "2023-07-26T16:50:32.689569Z",
"url": "https://files.pythonhosted.org/packages/32/ba/73e89d481002f5bc04e2857ed7764fcb873e048b105a3323dfcbdd0f9e36/xiangqi-setup-2.2.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-07-26 16:50:32",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "hartwork",
"github_project": "xiangqi-setup",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "xiangqi-setup"
}