Skip to main content

FenToBoardImage takes a Fen string representing a Chess position, and renders a Pillow image of the resulting position.

Project description

About

fentoboardimage takes a Fen string representing a Chess position, and renders a PIL image of the resulting position.

You can customize:

  • the size and color of the board
  • piece sprites
  • black or white perspective
  • Board highlighting for last move
  • Arrows

Installation

Install the package using pip

$ pip install fentoboardimage

Then import the fenToImage and loadPiecesFolder functions and use them as follows:

from fentoboardimage import fenToImage, loadPiecesFolder

boardImage = fenToImage(
	fen="rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1",
	squarelength=100,
	pieceSet=loadPiecesFolder("./pieces"),
	darkColor="#D18B47",
	lightColor="#FFCE9E"
)

In order to load a piece set, the pieces must follow this file structure, and must be a .png:

-piece_set_name
  -white
    - Knight.png
    - Rook.png
    - Pawn.png
    - Bishop.png
    - Queen.png
    - King.png
  -black
    - Knight.png
    - Rook.png
    - Pawn.png
    - Bishop.png
    - Queen.png
    - King.png

Usage

The fenToBoardImage has these parameters:

fen: str

Fen string representing a position

squarelength: int

the length of one square on the board

resulting board will be 8 * squarelength long

pieceSet: loadPiecesFolder

the piece set, loaded using the `loadPiecesFolder` function

darkColor: str

dark square color on the board

lightColor: str

light square color on the board

flipped: boolean

default = False

Whether to flip to board, and render it from black's perspective

ArrowSet: loadArrowsFolder

the piece set, loaded using the `loadArrowsFolder` function

The loadPiecesFolder has one parameter:

Arrows: list[(str,str)]

A list of tuples containing coordinates to place arrows. In the format of (start, end) using standard chess notation for the squares.

lastMove: dict A dictionary containing the fields before, after, darkColor and lightColor. before and after using standard chess notation for the squares, and darkColor and lightColor should be hex strings.

path: str

Loads piece set located at the path provided.

The loadArrowsFolder has one parameter:

path: str

Loads arrow set located at the path provided.

Dependencies

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fentoboardimage-1.1.0.tar.gz (18.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fentoboardimage-1.1.0-py3-none-any.whl (18.2 kB view details)

Uploaded Python 3

File details

Details for the file fentoboardimage-1.1.0.tar.gz.

File metadata

  • Download URL: fentoboardimage-1.1.0.tar.gz
  • Upload date:
  • Size: 18.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.2 CPython/3.10.4 Linux/5.10.16.3-microsoft-standard-WSL2

File hashes

Hashes for fentoboardimage-1.1.0.tar.gz
Algorithm Hash digest
SHA256 8d882dd933fb58891b72f9f322e3652f00358a420ee16f94051f67deb222c9ed
MD5 6cb50388794f824537ac65e1437e5186
BLAKE2b-256 73576ddc32bd46ab0288edd71d888e36d4f22d456da776162821db913dd3930f

See more details on using hashes here.

File details

Details for the file fentoboardimage-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: fentoboardimage-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 18.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.2 CPython/3.10.4 Linux/5.10.16.3-microsoft-standard-WSL2

File hashes

Hashes for fentoboardimage-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 71f8be2074251db9ede97d608a8730ead22bfb379689216d980077554bb2cb97
MD5 eb99b0008a9121bf1a457bebe7e4ad23
BLAKE2b-256 3be5e346821f30f226d928440ba2e832b0f85aeb2f1de7992b0c7351a7f90e8a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page