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.
Installation
You can install the development version of stringArt from GitHub with:
# install.packages("devtools")
devtools::install_github("fsbmat-ufv/stringArt")Main idea
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.
Examples
Circular string art
stcircle(
n = 40,
k = 7,
col = "steelblue",
lwd = 1
)Cardioid-like pattern
stcardioid(
n = 120,
k = 2,
col = "darkorange",
lwd = 0.8
)Elliptical string art
stellipse(
n = 60,
k = 9,
a = 2,
b = 1,
col = "purple",
lwd = 1
)Triangular string art
sttriangle(
n = 45,
k = 8,
side = 2,
col = "blue",
lwd = 1
)Hexagonal flower
sthexaflower(
n = 24,
k = 5,
show_points = TRUE
)Radial triangular modules
stradial(
n = 18,
k = 5,
m = 6,
col = "forestgreen",
lwd = 1
)Region-based string art
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
)Peg template without strings
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)Showing pegs and labels
stcircle(
n = 20,
k = 3,
show_points = TRUE,
show_labels = TRUE
)Audit information
Audit information is returned as part of the object and can also be printed to the console with verbose = TRUE.
Available functions
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.
