Skip to contents

d_polygon() is a wrapper around MZ() to create polygon shaped paths. If the argument offset is nonzero will use polyclip::polyoffset() to compute an offset region. It's vectorized in its offset argument.

Usage

d_polygon(
  x,
  y = NULL,
  ...,
  offset = 0,
  linejoin = c("miter", "round"),
  miterlimit = 4
)

Arguments

x

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

y

Either NULL or a numeric vector.

...

Passed to MZ().

offset

If a positive number the distance for outward polygon offsetting. If a negative number the distance for inward polygon offsetting.

linejoin

If offset is nonzero the type of join operation to use at each vertex when computing the offset region.

miterlimit

Tolerance parameter if offset is nonzero and linejoin = "miter". See polyclip::polyoffset().

Value

A dee() object.

See also

polyclip::polyoffset() for details on computing the offset region when offset is non-zero.

Examples

l <- list(x = c(2, 5, 8, 5), y = c(5, 8, 5, 2))
d <- d_polygon(l, offset = c(1, 0, -1))
if (requireNamespace("omsvg", quietly = TRUE) &&
    requireNamespace("nanosvgr", quietly = TRUE)) {
  plot(d, height = 10, width = 10,
       attrs = list(fill_rule = "evenodd"),
       fill = "red", stroke = "black", stroke_width = 4)
}