| Title: | Tools for Generating String Art Figures |
|---|---|
| Description: | Provides tools to generate, visualize, and audit geometric string art figures for mathematics teaching. The package includes functions for circular, cardioid-like, elliptical, triangular, polygonal, star, parabolic, net-based, radial, hexagonal, lotus-like, rose-like, spiral, Lissajous, grid-based, decimal, and contour-based string art patterns. Each function returns peg coordinates, connection tables, total string length, audit information, and metadata, supporting educational applications in geometry, analytic geometry, modular arithmetic, trigonometry, rational numbers, and visual mathematics. |
| Authors: | Fernando de Souza Bastos [aut, cre], Ivo Moreira Barbosa [aut] |
| Maintainer: | Fernando de Souza Bastos <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.0 |
| Built: | 2026-05-29 10:44:46 UTC |
| Source: | https://github.com/fsbmat-ufv/stringart |
Opens the interactive Shiny application included with the package.
run_stringArt_app(launch.browser = TRUE, ...)run_stringArt_app(launch.browser = TRUE, ...)
launch.browser |
Logical. If |
... |
Additional arguments passed to |
Invisibly returns the result of shiny::runApp().
if (interactive()) { run_stringArt_app() }if (interactive()) { run_stringArt_app() }
stcardioid() generates a circular string art pattern by placing equally
spaced pegs on a circle and connecting each peg to another peg according to
a multiplicative modular rule.
stcardioid( n = 120, k = 2, col = "antiquewhite", lwd = 0.8, plot = TRUE, show_points = FALSE, show_labels = FALSE, verbose = FALSE, r = 1, rotate = 0, show_strings = TRUE, template = FALSE, point_col = "darkorange2", point_cex = 0.8, point_pch = 21, point_bg = "white", label_cex = 0.7, label_col = "black", border_col = "goldenrod3", border_lwd = 1.2, bg = "white", main = NULL )stcardioid( n = 120, k = 2, col = "antiquewhite", lwd = 0.8, plot = TRUE, show_points = FALSE, show_labels = FALSE, verbose = FALSE, r = 1, rotate = 0, show_strings = TRUE, template = FALSE, point_col = "darkorange2", point_cex = 0.8, point_pch = 21, point_bg = "white", label_cex = 0.7, label_col = "black", border_col = "goldenrod3", border_lwd = 1.2, bg = "white", main = NULL )
n |
Integer. Number of pegs placed on the circle. Must be at least 3. |
k |
Integer. Multiplication factor used in the modular connection rule.
Must satisfy |
col |
String color passed to |
lwd |
Positive number. Line width used to draw the strings. |
plot |
Logical. If |
show_points |
Logical. If |
show_labels |
Logical. If |
verbose |
Logical. If |
r |
Positive number. Radius of the circle. |
rotate |
Numeric. Rotation angle in radians applied to the whole figure. |
show_strings |
Logical. If |
template |
Logical. If |
point_col |
Peg border color. |
point_cex |
Positive number. Peg size. |
point_pch |
Plotting symbol used for pegs. |
point_bg |
Peg background color when applicable. |
label_cex |
Positive number. Label size. |
label_col |
Label color. |
border_col |
Circle border color. |
border_lwd |
Positive number. Circle border line width. |
bg |
Plot background color. |
main |
Optional plot title. If |
The pegs are placed on a circle of radius r, centered at the origin. Pegs
are indexed from 1 to n in counterclockwise order, starting at (r, 0),
after applying the optional rotation angle rotate.
The multiplicative modular connection rule is:
to = ((k * (from - 1)) %% n) + 1.
For k = 2, this rule produces the classical circular multiplication-table
pattern commonly associated with a cardioid-like envelope.
Invisibly returns a list of class stringart_result with:
A data.frame with columns index, x, and y.
A data.frame with columns connection_index,
from, to, x_from, y_from, x_to, y_to, and length.
Total string length.
A character vector with audit information.
A list with construction metadata.
stcardioid() res <- stcardioid(plot = FALSE) head(res$pegs) head(res$connections) res$total_length stcardioid(n = 80, k = 2, col = "steelblue", lwd = 0.8) stcardioid(n = 24, k = 5, show_points = TRUE, show_labels = TRUE) stcardioid(template = TRUE)stcardioid() res <- stcardioid(plot = FALSE) head(res$pegs) head(res$connections) res$total_length stcardioid(n = 80, k = 2, col = "steelblue", lwd = 0.8) stcardioid(n = 24, k = 5, show_points = TRUE, show_labels = TRUE) stcardioid(template = TRUE)
stcircle() creates a circular String Art figure by placing equally spaced
pegs on a circle and connecting each peg to another peg using an additive
modular step.
stcircle( n = 30, k = 5, col = "blue", lwd = 1, plot = TRUE, show_points = TRUE, show_labels = FALSE, verbose = FALSE, r = 1, show_strings = TRUE, template = FALSE, point_col = "black", point_cex = 0.8, point_pch = 19, point_bg = "white", label_cex = 0.7, label_col = "black", border_col = "grey50", border_lwd = 1, main = NULL )stcircle( n = 30, k = 5, col = "blue", lwd = 1, plot = TRUE, show_points = TRUE, show_labels = FALSE, verbose = FALSE, r = 1, show_strings = TRUE, template = FALSE, point_col = "black", point_cex = 0.8, point_pch = 19, point_bg = "white", label_cex = 0.7, label_col = "black", border_col = "grey50", border_lwd = 1, main = NULL )
n |
Integer. Number of pegs on the circle. Defaults to |
k |
Integer. Additive modular step used to define the connections.
Defaults to |
col |
String color used to draw the segments. Defaults to |
lwd |
Positive number. Line width of the string segments. Defaults to |
plot |
Logical. If |
show_points |
Logical. If |
show_labels |
Logical. If |
verbose |
Logical. If |
r |
Positive number. Radius of the circle. Defaults to |
show_strings |
Logical. If |
template |
Logical. If |
point_col |
Color of the pegs. |
point_cex |
Positive number. Size of the pegs. |
point_pch |
Plotting symbol used for the pegs. |
point_bg |
Background color of the pegs when the plotting symbol allows filling. |
label_cex |
Positive number. Size of the peg labels. |
label_col |
Color of the peg labels. |
border_col |
Color of the circular border. |
border_lwd |
Positive number. Line width of the circular border. |
main |
Character string. Plot title. If |
Pegs are numbered from 1 to n counterclockwise, starting at (r, 0).
For each peg i, the connected peg is defined by
When gcd(n, k) = 1, the rule creates a single cycle passing through all
pegs. When gcd(n, k) > 1, the figure is decomposed into independent cycles.
Invisibly returns a list with the following elements:
A data frame with columns index, x, and y.
A data frame with columns connection_index, from,
to, x_from, y_from, x_to, y_to, and length.
Total string length.
Character vector with an audit summary.
List with metadata about the construction.
stcircle() res <- stcircle(plot = FALSE) res$total_length head(res$connections) stcircle(n = 24, k = 7, col = "firebrick", lwd = 1.2, show_points = TRUE, show_labels = TRUE) stcircle(n = 24, k = 7, template = TRUE)stcircle() res <- stcircle(plot = FALSE) res$total_length head(res$connections) stcircle(n = 24, k = 7, col = "firebrick", lwd = 1.2, show_points = TRUE, show_labels = TRUE) stcircle(n = 24, k = 7, template = TRUE)
stdecimal() places digit pegs on a circle and connects consecutive digits
in the expansion of a rational number. By default, the function uses base 10,
so the pegs are labeled from 0 to 9.
stdecimal( numerator = 1, denominator = 7, n = 10, k = 2, col = "blue", lwd = 1, plot = TRUE, show_points = TRUE, show_labels = TRUE, verbose = FALSE, radius = 1, rotate = pi/2, include_integer_part = TRUE, show_strings = TRUE, template = FALSE, point_col = "black", point_cex = 0.9, point_pch = 21, point_bg = "white", label_cex = 0.8, label_col = "black", border_col = "grey50", border_lwd = 1, bg = "white", main = NULL )stdecimal( numerator = 1, denominator = 7, n = 10, k = 2, col = "blue", lwd = 1, plot = TRUE, show_points = TRUE, show_labels = TRUE, verbose = FALSE, radius = 1, rotate = pi/2, include_integer_part = TRUE, show_strings = TRUE, template = FALSE, point_col = "black", point_cex = 0.9, point_pch = 21, point_bg = "white", label_cex = 0.8, label_col = "black", border_col = "grey50", border_lwd = 1, bg = "white", main = NULL )
numerator |
Integer. Numerator of the rational number. |
denominator |
Integer. Denominator of the rational number. Must be nonzero. |
n |
Integer. Numeral base and number of digit pegs. Default is 10. |
k |
Integer. Number of repetitions of the repetend shown in the plot when the expansion is repeating. Must be at least 1. |
col |
String color passed to |
lwd |
Positive number. Line width used to draw the digit path. |
plot |
Logical. If |
show_points |
Logical. If |
show_labels |
Logical. If |
verbose |
Logical. If |
radius |
Positive number. Circle radius. |
rotate |
Numeric. Rotation angle in radians applied to the digit circle. |
include_integer_part |
Logical. If |
show_strings |
Logical. If |
template |
Logical. If |
point_col |
Peg color. |
point_cex |
Positive number. Peg size. |
point_pch |
Plotting symbol used for pegs. |
point_bg |
Peg background color when applicable. |
label_cex |
Positive number. Label size. |
label_col |
Label color. |
border_col |
Border color of the digit circle. |
border_lwd |
Positive number. Border line width. |
bg |
Plot background color. |
main |
Optional plot title. If |
The function computes the base-n expansion of numerator / denominator
using exact long division. When the expansion is repeating, the repetend is
displayed k times after the preperiod.
For the default setting n = 10, the function is especially useful for
exploring decimal expansions, repeating decimals, periodicity, and patterns
in rational numbers.
Invisibly returns a list of class stringart_result with:
A data.frame with columns index, x, y, and digit.
A data.frame with columns connection_index,
from, to, x_from, y_from, x_to, y_to, length,
digit_from, digit_to, and position.
Total string length.
A character vector with audit information.
A list with construction metadata.
stdecimal() stdecimal(1, 7) stdecimal(1, 13) stdecimal(22, 7) stdecimal(template = TRUE)stdecimal() stdecimal(1, 7) stdecimal(1, 13) stdecimal(22, 7) stdecimal(template = TRUE)
stellipse() generates a string art pattern by placing equally spaced pegs
along an ellipse and connecting each peg to another peg according to an
additive modular rule.
stellipse( n = 30, k = 5, col = "blue", lwd = 1, plot = TRUE, show_points = TRUE, show_labels = FALSE, verbose = FALSE, a = 2, b = 1, rotate = 0, show_strings = TRUE, template = FALSE, point_col = "black", point_cex = 0.8, point_pch = 19, point_bg = "white", label_cex = 0.7, label_col = "black", border_col = "grey50", border_lwd = 1, bg = "white", main = NULL )stellipse( n = 30, k = 5, col = "blue", lwd = 1, plot = TRUE, show_points = TRUE, show_labels = FALSE, verbose = FALSE, a = 2, b = 1, rotate = 0, show_strings = TRUE, template = FALSE, point_col = "black", point_cex = 0.8, point_pch = 19, point_bg = "white", label_cex = 0.7, label_col = "black", border_col = "grey50", border_lwd = 1, bg = "white", main = NULL )
n |
Integer. Number of pegs placed on the ellipse. Must be at least 3. |
k |
Integer. Step used in the modular connection rule. Must satisfy
|
col |
String color passed to |
lwd |
Positive number. Line width used to draw the strings. |
plot |
Logical. If |
show_points |
Logical. If |
show_labels |
Logical. If |
verbose |
Logical. If |
a |
Positive number. Semi-major horizontal axis of the ellipse. |
b |
Positive number. Semi-minor vertical axis of the ellipse. |
rotate |
Numeric. Rotation angle in radians applied to the whole figure. |
show_strings |
Logical. If |
template |
Logical. If |
point_col |
Peg color. |
point_cex |
Positive number. Peg size. |
point_pch |
Plotting symbol used for pegs. |
point_bg |
Peg background color when applicable. |
label_cex |
Positive number. Label size. |
label_col |
Label color. |
border_col |
Ellipse border color. |
border_lwd |
Positive number. Ellipse border line width. |
bg |
Plot background color. |
main |
Optional plot title. If |
The pegs are placed along the parametric ellipse
x = a * cos(theta) and y = b * sin(theta), centered at the origin.
Pegs are indexed from 1 to n in counterclockwise order, starting at
(a, 0), after applying the optional rotation angle rotate.
The additive modular connection rule is:
to = ((from + k - 1) %% n) + 1.
When gcd(n, k) = 1, this rule generates a single cycle passing through all
pegs. When gcd(n, k) > 1, the figure decomposes into independent cycles.
Invisibly returns a list of class stringart_result with:
A data.frame with columns index, x, and y.
A data.frame with columns connection_index,
from, to, x_from, y_from, x_to, y_to, and length.
Total string length.
A character vector with audit information.
A list with construction metadata.
stellipse() res <- stellipse(plot = FALSE) head(res$pegs) head(res$connections) res$total_length stellipse(n = 40, k = 7, a = 2.5, b = 1.2, col = "purple", lwd = 1) stellipse(n = 24, k = 5, show_points = TRUE, show_labels = TRUE) stellipse(template = TRUE)stellipse() res <- stellipse(plot = FALSE) head(res$pegs) head(res$connections) res$total_length stellipse(n = 40, k = 7, a = 2.5, b = 1.2, col = "purple", lwd = 1) stellipse(n = 24, k = 5, show_points = TRUE, show_labels = TRUE) stellipse(template = TRUE)
stgrid() generates string art by placing pegs uniformly along the boundary
of a rectangle and connecting them using an additive modular rule.
stgrid( n = 60, k = 7, col = "blue", lwd = 1, plot = TRUE, show_points = TRUE, show_labels = FALSE, verbose = FALSE, width = 2, height = 1, rotate = 0, show_strings = TRUE, template = FALSE, border_col = "grey50", border_lwd = 1, point_col = "black", point_cex = 0.8, point_pch = 19, point_bg = "white", label_cex = 0.7, label_col = "black", bg = "white", main = NULL )stgrid( n = 60, k = 7, col = "blue", lwd = 1, plot = TRUE, show_points = TRUE, show_labels = FALSE, verbose = FALSE, width = 2, height = 1, rotate = 0, show_strings = TRUE, template = FALSE, border_col = "grey50", border_lwd = 1, point_col = "black", point_cex = 0.8, point_pch = 19, point_bg = "white", label_cex = 0.7, label_col = "black", bg = "white", main = NULL )
n |
Integer. Number of pegs placed on the rectangle boundary. Must be at least 4. |
k |
Integer. Additive modular step used in the connection rule. Must
satisfy |
col |
String color passed to |
lwd |
Positive number. Line width used to draw the strings. |
plot |
Logical. If |
show_points |
Logical. If |
show_labels |
Logical. If |
verbose |
Logical. If |
width |
Positive number. Rectangle width. |
height |
Positive number. Rectangle height. |
rotate |
Numeric. Rotation angle in radians. |
show_strings |
Logical. If |
template |
Logical. If |
border_col |
Rectangle border color. |
border_lwd |
Positive number. Border line width. |
point_col |
Peg color. |
point_cex |
Positive number. Peg size. |
point_pch |
Plotting symbol used for pegs. |
point_bg |
Peg background color when applicable. |
label_cex |
Positive number. Label size. |
label_col |
Label color. |
bg |
Plot background color. |
main |
Optional plot title. |
Pegs are distributed uniformly along the rectangle boundary and connected
using the additive modular rule
to = ((from + k - 1) %% n) + 1.
Invisibly returns a list of class stringart_result.
stgrid() stgrid(width = 2, height = 1) stgrid(template = TRUE)stgrid() stgrid(width = 2, height = 1) stgrid(template = TRUE)
sthexaflower() generates a string art pattern based on three concentric
hexagonal peg circuits and one central peg. The construction is fully
reproducible and returns both the peg coordinates and the connection table.
sthexaflower( n = 24, k = 5, col = c("black", "forestgreen", "darkorange", "deepskyblue4", "firebrick", "purple"), lwd = 1, plot = TRUE, show_points = TRUE, show_labels = FALSE, verbose = FALSE, r = 1, scale_mid = 0.72, scale_inner = 0.42, offset_mid = 0, offset_inner = 0, rotate = 0, show_strings = TRUE, template = FALSE, point_col = "black", point_cex = 0.8, point_pch = 19, point_bg = "white", label_cex = 0.7, label_col = "black", border_col = "grey50", border_lwd = 1, bg = "white", main = NULL )sthexaflower( n = 24, k = 5, col = c("black", "forestgreen", "darkorange", "deepskyblue4", "firebrick", "purple"), lwd = 1, plot = TRUE, show_points = TRUE, show_labels = FALSE, verbose = FALSE, r = 1, scale_mid = 0.72, scale_inner = 0.42, offset_mid = 0, offset_inner = 0, rotate = 0, show_strings = TRUE, template = FALSE, point_col = "black", point_cex = 0.8, point_pch = 19, point_bg = "white", label_cex = 0.7, label_col = "black", border_col = "grey50", border_lwd = 1, bg = "white", main = NULL )
n |
Integer. Number of pegs in each hexagonal circuit. Must be a multiple of 6 and at least 6. |
k |
Integer. Step used in the local modular connection rule. Must
satisfy |
col |
String color passed to |
lwd |
Positive number. Line width used to draw the strings. |
plot |
Logical. If |
show_points |
Logical. If |
show_labels |
Logical. If |
verbose |
Logical. If |
r |
Positive number. Radius of the outer hexagonal circuit. |
scale_mid |
Positive number in |
scale_inner |
Positive number in |
offset_mid |
Numeric value in |
offset_inner |
Numeric value in |
rotate |
Numeric. Rotation angle in radians applied to the whole figure. |
show_strings |
Logical. If |
template |
Logical. If |
point_col |
Peg color. |
point_cex |
Positive number. Peg size. |
point_pch |
Plotting symbol used for pegs. |
point_bg |
Peg background color when applicable. |
label_cex |
Positive number. Label size. |
label_col |
Label color. |
border_col |
Hexagonal border color. |
border_lwd |
Positive number. Hexagonal border line width. |
bg |
Plot background color. |
main |
Optional plot title. If |
The function builds three concentric hexagonal circuits with n pegs each
and one central peg.
The peg table contains the columns index, x, y, group, layer, and
local_index.
The construction uses four connection blocks:
outer_border: consecutive connections on the outer hexagon.
outer_to_middle: connections from the outer circuit to the middle circuit.
middle_to_inner: connections from the middle circuit to the inner circuit.
vertices_to_center: connections from the outer vertices to the central peg.
The local additive modular rule used in the two radial blocks is
to_local = ((from_local + k - 1) %% n) + 1.
Invisibly returns a list of class stringart_result with:
A data.frame with peg coordinates and metadata.
A data.frame with columns connection_index,
from, to, x_from, y_from, x_to, y_to, length, block, and
sector.
Total string length.
A character vector with audit information.
A list with construction metadata.
sthexaflower() res <- sthexaflower(plot = FALSE) head(res$pegs) head(res$connections) res$total_length sthexaflower(n = 30, k = 7, col = "steelblue", lwd = 0.8) sthexaflower(n = 24, k = 5, show_points = TRUE, show_labels = TRUE) sthexaflower(template = TRUE)sthexaflower() res <- sthexaflower(plot = FALSE) head(res$pegs) head(res$connections) res$total_length sthexaflower(n = 30, k = 7, col = "steelblue", lwd = 0.8) sthexaflower(n = 24, k = 5, show_points = TRUE, show_labels = TRUE) sthexaflower(template = TRUE)
stlissajous() generates a string art figure from pegs sampled on a
Lissajous curve.
stlissajous( n = 300, k = 19, col = "purple", lwd = 0.7, plot = TRUE, show_points = FALSE, show_labels = FALSE, verbose = FALSE, a = 3, b = 2, phase = pi/2, amplitude_x = 1, amplitude_y = 1, rotate = 0, show_strings = TRUE, template = FALSE, draw_curve = TRUE, border_col = "grey50", border_lwd = 1, point_col = "black", point_cex = 0.5, point_pch = 19, point_bg = "white", label_cex = 0.6, label_col = "black", bg = "white", main = NULL )stlissajous( n = 300, k = 19, col = "purple", lwd = 0.7, plot = TRUE, show_points = FALSE, show_labels = FALSE, verbose = FALSE, a = 3, b = 2, phase = pi/2, amplitude_x = 1, amplitude_y = 1, rotate = 0, show_strings = TRUE, template = FALSE, draw_curve = TRUE, border_col = "grey50", border_lwd = 1, point_col = "black", point_cex = 0.5, point_pch = 19, point_bg = "white", label_cex = 0.6, label_col = "black", bg = "white", main = NULL )
n |
Integer. Number of pegs sampled on the curve. Must be at least 3. |
k |
Integer. Additive modular step used in the connection rule. Must
satisfy |
col |
String color passed to |
lwd |
Positive number. Line width used to draw the strings. |
plot |
Logical. If |
show_points |
Logical. If |
show_labels |
Logical. If |
verbose |
Logical. If |
a |
Positive integer. Frequency in the x-coordinate. |
b |
Positive integer. Frequency in the y-coordinate. |
phase |
Numeric. Phase shift in radians. |
amplitude_x |
Positive number. Horizontal amplitude. |
amplitude_y |
Positive number. Vertical amplitude. |
rotate |
Numeric. Rotation angle in radians. |
show_strings |
Logical. If |
template |
Logical. If |
draw_curve |
Logical. If |
border_col |
Curve color. |
border_lwd |
Positive number. Curve line width. |
point_col |
Peg color. |
point_cex |
Positive number. Peg size. |
point_pch |
Plotting symbol used for pegs. |
point_bg |
Peg background color when applicable. |
label_cex |
Positive number. Label size. |
label_col |
Label color. |
bg |
Plot background color. |
main |
Optional plot title. |
The curve is given by
x(t) = amplitude_x * sin(a * t + phase) and
y(t) = amplitude_y * sin(b * t).
Invisibly returns a list of class stringart_result.
stlissajous() stlissajous(a = 3, b = 2) stlissajous(a = 5, b = 4, phase = pi / 3) stlissajous(template = TRUE)stlissajous() stlissajous(a = 3, b = 2) stlissajous(a = 5, b = 4, phase = pi / 3) stlissajous(template = TRUE)
stlotus() generates a stylized lotus-like string art figure by combining
one outer circular module, one central circular module, and several petal
modules arranged around the center.
stlotus( n = 40, k = 11, col = "deeppink4", lwd = 0.8, plot = TRUE, show_points = FALSE, show_labels = FALSE, verbose = FALSE, petals = 5, outer_radius = 1, petal_radius = 0.34, petal_center_radius = 0.34, inner_radius = 0.18, rotate = 0, show_strings = TRUE, template = FALSE, point_col = "black", point_cex = 0.6, point_pch = 19, point_bg = "white", label_cex = 0.6, label_col = "black", border_col = "grey50", border_lwd = 1, bg = "white", main = NULL )stlotus( n = 40, k = 11, col = "deeppink4", lwd = 0.8, plot = TRUE, show_points = FALSE, show_labels = FALSE, verbose = FALSE, petals = 5, outer_radius = 1, petal_radius = 0.34, petal_center_radius = 0.34, inner_radius = 0.18, rotate = 0, show_strings = TRUE, template = FALSE, point_col = "black", point_cex = 0.6, point_pch = 19, point_bg = "white", label_cex = 0.6, label_col = "black", border_col = "grey50", border_lwd = 1, bg = "white", main = NULL )
n |
Integer. Number of pegs in each circular module. Must be at least 3. |
k |
Integer. Additive modular step used in each module. Must satisfy
|
col |
String color passed to |
lwd |
Positive number. Line width used to draw the strings. |
plot |
Logical. If |
show_points |
Logical. If |
show_labels |
Logical. If |
verbose |
Logical. If |
petals |
Integer. Number of petal modules around the center. |
outer_radius |
Positive number. Radius of the outer circular module. |
petal_radius |
Positive number. Radius of each petal module. |
petal_center_radius |
Positive number. Distance from the origin to each petal center. |
inner_radius |
Positive number. Radius of the central circular module. |
rotate |
Numeric. Rotation angle in radians applied to the whole figure. |
show_strings |
Logical. If |
template |
Logical. If |
point_col |
Peg color. |
point_cex |
Positive number. Peg size. |
point_pch |
Plotting symbol used for pegs. |
point_bg |
Peg background color when applicable. |
label_cex |
Positive number. Label size. |
label_col |
Label color. |
border_col |
Border color used for the module outlines. |
border_lwd |
Positive number. Border line width. |
bg |
Plot background color. |
main |
Optional plot title. If |
The figure is built from petals + 2 circular modules:
one outer circular module;
petals petal modules;
one central circular module.
Each module contains n equally spaced pegs and uses the same additive
modular rule:
to_local = ((from_local + k - 1) %% n) + 1.
The final figure is obtained by superimposing all module connections.
Invisibly returns a list of class stringart_result with:
A data.frame with peg coordinates and metadata.
A data.frame with columns connection_index,
from, to, x_from, y_from, x_to, y_to, length, module,
local_from, and local_to.
Total string length.
A character vector with audit information.
A list with construction metadata.
stlotus() res <- stlotus(plot = FALSE) head(res$pegs) head(res$connections) res$total_length stlotus(n = 50, k = 13, col = "deeppink4", lwd = 0.8) stlotus(show_points = TRUE, show_labels = TRUE) stlotus(template = TRUE)stlotus() res <- stlotus(plot = FALSE) head(res$pegs) head(res$connections) res$total_length stlotus(n = 50, k = 13, col = "deeppink4", lwd = 0.8) stlotus(show_points = TRUE, show_labels = TRUE) stlotus(template = TRUE)
stnet() generates a string art net by placing pegs on two rays that share
a common vertex and connecting corresponding peg positions. The construction
generalizes the classical parabolic string art envelope by allowing the angle
between the two supporting rays to vary.
stnet( n = 30, k = 1, col = "blue", lwd = 1, plot = TRUE, show_points = TRUE, show_labels = FALSE, verbose = FALSE, length1 = 1, length2 = 1, angle = pi/2, rotate = 0, show_strings = TRUE, template = FALSE, show_envelope = FALSE, envelope_col = "red", envelope_lwd = 1, envelope_lty = 2, point_col = "black", point_cex = 0.8, point_pch = 19, point_bg = "white", label_cex = 0.7, label_col = "black", border_col = "grey50", border_lwd = 1, bg = "white", main = NULL )stnet( n = 30, k = 1, col = "blue", lwd = 1, plot = TRUE, show_points = TRUE, show_labels = FALSE, verbose = FALSE, length1 = 1, length2 = 1, angle = pi/2, rotate = 0, show_strings = TRUE, template = FALSE, show_envelope = FALSE, envelope_col = "red", envelope_lwd = 1, envelope_lty = 2, point_col = "black", point_cex = 0.8, point_pch = 19, point_bg = "white", label_cex = 0.7, label_col = "black", border_col = "grey50", border_lwd = 1, bg = "white", main = NULL )
n |
Integer. Number of pegs placed on each ray. Must be at least 3. |
k |
Integer. Number of shifted sweeps used in the construction. Must
satisfy |
col |
String color passed to |
lwd |
Positive number. Line width used to draw the strings. |
plot |
Logical. If |
show_points |
Logical. If |
show_labels |
Logical. If |
verbose |
Logical. If |
length1 |
Positive number. Length of the first ray. |
length2 |
Positive number. Length of the second ray. |
angle |
Numeric. Angle in radians from the first ray to the second ray.
Must not be a multiple of |
rotate |
Numeric. Rotation angle in radians applied to the whole net. |
show_strings |
Logical. If |
template |
Logical. If |
show_envelope |
Logical. If |
envelope_col |
Color used for the theoretical envelope. |
envelope_lwd |
Positive number. Line width used for the envelope. |
envelope_lty |
Line type used for the envelope. |
point_col |
Peg color. |
point_cex |
Positive number. Peg size. |
point_pch |
Plotting symbol used for pegs. |
point_bg |
Peg background color when applicable. |
label_cex |
Positive number. Label size. |
label_col |
Label color. |
border_col |
Ray color. |
border_lwd |
Positive number. Ray line width. |
bg |
Plot background color. |
main |
Optional plot title. If |
The construction uses two rays with a common vertex. Pegs are placed uniformly along the first ray from the common vertex to the first endpoint and along the second ray from the second endpoint back to the common vertex.
For k = 1, the peg at local position i on the first ray is connected to
the peg at local position i on the second ray. In oblique coordinates
determined by the two rays, the theoretical envelope is given by
C(t) = t^2 A + (1 - t)^2 B,
where A and B are the endpoints of the two rays and 0 <= t <= 1.
For k > 1, the function adds shifted sweeps of the same construction,
producing denser string art nets.
Invisibly returns a list of class stringart_result with:
A data.frame with columns index, x, y, ray, and
local_index.
A data.frame with columns connection_index,
from, to, x_from, y_from, x_to, y_to, length, sweep,
offset, local_from, and local_to.
Total string length.
A character vector with audit information.
A list with construction metadata.
stnet() res <- stnet(plot = FALSE) head(res$pegs) head(res$connections) res$total_length stnet(n = 40, k = 1, angle = pi / 2, col = "steelblue") stnet(n = 40, k = 3, angle = 2 * pi / 3, col = "firebrick", lwd = 0.7) stnet(show_envelope = TRUE) stnet(template = TRUE)stnet() res <- stnet(plot = FALSE) head(res$pegs) head(res$connections) res$total_length stnet(n = 40, k = 1, angle = pi / 2, col = "steelblue") stnet(n = 40, k = 3, angle = 2 * pi / 3, col = "firebrick", lwd = 0.7) stnet(show_envelope = TRUE) stnet(template = TRUE)
stparabola() generates a classical string art construction on two
perpendicular axes. Pegs are placed on a horizontal axis and on a vertical
axis, and straight strings are drawn between corresponding peg positions.
The resulting family of line segments visually suggests a parabolic envelope.
stparabola( n = 30, k = 1, col = "blue", lwd = 1, plot = TRUE, show_points = TRUE, show_labels = FALSE, verbose = FALSE, width = 1, height = 1, show_strings = TRUE, template = FALSE, show_envelope = FALSE, envelope_col = "red", envelope_lwd = 1, envelope_lty = 2, point_col = "black", point_cex = 0.8, point_pch = 19, point_bg = "white", label_cex = 0.7, label_col = "black", border_col = "grey50", border_lwd = 1, bg = "white", main = NULL )stparabola( n = 30, k = 1, col = "blue", lwd = 1, plot = TRUE, show_points = TRUE, show_labels = FALSE, verbose = FALSE, width = 1, height = 1, show_strings = TRUE, template = FALSE, show_envelope = FALSE, envelope_col = "red", envelope_lwd = 1, envelope_lty = 2, point_col = "black", point_cex = 0.8, point_pch = 19, point_bg = "white", label_cex = 0.7, label_col = "black", border_col = "grey50", border_lwd = 1, bg = "white", main = NULL )
n |
Integer. Number of pegs placed on each axis. Must be at least 3. |
k |
Integer. Number of shifted sweeps used in the construction. Must
satisfy |
col |
String color passed to |
lwd |
Positive number. Line width used to draw the strings. |
plot |
Logical. If |
show_points |
Logical. If |
show_labels |
Logical. If |
verbose |
Logical. If |
width |
Positive number. Length of the horizontal axis. |
height |
Positive number. Length of the vertical axis. |
show_strings |
Logical. If |
template |
Logical. If |
show_envelope |
Logical. If |
envelope_col |
Color used for the theoretical envelope. |
envelope_lwd |
Positive number. Line width used for the envelope. |
envelope_lty |
Line type used for the envelope. |
point_col |
Peg color. |
point_cex |
Positive number. Peg size. |
point_pch |
Plotting symbol used for pegs. |
point_bg |
Peg background color when applicable. |
label_cex |
Positive number. Label size. |
label_col |
Label color. |
border_col |
Axis color. |
border_lwd |
Positive number. Axis line width. |
bg |
Plot background color. |
main |
Optional plot title. If |
This is one of the most classical string art constructions. Pegs are placed
on two perpendicular axes. In the basic case, the peg at position i on the
horizontal axis is connected to the peg at position i on the vertical axis,
where the vertical axis is indexed from top to bottom.
For k = 1, the construction corresponds to the standard family of segments
joining points (t, 0) and (0, 1 - t), after scaling by width and
height. Its ideal envelope satisfies
sqrt(x / width) + sqrt(y / height) = 1.
For k > 1, the function adds shifted sweeps of the same construction,
producing denser string art patterns while preserving the same pedagogical
idea of a family of straight lines generating a curved envelope.
Invisibly returns a list of class stringart_result with:
A data.frame with columns index, x, y, axis, and
local_index.
A data.frame with columns connection_index,
from, to, x_from, y_from, x_to, y_to, length, sweep,
offset, local_from, and local_to.
Total string length.
A character vector with audit information.
A list with construction metadata.
stparabola() res <- stparabola(plot = FALSE) head(res$pegs) head(res$connections) res$total_length stparabola(n = 40, k = 1, col = "steelblue", lwd = 1) stparabola(n = 40, k = 4, col = "firebrick", lwd = 0.6) stparabola(show_points = TRUE, show_labels = TRUE) stparabola(template = TRUE)stparabola() res <- stparabola(plot = FALSE) head(res$pegs) head(res$connections) res$total_length stparabola(n = 40, k = 1, col = "steelblue", lwd = 1) stparabola(n = 40, k = 4, col = "firebrick", lwd = 0.6) stparabola(show_points = TRUE, show_labels = TRUE) stparabola(template = TRUE)
stpolygon() generates a string art figure on the boundary of a regular
polygon. Pegs are distributed uniformly along the polygon perimeter and
connected using an additive modular rule.
stpolygon( n = 60, k = 7, col = "blue", lwd = 1, plot = TRUE, show_points = TRUE, show_labels = FALSE, verbose = FALSE, sides = 5, radius = 1, rotate = pi/2, show_strings = TRUE, template = FALSE, point_col = "black", point_cex = 0.8, point_pch = 19, point_bg = "white", label_cex = 0.7, label_col = "black", border_col = "grey50", border_lwd = 1, bg = "white", main = NULL )stpolygon( n = 60, k = 7, col = "blue", lwd = 1, plot = TRUE, show_points = TRUE, show_labels = FALSE, verbose = FALSE, sides = 5, radius = 1, rotate = pi/2, show_strings = TRUE, template = FALSE, point_col = "black", point_cex = 0.8, point_pch = 19, point_bg = "white", label_cex = 0.7, label_col = "black", border_col = "grey50", border_lwd = 1, bg = "white", main = NULL )
n |
Integer. Number of pegs placed along the polygon boundary. Must be
at least 3 and at least |
k |
Integer. Additive modular step used in the connection rule. Must
satisfy |
col |
String color passed to |
lwd |
Positive number. Line width used to draw the strings. |
plot |
Logical. If |
show_points |
Logical. If |
show_labels |
Logical. If |
verbose |
Logical. If |
sides |
Integer. Number of polygon sides. Must be at least 3. |
radius |
Positive number. Circumradius of the polygon. |
rotate |
Numeric. Rotation angle in radians applied to the polygon. |
show_strings |
Logical. If |
template |
Logical. If |
point_col |
Peg color. |
point_cex |
Positive number. Peg size. |
point_pch |
Plotting symbol used for pegs. |
point_bg |
Peg background color when applicable. |
label_cex |
Positive number. Label size. |
label_col |
Label color. |
border_col |
Polygon border color. |
border_lwd |
Positive number. Polygon border line width. |
bg |
Plot background color. |
main |
Optional plot title. If |
The polygon is inscribed in a circle of radius radius. Pegs are distributed
uniformly along the full boundary, not only at the vertices. The additive
modular connection rule is:
to = ((from + k - 1) %% n) + 1.
This construction supports the exploration of regular polygons, central and interior angles, symmetry, congruence, divisibility, and modular arithmetic.
Invisibly returns a list of class stringart_result with:
A data.frame with columns index, x, y, side,
and local_index.
A data.frame with columns connection_index,
from, to, x_from, y_from, x_to, y_to, and length.
Total string length.
A character vector with audit information.
A list with construction metadata.
stpolygon() stpolygon(sides = 5) stpolygon(sides = 6) stpolygon(sides = 8) stpolygon(n = 60, k = 7, sides = 5) stpolygon(template = TRUE)stpolygon() stpolygon(sides = 5) stpolygon(sides = 6) stpolygon(sides = 8) stpolygon(n = 60, k = 7, sides = 5) stpolygon(template = TRUE)
stradial() generates a radial string art pattern composed of triangular
modules rotated around the origin. In each module, pegs are placed along the
triangular boundary and connected according to an additive modular rule.
stradial( n = 18, k = 5, col = "blue", lwd = 1, plot = TRUE, show_points = TRUE, show_labels = FALSE, verbose = FALSE, m = 6, r = 1.2, spread = pi/5, rotate = 0, show_strings = TRUE, template = FALSE, point_col = "black", point_cex = 0.8, point_pch = 21, point_bg = "white", label_cex = 0.7, label_col = "black", border_col = "grey50", border_lwd = 1, bg = "white", main = NULL, show_center = TRUE, center_col = "black", center_cex = 0.9 )stradial( n = 18, k = 5, col = "blue", lwd = 1, plot = TRUE, show_points = TRUE, show_labels = FALSE, verbose = FALSE, m = 6, r = 1.2, spread = pi/5, rotate = 0, show_strings = TRUE, template = FALSE, point_col = "black", point_cex = 0.8, point_pch = 21, point_bg = "white", label_cex = 0.7, label_col = "black", border_col = "grey50", border_lwd = 1, bg = "white", main = NULL, show_center = TRUE, center_col = "black", center_cex = 0.9 )
n |
Integer. Number of pegs in each triangular module. Must be at least 3. |
k |
Integer. Additive modular step used inside each module. Must satisfy
|
col |
String color, or a vector of colors with length 1 or |
lwd |
Positive number. Line width used to draw the strings. |
plot |
Logical. If |
show_points |
Logical. If |
show_labels |
Logical. If |
verbose |
Logical. If |
m |
Integer. Number of triangular modules. |
r |
Positive number. Distance from the origin to the two outer vertices of each triangular module. |
spread |
Positive number. Angular opening, in radians, of each module. |
rotate |
Numeric. Rotation angle in radians applied to the whole figure. |
show_strings |
Logical. If |
template |
Logical. If |
point_col |
Peg border color. |
point_cex |
Positive number. Peg size. |
point_pch |
Plotting symbol used for pegs. |
point_bg |
Peg background color when applicable. |
label_cex |
Positive number. Label size. |
label_col |
Label color. |
border_col |
Module border color. |
border_lwd |
Positive number. Module border line width. |
bg |
Plot background color. |
main |
Optional plot title. If |
show_center |
Logical. If |
center_col |
Color used to highlight the origin. |
center_cex |
Positive number. Size of the highlighted origin. |
Each module is a triangle with vertices at the origin and at two outer points
determined by r and spread. The base module is rotated m times around
the origin.
Within each module, the local connection rule is:
to = ((from + k - 1) %% n) + 1.
This means that each local peg is connected to the peg k positions ahead,
using modular indexing. The same local rule is applied independently to all
modules.
Invisibly returns a list of class stringart_result with:
A data.frame with columns index, x, y, module, and
local_index.
A data.frame with columns connection_index, from,
to, x_from, y_from, x_to, y_to, length, module,
local_from, local_to, and color.
Total string length.
A character vector with audit information.
A list with construction metadata.
stradial() res <- stradial(plot = FALSE) head(res$pegs) head(res$connections) res$total_length stradial(n = 18, k = 5, m = 6, col = "steelblue", lwd = 0.8) stradial(n = 12, k = 4, m = 5, show_points = TRUE, show_labels = TRUE) stradial(template = TRUE)stradial() res <- stradial(plot = FALSE) head(res$pegs) head(res$connections) res$total_length stradial(n = 18, k = 5, m = 6, col = "steelblue", lwd = 0.8) stradial(n = 12, k = 4, m = 5, show_points = TRUE, show_labels = TRUE) stradial(template = TRUE)
stregion() generates a filled string art pattern from a closed contour.
Pegs are distributed along the contour and connected to approximately opposite
pegs, producing strings that cross the interior of the region.
stregion( n = 100, k = 4, col = "red", lwd = 0.6, plot = TRUE, show_points = TRUE, show_labels = FALSE, verbose = FALSE, contour = NULL, show_strings = TRUE, template = FALSE, draw_border = TRUE, border_col = "grey50", border_lwd = 1, point_col = "black", point_cex = 0.5, point_pch = 19, point_bg = "white", label_cex = 0.6, label_col = "black", bg = "white", main = NULL, add = FALSE, xlim = NULL, ylim = NULL )stregion( n = 100, k = 4, col = "red", lwd = 0.6, plot = TRUE, show_points = TRUE, show_labels = FALSE, verbose = FALSE, contour = NULL, show_strings = TRUE, template = FALSE, draw_border = TRUE, border_col = "grey50", border_lwd = 1, point_col = "black", point_cex = 0.5, point_pch = 19, point_bg = "white", label_cex = 0.6, label_col = "black", bg = "white", main = NULL, add = FALSE, xlim = NULL, ylim = NULL )
n |
Integer. Number of pegs placed along the contour. Must be at least 4. |
k |
Integer. Number of sweep offsets used to fill the region. Must be at least 1. |
col |
String color passed to |
lwd |
Positive number. Line width used to draw the strings. |
plot |
Logical. If |
show_points |
Logical. If |
show_labels |
Logical. If |
verbose |
Logical. If |
contour |
Optional |
show_strings |
Logical. If |
template |
Logical. If |
draw_border |
Logical. If |
border_col |
Border color. |
border_lwd |
Positive number. Border line width. |
point_col |
Peg color. |
point_cex |
Positive number. Peg size. |
point_pch |
Plotting symbol used for pegs. |
point_bg |
Peg background color when applicable. |
label_cex |
Positive number. Label size. |
label_col |
Label color. |
bg |
Plot background color. |
main |
Optional plot title. If |
add |
Logical. If |
xlim, ylim
|
Optional axis limits used when |
Unlike circular, elliptical, or triangular modular string art patterns that
usually connect nearby pegs using a fixed additive step, stregion() is
designed to fill a region. It connects each peg to a peg located approximately
on the opposite side of the contour.
The main connection rule is:
to = ((from - 1 + floor(n / 2) + offset) %% n) + 1.
The argument k controls the number of offsets. Each offset produces one
sweep of strings across the interior. Larger values of k create denser
fillings.
Invisibly returns a list of class stringart_result with:
A data.frame with columns index, x, and y.
A data.frame with columns connection_index,
from, to, x_from, y_from, x_to, y_to, length, sweep,
and offset.
Total string length.
A character vector with audit information.
A list with construction metadata.
stregion() res <- stregion(plot = FALSE) head(res$pegs) head(res$connections) res$total_length custom_contour <- data.frame( x = c(0, 1, 0.6, -0.6, -1), y = c(1, 0.2, -0.9, -0.9, 0.2) ) stregion(contour = custom_contour, n = 80, k = 3, col = "steelblue") stregion(template = TRUE)stregion() res <- stregion(plot = FALSE) head(res$pegs) head(res$connections) res$total_length custom_contour <- data.frame( x = c(0, 1, 0.6, -0.6, -1), y = c(1, 0.2, -0.9, -0.9, 0.2) ) stregion(contour = custom_contour, n = 80, k = 3, col = "steelblue") stregion(template = TRUE)
strose() generates a rose-like string art figure based on a polar curve of
the form r(theta) = amplitude * (1 + cos(petals * theta)) / 2.
strose( n = 240, k = 17, col = "deeppink4", lwd = 0.7, plot = TRUE, show_points = FALSE, show_labels = FALSE, verbose = FALSE, petals = 6, amplitude = 1, rotate = 0, show_strings = TRUE, template = FALSE, draw_curve = TRUE, border_col = "grey50", border_lwd = 1, point_col = "black", point_cex = 0.5, point_pch = 19, point_bg = "white", label_cex = 0.6, label_col = "black", bg = "white", main = NULL )strose( n = 240, k = 17, col = "deeppink4", lwd = 0.7, plot = TRUE, show_points = FALSE, show_labels = FALSE, verbose = FALSE, petals = 6, amplitude = 1, rotate = 0, show_strings = TRUE, template = FALSE, draw_curve = TRUE, border_col = "grey50", border_lwd = 1, point_col = "black", point_cex = 0.5, point_pch = 19, point_bg = "white", label_cex = 0.6, label_col = "black", bg = "white", main = NULL )
n |
Integer. Number of pegs sampled along the curve. Must be at least 3. |
k |
Integer. Additive modular step used in the connection rule. Must
satisfy |
col |
String color passed to |
lwd |
Positive number. Line width used to draw the strings. |
plot |
Logical. If |
show_points |
Logical. If |
show_labels |
Logical. If |
verbose |
Logical. If |
petals |
Integer. Number of petals in the rose-like curve. |
amplitude |
Positive number. Maximum radial amplitude. |
rotate |
Numeric. Rotation angle in radians. |
show_strings |
Logical. If |
template |
Logical. If |
draw_curve |
Logical. If |
border_col |
Curve color. |
border_lwd |
Positive number. Curve line width. |
point_col |
Peg color. |
point_cex |
Positive number. Peg size. |
point_pch |
Plotting symbol used for pegs. |
point_bg |
Peg background color when applicable. |
label_cex |
Positive number. Label size. |
label_col |
Label color. |
bg |
Plot background color. |
main |
Optional plot title. If |
The pegs are sampled from the polar curve
r(theta) = amplitude * (1 + cos(petals * theta)) / 2, which produces a
rose-like pattern with petals visible petals.
The connections follow the additive modular rule
to = ((from + k - 1) %% n) + 1.
Invisibly returns a list of class stringart_result.
strose() strose(petals = 6) strose(petals = 8) strose(template = TRUE)strose() strose(petals = 6) strose(petals = 8) strose(template = TRUE)
stspiral() generates a string art pattern from pegs placed on an
Archimedean spiral.
stspiral( n = 180, k = 13, col = "steelblue", lwd = 0.7, plot = TRUE, show_points = FALSE, show_labels = FALSE, verbose = FALSE, turns = 3, spacing = 0.6, inner_radius = 0, rotate = 0, show_strings = TRUE, template = FALSE, draw_curve = TRUE, border_col = "grey50", border_lwd = 1, point_col = "black", point_cex = 0.5, point_pch = 19, point_bg = "white", label_cex = 0.6, label_col = "black", bg = "white", main = NULL )stspiral( n = 180, k = 13, col = "steelblue", lwd = 0.7, plot = TRUE, show_points = FALSE, show_labels = FALSE, verbose = FALSE, turns = 3, spacing = 0.6, inner_radius = 0, rotate = 0, show_strings = TRUE, template = FALSE, draw_curve = TRUE, border_col = "grey50", border_lwd = 1, point_col = "black", point_cex = 0.5, point_pch = 19, point_bg = "white", label_cex = 0.6, label_col = "black", bg = "white", main = NULL )
n |
Integer. Number of pegs placed on the spiral. Must be at least 3. |
k |
Integer. Additive modular step used in the connection rule. Must
satisfy |
col |
String color passed to |
lwd |
Positive number. Line width used to draw the strings. |
plot |
Logical. If |
show_points |
Logical. If |
show_labels |
Logical. If |
verbose |
Logical. If |
turns |
Positive number. Number of spiral turns. |
spacing |
Positive number. Radial growth per turn. |
inner_radius |
Nonnegative number. Initial spiral radius. |
rotate |
Numeric. Rotation angle in radians. |
show_strings |
Logical. If |
template |
Logical. If |
draw_curve |
Logical. If |
border_col |
Curve color. |
border_lwd |
Positive number. Curve line width. |
point_col |
Peg color. |
point_cex |
Positive number. Peg size. |
point_pch |
Plotting symbol used for pegs. |
point_bg |
Peg background color when applicable. |
label_cex |
Positive number. Label size. |
label_col |
Label color. |
bg |
Plot background color. |
main |
Optional plot title. |
The spiral uses the polar form
r(theta) = inner_radius + spacing * theta / (2 * pi).
Invisibly returns a list of class stringart_result.
stspiral() stspiral(turns = 4) stspiral(template = TRUE)stspiral() stspiral(turns = 4) stspiral(template = TRUE)
ststar() generates a classical star polygon {n/k} by placing n pegs on
a circle and connecting each peg to the peg k positions ahead.
ststar( n = 5, k = 2, col = "blue", lwd = 1, plot = TRUE, show_points = TRUE, show_labels = FALSE, verbose = FALSE, radius = 1, rotate = pi/2, show_strings = TRUE, template = FALSE, draw_polygon = TRUE, border_col = "grey50", border_lwd = 1, point_col = "black", point_cex = 0.8, point_pch = 19, point_bg = "white", label_cex = 0.7, label_col = "black", bg = "white", main = NULL )ststar( n = 5, k = 2, col = "blue", lwd = 1, plot = TRUE, show_points = TRUE, show_labels = FALSE, verbose = FALSE, radius = 1, rotate = pi/2, show_strings = TRUE, template = FALSE, draw_polygon = TRUE, border_col = "grey50", border_lwd = 1, point_col = "black", point_cex = 0.8, point_pch = 19, point_bg = "white", label_cex = 0.7, label_col = "black", bg = "white", main = NULL )
n |
Integer. Number of pegs on the circle. Must be at least 3. |
k |
Integer. Star step. Must satisfy |
col |
String color passed to |
lwd |
Positive number. Line width used to draw the star. |
plot |
Logical. If |
show_points |
Logical. If |
show_labels |
Logical. If |
verbose |
Logical. If |
radius |
Positive number. Circle radius. |
rotate |
Numeric. Rotation angle in radians applied to the star. |
show_strings |
Logical. If |
template |
Logical. If |
draw_polygon |
Logical. If |
border_col |
Polygon border color. |
border_lwd |
Positive number. Border line width. |
point_col |
Peg color. |
point_cex |
Positive number. Peg size. |
point_pch |
Plotting symbol used for pegs. |
point_bg |
Peg background color when applicable. |
label_cex |
Positive number. Label size. |
label_col |
Label color. |
bg |
Plot background color. |
main |
Optional plot title. If |
The star polygon uses the additive modular rule
to = ((from + k - 1) %% n) + 1.
The greatest common divisor gcd(n, k) determines the number of cycles. If
gcd(n, k) = 1, the star is a single cycle. Otherwise, the construction
decomposes into several independent cycles.
Invisibly returns a list of class stringart_result with:
A data.frame with columns index, x, and y.
A data.frame with columns connection_index,
from, to, x_from, y_from, x_to, y_to, and length.
Total string length.
A character vector with audit information.
A list with construction metadata.
ststar() ststar(n = 5, k = 2) ststar(n = 7, k = 2) ststar(n = 8, k = 3) ststar(template = TRUE)ststar() ststar(n = 5, k = 2) ststar(n = 7, k = 2) ststar(n = 8, k = 3) ststar(template = TRUE)
sttriangle() generates a string art pattern on the boundary of an
equilateral triangle. Pegs are distributed uniformly along the triangle
perimeter and connected using an additive modular rule.
sttriangle( n = 30, k = 7, col = "blue", lwd = 1, plot = TRUE, show_points = TRUE, show_labels = FALSE, verbose = FALSE, side = 2, rotate = 0, show_strings = TRUE, template = FALSE, point_col = "black", point_cex = 0.8, point_pch = 19, point_bg = "white", label_cex = 0.7, label_col = "black", border_col = "grey50", border_lwd = 1, bg = "white", main = NULL )sttriangle( n = 30, k = 7, col = "blue", lwd = 1, plot = TRUE, show_points = TRUE, show_labels = FALSE, verbose = FALSE, side = 2, rotate = 0, show_strings = TRUE, template = FALSE, point_col = "black", point_cex = 0.8, point_pch = 19, point_bg = "white", label_cex = 0.7, label_col = "black", border_col = "grey50", border_lwd = 1, bg = "white", main = NULL )
n |
Integer. Number of pegs placed along the triangle boundary. Must be at least 3. |
k |
Integer. Additive modular step used in the connection rule. Must
satisfy |
col |
String color passed to |
lwd |
Positive number. Line width used to draw the strings. |
plot |
Logical. If |
show_points |
Logical. If |
show_labels |
Logical. If |
verbose |
Logical. If |
side |
Positive number. Side length of the equilateral triangle. |
rotate |
Numeric. Rotation angle in radians applied to the whole figure. |
show_strings |
Logical. If |
template |
Logical. If |
point_col |
Peg color. |
point_cex |
Positive number. Peg size. |
point_pch |
Plotting symbol used for pegs. |
point_bg |
Peg background color when applicable. |
label_cex |
Positive number. Label size. |
label_col |
Label color. |
border_col |
Triangle border color. |
border_lwd |
Positive number. Triangle border line width. |
bg |
Plot background color. |
main |
Optional plot title. If |
The triangle is centered at the origin using its centroid. The pegs are placed uniformly along the perimeter in counterclockwise order.
The additive modular connection rule is:
to = ((from + k - 1) %% n) + 1.
When gcd(n, k) = 1, the modular rule forms a single cycle through all
pegs. When gcd(n, k) > 1, the construction decomposes into independent
cycles.
Invisibly returns a list of class stringart_result with:
A data.frame with columns index, x, and y.
A data.frame with columns connection_index,
from, to, x_from, y_from, x_to, y_to, and length.
Total string length.
A character vector with audit information.
A list with construction metadata, including the triangle vertices.
sttriangle() res <- sttriangle(plot = FALSE) head(res$pegs) head(res$connections) res$total_length sttriangle(n = 30, k = 7, side = 2, col = "blue", lwd = 1) sttriangle(n = 18, k = 5, show_points = TRUE, show_labels = TRUE) sttriangle(template = TRUE)sttriangle() res <- sttriangle(plot = FALSE) head(res$pegs) head(res$connections) res$total_length sttriangle(n = 30, k = 7, side = 2, col = "blue", lwd = 1) sttriangle(n = 18, k = 5, show_points = TRUE, show_labels = TRUE) sttriangle(template = TRUE)