Tools for Generating String Art Figures

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.


stringArt

R-CMD-check License:MIT Lifecycle:experimental

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.
library(stringArt)

res <- stcircle(plot = FALSE)

names(res)
head(res$pegs)
head(res$connections)
res$total_length
res$audit
res$meta

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.

res <- stcircle(n = 20, k = 3, plot = FALSE)

res$audit

stcircle(n = 20, k = 3, 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.

Development

To document, test, and check the package, use:

devtools::document()
devtools::test()
devtools::check()

To build the GitHub README, use:

devtools::build_readme()

License

This package is licensed under the MIT License.

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("stringArt")

0.1.0 by Fernando de Souza Bastos, 4 months ago


https://github.com/fsbmat-ufv/stringArt


Report a bug at https://github.com/fsbmat-ufv/stringArt/issues


Browse source code at https://github.com/cran/stringArt


Authors: Fernando de Souza Bastos [aut, cre] , Ivo Moreira Barbosa [aut]


Documentation:   PDF Manual  


MIT + file LICENSE license


Imports graphics

Suggests testthat


See at CRAN