Description Usage Arguments Details Value Author(s) See Also Examples
View source: R/sierpinski_trapezoid_maze.r
Recursively draw a Sierpinski isosceles trapezoid maze,
with three sides consisting
of 2^{depth} pieces of length unit_len
, and one long
side of length 2^{depth+1} pieces, starting from the
long side.
1 2 3 4 5 6  sierpinski_trapezoid_maze(depth, unit_len = 4L, clockwise = TRUE,
start_from = c("midpoint", "corner"), color1 = "black",
color2 = "gray40", flip_color_parts = 1, 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)

depth 
the depth of recursion. This controls the
side length: three sides have 
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. 
clockwise 
whether to draw clockwise. 
start_from 
whether to start from the midpoint of the first side of a maze, or from the corner facing the first side. 
color1 
The dominant color of the maze. 
color2 
The negative color of the maze. 
flip_color_parts 
a numerical array which can contain values 1
through 4. Those parts of the maze, when drawn recursively, have
their colors flipped. A value of 
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 
Draws a maze in an isoscelese trapezoid with three sides of equal length
and one long side of twice that length, starting from the midpoint
of the long side (or the corner before the first side via the
start_from
option). Differently colors the parts of the
maze for a Sierpinski effect.
Here are mazes for different values of flip_color_parts
ranging
from 1 to 4:
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
iso_trapezoid_maze
,
hexaflake_maze
,
sierpinski_carpet_maze
,
sierpinski_maze
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52  require(TurtleGraphics)
turtle_init(1000,1000,mode='clip')
turtle_hide()
turtle_up()
turtle_do({
turtle_setpos(500,500)
turtle_setangle(0)
sierpinski_trapezoid_maze(unit_len=15,depth=4,color1='black',color2='green',
clockwise=TRUE,draw_boundary=TRUE,boundary_holes=c(1,3))
sierpinski_trapezoid_maze(unit_len=15,depth=4,color1='black',color2='green',
clockwise=FALSE,draw_boundary=TRUE,
boundary_lines=c(2,3,4),boundary_holes=3)
})
# stack some trapezoids!
require(TurtleGraphics)
turtle_init(750,900,mode='clip')
turtle_hide()
turtle_up()
turtle_do({
turtle_setpos(25,450)
turtle_setangle(0)
blines < c(1,2,4)
for (dep in seq(from=4,to=0)) {
sierpinski_trapezoid_maze(unit_len=13,depth=dep,color1='black',color2='green',
flip_color_parts=2,
clockwise=TRUE,boundary_lines=blines,draw_boundary=TRUE,boundary_holes=c(1,3),
end_side=3)
turtle_right(180)
blines < c(1,2,4)
}
})
## Not run:
require(TurtleGraphics)
turtle_init(750,900,mode='clip')
turtle_hide()
turtle_up()
turtle_do({
turtle_setpos(25,450)
turtle_setangle(0)
blines < c(1,2,4)
for (dep in seq(from=5,to=0)) {
sierpinski_trapezoid_maze(unit_len=13,depth=dep,color1='black',color2='green',
flip_color_parts=3,
clockwise=TRUE,boundary_lines=blines,draw_boundary=TRUE,boundary_holes=c(1,3),
end_side=3)
turtle_right(180)
blines < c(1,2,4)
}
})
## End(Not run)

Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.