Learn R Programming

aRtsy (version 0.2.4)

canvas_recaman: Draw Recaman's Sequence

Description

This function draws Recaman's sequence on a canvas. The algorithm takes increasingly large steps backward on the positive number line, but if it is unable to it takes a step forward.

Usage

canvas_recaman(
  colors,
  background = "#fafafa",
  iterations = 100,
  start = 0,
  increment = 1,
  curvature = 1,
  angle = 0,
  size = 0.1,
  closed = FALSE
)

Value

A ggplot object containing the artwork.

Arguments

colors

a string or character vector specifying the color(s) used for the artwork.

background

a character specifying the color used for the background.

iterations

the number of iterations of the algorithm.

start

the starting point of the algorithm.

increment

the increment of each step.

curvature

the curvature of each line.

angle

the angle at which to place the artwork.

size

the size of the lines.

closed

logical. Whether to plot a curve from the end of the sequence back to the starting point.

Author

Koen Derks, koen-derks@hotmail.com

References

https://mathworld.wolfram.com/RecamansSequence.html

See Also

colorPalette

Examples

Run this code
# \donttest{
set.seed(1)

# Simple example
canvas_recaman(colors = colorPalette("tuscany1"))
# }

Run the code above in your browser using DataLab