| 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 types.
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, and3Lwe use the "hex1" pattern. For subtype4Lwe use the "hex2" pattern. For subtype7Lwe 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
subtype1L,2L, or3L.- "hex2"
Provides the 2-uniform colorings of a hexagonal tiling. Only exists for
subtype2Lor4L.- "hex3"
Provides the 3-uniform colorings of a hexagonal tiling. Only exists for
subtype2Lor7L.- "hex_skew"
For the "hex_skew"
typewe cycle throughsubtypeelements on the horizontal line and "main" diagonal line. For somesubtypenumbers this may lead to noticeable color repeats on the "skew" diagonal line. Ifsubtypeis strictly greater than2Lthen 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)