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, ... )
The radius of the fixed circle being cycled around. Can be positive or negative. Defaults to 3.
The radius of the moving circle cycling around the fixed circle. Can be positive or negative. Defaults to 1.
The pen placement inside the moving circle cycling around the fixed circle. Can be positive or negative.
The number of times the the moving circle winds around the fixed circle.
Number of groups in group_id variable
Vector of colors for groups. Defaults to a random hsv color when color_groups is 1 and to a random palette from the paletteer package when color_groups > 1.
Transparency of colors. Ranges from 0 to 1. Default is NA (i.e., leave the colors as specified in the colors argument).
The number of times the color vector is recycled
Arranges all paths of the same color to be written in groups
Draw fills. Default is TRUE
The width of lines. Only relevant when draw_fills is FALSE.
The x coordinate of the center of the fixed circle
The y coordinate of the center of the fixed circle
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.
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.
The number of radians by which the entire figure should be rotated around the origin of the fixed circle
The number of radians on the fixed circle's arc where the moving circle starts cycling.
The number of points for each color grouping
Character value specifying the path fill mode: either "evenodd" or "winding". Defaults to "evenodd"
Open file in default program for .svg format. Defaults to TRUE.
Adds the first point to the end of the figure but with the colors of the last color group. Defaults to FALSE.
Save a file. Defaults to TRUE.
Name of the output file. Defaults to "spiro.svg"
parameters passed to the par function
object of class spiro, which contains the file name. If savefile = FALSE, will return a tibble with raw data.
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()
spiro( fixed_radius = 3, cycling_radius = 1, file = "spiro.svg")