trevorld / gridpattern

Compare 064a829 ... +1 ... a8fbfc2


@@ -11,9 +11,11 @@
Loading
11 11
#' \item{herringbone}{Creates a herringbone tiling made of rectangles.}
12 12
#' \item{hexagonal}{Creates a hexagonal tiling made of hexagons.}
13 13
#' \item{pythagorean}{Creates a Pythagorean tiling made of squares of two different sizes.}
14 -
#' \item{square}{Creates a square tiling made of squares.}
15 14
#' \item{rhombitrihexagonal}{Creates a rhombitrihexagonal tiling made out of
16 15
#'                           dodecagons, hexagons, and squares.}
16 +
#' \item{snub_square}{Creates a snub square tiling made of squares and triangles.}
17 +
#' \item{snub_trihexagonal}{Creates a snub trihexagonal tiling made of hexagons and triangles.}
18 +
#' \item{square}{Creates a square tiling made of squares.}
17 19
#' \item{triangular}{Creates a triangular tiling made of equilateral triangles.}
18 20
#' \item{trihexagonal}{Creates a trihexagonal tiling made of hexagons and triangles.}
19 21
#' \item{truncated_square}{Creates a truncated square tiling made of octagons and squares.}
@@ -71,8 +73,10 @@
Loading
71 73
72 74
#' @rdname grid.pattern_polygon_tiling
73 75
#' @export
74 -
names_polygon_tiling <- c("herringbone", "hexagonal", "pythagorean", "square",
75 -
                          "rhombitrihexagonal", "triangular", "trihexagonal",
76 +
names_polygon_tiling <- c("herringbone", "hexagonal", "pythagorean",
77 +
                          "rhombitrihexagonal",
78 +
                          "snub_square", "snub_trihexagonal", "square",
79 +
                          "triangular", "trihexagonal",
76 80
                          "truncated_square", "truncated_hexagonal",
77 81
                          "truncated_trihexagonal")
78 82
@@ -106,6 +110,8 @@
Loading
106 110
                 herringbone = create_herringbone_tiling(xyi, gp, spacing, angle),
107 111
                 hexagonal = create_hexagonal_tiling(xyi, gp, spacing, angle),
108 112
                 pythagorean = create_pythagorean_tiling(xyi, gp, spacing, angle),
113 +
                 snub_square = create_snub_square_tiling(xyi, gp, spacing, angle),
114 +
                 snub_trihexagonal = create_snub_trihex_tiling(xyi, gp, spacing, angle),
109 115
                 square = create_square_tiling(xyi, gp, spacing, angle),
110 116
                 rhombitrihexagonal = create_rhombitrihexagonal_tiling(xyi, gp, spacing, angle),
111 117
                 triangular = create_triangular_tiling(xyi, gp, spacing, angle),
@@ -201,6 +207,57 @@
Loading
201 207
    gList(bg, stripe1, stripe2, stripe3, grob)
202 208
}
203 209
210 +
create_snub_square_tiling <- function(xyi, gp, spacing, angle) {
211 +
    scale_star <- star_scale(4, 90 + 60, external = TRUE)
212 +
    n_col <- length(gp$fill)
213 +
    gp_sq <- gp_sq2 <- gp_tri <- gp
214 +
    if (n_col == 2) {
215 +
        gp_sq2$fill <- gp_sq$fill <- gp$fill[1L]
216 +
        gp_tri$fill <- gp$fill[2L]
217 +
    } else if (n_col == 3) {
218 +
        gp_tri$fill <- gp$fill[1L]
219 +
        gp_sq$fill <- gp$fill[2L]
220 +
        gp_sq2$fill <- gp$fill[3L]
221 +
    }
222 +
    sq1 <- polygonGrob(xyi$x, xyi$y, xyi$id, default.units = "npc",
223 +
                       gp = gp_sq, name = "squares.1")
224 +
    tri <- patternGrob("regular_polygon", xyi$x, xyi$y, xyi$id,
225 +
                       shape = "star4", scale = scale_star,
226 +
                       angle = angle, rot = 15, spacing = spacing,
227 +
                       density = 1.41, gp = gp_tri, name = "triangles")
228 +
    sq2 <- patternGrob("regular_polygon", xyi$x, xyi$y, xyi$id,
229 +
                       shape = "convex4", scale = scale_star,
230 +
                       angle = angle, rot = 60, spacing = spacing,
231 +
                       density = scale_star * 1.41, gp = gp_sq2, name = "squares.2")
232 +
    gList(sq1, tri, sq2)
233 +
}
234 +
235 +
create_snub_trihex_tiling <- function(xyi, gp, spacing, angle) {
236 +
    scale_star <- star_scale(6, 60 + 60, external = TRUE)
237 +
    n_col <- length(gp$fill)
238 +
    gp_tri1 <- gp_tri2 <- gp_hex <- gp
239 +
    if (n_col == 2) {
240 +
        gp_tri1$fill <- gp_tri2$fill <- gp$fill[1L]
241 +
        gp_hex$fill <- gp$fill[2L]
242 +
    } else if (n_col == 3) {
243 +
        gp_tri2$fill <- gp$fill[1L]
244 +
        gp_hex$fill <- gp$fill[2L]
245 +
        gp_tri1$fill <- gp$fill[3L]
246 +
    }
247 +
    tri1 <- polygonGrob(xyi$x, xyi$y, xyi$id, default.units = "npc",
248 +
                        gp = gp_tri1, name = "triangles.1")
249 +
    tri2 <- patternGrob("regular_polygon", xyi$x, xyi$y, xyi$id,
250 +
                        shape = "star6", scale = scale_star,
251 +
                        grid = "hex_circle",
252 +
                        angle = angle, rot = 19, spacing = spacing,
253 +
                        density = 1.305, gp = gp_tri2, name = "triangles.2")
254 +
    hex <- patternGrob("regular_polygon", xyi$x, xyi$y, xyi$id,
255 +
                       shape = "convex6", grid = "hex_circle",
256 +
                       angle = angle, rot = 49, spacing = spacing,
257 +
                       density = scale_star * 1.305, gp = gp_hex, name = "hexagons")
258 +
    gList(tri1, tri2, hex)
259 +
}
260 +
204 261
create_square_tiling <- function(xyi, gp, spacing, angle) {
205 262
    grob <- patternGrob("regular_polygon", xyi$x, xyi$y, xyi$id,
206 263
                        shape = "square", density = 1,

Everything is accounted for!

No changes detected that need to be reviewed.
What changes does Codecov check for?
Lines, not adjusted in diff, that have changed coverage data.
Files that introduced coverage data that had none before.
Files that have missing coverage data that once were tracked.
Files Coverage
R -0.08% 93.59%
Project Totals (32 files) 93.59%
Loading