跳转到主要内容

用于生成锐利象棋(中国象棋)设置图形的命令行工具

项目描述

pre-commit Build and smoke test

象棋设置(以及象棋棋盘)

概述

象棋设置 是一个命令行工具,使用 svgutils 0.3.4 将 WXF/FEN/annoFEN/XAY 文件渲染为 SVG 图像。对于包含移动历史的 WXF 文件,象棋设置 可以在初始设置上回放这些移动——全部、没有,或任何自定义数量的移动(使用 --moves COUNT 参数)。对于 XAY/annoFEN 文件,它还可以绘制 箭头,将棋盘标记为“好”、“坏”或涉及移动——它还可以添加 注释

渲染给定设置的 simplest 方法是

# xiangqi-setup input.wxf output.svg

对于文件 doc/demo.wxf,结果是

(左:默认棋盘,默认棋子 — 右:默认棋盘, euro_xiangqi_js 棋子)

可以从中选择多种主题用于棋盘和棋子(独立选择)。下面的 --help 列表中还包括所有主题及其许可证信息。

默认棋盘主题 clean_alpha 已由包含在 xiangqi-setup 包中的命令行工具 xiangqi-board 生成。它可以用来创建默认主题的变体,例如,要创建一个交叉间距较小的版本,您将运行

# xiangqi-board --cross-gap-px 2 board.{svg,ini}

安装

您可以使用 pip 安装最新版本,如下所示

# pip install xiangqi-setup

如果您想要在虚拟环境中运行 Git master 分支的最新预发布代码,可以这样做

# git clone --depth 1 https://github.com/hartwork/xiangqi-setup
# cd xiangqi-setup/
# python3 -m venv venv
# source venv/bin/activate
# pip install -e .

编写书籍

有关如何使用 xiangqi-setup 编写书籍的演示,请参阅 https://github.com/hartwork/xiangqi-book-example

详细用法

xiangqi-setup — 将 WXF/FEN/annoFEN/XAY 文件渲染为 SVG 图像

# 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 — 创建自定义棋盘主题

# 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)

项目详情


下载文件

下载适用于您平台的应用程序。如果您不确定选择哪个,请了解有关 安装包 的更多信息。

源分布

xiangqi-setup-2.2.0.tar.gz (1.4 MB 查看哈希值)

上传时间

构建分布

xiangqi_setup-2.2.0-py3-none-any.whl (1.2 MB 查看哈希值)

上传时间 Python 3

由以下机构支持

AWSAWS云计算和安全赞助商DatadogDatadog监控FastlyFastlyCDNGoogleGoogle下载分析MicrosoftMicrosoftPSF赞助商PingdomPingdom监控SentrySentry错误记录StatusPageStatusPage状态页面