Skip to contents

d_isotoxal_2ngon() is a wrapper around d_polygon() to create isotoxal 2n-gon polygon shaped paths. Its vectorized in its x, y, r, n, a, s, and offset arguments. d_star() is provided as an alias.

Usage

d_isotoxal_2ngon(
  x,
  y,
  r,
  n,
  a = 90,
  ...,
  s = affiner::isotoxal_2ngon_inner_radius(n, alpha = alpha, beta_ext = beta_ext, d = d),
  alpha = NULL,
  beta_ext = NULL,
  d = NULL,
  offset = 0,
  origin_at_bottom = getOption("dee.origin_at_bottom", FALSE),
  height = getOption("dee.height")
)

d_star(
  x,
  y,
  r,
  n,
  a = 90,
  ...,
  s = affiner::isotoxal_2ngon_inner_radius(n, alpha = alpha, beta_ext = beta_ext, d = d),
  alpha = NULL,
  beta_ext = NULL,
  d = NULL,
  offset = 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.

r

The outer radius of the isotoxal 2n-gon polygon.

n

The number of outer vertices.

a

The angle of the first outer vertex (will be coerced by affiner::degrees()).

...

Passed to d_polygon().

s

The inner radius of the isotoxal 2n-gon polygon as a fraction of the outer radius i.e. the inner radius = s * r. Defaults to affiner::isotoxal_2ngon_inner_radius() computed from exactly one of alpha, beta_ext, or d.

alpha

Interior angle of an outer vertex passed to affiner::isotoxal_2ngon_inner_radius() to compute s. Will be coerced by affiner::degrees().

beta_ext

Exterior angle of an inner vertex passed to affiner::isotoxal_2ngon_inner_radius() to compute s. Will be coerced by affiner::degrees().

d

Density (winding number) of the star polygon |n/d| passed to affiner::isotoxal_2ngon_inner_radius() to compute s.

offset

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

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.

Examples

# A |5/2| star e.g. the *verda stelo* (using `d` shortcut)
d <- d_isotoxal_2ngon(x = 5, y = 5, r = 3, n = 5, d = 2)
if (requireNamespace("omsvg", quietly = TRUE) &&
    requireNamespace("nanosvgr", quietly = TRUE)) {
  plot(d, height = 10, width = 10,
       fill = "green", stroke = "none")
}

# "lozenge" shape most often has acute angles of 45 degrees (using `alpha`)
d <- d_isotoxal_2ngon(x = 5, y = 5, r = 4, n = 2, alpha = 45)
if (requireNamespace("omsvg", quietly = TRUE) &&
    requireNamespace("nanosvgr", quietly = TRUE)) {
  plot(d, height = 10, width = 10,
       fill = "cyan", stroke = "black", stroke_width = 4)
}

# `d_star()` is an alias for `d_isotoxal_2ngon()`
# Inner exterior angle of |8/3| star is 90 degrees (using `beta_ext`)
d <- d_star(x = 5, y = 5, r = 4, n = 8, a = 22.5, beta_ext = 90)
if (requireNamespace("omsvg", quietly = TRUE) &&
    requireNamespace("nanosvgr", quietly = TRUE)) {
  plot(d, height = 10, width = 10,
       fill = "yellow", stroke = "black", stroke_width = 4)
}


# Degenerate case of inner vertex with exterior angle of 180 degrees
# creates a regular `n`-gon.
d <- d_star(x = 5, y = 5, r = 4, n = 8, a = 22.5, beta_ext = 180)
if (requireNamespace("omsvg", quietly = TRUE) &&
    requireNamespace("nanosvgr", quietly = TRUE)) {
  plot(d, height = 10, width = 10,
       fill = "red", stroke = "black", stroke_width = 4)
}