This function uses a reaction diffusion algorithm in an attempt to draw a Portuguese-styled tiling pattern.
canvas_tiles(
colors,
background = "#ffffff",
iterations = 1000,
size = 5,
col.line = "#000000",
resolution = 100,
layout = NULL
)
a string or character vector specifying the color(s) used for the artwork, or a list containing a set of colors for each unique tile on the wall.
a character specifying the color of the background.
a positive integer specifying the number of iterations of the algorithm.
a positive integer specifying how many tiles should be in each row of the wall.
a character specifying the color of the joints between the tiles.
resolution of the artwork in pixels per row/column. Increasing the resolution increases the quality of the artwork but also increases the computation time exponentially.
optional. A matrix containing integers ranging from 1 to the maximum number of unique tiles (i.e., length(colors)
) specifying the placement of the tiles on the wall.
A ggplot
object containing the artwork.
colorPalette
# \donttest{
set.seed(3)
# Simple example
canvas_tiles(colors = colorPalette("azul"), iterations = 5000)
# Advanced example
canvas_tiles(colors = list(
colorPalette("blossom"),
colorPalette("neon1"),
colorPalette("dark1")
))
# Custom layout
layout <- matrix(c(
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1,
1, 1, 2, 2, 2, 1, 2, 2, 2, 1, 1,
1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1,
1, 1, 2, 2, 2, 2, 2, 2, 2, 1, 1,
1, 1, 1, 2, 2, 2, 2, 2, 1, 1, 1,
1, 1, 1, 1, 2, 2, 2, 1, 1, 1, 1,
1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
), nrow = 11, byrow = TRUE)
canvas_tiles(
colors = list(colorPalette("azul"), colorPalette("blossom")),
size = nrow(layout), layout = layout
)
# Another custom layout
set.seed(11)
layout <- matrix(c(
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2,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2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2
), nrow = 21, byrow = TRUE)
canvas_tiles(
colors = list(
colorPalette("blossom"),
colorPalette("azul"),
colorPalette("neon1"),
colorPalette("mixer4"),
colorPalette("neon2"),
colorPalette("vrolik1"),
colorPalette("blackwhite")
),
iterations = 2000,
size = nrow(layout), layout = layout
)
# }