holey_line: holey_line .

View source: R/holey_line.r

holey_lineR Documentation

holey_line .

Description

Draws a line with a randomly selected ‘hole’ in it.

Usage

holey_line(unit_len, num_segs, which_seg = NULL, go_back = FALSE,
  hole_color = NULL, hole_arrow = FALSE)

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.

num_segs

the total number of segments. All but one of these, of length unit_len will be drawn. The other, randomly chosen, will be a hole. If num_segs is one, only a hole is made, and no line drawn. If zero or less, no action taken.

which_seg

optional numeric indicating which segment should have the hole. If NULL, the hole segment is chosen uniformly at random.

go_back

whether to return the turtle to starting position when the line has been drawn.

hole_color

the color to plot the ‘hole’. A NULL value corresponds to no drawn hole. See the colors function for acceptable values.

hole_arrow

a boolean or indicating whether to draw a perpendicular arrow at a hole.

Details

This function is the workhorse of drawing mazes, as it creates a maze wall with a single hole in it.

Value

Returns the which_seg variable, the location of the hole, though typically the function is called for side effects only.

Author(s)

Steven E. Pav shabbychef@gmail.com

Examples


library(TurtleGraphics)
turtle_init(1000,1000,mode='clip')
turtle_hide()
y <- holey_line(unit_len=20, num_segs=15)

turtle_right(90)
y <- holey_line(unit_len=20, num_segs=10,hole_arrow=TRUE)


shabbychef/mazealls documentation built on Oct. 18, 2023, 8:27 p.m.