The spiro package creates spirographs in the svg format and can create svg animations of spirographs.'

`spiro` creates a spirograph.

spiro(fixed_radius = 3, cycling_radius = 1,
  pen_radius = cycling_radius, windings = cycling_radius,
  color_groups = 1, colors = NA, transparency = NA,
  color_cycles = 1, color_sort = FALSE, draw_fills = TRUE,
  line_width = 1, origin_x = 0, origin_y = 0, xlim = NULL,
  ylim = NULL, rotation = 0, start_angle = 0,
  points_per_polygon = round(abs(1000 * windings), 0),
  rule = c("evenodd", "winding"), openfile = TRUE,
  end_at_beginning = F, savefile = TRUE, file = NA, ...)

Arguments

fixed_radius

The radius of the fixed circle being cycled around. Can be positive or negative. Defaults to 3.

cycling_radius

The radius of the moving circle cycling around the fixed circle. Can be positive or negative. Defaults to 1.

pen_radius

The pen placement inside the moving circle cycling around the fixed circle. Can be positive or negative.

windings

The number of times the the moving circle winds around the fixed circle.

color_groups

Number of groups in group_id variable

colors

Vector of colors for groups. Defaults to black when color_groups is 1 and to the viridis scale when color_groups > 1.

transparency

Transparency of colors. Ranges from 0 to 1. Default is NA (i.e., leave the colors as specified in the colors argument).

color_cycles

The number of times the color vector is recycled

color_sort

Arranges all paths of the same color to be written in groups

draw_fills

Draw fills. Default is TRUE

line_width

The width of lines. Only relevant when draw_fills is FALSE.

origin_x

The x coordinate of the center of the fixed circle

origin_y

The y coordinate of the center of the fixed circle

xlim

The limits of the x coordinates. For example, c(-5,5). NULL means that the limits are determined by the data point that has the largest distance from the origin.

ylim

The limits of the y coordinates. For example, c(-5,5). NULL means that the limits are determined by the data point that has the largest distance from the origin.

rotation

The number of radians by which the entire figure should be rotated around the origin of the fixed circle

start_angle

The number of radians on the fixed circle's arc where the moving circle starts cycling.

points_per_polygon

The number of points for each color grouping

rule

Character value specifying the path fill mode: either "evenodd" or "winding". Defaults to "evenodd"

openfile

Open file in default program for .svg format. Defaults to TRUE.

end_at_beginning

Adds the first point to the end of the figure but with the colors of the last color group. Defaults to FALSE.

savefile

Save a file. Defaults to TRUE.

file

Name of the output file. Defaults to "spiro.svg"

...

parameters passed to the par function

Value

object of class spiro, which contains the file name. If savefile = FALSE, will return a tibble with raw data.

Details

The `spiro` function by default returns an object of class spiro. This object contains the name of the file that `spiro` has created. Its print method opens the file in your computers default svg viewer. Google Chrome is the viewer on which best results will likely be seen. When used with knitr, object of class spiro will print via knitr::include_graphics()

Examples

spiro( fixed_radius = 3, cycling_radius = 1, file = "spiro.svg")