diff --git a/DESCRIPTION b/DESCRIPTION index c84b44a..dc93672 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: brickr Title: Tools to emulate the LEGO® System in R -Version: 0.1.0.9009 +Version: 0.1.0.9011 Authors@R: person(given = "Ryan", family = "Timpe", @@ -30,24 +30,21 @@ RoxygenNote: 6.1.1 URL: https://github.com/ryantimpe/brickr BugReports: https://github.com/ryantimpe/brickr/issues Collate: - 'bricks_from.R' - 'bricks_from_data.R' 'bricks-from-mosaic.R' 'bricks-from-rayshader.R' + 'bricks-from-tables.R' 'build-bricks.R' - 'collect_bricks.R' + 'build-mosaic.R' + 'collect-bricks.R' 'colors-and-themes.R' - 'coord_brick.R' - 'draw_key.R' + 'coord-brick.R' + 'draw-key.R' 'geom-brick-col.R' - 'geom-brick-point.R' 'geom-brick-rect.R' 'image-to-mosaic.R' 'image-to-prep-mosaic.R' - 'piece_count.R' - 'resizing_text_grob.R' - 'scale_brick.R' - 'theme_brick.R' + 'piece-count.R' + 'scale-brick.R' + 'theme-brick.R' 'utils-pipe.R' - 'view_image.R' VignetteBuilder: knitr diff --git a/NAMESPACE b/NAMESPACE index 239addf..b28e1ff 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,7 +1,6 @@ # Generated by roxygen2: do not edit by hand export("%>%") -export(GeomBrick) export(bricks_from_coords) export(bricks_from_excel) export(bricks_from_mosaic) @@ -12,19 +11,13 @@ export(build_colors) export(build_instructions) export(build_mosaic) export(build_pieces) +export(build_pieces_table) export(build_themes) -export(collect_bricks) export(coord_brick) export(coord_brick_flip) -export(draw_key_brick) export(geom_brick_col) -export(geom_brick_point) export(geom_brick_rect) export(image_to_mosaic) -export(image_to_scaled) -export(resizingTextGrob) export(scale_fill_brick) -export(scaled_to_colors) -export(table_pieces) export(theme_brick) importFrom(magrittr,"%>%") diff --git a/NEWS.md b/NEWS.md index cd25a88..3521b6e 100644 --- a/NEWS.md +++ b/NEWS.md @@ -4,7 +4,7 @@ * **Breaking:** Data "lego_colors.rda" has been updated with more accurate RGB values and new `brickrID` numbers. This will impact previously created mosaics and 3D models. -**Mosaics** +## Mosaics * New rendering of mosaics in ggplot2. Includes embossed text with custom labels. * Color_palette allows option to choose brick colors by rarity. 'universal' (most common), 'generic', and 'special' (least common). @@ -13,7 +13,7 @@ * Updated brick collection algorithm to allow for custom brick input. * 3D mosaics have been rewritten as 3D models using plates with `bricks_from_mosaic()`. -**3D Models** +## 3D Models * `brick_res` input options to render models in higher definition ('sd', 'hd', 'uhd') * `bricks_from_rayshader()` to render LEGO models from rayshader plot_3d() input. @@ -21,13 +21,13 @@ * Updated brick collection algorithm to allow for custom brick input. * Updated brick collection algorithm staggers bricks over layer, though still prioritizes larger bricks. -**ggplot Extension** +## ggplot Extension * `geom_brick_col` for bar charts in the shape of bricks. Negative values are fine, but `position = stack` is not available. * `coord_brick` to prevent chart brick distortion. `coord_brick_flip` for horizontal bars. * `scale_fill_brick` and `theme_brick` for different LEGO color options. -### TO DO +## TO DO * ggplot - continuous scale @@ -41,12 +41,12 @@ - IRL * Website * Check() breaks at the size check -* CRAN! -### TO DO for a future update +## TO DO in the future * Negative bricks are "underside" * bricks_from_models +* CRAN! ---- diff --git a/R/bricks-from-mosaic.R b/R/bricks-from-mosaic.R index 924ca09..af087fc 100644 --- a/R/bricks-from-mosaic.R +++ b/R/bricks-from-mosaic.R @@ -1,22 +1,20 @@ -#' Convert image output from scale_image() to bricks +#' Convert a 2D LEGO mosaic into a brickr 3D object #' -#' @param image_list List output from collect_bricks() or image_to_bricks(). Contains an element \code{Img_lego}. +#' @param mosaic_list List output from collect_bricks() or image_to_bricks(). Contains an element \code{Img_lego}. #' @param mosaic_height Number of layers in the 3D image. #' @param highest_el Brick height is determined by brightness of color. Use \code{highest_el = 'dark'} for darkest bricks to have \code{mosaic_height}. #' @return A list with elements \code{threed_elevation} and \code{threed_hillshade} to created 3D mosiacs with the \code{rayshader} package. #' @export #' -bricks_from_mosaic <- function(image_list, mosaic_height = 6, highest_el = "light"){ +bricks_from_mosaic <- function(mosaic_list, mosaic_height = 6, highest_el = "light"){ #Get previous data - in_list <- image_list - - if(in_list$mosaic_type != "flat")stop("3D mosaics can only be generated with 'flat' mosaics. Set this input in the 'collect_bricks' function.") - + in_list <- mosaic_list + BrickIDs <- in_list$ID_bricks img_lego <- in_list$Img_lego - img_sorted_by_lum <- image_list$Img_lego %>% + img_sorted_by_lum <- mosaic_list$Img_lego %>% dplyr::left_join(lego_colors %>% dplyr::select(Lego_name = Color, lum), by = "Lego_name") %>% dplyr::mutate(Level = as.numeric(as.factor(cut(lum, mosaic_height)))) %>% dplyr::do( diff --git a/R/bricks-from-rayshader.R b/R/bricks-from-rayshader.R index 2754151..5c4d406 100644 --- a/R/bricks-from-rayshader.R +++ b/R/bricks-from-rayshader.R @@ -1,4 +1,4 @@ -#' Convert image output from scale_image() to bricks +#' Build a brickr 3D object from rayshader hillshade & heightmap matrices #' #' @param hillshade Same as \code{rayshader::plot_3d()}. Hillshade/image to be added to 3D surface map. #' @param heightmap Same as \code{rayshader::plot_3d()}. A two-dimensional matrix, where each entry in the matrix is the elevation at that point. All points are assumed to be evenly spaced. diff --git a/R/bricks_from.R b/R/bricks-from-tables.R similarity index 97% rename from R/bricks_from.R rename to R/bricks-from-tables.R index af2d916..616b11a 100644 --- a/R/bricks_from.R +++ b/R/bricks-from-tables.R @@ -1,4 +1,4 @@ -#' Convert a data frame in 3D matrix format into bricks for 3D Model +#' Convert a matrix table into a brickr 3D object #' #' @param matrix_table A data frame of a 3D brick model desigh. Left-most column is level/height/z dimension, with rows as Y axis and columns as X axis. See example. Use \code{tribble} for ease. #' @param color_guide A data frame linking numeric \code{.value} in \code{matrix_table} to official LEGO color names. Defaults to data frame 'lego_colors'. @@ -102,7 +102,7 @@ bricks_from_table <- function(matrix_table, color_guide = lego_colors, .re_level ) } -#' Convert an Excel {brickr} template into a 3D model. https://github.com/ryantimpe/brickr_toybox +#' Convert an Excel {brickr} template into a brickr 3D object #' @param excel_table Sheet imported from a brickr Excel template to build model. Contains stud placement and colors. #' @param repeat_levels How many times to repeat a level. Can save time in model planning. Default is 1. #' @inheritParams bricks_from_table @@ -153,7 +153,7 @@ bricks_from_excel <- function(excel_table, repeat_levels = 1, return(brickr_out) } -#' Convert a data frame with x, y, & z coordinates & Color into bricks for 3D Model +#' Convert a data frame with x, y, z & Color columns into a brickr 3D object #' #' @param coord_table A data frame of a 3D brick model design. Contains x, y, and z (vertical height) dimensions, as well as Color from official LEGO color names. See \code{build_colors()}. #' @param increment_level Default '0'. Use in animations. Shift Level/z dimension by an integer. diff --git a/R/bricks_from_data.R b/R/bricks_from_data.R deleted file mode 100644 index 6e926ba..0000000 --- a/R/bricks_from_data.R +++ /dev/null @@ -1,59 +0,0 @@ -### -# Development of bricks_from_data() -### -# library(brickr) -# dat_table <- PlantGrowth %>% -# dplyr::group_by(group) %>% -# dplyr::summarize_at(dplyr::vars(weight), mean) %>% -# dplyr::ungroup() -# -# dat_table <- Titanic %>% -# as.data.frame() %>% -# dplyr::count(Class, wt = Freq) - - - -bricks_from_data <- function(dat_table = dat_table, x, y, color, - color_scale = lego_colors$Color[-1:-4], - brick_value = 1){ - xvar <- rlang::enquo(x) - yvar <- rlang::enquo(y) - colorvar <- rlang::enquo(color) - - dat_prep <- dat_table %>% - #If X is a factor, convert to numeric. If not, convert to factor, then numeric - dplyr::mutate(.value_x = as.numeric(as.factor(!!xvar))) %>% - dplyr::mutate(.value_z = round(!!yvar / brick_value), - .value_color1 = as.numeric(as.factor(!!colorvar))) %>% - dplyr::do(if(color_scale[1] == "identity"){ - dplyr::mutate(., .value_color = !!colorvar) - } else { - dplyr::mutate(., .value_color = color_scale[.value_color1]) - }) - - - dat_bricks <- dat_prep %>% - dplyr::mutate(x = .value_x * 6 + 1, - z = .value_z, - Color = .value_color) %>% - #Duplicate over x... bars are 4-studs wide - dplyr::bind_rows(list( - dplyr::mutate(., x = x+1), - dplyr::mutate(., x = x+2), - dplyr::mutate(., x = x+3))) %>% - #Duplicate over y - dplyr::mutate(y = 3) %>% - dplyr::bind_rows(dplyr::mutate(., y = 4)) - - #Duplicate over Z - dat_bricks2 <- 1:max(dat_bricks$z) %>% - purrr::map_df(~dplyr::filter(dat_bricks, z >= .x) %>% dplyr::mutate(z=.x)) - - bricks <- bricks_from_coords(dat_bricks2) - return(bricks) -} -# -# -# dat_table %>% -# bricks_from_data(x = Class, y = n, color = Class, brick_value = 50) %>% -# display_bricks() diff --git a/R/build-bricks.R b/R/build-bricks.R index ab4019e..257a71e 100644 --- a/R/build-bricks.R +++ b/R/build-bricks.R @@ -1,6 +1,6 @@ -#' Helper function to convert a level from a 3D model into a rayshader-friendly object. +#' Display a brickr object as a 3D model #' -#' @param brick_list List output from table_to_bricks(). Contains an element \code{Img_lego}. +#' @param brick_list A 3D brickr object from a bricks_from_*() function.. #' @param brick_type Type of brick to use. Default is 'brick'. Other option is 'plate', which is 1/3 the height of a brick. #' @param lev z-level of 3D model #' @param brick_res Resolution, expressed at number of pixels on one side of a 1x1 brick. Defaults to 'sd' (15px). Use 'hd' for 30px per brick, and 'uhd' for 60px. diff --git a/R/view_image.R b/R/build-mosaic.R similarity index 95% rename from R/view_image.R rename to R/build-mosaic.R index 36e69e9..bc0e9f8 100644 --- a/R/view_image.R +++ b/R/build-mosaic.R @@ -1,4 +1,4 @@ -#' Display 2D mosaic output as a plot image +#' Display 2D LEGO mosaic as a plot image #' #' @param image_list List output from collect_bricks() or image_to_bricks(). Contains an element \code{Img_lego}. #' @param title Optional title to include above plotted mosaic. @@ -58,11 +58,7 @@ build_instructions <- function(image_list, num_steps=6) { } #Ratio of the "pixels" is different for flat or stacked bricks - if(type == "flat"){ - coord_ratio <- 1 - } else { - coord_ratio <- 6/5 - } + coord_ratio <- 1 1:num_steps %>% purrr::map(create_steps, num_steps) %>% diff --git a/R/collect_bricks.R b/R/collect-bricks.R similarity index 98% rename from R/collect_bricks.R rename to R/collect-bricks.R index bc81967..62c8674 100644 --- a/R/collect_bricks.R +++ b/R/collect-bricks.R @@ -1,11 +1,9 @@ - -#' Collect legoize image from individual bricks into grouped bricks. +#' Consolidate 1x1 bricks into larger ones of the same color. Internal function. #' #' @param image_list List output from legoize(). Contains an element \code{Img_lego}. #' @param use_bricks Array of brick sizes to use in mosaic. Defaults to \code{c('4x2', '2x2', '3x1', '2x1', '1x1')}`. #' @return A list with element \code{Img_bricks} containing a data frame of the x- & y-coordinates, R, G, B channels, and brick ID. Other helper elements. -#' @export -#' + collect_bricks <- function(image_list, use_bricks = NULL){ in_list <- image_list diff --git a/R/colors-and-themes.R b/R/colors-and-themes.R index 8959ccc..e3239df 100644 --- a/R/colors-and-themes.R +++ b/R/colors-and-themes.R @@ -1,6 +1,7 @@ -#' Available brick colors +#' Dispaly available brick colors #' #' Generates a plot of available brick colors. Use .names_only = TRUE to get a list of color names. +#' #' @param .names_only Return an array of the 41 brick color names. Does not plot. #' @return A table and ggplot of brick colors & ID numbers. #' @examples @@ -10,7 +11,7 @@ #' #Print list of colors #' build_colors(TRUE) #' @export -#' + build_colors <- function(.names_only = FALSE){ if(.names_only){ return(lego_colors$Color) @@ -33,7 +34,7 @@ build_colors <- function(.names_only = FALSE){ } -#' Available brick themes for scale_fill_brick() +#' Display available brick themes for ggplot feature scale_fill_brick() #' #' Generates a plot of available brick themes. #' @param show_theme Defaults to "all". Pass an array of theme names to only plot a subset. diff --git a/R/coord_brick.R b/R/coord-brick.R similarity index 97% rename from R/coord_brick.R rename to R/coord-brick.R index c090761..53140aa 100644 --- a/R/coord_brick.R +++ b/R/coord-brick.R @@ -1,4 +1,4 @@ -#' Cartesian coordinates for bricks +#' Cartesian coordinates for bricks - ggplot2 extension #' #' A fixed scale coordinate system that ensures correct brick proportions are maintained regardless of device size. #' Use \code{coord_brick_flip()} for horizontal bars. @@ -17,7 +17,7 @@ #' coord_brick_flip() #' #' @export -#' @rdname coord_brick +#' @rdname coord-brick coord_brick <- function(xlim = NULL, ylim = NULL, expand = TRUE, clip = "on") { ggproto(NULL, CoordBrick, limits = list(x = xlim, y = ylim), @@ -27,7 +27,7 @@ coord_brick <- function(xlim = NULL, ylim = NULL, expand = TRUE, clip = "on") { } #' @export -#' @rdname coord_brick +#' @rdname coord-brick coord_brick_flip <- function(xlim = NULL, ylim = NULL, expand = TRUE, clip = "on") { ggproto(NULL, CoordBrickFlip, limits = list(x = xlim, y = ylim), diff --git a/R/draw_key.R b/R/draw-key.R similarity index 99% rename from R/draw_key.R rename to R/draw-key.R index d106b7a..5311bbb 100644 --- a/R/draw_key.R +++ b/R/draw-key.R @@ -1,4 +1,3 @@ -#' @export #' @rdname brickr-ggproto draw_key_brick <- function(data, params, size) { diff --git a/R/geom-brick-point.R b/R/geom-brick-point.R deleted file mode 100644 index 2778a1e..0000000 --- a/R/geom-brick-point.R +++ /dev/null @@ -1,104 +0,0 @@ -#' ggplot2 Points, as Bricks -#' -#' `geom_point`, except points look like LEGO(R) studs -#' -#' @inheritParams ggplot2::geom_rect -#' @export -geom_brick_point <- function(mapping = NULL, data = NULL, - stat = "identity", position = "identity", - ..., - label = "LEGO", simplified_threshold = 24, - size = 1, stud_scale = 6/5, - linejoin = "mitre", - na.rm = FALSE, - show.legend = NA, - inherit.aes = TRUE) { - layer_stud <- layer( - data = data, - mapping = mapping, - stat = stat, - geom = GeomStud, - position = position, - show.legend = show.legend, - inherit.aes = inherit.aes, - params = list( - stud_scale = stud_scale, - nudge = c(0, 0), - na.rm = na.rm, - ... - ) - ) - - layer_knob_shadow <- layer( - data = data, - mapping = mapping, - stat = stat, - geom = GeomStud, - position = position, - show.legend = show.legend, - inherit.aes = inherit.aes, - params = list( - stud_scale = stud_scale, - nudge = c(0.08, -0.08), - fill = "#333333", - color = NA, - alpha = 0.2, - size = size * (5/8), - na.rm = na.rm, - ... - ) - ) - - layer_knob_base<- layer( - data = data, - mapping = mapping, - stat = stat, - geom = GeomStud, - position = position, - show.legend = show.legend, - inherit.aes = inherit.aes, - params = list( - stud_scale = stud_scale, - nudge = c(0, 0), - size = size * (5/8), - na.rm = na.rm, - ... - ) - ) - - return(list(layer_stud, layer_knob_shadow, layer_knob_base)) -} - - -#' @rdname brickr-ggproto -GeomStud <- ggproto("GeomStud", Geom, - required_aes = c("x", "y"), - default_aes = aes(colour = "#333333", fill = "#B40000", size = 1, linetype = 1, - alpha = NA), - - draw_panel = function(data, panel_params, coord, na.rm = FALSE, - stud_scale = 6/5, nudge = c(0,0)) { - - coords <- coord$transform(data, panel_params) - - #Size of stud is proportional to number of studs on single plot? - n <- max(table(data$PANEL)) - diameter <- 1/(n^(stud_scale)) - - xn <- coords$x + (nudge[1])*diameter - yn <- coords$y + (nudge[2])*diameter - - ggplot2:::ggname("geom_brick_point", - grid::circleGrob( - xn, yn, - r= diameter * (1/2) * coords$size, - gp = grid::gpar( - col = alpha(coords$colour, coords$alpha), - fill = alpha(coords$fill, coords$alpha) - ) - ) - ) - }, - - draw_key = draw_key_polygon -) \ No newline at end of file diff --git a/R/geom-brick-rect.R b/R/geom-brick-rect.R index 0953d97..c8f3df0 100644 --- a/R/geom-brick-rect.R +++ b/R/geom-brick-rect.R @@ -1,7 +1,11 @@ #' ggplot2 Bar Charts as Bricks #' #' `geom_rect`, except bars look like LEGO(R) bricks. -#' +#' @inheritParams ggplot2::geom_rect +#' @param label Character string to include as embossed text inside brick knobs. Maximum 6 characters. +#' @param label_scale Scale text size of label as a percentage. +#' @param simplified_threshold Maximum number of knobs on the plot before embossed label is suppressed. +#' @param use_bricks Array of brick sizes to use in mosaic. Defaults to \code{c('4x2', '2x2', '3x1', '2x1', '1x1')}`. #' @export geom_brick_rect <- function(mapping = NULL, data = NULL, stat = "identity", position = "identity", @@ -41,7 +45,6 @@ geom_brick_rect <- function(mapping = NULL, data = NULL, #' @rdname brickr-ggproto #' @format NULL #' @usage NULL -#' @export GeomBrick <- ggproto("GeomBrick", Geom, default_aes = aes(colour = "#333333", fill = "#B40000", size = 0.5, linetype = 1, alpha = NA, label = "brickr", label_scale = 1, diff --git a/R/image-to-mosaic.R b/R/image-to-mosaic.R index 8bead5f..cba321f 100644 --- a/R/image-to-mosaic.R +++ b/R/image-to-mosaic.R @@ -1,5 +1,4 @@ - -#' Convert image raster array to a LEGO-esque mosaic. Wrapper function. +#' Create a 2D LEGO mosaic from an image array #' #' @param img Image to convert into mosaic. Usually from \code{jpeg::readJPEG()} or \code{png::readPNG()}. #' @param img_size Size of output image in pixel, where one pixel = one 'brick'. Use a single value (e.g. \code{48}) for a square image with 48 pixels on each side. diff --git a/R/image-to-prep-mosaic.R b/R/image-to-prep-mosaic.R index dcdb771..2b0a924 100644 --- a/R/image-to-prep-mosaic.R +++ b/R/image-to-prep-mosaic.R @@ -1,4 +1,4 @@ -#' Scale an image raster array to a small number of pixels. Process into a data frame. +#' Scale an image raster array to a small number of pixels. Process into a data frame. Internal function. #' #' @param image A raster array from an image. #' @param img_size Size of output image in pixel, where one pixel = one 'brick'. Use a single value (e.g. \code{48}) for a square image with 48 pixels on each side. @@ -8,7 +8,6 @@ #' @format NULL #' @usage NULL #' @return A list with element \code{Img_scaled} containing a data frame of the x- & y-coordinates, R, G, B channels, and hex color of each brick (pixel). -#' @export #' image_to_scaled <- function(image, img_size = 48, brightness = 1, warhol = 1:3){ @@ -95,7 +94,6 @@ image_to_scaled <- function(image, img_size = 48, brightness = 1, warhol = 1:3){ #' @format NULL #' @usage NULL #' @return A list with element \code{Img_lego} containing a data frame of the x- & y-coordinates, R, G, B channels, and mapped color of each brick (pixel). -#' @export scaled_to_colors <- function(image_list, method = "cie94", color_table = NULL, color_palette = c("universal", "generic", "special"), diff --git a/R/piece_count.R b/R/piece-count.R similarity index 96% rename from R/piece_count.R rename to R/piece-count.R index f262003..b770f64 100644 --- a/R/piece_count.R +++ b/R/piece-count.R @@ -5,7 +5,7 @@ #' @export #' -table_pieces <- function(image_list){ +build_pieces_table <- function(image_list){ pcs <- image_list$pieces pcs %>% @@ -49,14 +49,9 @@ build_pieces <- function(image_list){ "White"))) %>% dplyr::left_join(pcs_coords, by = "Brick_size") - if(in_list$mosaic_type == "flat"){ coord_xlim <- c(-0.5, 10) facet_cols <- 5 - } else { - coord_xlim <- c(-0.5, 9) - facet_cols <- 6 - } - + pcs2 %>% ggplot2::ggplot() + ggplot2::geom_rect(ggplot2::aes(xmin=xmin, xmax=xmax, ymin=-ymin, ymax=-ymax, diff --git a/R/resizing_text_grob.R b/R/resizing_text_grob.R deleted file mode 100644 index 5f1ed65..0000000 --- a/R/resizing_text_grob.R +++ /dev/null @@ -1,28 +0,0 @@ -#' grob for scaleable text size in geom_brick_*() -#' -#' @rdname brickr-ggproto -#' @export -#' - -resizingTextGrob <- function(...) { - # https://ryouready.wordpress.com/2012/08/01/creating-a-text-grob-that-automatically-adjusts-to-viewport-size/ - - grid::grob(tg=grid::textGrob(...), cl="resizingTextGrob") -} - -#' @rdname brickr-ggproto -drawDetails.resizingTextGrob <- function(x, recording=TRUE){ - grid::grid.draw(x$tg) -} - -#' @rdname brickr-ggproto -preDrawDetails.resizingTextGrob <- function(x){ - w <- grid::convertWidth(unit(1, "snpc"), "mm", valueOnly=TRUE) - fs <- scales::rescale(w, to=c(20, 7), from=c(120, 20)) - grid::pushViewport(grid::viewport(gp = grid::gpar(fontsize = fs))) -} - -#' @rdname brickr-ggproto -postDrawDetails.resizingTextGrob <- function(x){ - grid::popViewport() -} diff --git a/R/scale_brick.R b/R/scale-brick.R similarity index 93% rename from R/scale_brick.R rename to R/scale-brick.R index 9b2101b..0491c67 100644 --- a/R/scale_brick.R +++ b/R/scale-brick.R @@ -1,4 +1,4 @@ -#' Color scales for bricks +#' Color scales for bricks - ggplot2 extension #' #' brickr counterpart to \code{ggplot2::scale_fill_discrete()} to map bar colors to the palette of LEGO mold colors. #' @@ -6,7 +6,7 @@ #' @param brick_theme Color palette for bricks. Same as \code{brickr::theme_brick()}. Options include: #' \code{ c("classic", "hp", "sw_light", "sw_dark", "friends", "elves", #' "ninja", "classy", "city", "ocean", "movie", "space", -#' "jurassic", "duplo", "superhero", +#' "jurassic", "duplo", "superhero", "80s", #' "rainbow7", "rainbow13", "doublerainbow", "blue")}. #' @examples #' df <- data.frame(trt = c("a", "b", "c"), outcome = c(2.3, 1.9, 3.2)) diff --git a/R/theme_brick.R b/R/theme-brick.R similarity index 70% rename from R/theme_brick.R rename to R/theme-brick.R index efa5bb6..993d168 100644 --- a/R/theme_brick.R +++ b/R/theme-brick.R @@ -1,5 +1,10 @@ -#' Brick color themes - +#' Brick color themes - ggplot2 extension +#' +#' @param brick_theme Color palette for bricks. Same as \code{brickr::theme_brick()}. Options include: +#' \code{ c("classic", "hp", "sw_light", "sw_dark", "friends", "elves", +#' "ninja", "classy", "city", "ocean", "movie", "space", +#' "jurassic", "duplo", "superhero", "80s", +#' "rainbow7", "rainbow13", "doublerainbow", "blue")}. #'@export theme_brick <- function(brick_theme = "classic"){ diff --git a/docs/LICENSE-text.html b/docs/LICENSE-text.html index e269e97..f90481c 100644 --- a/docs/LICENSE-text.html +++ b/docs/LICENSE-text.html @@ -70,7 +70,7 @@ diff --git a/docs/LICENSE.html b/docs/LICENSE.html index d0f0c36..825e02e 100644 --- a/docs/LICENSE.html +++ b/docs/LICENSE.html @@ -6,7 +6,7 @@ -
Copyright (c) 2019 Ryan Timpe
-Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+Version 3, 29 June 2007
Copyright © 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
+The GNU General Public License is a free, copyleft license for software and other kinds of works.
+The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program–to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too.
+When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things.
+To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others.
+For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights.
+Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it.
+For the developers’ and authors’ protection, the GPL clearly explains that there is no warranty for this free software. For both users’ and authors’ sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions.
+Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users’ freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users.
+Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free.
+The precise terms and conditions for copying, distribution and modification follow.
+“This License” refers to version 3 of the GNU General Public License.
+“Copyright” also means copyright-like laws that apply to other kinds of works, such as semiconductor masks.
+“The Program” refers to any copyrightable work licensed under this License. Each licensee is addressed as “you”. “Licensees” and “recipients” may be individuals or organizations.
+To “modify” a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a “modified version” of the earlier work or a work “based on” the earlier work.
+A “covered work” means either the unmodified Program or a work based on the Program.
+To “propagate” a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well.
+To “convey” a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying.
+An interactive user interface displays “Appropriate Legal Notices” to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion.
+The “source code” for a work means the preferred form of the work for making modifications to it. “Object code” means any non-source form of a work.
+A “Standard Interface” means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language.
+The “System Libraries” of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A “Major Component”, in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it.
+The “Corresponding Source” for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work’s System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work.
+The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source.
+The Corresponding Source for a work in source code form is that same work.
+All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law.
+You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you.
+Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary.
+No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures.
+When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work’s users, your or third parties’ legal rights to forbid circumvention of technological measures.
+You may convey verbatim copies of the Program’s source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program.
+You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee.
+You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions:
+A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an “aggregate” if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation’s users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate.
+You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways:
+A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work.
+A “User Product” is either (1) a “consumer product”, which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, “normally used” refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product.
+“Installation Information” for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made.
+If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM).
+The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network.
+Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying.
+“Additional permissions” are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions.
+When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission.
+Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms:
+All other non-permissive additional terms are considered “further restrictions” within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying.
+If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms.
+Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way.
+You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11).
+However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation.
+Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice.
+Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10.
+You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so.
+Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License.
+An “entity transaction” is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party’s predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts.
+You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it.
+A “contributor” is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor’s “contributor version”.
+A contributor’s “essential patent claims” are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, “control” includes the right to grant patent sublicenses in a manner consistent with the requirements of this License.
+Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor’s essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version.
+In the following three paragraphs, a “patent license” is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To “grant” such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party.
+If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. “Knowingly relying” means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient’s use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid.
+If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it.
+A patent license is “discriminatory” if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007.
+Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law.
+If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program.
+Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such.
+The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
+Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License “or any later version” applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation.
+If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy’s public statement of acceptance of a version permanently authorizes you to choose that version for the Program.
+Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version.
+THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee.
+END OF TERMS AND CONDITIONS
+If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms.
+To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the “copyright” line and a pointer to where the full notice is found.
+<one line to give the program's name and a brief idea of what it does.>
+Copyright (C) 2019 Ryan Timpe
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.Also add information on how to contact you by electronic and paper mail.
+If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode:
+brickr Copyright (C) 2019 Ryan Timpe
+This program comes with ABSOLUTELY NO WARRANTY; for details type 'show w'.
+This is free software, and you are welcome to redistribute it
+under certain conditions; type 'show c' for details.The hypothetical commands show w and show c should show the appropriate parts of the General Public License. Of course, your program’s commands might be different; for a GUI interface, you would use an “about box”.
You should also get your employer (if you work as a programmer) or school, if any, to sign a “copyright disclaimer” for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see <http://www.gnu.org/licenses/>.
+The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read <http://www.gnu.org/philosophy/why-not-lgpl.html>.
+

