Skip to contents

dice_dice() generates data frames for standard six-sided dice. d4_dice(), numeral_dice(), d8_dice(), d10_dice(), percentile_dice(), d12_dice(), and d20_dice() generates data frames for the classic seven polyhedral dice. fudge_dice() generates data frames for fudge dice.

Usage

dice_dice(
  ...,
  suit = 1:6,
  rank = 1L,
  x = as.double(1:6),
  y = 1,
  angle = 0,
  length.out = NA_integer_
)

d4_dice(
  ...,
  suit = 1:6,
  rank = 1L,
  x = as.double(1:6),
  y = 1,
  angle = 0,
  length.out = NA_integer_
)

fudge_dice(
  ...,
  suit = 1:6,
  rank = 1L,
  x = as.double(1:6),
  y = 1,
  angle = 0,
  length.out = NA_integer_
)

numeral_dice(
  ...,
  suit = 1:6,
  rank = 1L,
  x = as.double(1:6),
  y = 1,
  angle = 0,
  length.out = NA_integer_
)

d8_dice(
  ...,
  suit = 1:6,
  rank = 1L,
  x = as.double(1:6),
  y = 1,
  angle = 0,
  length.out = NA_integer_
)

d10_dice(
  ...,
  suit = 1:6,
  rank = 1L,
  x = as.double(1:6),
  y = 1,
  angle = 0,
  length.out = NA_integer_
)

percentile_dice(
  ...,
  suit = 1:6,
  rank = 1L,
  x = as.double(1:6),
  y = 1,
  angle = 0,
  length.out = NA_integer_
)

d12_dice(
  ...,
  suit = 1:6,
  rank = 1L,
  x = as.double(1:6),
  y = 1,
  angle = 0,
  length.out = NA_integer_
)

d20_dice(
  ...,
  suit = 1:6,
  rank = 1L,
  x = as.double(1:6),
  y = 1,
  angle = 0,
  length.out = NA_integer_
)

Arguments

...

Should be left empty.

suit

Suit value (color) of dice. 1L is "red", 2L is "black", 3L is "green", 4L is "blue", 5L is "yellow", and 6L is "white". Will be coerced by piece_suit().

rank

Rank value of dice from 1L (one) on up. d10 zeroes are 10L. Will be coerced by dice_rank() except percentile_dice() will coerce with percentile_dice_rank() and fudge_dice() will coerce with fudge_dice_rank().

x, y

Cartesian coordinates (numeric vectors)

angle

Rotation of dice (numeric vector of degrees, counter-clockwise). Will be coerced by piece_angle().

length.out

The number of pieces. Not needed if all the arguments are the same length (or of length one) and this length is the same as the number of desired pieces.

Value

A tibble::tibble() data frame with the following columns:

  • "piece_side"

  • "suit"

  • "rank"

  • "cfg" (optional, defaults to "piecepack")

  • "x"

  • "y"

  • "angle" (optional, defaults to 0).

This data frame is compatible with piecepackr::render_piece() and likely ppcli::cat_piece().

Examples

dfd <- dice_dice(suit = 1:6, rank = 1:6, x = 1:6, y = 1)
dfn <- numeral_dice(suit = 1:6, rank = 1:6, x = 1:6, y = 2)
dff <- fudge_dice(suit = 1:6, rank = rep(c("-", " ", "+"), 2L),
                  x = 1:6, y = 3)
dfd12 <- d12_dice(suit = 1:6, rank = 1:6, x = 1:6, y = 4)
df <- rbind(dfd, dfn, dff, dfd12)
if (require("piecepackr", quietly = TRUE) &&
    packageVersion("piecepackr") >= "1.15.0-1" &&
    piecepackr:::device_supports_unicode()) {
  grid::grid.newpage()
  envir = game_systems()
  pmap_piece(df, envir = envir, default.units = "in", op_scale = 0.01)
}