pattern_hex {gridpattern} | R Documentation |
Hex pattern matrix
Description
pattern_hex()
returns an integer matrix indicating where each
color (or other graphical element) should be drawn on a (horizontal) hex grid
for a specified hex pattern type and subtype.
names_hex
lists the currently supported hex type
s.
Usage
pattern_hex(type = "hex", subtype = NULL, nrow = 5L, ncol = 5L)
names_hex
Arguments
type |
Currently just supports "hex". |
subtype |
An integer indicating number of colors (or other graphical elements). |
nrow |
Number of rows (height). |
ncol |
Number of columns (width). |
Format
An object of class character
of length 5.
Details
- "hex"
Attempts to use a uniform coloring if it exists. For subtype
1L
,2L
, and3L
we use the "hex1" pattern. For subtype4L
we use the "hex2" pattern. For subtype7L
we use the "hex3" pattern. Else a uniform coloring does not exist and we use the "hex_skew" pattern.- "hex1"
Provides the 1-uniform colorings of a hexagonal tiling. Only exists for
subtype
1L
,2L
, or3L
.- "hex2"
Provides the 2-uniform colorings of a hexagonal tiling. Only exists for
subtype
2L
or4L
.- "hex3"
Provides the 3-uniform colorings of a hexagonal tiling. Only exists for
subtype
2L
or7L
.- "hex_skew"
For the "hex_skew"
type
we cycle throughsubtype
elements on the horizontal line and "main" diagonal line. For somesubtype
numbers this may lead to noticeable color repeats on the "skew" diagonal line. Ifsubtype
is strictly greater than2L
then a hexagon should never touch another hexagon of the same color.
Value
A matrix of integer values indicating where the each color
or other graphical elements should be drawn on a horizontal hex grid
(i.e. hexagons are assumed to be pointy side up).
Indices [1,1]
of the matrix corresponds to the bottom-left of the grid
while indices [1,ncol]
corresponds to the bottom-right of the grid.
The even rows are assumed to be on the left of the ones on the odd rows
(for those in the same column in the matrix).
This matrix has a "pattern_hex" subclass which supports a special print()
method.
See Also
grid.pattern_regular_polygon()
for drawing to a graphics device
hexagons, triangles, circles, etc. in hexagon patterns.
The tiling vignette features several examples of regular polygon tiling using
this both the "hex" and "hex_circle" types vignette("tiling", package = "gridpattern")
.
For more information on uniform colorings of a hexagonal tiling see
https://en.wikipedia.org/wiki/Hexagonal_tiling#Uniform_colorings.
Examples
# supported hex names
print(names_hex)
# 1-uniform 3-color
hex_3color <- pattern_hex("hex1", 3L, nrow = 7L, ncol = 9L)
print(hex_3color)
# 2-uniform 4-color
hex_4color <- pattern_hex("hex2", 4L, nrow = 7L, ncol = 9L)
print(hex_4color)