The default is to create a mosaic with 48 knobs (brick studs) on each side. Change this using the img_size input. A single value will create a square mosaic, while an array of two values represent the width and length.












The input brightness can be used to scale up or down the RGB values of the image before color matching. The default is 1.
Use the warhol input to swap the R, G, or B channels in the original image. This can be used to create pop-art style mosaics.
png::readPNG("../Images/mf_unicorn.PNG") %>%
- image_to_mosaic(32, brightness = 0.9, warhol = c(2, 3, 1))%>%
- build_mosaic()
With rayshader installed, passing the mosaic object to bricks_from_mosaic() will render a 3D object, stacking layers of bricks on each other to create an elevated mosaic. By default, the lightest color bricks will be on top, but this can be changed using the highest_el = 'dark' option.
png::readPNG("../Images/mf_unicorn.PNG") %>%
- image_to_mosaic(32) %>%
- bricks_from_mosaic(highest_el = "dark") %>%
- build_bricks(brick_type = "plate")
-
-rayshader::render_camera(theta = 15)
-rayshader::render_snapshot(clear = TRUE)
png::readPNG("../Images/mf_unicorn.PNG") %>%
+ image_to_mosaic(32) %>%
+ bricks_from_mosaic(highest_el = "dark") %>%
+ build_bricks(brick_type = "plate")
+
+rayshader::render_camera(theta = 15)
+rayshader::render_snapshot(clear = TRUE)


