Package 'ppcli'

Title: Plaintext Board Game Visualizations
Description: Functions to visualize board games in plaintext. Provides colorization support for the terminal and HTML.
Authors: Trevor L Davis [aut, cre]
Maintainer: Trevor L Davis <[email protected]>
License: MIT + file LICENSE
Version: 0.1.0-4
Built: 2024-11-03 05:42:41 UTC
Source: https://github.com/piecepackr/ppcli

Help Index


Prints 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")
)

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.

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.

Value

String of text diagram (returned invisibly). As a side effect prints out the text diagram using cat().

See Also

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


Generate plaintext piecepack diagrams

Description

str_piece() generates plaintext piecepack diagrams.

Usage

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

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.

...

Mainly ignored except for a couple of undocumented features.

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.

Value

Character vector for text diagram.

See Also

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