sierpinski_carpet_maze {mazealls} | R Documentation |
sierpinski_carpet_maze .
Description
Recursively draw a Sierpinski carpet maze in a parallelogram,
with the first side consisting of
height
segments of length unit_len
, and the second side
width
segments of length unit_len
. The angle between
the first and second side may be set.
Usage
sierpinski_carpet_maze(unit_len, height, width = height, angle = 90,
clockwise = TRUE, method = "random", color1 = "black",
color2 = "gray40", start_from = c("midpoint", "corner"), balance = 0,
draw_boundary = FALSE, num_boundary_holes = 2, boundary_lines = TRUE,
boundary_holes = NULL, boundary_hole_color = NULL,
boundary_hole_locations = NULL, boundary_hole_arrows = FALSE,
end_side = 1)
Arguments
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. |
height |
the length of the first side in numbers of |
width |
the length of the second side in numbers of |
angle |
the angle (in degrees) between the first and second sides. |
clockwise |
whether to draw clockwise. |
method |
passed to |
color1 |
The dominant color of the maze. |
color2 |
The negative color of the maze. |
start_from |
whether to start from the midpoint of the first side of a maze, or from the corner facing the first side. |
balance |
passed to |
draw_boundary |
a boolean indicating whether a final boundary shall be drawn around the maze. |
num_boundary_holes |
the number of boundary sides which should be
randomly selected to have holes. Note that the |
boundary_lines |
indicates which of the sides of the maze shall have drawn boundary lines. Can be a logical array indicating which sides shall have lines, or a numeric array, giving the index of sides that shall have lines. |
boundary_holes |
an array indicating which of the boundary lines
have holes. If |
boundary_hole_color |
the color of boundary holes. A value of
|
boundary_hole_locations |
the ‘locations’ of the boundary holes
within each boundary segment.
A value of |
boundary_hole_arrows |
a boolean or boolean array indicating whether to draw perpendicular double arrows at the boundary holes, as a visual guide. These can be useful for locating the entry and exit points of a maze. |
end_side |
the number of the side to end on. A value of
1 corresponds to the starting side, while higher numbers
correspond to the drawn side of the figure in the canonical order
(that is, the order induced by the |
Details
Draws a Sierpinski carpet as two-color maze in a parallelogram.
Value
nothing; the function is called for side effects only, though in the future this might return information about the drawn boundary of the shape.
Author(s)
Steven E. Pav shabbychef@gmail.com
See Also
parallelogram_maze
,
sierpinski_maze
.
Examples
library(TurtleGraphics)
turtle_init(800,900,mode='clip')
turtle_hide()
turtle_up()
turtle_do({
turtle_setpos(35,400)
turtle_setangle(0)
sierpinski_carpet_maze(angle=80,unit_len=8,width=30,height=30,
method='two_parallelograms',draw_boundary=TRUE,balance=-1.0,color2='green')
})
## Not run:
library(TurtleGraphics)
turtle_init(2000,2000,mode='clip')
turtle_hide()
turtle_up()
bholes <- list(c(1,2), c(1), c(2))
turtle_do({
turtle_setpos(1000,1100)
turtle_setangle(180)
for (iii in c(1:3)) {
mybhol <- bholes[[iii]]
sierpinski_carpet_maze(angle=120,unit_len=12,width=81,height=81,
draw_boundary=TRUE,boundary_lines=c(1,2,3),num_boundary_holes=0,
boundary_holes=mybhol,balance=1.0,color2='green',
start_from='corner')
turtle_left(120)
}
})
## End(Not run)