Skip to content

art.games

draw chess positions, playing cards and dice

Draws game pieces as text: a chess position, playing cards, and dice faces. Each returns a picture you can print, or place beside other pictures with the frame functions.

Tags: art

  • chess draw a chess board from FEN, the standard text notation for a position
  • card draw a playing card, written as its rank and suit like “A♠”, “10h” or “qd”
  • cards draw several playing cards side by side, written as for card
  • dice draw a die showing 1 to 6, or several side by side for a list
chess(fen?: str) -> str

draw a chess board from FEN, the standard text notation for a position

Only the first part, where the pieces are, is used. Shows the starting position without one

1
chess()
8 ♜ ♞ ♝ ♛ ♚ ♝ ♞ ♜ 7 ♟ ♟ ♟ ♟ ♟ ♟ ♟ ♟ 6 · · · · 5 · · · · 4 · · · · 3 · · · · 2 ♙ ♙ ♙ ♙ ♙ ♙ ♙ ♙ 1 ♖ ♘ ♗ ♕ ♔ ♗ ♘ ♖ a b c d e f g h
2
chess("8/8/8/4k3/8/8/4P3/4K3 w - - 0 1")
8 · · · · 7 · · · · 6 · · · · 5 · · ♚ · 4 · · · · 3 · · · · 2 · · ♙ · · 1 · · ♔ · a b c d e f g h
Example outputCtrl+Enter to run

See also card

card(c: str) -> str

draw a playing card, written as its rank and suit like “A♠”, “10h” or “qd”

Suits are ♠♥♦♣ or the letters s h d c, and “?” draws the card’s back

1
card("Q♥")
┌─────┐ │Q │ │ ♥ │ │ Q│ └─────┘
Example outputCtrl+Enter to run

See also cards, dice

cards(hand: list) -> str

draw several playing cards side by side, written as for card

1
cards(["As", "Kh", "?"])
┌─────┐ ┌─────┐ ┌─────┐ │A │ │K │ │░░░░░│ │ ♠ │ │ ♥ │ │░░░░░│ │ A│ │ K│ │░░░░░│ └─────┘ └─────┘ └─────┘
Example outputCtrl+Enter to run

See also card

dice(faces: int|list) -> str

draw a die showing 1 to 6, or several side by side for a list

1
dice(5)
┌───────┐ │ ● ● │ │ ● │ │ ● ● │ └───────┘
2
dice([1, 2, 3])
┌───────┐ ┌───────┐ ┌───────┐ │ │ │ ● │ │ ● │ │ ● │ │ │ │ ● │ │ │ │ ● │ │ ● │ └───────┘ └───────┘ └───────┘
Example outputCtrl+Enter to run

See also roll, card

1
# roll three dice and draw them
2
dice(roll("3d6").rolls)
┌───────┐ ┌───────┐ ┌───────┐ │ ● ● │ │ ● │ │ ● │ │ ● ● │ │ │ │ ● │ │ ● ● │ │ ● │ │ ● │ └───────┘ └───────┘ └───────┘
3
# a royal flush
4
cards(["10♠", "J♠", "Q♠", "K♠", "A♠"])
┌─────┐ ┌─────┐ ┌─────┐ ┌─────┐ ┌─────┐ │10 │ │J │ │Q │ │K │ │A │ │ ♠ │ │ ♠ │ │ ♠ │ │ ♠ │ │ ♠ │ │ 10│ │ J│ │ Q│ │ K│ │ A│ └─────┘ └─────┘ └─────┘ └─────┘ └─────┘
5
# a chess board at the start of a game
6
chess()
8 ♜ ♞ ♝ ♛ ♚ ♝ ♞ ♜ 7 ♟ ♟ ♟ ♟ ♟ ♟ ♟ ♟ 6 · · · · 5 · · · · 4 · · · · 3 · · · · 2 ♙ ♙ ♙ ♙ ♙ ♙ ♙ ♙ 1 ♖ ♘ ♗ ♕ ♔ ♗ ♘ ♖ a b c d e f g h
Example outputCtrl+Enter to run

Example results generated on 2026-11-04. Ones using now, today or randomness will differ when you run them.