In general, any {brickr} function that begins with build_ generates a graphical output from a {brickr} list object from other functions.








Both scale_fill_brick() and theme_brick() take an input ‘brick_theme’, which ensures all colors match official LEGO brick colors. See build_themes() for a sample of all available brick theme.
df <- data.frame(trt = letters[1:6], outcome = rnorm(6, mean = 5, sd = 2))
@@ -276,10 +276,10 @@
ggplot(df, aes(trt, outcome)) +
geom_brick_col(aes(fill = trt), two_knob = F) +
scale_fill_brick(use_theme) +
- coord_brick_flip() +
+ coord_brick_flip() +
theme_brick(use_theme) +
theme(legend.position = "none")

Use build_instructions() to break the mosaics and 3D models into easier-to-read steps for building the set. This defaults to 6 steps, but passing any integer value will generate that many steps.


Use build_pieces() to generate a graphic and count of all required plates or bricks (for stacked mosaics). These are sorted by color and size for easy purchase on LEGO.com’s Pick-a-Brick section using the advanced search option. Alternatively, use table_pieces() to produce a data frame table of all required bricks.
Use build_pieces() to generate a graphic and count of all required plates or bricks (for stacked mosaics). These are sorted by color and size for easy purchase on LEGO.com’s Pick-a-Brick section using the advanced search option. Alternatively, use table_pieces() to produce a data frame table of all required bricks.


