cat_piece: Generate plaintext piecepack diagrams

View source: R/cat_piece.R

cat_pieceR Documentation

Generate plaintext piecepack diagrams

Description

cat_piece() generates plaintext piecepack diagrams and outputs them using base::cat(). cat_move() generates a plaintext diagram for a move within a game. cat_game() renders an animation of a game in the terminal.

Usage

cat_piece(
  df,
  color = NULL,
  reorient = "none",
  annotate = FALSE,
  ...,
  file = "",
  annotation_scale = NULL,
  style = c("Unicode", "Game Bit Mono", "Game Bit Duo")
)

cat_move(game, move = NULL, ...)

cat_game(game, ..., fps = 1)

Arguments

df

Data frame containing piece info.

color

How should the text be colorized. If FALSE won't colorize output at all. If "html" will colorize output for html. Otherwise will colorize output for the terminal using ANSI CSI SGR control sequences.

reorient

Determines whether and how we should reorient (the angle) of pieces or symbols:

  1. The default "none" (or FALSE) means don't reorient any pieces/symbols.

  2. "all" (or TRUE) means setting the angle to zero for all pieces (reorienting them all “up”).

  3. "symbols" means just re-orient suit/rank symbols but not the orientation of the piece itself. In particular, in contrast with "all" this preserves the location of the upper-left "corner" of piecepack tile faces.

annotate

If TRUE or "algebraic" annotate the plot with “algrebraic” coordinates, if FALSE or "none" don't annotate, if "cartesian" annotate the plot with “cartesian” coordinates.

...

Passed to cat()

file

file argument of cat(). Default ("") is to print to standard output. NULL means we don't cat()

annotation_scale

Multiplicative factor that scales (stretches) any annotation coordinates. By default uses attr(df, "scale_factor") %||% 1.

style

If "Unicode" (default) only use glyphs in Unicode proper. If "Game Bit Duo" use glyphs in Private Use Area of "Game Bit Duo" font. If "Game Bit Mono" use glyphs in Private Use Area of "Game Bit Mono" font.

game

A list containing a parsed ppn game (as parsed by read_ppn)

move

Which move to cat game state (after the move, will use game$dfs[[move]]) unless NULL in which case will cat the game state after the last move.

fps

Frames per second.

Value

String of text diagram (returned invisibly).

See Also

See https://github.com/trevorld/game-bit-font for more information about the “Game Bit” family of fonts.


piecepackr/ppgames documentation built on Jan. 17, 2025, 2:24 p.m.