Skip to contents

d_rect() is a wrapper around d_polygon() to create rectangle shaped paths. It's vectorized in its x, y, w, and h arguments.

Usage

d_rect(
  x,
  y = NULL,
  w,
  h,
  a = 0,
  ...,
  origin_at_bottom = getOption("dee.origin_at_bottom", FALSE),
  height = getOption("dee.height")
)

Arguments

x

If y is NULL will be coerced by affiner::as_coord2d(). Else a numeric vector.

y

Either NULL or a numeric vector.

w, h

The width and height of the rectangle.

a

The angle of rotation (will be coerced by affiner::degrees()).

...

Passed to d_polygon().

origin_at_bottom, height

If origin_at_bottom is TRUE then y (and any y1 and y2) coordinates is transformed by height - y for absolute coordinates and -y for relative coordinates.

Value

A dee() object.

See also

Examples

d_rect(x = 5, y = 5, w = 4, h = 6)
#> <dee[1]>
#> M 3,2 3,8 7,8 7,2 Z
if (requireNamespace("omsvg", quietly = TRUE) &&
    requireNamespace("nanosvgr", quietly = TRUE)) {
  plot(d_rect(x = 5, y = 5, w = 4, h = 6),
       height = 10, width = 10,
       fill = "red", stroke = "black", stroke_width = 4)
}