
The stringArt package provides tools to generate, visualize, and audit geometric string art figures for mathematics teaching.
String art figures are built from pegs and straight string connections, creating visual patterns related to geometry, modular arithmetic, symmetry, and visual mathematics.
The package is designed for educational use and can support classroom activities in geometry, analytic geometry, modular arithmetic, mathematical visualization, and graphical programming in R.
You can install the development version of stringArt from GitHub with:
# install.packages("devtools")
devtools::install_github("fsbmat-ufv/stringArt")Each exported function generates a string art figure and returns a standardized object containing:
pegs: peg coordinates;connections: connection table;total_length: total string length;audit: audit information;meta: construction metadata.library(stringArt)
res <- stcircle(plot = FALSE)
names(res)
head(res$pegs)
head(res$connections)
res$total_length
res$audit
res$metastcircle(
n = 40,
k = 7,
col = "steelblue",
lwd = 1
)stcardioid(
n = 120,
k = 2,
col = "darkorange",
lwd = 0.8
)stellipse(
n = 60,
k = 9,
a = 2,
b = 1,
col = "purple",
lwd = 1
)sttriangle(
n = 45,
k = 8,
side = 2,
col = "blue",
lwd = 1
)sthexaflower(
n = 24,
k = 5,
show_points = TRUE
)stradial(
n = 18,
k = 5,
m = 6,
col = "forestgreen",
lwd = 1
)stregion(
n = 100,
k = 4,
col = "firebrick",
lwd = 0.6
)Custom contour:
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",
lwd = 0.7
)All main functions support template mode. This is useful for generating peg templates without drawing the string connections.
stcircle(template = TRUE)
sttriangle(template = TRUE)
stregion(template = TRUE)stcircle(
n = 20,
k = 3,
show_points = TRUE,
show_labels = TRUE
)Audit information is returned as part of the object and can also be
printed to the console with verbose = TRUE.
res <- stcircle(n = 20, k = 3, plot = FALSE)
res$audit
stcircle(n = 20, k = 3, verbose = TRUE)The current version includes:
stcircle(): circular string art with additive modular
step;stcardioid(): circular multiplicative modular
pattern;stellipse(): elliptical string art;sttriangle(): triangular string art;sthexaflower(): concentric hexagonal circuits;stradial(): rotated triangular modules;stregion(): contour-based region filling.To document, test, and check the package, use:
devtools::document()
devtools::test()
devtools::check()To build the GitHub README, use:
devtools::build_readme()This package is licensed under the MIT License.