Breaking: Pretty much EVERY function. Seriously, check out the README and start fresh.
Breaking: Data “lego_colors.rda” has been updated with more accurate RGB values and new brickrID numbers. This will impact previously created mosaics and 3D models.
Mosaics
+bricks_from_mosaic().3D Models
+brick_res input options to render models in higher definition (‘sd’, ‘hd’, ‘uhd’)ggplot Extension
+geom_brick_col for bar charts in the shape of bricks. Negative values are fine, but position = stack is not available.scale_fill_brick and theme_brick for different LEGO color options.ggplot - continuous scale
CRAN!
Check() breaks at the size check
R/coord_brick.R, R/draw_key.R, R/geom-brick-col.R, and 4 more
+ Source: R/coord-brick.R, R/draw-key.R, R/geom-brick-col.R, and 2 more
brickr-ggproto.Rddraw_key_brick(data, params, size) - -GeomStud - -resizingTextGrob(...) - -drawDetails.resizingTextGrob(x, recording = TRUE) - -preDrawDetails.resizingTextGrob(x) - -postDrawDetails.resizingTextGrob(x)+
draw_key_brick(data, params, size)-
An object of class GeomStud (inherits from Geom, ggproto, gg) of length 5.
R/bricks_from.R
+ R/bricks-from-tables.R
bricks_from_coords.RdConvert a data frame with x, y, & z coordinates & Color into bricks for 3D Model
+Convert a data frame with x, y, z & Color columns into a brickr 3D object
R/bricks_from.R
+ R/bricks-from-tables.R
bricks_from_excel.RdConvert an Excel brickr template into a 3D model. https://github.com/ryantimpe/brickr_toybox
+Convert an Excel brickr template into a brickr 3D object
R/bricks-from-mosaic.R
bricks_from_mosaic.RdConvert image output from scale_image() to bricks
+Convert a 2D LEGO mosaic into a brickr 3D object
bricks_from_mosaic(image_list, mosaic_height = 6, highest_el = "light")+
bricks_from_mosaic(mosaic_list, mosaic_height = 6, + highest_el = "light")
| image_list | +mosaic_list | List output from collect_bricks() or image_to_bricks(). Contains an element |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| xlim | +Limits for the x and y axes. |
+
|---|---|
| ylim | +Limits for the x and y axes. |
+
| expand | +If |
+
| clip | +Should drawing be clipped to the extent of the plot panel? A
+setting of |
+
+#geom_brick_col should be used in conjunction with other brickr charting functions, especially coord_brick. +df <- data.frame(trt = c("a", "b", "c"), outcome = c(2.3, 1.9, 3.2)) +ggplot(df, aes(trt, outcome)) + + geom_brick_col(aes(fill = trt)) + + coord_brick()+ #horizontal bars +ggplot(df, aes(trt, outcome)) + + geom_brick_col(aes(fill = trt)) + + coord_brick_flip()+
borders().
df <- data.frame(trt = c("a", "b", "c"), outcome = c(2.3, 1.9, 3.2))
ggplot(df, aes(trt, outcome)) +
geom_brick_col() +
- coord_brick()


