View source: R/crosshairGrob.R
grid.crosshair | R Documentation |
grid.crosshair()
draws crosshairs at the corners of a rectangular area.
crosshairGrob()
is its grid grob counterpart.
They are intended for use in adding crosshairs at the corners of
game pieces in print-and-play layouts.
crosshairGrob(
...,
piece_side = "tile_back",
suit = NA,
rank = NA,
cfg = getOption("piecepackr.cfg", pp_cfg()),
x = unit(0.5, "npc"),
y = unit(0.5, "npc"),
angle = 0,
width = NA,
height = NA,
scale = 1,
default.units = "npc",
envir = getOption("piecepackr.envir"),
name = NULL,
gp = gpar(),
vp = NULL,
ch_width = unit(1/6, "in"),
ch_grob = squaresCrosshairGrob()
)
grid.crosshair(..., draw = TRUE)
segmentsCrosshairGrob(
...,
x = unit(0.5, "npc"),
y = unit(0.5, "npc"),
width = unit(1, "snpc"),
height = unit(1, "snpc"),
default.units = "npc",
name = NULL,
gp = gpar(),
vp = NULL
)
squaresCrosshairGrob(
...,
x = unit(0.5, "npc"),
y = unit(0.5, "npc"),
width = unit(1, "snpc"),
height = unit(1, "snpc"),
default.units = "npc",
name = NULL,
gp = gpar(),
vp = NULL
)
... |
|
piece_side |
A string with piece and side separated by a underscore e.g. "coin_face" |
suit |
Number of suit (starting from 1). |
rank |
Number of rank (starting from 1) |
cfg |
Piecepack configuration list or |
x |
Where to place piece on x axis of viewport |
y |
Where to place piece on y axis of viewport |
angle |
Angle (on xy plane) to draw piece at |
width |
Width of piece |
height |
Height of piece |
scale |
Multiplicative scaling factor to apply to width, height, and depth. |
default.units |
A string indicating the default units to use if 'x', 'y', 'width', and/or 'height' are only given as numeric vectors. |
envir |
Environment (or named list) containing configuration list(s). |
name |
A character identifier (for grid) |
gp |
An object of class “gpar”. |
vp |
A |
ch_width |
Width/height of |
ch_grob |
Crosshair grob. Will be drawn in each corner of the piece in a viewport with |
draw |
A logical value indicating whether graphics output should be produced. |
One can use the lower level segmentsCrosshairGrob()
and squaresCrosshairGrob()
(which can be drawn with grid::grid.draw()
)
to add individual crosshairs to specified (x,y) locations.
A grid grob.
if (requireNamespace("grid", quietly = TRUE) &&
piecepackr:::device_supports_unicode()) {
cfg <- pp_cfg(list(border_color = NA))
grid::grid.newpage()
df <- data.frame(piece_side = "tile_face", suit = 2, rank = 2,
x = 2, y = 2, angle = 0,
stringsAsFactors = FALSE)
pmap_piece(df, grid.piece, cfg = cfg, default.units = "in")
pmap_piece(df, grid.crosshair, cfg = cfg, default.units = "in")
}
if (requireNamespace("grid", quietly = TRUE) &&
piecepackr:::device_supports_unicode()) {
grid::grid.newpage()
pmap_piece(df, grid.piece, cfg = cfg, default.units = "in")
pmap_piece(df, grid.crosshair, cfg = cfg, default.units = "in",
ch_grob = segmentsCrosshairGrob())
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.