shogi_img/
lib.rs

1//! `shogi-img` is a library for generating images that visualize the position in Shogi (Japanese chess).
2//! It takes [`shogi_core::PartialPosition`] as input and returns an image corresponding to that position as [`image::RgbaImage`].
3//! There are several selectable styles for the board and pieces used in image generation.
4mod generator;
5
6pub use crate::generator::{AsPosition, Generator};
7pub use image;
8pub use shogi_core;
9
10/// Values to specify the style of the board.
11#[derive(Default)]
12pub enum BoardStyle {
13    #[default]
14    /// Light-colored wood
15    Light,
16    /// Warm-colored wood
17    Warm,
18    /// Synthetic resin
19    Resin,
20}
21
22/// Values to specify the style of the pieces.
23#[derive(Default)]
24pub enum PiecesStyle {
25    #[default]
26    Hitomoji,
27    HitomojiGothic,
28}
29
30/// Values to specify the style of the coordinates.
31#[derive(Default)]
32pub enum CoordinateStyle {
33    #[default]
34    None,
35    DrawCoordinates,
36}
37
38/// Hightlight mode for last moved pieces.
39#[derive(Default)]
40pub enum HighlightSquare {
41    #[default]
42    None,
43    LastMoveTo,
44}
45
46/// A simple function to generate an image from a position using the default styles.
47pub fn pos2img<T>(position: &T) -> image::RgbaImage
48where
49    T: AsPosition,
50{
51    Generator::default().generate(position)
52}