View source: R/sierpinski_hexagon_maze.r
sierpinski_hexagon_maze | R Documentation |
Draws a Sierpinski hexagon maze.
sierpinski_hexagon_maze(depth, unit_len, clockwise = TRUE,
start_from = c("midpoint", "corner"), style = c("sierpinski",
"four_triangles", "hexaflake", "reverse_flake", "outer_flake", "dragon_left",
"dragon_right", "dragon_leftright", "dragon_rightleft"), color1 = "black",
color2 = "gray40", 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. Should be an integer. |
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. |
style |
controls the style of Sierpinski triangle. The following are recognized:
|
color1 |
The dominant color of the maze. |
color2 |
The negative color of the maze. |
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 |
Recursively draw a Sierpinski hexagon maze. The sides of the
hexagon consist of 2^{depth}
pieces of length
unit_len
. The hexagon is drawn as a ring of six
Sierpinski trapezoids in a ring around a Sierpinski
hexagon of a smaller size.
The ‘inner’ and ‘outer’ pieces of
mazes drawn in different colors. The
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
eq_triangle_maze
,
hexaflake_maze
,
sierpinski_carpet_maze
,
sierpinski_trapezoid_maze
.
library(TurtleGraphics)
turtle_init(800,800,mode='clip')
turtle_up()
turtle_hide()
turtle_do({
turtle_setpos(50,400)
turtle_setangle(30)
sierpinski_hexagon_maze(depth=4,unit_len=20,boundary_lines=TRUE,
draw_boundary=TRUE,boundary_holes=c(1,3),
start_from='corner',
color1='black',color2='green',
style='sierpinski')
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.