| mapping | +Set of aesthetic mappings created by |
+
|---|---|
| data | +The data to be displayed in this layer. There are three +options: +If A A |
+
| stat | +The statistical transformation to use on the data for this +layer, as a string. |
+
| position | +Position adjustment, either as a string, or the result of +a call to a position adjustment function. |
+
| ... | +Other arguments passed on to |
+
| label | +Character string to include as embossed text inside brick knobs. Maximum 6 characters. |
+
| simplified_threshold | +Maximum number of knobs on the plot before embossed label is suppressed. |
+
| label_scale | +Scale text size of label as a percentage. |
+
| use_bricks | +Array of brick sizes to use in mosaic. Defaults to |
+
| na.rm | +If |
+
| show.legend | +logical. Should this layer be included in the legends?
+ |
+
| inherit.aes | +If |
+
R/image-to-mosaic.R
image_to_mosaic.RdConvert image raster array to a LEGO-esque mosaic. Wrapper function.
+Create a 2D LEGO mosaic from an image array
R/image-to-prep-mosaic.R
image_to_scaled.RdScale an image raster array to a small number of pixels. Process into a data frame.
+Scale an image raster array to a small number of pixels. Process into a data frame. Internal function.
draw_key_brick() GeomStud resizingTextGrob() drawDetails.resizingTextGrob() preDrawDetails.resizingTextGrob() postDrawDetails.resizingTextGrob()
GeomBrick
Convert a data frame with x, y, & z coordinates & Color into bricks for 3D Model
Convert a data frame with x, y, z & Color columns into a brickr 3D object
Convert an Excel brickr template into a 3D model. https://github.com/ryantimpe/brickr_toybox
Convert an Excel brickr template into a brickr 3D object
Convert image output from scale_image() to bricks
Convert a 2D LEGO mosaic into a brickr 3D object
Convert image output from scale_image() to bricks
Build a brickr 3D object from rayshader hillshade & heightmap matrices
Convert a data frame in 3D matrix format into bricks for 3D Model
Convert a matrix table into a brickr 3D object
Available brick colors
Dispaly available brick colors
Display 2D mosaic output as a plot image
Display 2D LEGO mosaic as a plot image
Graphically display required bricks.
Generate required bricks as a data frame.
Available brick themes for scale_fill_brick()
Display available brick themes for ggplot feature scale_fill_brick()
Collect legoize image from individual bricks into grouped bricks.
Consolidate 1x1 bricks into larger ones of the same color. Internal function.
Cartesian coordinates for bricks
Cartesian coordinates for bricks - ggplot2 extension
Bar charts with bricks
ggplot2 Points, as Bricks
Convert image raster array to a LEGO-esque mosaic. Wrapper function.
Create a 2D LEGO mosaic from an image array
Scale an image raster array to a small number of pixels. Process into a data frame.
Scale an image raster array to a small number of pixels. Process into a data frame. Internal function.
Helper function to convert a level from a 3D model into a rayshader-friendly object.
Display a brickr object as a 3D model
Color scales for bricks
Generate required bricks as a data frame.
Color scales for bricks - ggplot2 extension
Brick color themes
Brick color themes - ggplot2 extension
R/build-bricks.R
layer_from_bricks.RdHelper function to convert a level from a 3D model into a rayshader-friendly object.
+Display a brickr object as a 3D model
List output from table_to_bricks(). Contains an element Img_lego.
A 3D brickr object from a bricks_from_*() function..
R/scale_brick.R
+ R/scale-brick.R
scale_fill_brick.RdColor palette for bricks. Same as brickr::theme_brick(). Options include:
c("classic", "hp", "sw_light", "sw_dark", "friends", "elves",
"ninja", "classy", "city", "ocean", "movie", "space",
-"jurassic", "duplo", "superhero",
+"jurassic", "duplo", "superhero", "80s",
"rainbow7", "rainbow13", "doublerainbow", "blue").
df <- data.frame(trt = c("a", "b", "c"), outcome = c(2.3, 1.9, 3.2)) p <- ggplot(df, aes(trt, outcome)) + geom_brick_col(aes(fill = trt)) + - coord_brick() + coord_brick() p + scale_fill_brick()#Select a brick_theme and use with theme_brick() diff --git a/docs/reference/scaled_to_colors.html b/docs/reference/scaled_to_colors.html index aa917a2..585075c 100644 --- a/docs/reference/scaled_to_colors.html +++ b/docs/reference/scaled_to_colors.html @@ -72,7 +72,7 @@diff --git a/docs/reference/table_pieces.html b/docs/reference/table_pieces.html index ea411af..02e83c3 100644 --- a/docs/reference/table_pieces.html +++ b/docs/reference/table_pieces.html @@ -72,7 +72,7 @@ diff --git a/docs/reference/theme_brick.html b/docs/reference/theme_brick.html index d93b952..8ca3ed9 100644 --- a/docs/reference/theme_brick.html +++ b/docs/reference/theme_brick.html @@ -6,7 +6,7 @@ -Brick color themes — theme_brick • brickr +Brick color themes - ggplot2 extension — theme_brick • brickr @@ -37,9 +37,9 @@ - + - + @@ -72,7 +72,7 @@ @@ -123,24 +123,38 @@diff --git a/man/brickr-ggproto.Rd b/man/brickr-ggproto.Rd index 0d12a97..59e7176 100644 --- a/man/brickr-ggproto.Rd +++ b/man/brickr-ggproto.Rd @@ -1,33 +1,16 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/coord_brick.R, R/draw_key.R, -% R/geom-brick-col.R, R/geom-brick-point.R, R/geom-brick-rect.R, -% R/resizing_text_grob.R +% Please edit documentation in R/coord-brick.R, R/draw-key.R, +% R/geom-brick-col.R, R/geom-brick-rect.R \docType{data} \name{CoordBrick} \alias{CoordBrick} \alias{CoordBrickFlip} \alias{draw_key_brick} \alias{GeomBrickCol} -\alias{GeomStud} \alias{GeomBrick} -\alias{resizingTextGrob} -\alias{drawDetails.resizingTextGrob} -\alias{preDrawDetails.resizingTextGrob} -\alias{postDrawDetails.resizingTextGrob} \title{GeomBrick} -\format{An object of class \code{GeomStud} (inherits from \code{Geom}, \code{ggproto}, \code{gg}) of length 5.} \usage{ draw_key_brick(data, params, size) - -GeomStud - -resizingTextGrob(...) - -drawDetails.resizingTextGrob(x, recording = TRUE) - -preDrawDetails.resizingTextGrob(x) - -postDrawDetails.resizingTextGrob(x) } \description{ ggproto for brickr geoms diff --git a/man/bricks_from_coords.Rd b/man/bricks_from_coords.Rd index b4024e6..2a1af28 100644 --- a/man/bricks_from_coords.Rd +++ b/man/bricks_from_coords.Rd @@ -1,8 +1,8 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/bricks_from.R +% Please edit documentation in R/bricks-from-tables.R \name{bricks_from_coords} \alias{bricks_from_coords} -\title{Convert a data frame with x, y, & z coordinates & Color into bricks for 3D Model} +\title{Convert a data frame with x, y, z & Color columns into a brickr 3D object} \usage{ bricks_from_coords(coord_table, color_guide = lego_colors, increment_level = 0, max_level = Inf, increment_x = 0, @@ -32,5 +32,5 @@ bricks_from_coords(coord_table, color_guide = lego_colors, A list with elements \code{Img_lego} to pass to \code{collect_bricks()}. } \description{ -Convert a data frame with x, y, & z coordinates & Color into bricks for 3D Model +Convert a data frame with x, y, z & Color columns into a brickr 3D object } diff --git a/man/bricks_from_excel.Rd b/man/bricks_from_excel.Rd index d3252da..f9b0446 100644 --- a/man/bricks_from_excel.Rd +++ b/man/bricks_from_excel.Rd @@ -1,8 +1,8 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/bricks_from.R +% Please edit documentation in R/bricks-from-tables.R \name{bricks_from_excel} \alias{bricks_from_excel} -\title{Convert an Excel {brickr} template into a 3D model. https://github.com/ryantimpe/brickr_toybox} +\title{Convert an Excel {brickr} template into a brickr 3D object} \usage{ bricks_from_excel(excel_table, repeat_levels = 1, increment_level = 0, max_level = Inf, increment_x = 0, max_x = Inf, increment_y = 0, @@ -33,5 +33,5 @@ bricks_from_excel(excel_table, repeat_levels = 1, increment_level = 0, A list with elements \code{Img_lego} to pass to \code{collect_bricks()}. } \description{ -Convert an Excel {brickr} template into a 3D model. https://github.com/ryantimpe/brickr_toybox +Convert an Excel {brickr} template into a brickr 3D object } diff --git a/man/bricks_from_mosaic.Rd b/man/bricks_from_mosaic.Rd index c5fdc8f..84f75ab 100644 --- a/man/bricks_from_mosaic.Rd +++ b/man/bricks_from_mosaic.Rd @@ -2,12 +2,13 @@ % Please edit documentation in R/bricks-from-mosaic.R \name{bricks_from_mosaic} \alias{bricks_from_mosaic} -\title{Convert image output from scale_image() to bricks} +\title{Convert a 2D LEGO mosaic into a brickr 3D object} \usage{ -bricks_from_mosaic(image_list, mosaic_height = 6, highest_el = "light") +bricks_from_mosaic(mosaic_list, mosaic_height = 6, + highest_el = "light") } \arguments{ -\item{image_list}{List output from collect_bricks() or image_to_bricks(). Contains an element \code{Img_lego}.} +\item{mosaic_list}{List output from collect_bricks() or image_to_bricks(). Contains an element \code{Img_lego}.} \item{mosaic_height}{Number of layers in the 3D image.} @@ -17,5 +18,5 @@ bricks_from_mosaic(image_list, mosaic_height = 6, highest_el = "light") A list with elements \code{threed_elevation} and \code{threed_hillshade} to created 3D mosiacs with the \code{rayshader} package. } \description{ -Convert image output from scale_image() to bricks +Convert a 2D LEGO mosaic into a brickr 3D object } diff --git a/man/bricks_from_rayshader.Rd b/man/bricks_from_rayshader.Rd index 9eb685a..d5cadef 100644 --- a/man/bricks_from_rayshader.Rd +++ b/man/bricks_from_rayshader.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/bricks-from-rayshader.R \name{bricks_from_rayshader} \alias{bricks_from_rayshader} -\title{Convert image output from scale_image() to bricks} +\title{Build a brickr 3D object from rayshader hillshade & heightmap matrices} \usage{ bricks_from_rayshader(hillshade, heightmap, max_height = 12, img_size = 48) @@ -21,5 +21,5 @@ Use an array of two values for a rectangular image \code{c(width, height)}.} A list with elements \code{threed_elevation} and \code{threed_hillshade} to created 3D mosiacs with the \code{rayshader} package. } \description{ -Convert image output from scale_image() to bricks +Build a brickr 3D object from rayshader hillshade & heightmap matrices } diff --git a/man/bricks_from_table.Rd b/man/bricks_from_table.Rd index 97ae8bf..233edba 100644 --- a/man/bricks_from_table.Rd +++ b/man/bricks_from_table.Rd @@ -1,8 +1,8 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/bricks_from.R +% Please edit documentation in R/bricks-from-tables.R \name{bricks_from_table} \alias{bricks_from_table} -\title{Convert a data frame in 3D matrix format into bricks for 3D Model} +\title{Convert a matrix table into a brickr 3D object} \usage{ bricks_from_table(matrix_table, color_guide = lego_colors, .re_level = TRUE, increment_level = 0, max_level = Inf, @@ -36,5 +36,5 @@ bricks_from_table(matrix_table, color_guide = lego_colors, A list with elements \code{Img_lego} to pass to \code{collect_bricks()}. } \description{ -Convert a data frame in 3D matrix format into bricks for 3D Model +Convert a matrix table into a brickr 3D object } diff --git a/man/build_colors.Rd b/man/build_colors.Rd index f6c2744..02f1b32 100644 --- a/man/build_colors.Rd +++ b/man/build_colors.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/colors-and-themes.R \name{build_colors} \alias{build_colors} -\title{Available brick colors} +\title{Dispaly available brick colors} \usage{ build_colors(.names_only = FALSE) } diff --git a/man/build_instructions.Rd b/man/build_instructions.Rd index 3d0ed9a..45e73eb 100644 --- a/man/build_instructions.Rd +++ b/man/build_instructions.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/view_image.R +% Please edit documentation in R/build-mosaic.R \name{build_instructions} \alias{build_instructions} \title{Create instruction manual for 2D image mosaics} diff --git a/man/build_mosaic.Rd b/man/build_mosaic.Rd index d0e79f8..1fc27a7 100644 --- a/man/build_mosaic.Rd +++ b/man/build_mosaic.Rd @@ -1,8 +1,8 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/view_image.R +% Please edit documentation in R/build-mosaic.R \name{build_mosaic} \alias{build_mosaic} -\title{Display 2D mosaic output as a plot image} +\title{Display 2D LEGO mosaic as a plot image} \usage{ build_mosaic(image_list, title = NULL) } @@ -12,5 +12,5 @@ build_mosaic(image_list, title = NULL) \item{title}{Optional title to include above plotted mosaic.} } \description{ -Display 2D mosaic output as a plot image +Display 2D LEGO mosaic as a plot image } diff --git a/man/build_pieces.Rd b/man/build_pieces.Rd index acbb930..c1ed012 100644 --- a/man/build_pieces.Rd +++ b/man/build_pieces.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/piece_count.R +% Please edit documentation in R/piece-count.R \name{build_pieces} \alias{build_pieces} \title{Graphically display required bricks.} diff --git a/man/table_pieces.Rd b/man/build_pieces_table.Rd similarity index 73% rename from man/table_pieces.Rd rename to man/build_pieces_table.Rd index 4432d16..fe10c8d 100644 --- a/man/table_pieces.Rd +++ b/man/build_pieces_table.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/piece_count.R -\name{table_pieces} -\alias{table_pieces} +% Please edit documentation in R/piece-count.R +\name{build_pieces_table} +\alias{build_pieces_table} \title{Generate required bricks as a data frame.} \usage{ -table_pieces(image_list) +build_pieces_table(image_list) } \arguments{ \item{image_list}{List output from collect_bricks() or image_to_bricks(). Contains an element \code{Img_lego}.} diff --git a/man/build_themes.Rd b/man/build_themes.Rd index 4bd40bc..dfa743a 100644 --- a/man/build_themes.Rd +++ b/man/build_themes.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/colors-and-themes.R \name{build_themes} \alias{build_themes} -\title{Available brick themes for scale_fill_brick()} +\title{Display available brick themes for ggplot feature scale_fill_brick()} \usage{ build_themes(show_themes = "all", .names_only = FALSE) } diff --git a/man/collect_bricks.Rd b/man/collect_bricks.Rd index 31928f3..48d40de 100644 --- a/man/collect_bricks.Rd +++ b/man/collect_bricks.Rd @@ -1,8 +1,8 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/collect_bricks.R +% Please edit documentation in R/collect-bricks.R \name{collect_bricks} \alias{collect_bricks} -\title{Collect legoize image from individual bricks into grouped bricks.} +\title{Consolidate 1x1 bricks into larger ones of the same color. Internal function.} \usage{ collect_bricks(image_list, use_bricks = NULL) } @@ -15,5 +15,5 @@ collect_bricks(image_list, use_bricks = NULL) A list with element \code{Img_bricks} containing a data frame of the x- & y-coordinates, R, G, B channels, and brick ID. Other helper elements. } \description{ -Collect legoize image from individual bricks into grouped bricks. +Consolidate 1x1 bricks into larger ones of the same color. Internal function. } diff --git a/man/coord_brick.Rd b/man/coord-brick.Rd similarity index 94% rename from man/coord_brick.Rd rename to man/coord-brick.Rd index 000d5e4..7b3ad74 100644 --- a/man/coord_brick.Rd +++ b/man/coord-brick.Rd @@ -1,9 +1,9 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/coord_brick.R +% Please edit documentation in R/coord-brick.R \name{coord_brick} \alias{coord_brick} \alias{coord_brick_flip} -\title{Cartesian coordinates for bricks} +\title{Cartesian coordinates for bricks - ggplot2 extension} \usage{ coord_brick(xlim = NULL, ylim = NULL, expand = TRUE, clip = "on") diff --git a/man/geom_brick_point.Rd b/man/geom_brick_point.Rd deleted file mode 100644 index e109038..0000000 --- a/man/geom_brick_point.Rd +++ /dev/null @@ -1,60 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/geom-brick-point.R -\name{geom_brick_point} -\alias{geom_brick_point} -\title{ggplot2 Points, as Bricks} -\usage{ -geom_brick_point(mapping = NULL, data = NULL, stat = "identity", - position = "identity", ..., label = "LEGO", - simplified_threshold = 24, size = 1, stud_scale = 6/5, - linejoin = "mitre", na.rm = FALSE, show.legend = NA, - inherit.aes = TRUE) -} -\arguments{ -\item{mapping}{Set of aesthetic mappings created by \code{\link[=aes]{aes()}} or -\code{\link[=aes_]{aes_()}}. If specified and \code{inherit.aes = TRUE} (the -default), it is combined with the default mapping at the top level of the -plot. You must supply \code{mapping} if there is no plot mapping.} - -\item{data}{The data to be displayed in this layer. There are three -options: - -If \code{NULL}, the default, the data is inherited from the plot -data as specified in the call to \code{\link[=ggplot]{ggplot()}}. - -A \code{data.frame}, or other object, will override the plot -data. All objects will be fortified to produce a data frame. See -\code{\link[=fortify]{fortify()}} for which variables will be created. - -A \code{function} will be called with a single argument, -the plot data. The return value must be a \code{data.frame}, and -will be used as the layer data.} - -\item{stat}{The statistical transformation to use on the data for this -layer, as a string.} - -\item{position}{Position adjustment, either as a string, or the result of -a call to a position adjustment function.} - -\item{...}{Other arguments passed on to \code{\link[=layer]{layer()}}. These are -often aesthetics, used to set an aesthetic to a fixed value, like -\code{colour = "red"} or \code{size = 3}. They may also be parameters -to the paired geom/stat.} - -\item{na.rm}{If \code{FALSE}, the default, missing values are removed with -a warning. If \code{TRUE}, missing values are silently removed.} - -\item{show.legend}{logical. Should this layer be included in the legends? -\code{NA}, the default, includes if any aesthetics are mapped. -\code{FALSE} never includes, and \code{TRUE} always includes. -It can also be a named logical vector to finely select the aesthetics to -display.} - -\item{inherit.aes}{If \code{FALSE}, overrides the default aesthetics, -rather than combining with them. This is most useful for helper functions -that define both data and aesthetics and shouldn't inherit behaviour from -the default plot specification, e.g. \code{\link[=borders]{borders()}}.} -} -\description{ -\code{geom_point}, except points look like LEGO(R) studs -} diff --git a/man/geom_brick_rect.Rd b/man/geom_brick_rect.Rd index 5f06c71..6deeec4 100644 --- a/man/geom_brick_rect.Rd +++ b/man/geom_brick_rect.Rd @@ -10,6 +10,59 @@ geom_brick_rect(mapping = NULL, data = NULL, stat = "identity", linejoin = "mitre", na.rm = FALSE, show.legend = NA, inherit.aes = TRUE) } +\arguments{ +\item{mapping}{Set of aesthetic mappings created by \code{\link[=aes]{aes()}} or +\code{\link[=aes_]{aes_()}}. If specified and \code{inherit.aes = TRUE} (the +default), it is combined with the default mapping at the top level of the +plot. You must supply \code{mapping} if there is no plot mapping.} + +\item{data}{The data to be displayed in this layer. There are three +options: + +If \code{NULL}, the default, the data is inherited from the plot +data as specified in the call to \code{\link[=ggplot]{ggplot()}}. + +A \code{data.frame}, or other object, will override the plot +data. All objects will be fortified to produce a data frame. See +\code{\link[=fortify]{fortify()}} for which variables will be created. + +A \code{function} will be called with a single argument, +the plot data. The return value must be a \code{data.frame}, and +will be used as the layer data.} + +\item{stat}{The statistical transformation to use on the data for this +layer, as a string.} + +\item{position}{Position adjustment, either as a string, or the result of +a call to a position adjustment function.} + +\item{...}{Other arguments passed on to \code{\link[=layer]{layer()}}. These are +often aesthetics, used to set an aesthetic to a fixed value, like +\code{colour = "red"} or \code{size = 3}. They may also be parameters +to the paired geom/stat.} + +\item{label}{Character string to include as embossed text inside brick knobs. Maximum 6 characters.} + +\item{simplified_threshold}{Maximum number of knobs on the plot before embossed label is suppressed.} + +\item{label_scale}{Scale text size of label as a percentage.} + +\item{use_bricks}{Array of brick sizes to use in mosaic. Defaults to \code{c('4x2', '2x2', '3x1', '2x1', '1x1')}`.} + +\item{na.rm}{If \code{FALSE}, the default, missing values are removed with +a warning. If \code{TRUE}, missing values are silently removed.} + +\item{show.legend}{logical. Should this layer be included in the legends? +\code{NA}, the default, includes if any aesthetics are mapped. +\code{FALSE} never includes, and \code{TRUE} always includes. +It can also be a named logical vector to finely select the aesthetics to +display.} + +\item{inherit.aes}{If \code{FALSE}, overrides the default aesthetics, +rather than combining with them. This is most useful for helper functions +that define both data and aesthetics and shouldn't inherit behaviour from +the default plot specification, e.g. \code{\link[=borders]{borders()}}.} +} \description{ \code{geom_rect}, except bars look like LEGO(R) bricks. } diff --git a/man/image_to_mosaic.Rd b/man/image_to_mosaic.Rd index 37efd32..9c88a5d 100644 --- a/man/image_to_mosaic.Rd +++ b/man/image_to_mosaic.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/image-to-mosaic.R \name{image_to_mosaic} \alias{image_to_mosaic} -\title{Convert image raster array to a LEGO-esque mosaic. Wrapper function.} +\title{Create a 2D LEGO mosaic from an image array} \usage{ image_to_mosaic(img, img_size = 48, color_table = NULL, method = "cie94", color_palette = c("universal", "generic", @@ -39,5 +39,5 @@ Use "bw" for only grayscale bricks. Ignored if a \code{color_table} is supplied. A list with element \code{Img_lego} containing a data frame of the x- & y-coordinates, R, G, B channels, and mapped color of each brick (pixel). } \description{ -Convert image raster array to a LEGO-esque mosaic. Wrapper function. +Create a 2D LEGO mosaic from an image array } diff --git a/man/image_to_scaled.Rd b/man/image_to_scaled.Rd index a13e1e5..fffff45 100644 --- a/man/image_to_scaled.Rd +++ b/man/image_to_scaled.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/image-to-prep-mosaic.R \name{image_to_scaled} \alias{image_to_scaled} -\title{Scale an image raster array to a small number of pixels. Process into a data frame.} +\title{Scale an image raster array to a small number of pixels. Process into a data frame. Internal function.} \arguments{ \item{image}{A raster array from an image.} @@ -17,5 +17,5 @@ Use an array of two values for a rectangular image \code{c(width, height)}.} A list with element \code{Img_scaled} containing a data frame of the x- & y-coordinates, R, G, B channels, and hex color of each brick (pixel). } \description{ -Scale an image raster array to a small number of pixels. Process into a data frame. +Scale an image raster array to a small number of pixels. Process into a data frame. Internal function. } diff --git a/man/layer_from_bricks.Rd b/man/layer_from_bricks.Rd index 2950d45..d3a81cb 100644 --- a/man/layer_from_bricks.Rd +++ b/man/layer_from_bricks.Rd @@ -2,13 +2,13 @@ % Please edit documentation in R/build-bricks.R \name{layer_from_bricks} \alias{layer_from_bricks} -\title{Helper function to convert a level from a 3D model into a rayshader-friendly object.} +\title{Display a brickr object as a 3D model} \usage{ layer_from_bricks(brick_list, brick_type = "brick", lev = 1, brick_res = "sd") } \arguments{ -\item{brick_list}{List output from table_to_bricks(). Contains an element \code{Img_lego}.} +\item{brick_list}{A 3D brickr object from a bricks_from_*() function..} \item{brick_type}{Type of brick to use. Default is 'brick'. Other option is 'plate', which is 1/3 the height of a brick.} @@ -21,5 +21,5 @@ Enter a value for a custom resolution. High resolutions take longer to render.} A list with elements \code{threed_elevation} and \code{threed_hillshade} to created 3D mosiacs with the \code{rayshader} package. } \description{ -Helper function to convert a level from a 3D model into a rayshader-friendly object. +Display a brickr object as a 3D model } diff --git a/man/scale_fill_brick.Rd b/man/scale_fill_brick.Rd index 25c9444..dee4761 100644 --- a/man/scale_fill_brick.Rd +++ b/man/scale_fill_brick.Rd @@ -1,8 +1,8 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/scale_brick.R +% Please edit documentation in R/scale-brick.R \name{scale_fill_brick} \alias{scale_fill_brick} -\title{Color scales for bricks} +\title{Color scales for bricks - ggplot2 extension} \usage{ scale_fill_brick(brick_theme = "classic", ...) } @@ -10,7 +10,7 @@ scale_fill_brick(brick_theme = "classic", ...) \item{brick_theme}{Color palette for bricks. Same as \code{brickr::theme_brick()}. Options include: \code{ c("classic", "hp", "sw_light", "sw_dark", "friends", "elves", "ninja", "classy", "city", "ocean", "movie", "space", -"jurassic", "duplo", "superhero", +"jurassic", "duplo", "superhero", "80s", "rainbow7", "rainbow13", "doublerainbow", "blue")}.} \item{...}{Arguments passed on to \code{discrete_scale} diff --git a/man/theme_brick.Rd b/man/theme_brick.Rd index 56a8fce..e56b791 100644 --- a/man/theme_brick.Rd +++ b/man/theme_brick.Rd @@ -1,11 +1,18 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/theme_brick.R +% Please edit documentation in R/theme-brick.R \name{theme_brick} \alias{theme_brick} -\title{Brick color themes} +\title{Brick color themes - ggplot2 extension} \usage{ theme_brick(brick_theme = "classic") } -\description{ -Brick color themes +\arguments{ +\item{brick_theme}{Color palette for bricks. Same as \code{brickr::theme_brick()}. Options include: +\code{ c("classic", "hp", "sw_light", "sw_dark", "friends", "elves", +"ninja", "classy", "city", "ocean", "movie", "space", +"jurassic", "duplo", "superhero", "80s", +"rainbow7", "rainbow13", "doublerainbow", "blue")}.} +} +\description{ +Brick color themes - ggplot2 extension } diff --git a/vignettes/mosaics.Rmd b/vignettes/mosaics.Rmd index fcee136..203273f 100644 --- a/vignettes/mosaics.Rmd +++ b/vignettes/mosaics.Rmd @@ -130,14 +130,6 @@ gridExtra::grid.arrange(grobs = mosaics_by_dither, layout_matrix = matrix(c(1,2) The input `brightness` can be used to scale up or down the RGB values of the image before color matching. The default is 1. -Use the `warhol` input to swap the R, G, or B channels in the original image. This can be used to create pop-art style mosaics. - -```{r c_other} -png::readPNG("../Images/mf_unicorn.PNG") %>% - image_to_mosaic(32, brightness = 0.9, warhol = c(2, 3, 1))%>% - build_mosaic() -``` - ## 3D Mosaics With [rayshader](https://www.rayshader.com/) installed, passing the mosaic object to `bricks_from_mosaic()` will render a 3D object, stacking layers of bricks on each other to create an elevated mosaic. By default, the lightest color bricks will be on top, but this can be changed using the `highest_el = 'dark'` option.-Brick color themes
- Source:R/theme_brick.R+Brick color themes - ggplot2 extension
+ Source:R/theme-brick.Rtheme_brick.Rd-Brick color themes
+Brick color themes - ggplot2 extension
theme_brick(brick_theme = "classic")- + +Arguments
++
++ + +brick_theme ++ Color palette for bricks. Same as
brickr::theme_brick(). Options include: +c("classic", "hp", "sw_light", "sw_dark", "friends", "elves", +"ninja", "classy", "city", "ocean", "movie", "space", +"jurassic", "duplo", "superhero", "80s", +"rainbow7", "rainbow13", "doublerainbow", "blue").