Description Usage Arguments Details Value Author(s) See Also Examples
Make the turtle move multiple units, making turns, and possibly drawing line segments possibly with holes in them.
1 2 |
unit_len |
the unit length in graph coordinates. This controls the width of the ‘holes’ in the boundary lines and generally controls the spacing of mazes. |
lengths |
an array of the number of units
each part of the path. An array of length |
angles |
after each part of the path is drawn, the turtle turns right by the given angle. |
draw_line |
a boolean array telling whether each part of the path is drawn at all, or whether the turtle simply moves through that path. |
has_hole |
a boolean array telling whether, conditional on the path being drawn, it has a one unit hole. |
hole_color |
the color to plot the ‘hole’.
A value |
hole_locations |
an optional array of ‘locations’
of the holes. These affect the |
hole_arrows |
a boolean or boolean array telling whether to draw a perpendicular arrow at a hole. |
Causes the turtle to move through a path of connected line segments,
possibly drawing lines, possibly drawing holes in those lines.
All arguments are recycled to the length of the longest
argument via mapply
, which simplifies
the path description.
nothing; the function is called for side effects only, though in the future this might return information about the drawn boundary of the shape.
Steven E. Pav shabbychef@gmail.com
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | library(TurtleGraphics)
# draw a triangle with holes on the boundaries
turtle_init(1000,1000)
holey_path(unit_len=20, lengths=rep(10,3), angles=c(120), draw_line=TRUE, has_hole=TRUE)
# draw a square with holes on the boundaries
turtle_init(1000,1000)
turtle_hide()
holey_path(unit_len=20, lengths=rep(10,4), angles=c(90), draw_line=TRUE, has_hole=TRUE,
hole_color=c('red','green'))
# draw a square spiral
turtle_init(1000,1000)
turtle_hide()
holey_path(unit_len=20, lengths=sort(rep(1:10,2),decreasing=TRUE), angles=c(90),
draw_line=TRUE, has_hole=FALSE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.