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
yisNULLwill be coerced byaffiner::as_coord2d(). Else a numeric vector.- y
Either
NULLor 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 toaffiner::isotoxal_2ngon_inner_radius()computed from exactly one ofalpha,beta_ext, ord.- alpha
Interior angle of an outer vertex passed to
affiner::isotoxal_2ngon_inner_radius()to computes. Will be coerced byaffiner::degrees().- beta_ext
Exterior angle of an inner vertex passed to
affiner::isotoxal_2ngon_inner_radius()to computes. Will be coerced byaffiner::degrees().- d
Density (winding number) of the star polygon
|n/d|passed toaffiner::isotoxal_2ngon_inner_radius()to computes.- 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_bottomisTRUEtheny(and anyy1andy2) coordinates is transformed byheight - yfor absolute coordinates and-yfor relative coordinates.
Value
A dee() object.
See also
d_polygon() and d_regular_ngon(). See
https://en.wikipedia.org/wiki/Isotoxal_figure#Isotoxal_polygons and
https://en.wikipedia.org/wiki/Star_polygon#Isotoxal_star_simple_polygons
for more information on isotoxal polygons.
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)
}