This commit is contained in:
ryantimpe
2020-03-26 10:04:42 -04:00
113 changed files with 2412 additions and 1617 deletions

View File

@@ -12,3 +12,4 @@ admin_color_tools
^README\.Rmd$
R_experiments
^CNAME
^cran-comments\.md$

View File

@@ -13,7 +13,6 @@ addons:
packages:
- libgdal-dev
- libproj-dev
- r-cran-rayshader
#env
env:

View File

@@ -1,14 +1,15 @@
Package: brickr
Title: Tools to emulate the LEGO® System in R
Version: 0.2.9.9003
Title: Tools to Emulate the LEGO® System in R
Version: 0.3.0
Authors@R:
person(given = "Ryan",
family = "Timpe",
role = c("aut", "cre"),
email = "ryan.timpe@gmail.com")
Description:
Generate digital LEGO-esque models using tidyverse functions. Convert image files into 2D and 3D mosaics, along with piece counts and instructions.
Build 3D models using data frames with rgl.
Generate digital LEGO models using tidyverse functions.
Convert image files into 2D and 3D LEGO mosaics, complete with piece counts and instructions.
Render 3D models using simple data frame instructions.
License: MIT + file LICENSE
Encoding: UTF-8
LazyData: true
@@ -24,7 +25,6 @@ Imports:
colorspace,
rgl
Suggests:
rayshader,
knitr,
rmarkdown,
gridExtra,
@@ -32,7 +32,6 @@ Suggests:
jpeg,
tibble,
raster,
rgdal,
stringr
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.0.2
@@ -41,9 +40,7 @@ BugReports: https://github.com/ryantimpe/brickr/issues
Collate:
'brickr.R'
'bricks-from-mosaic.R'
'bricks-from-rayshader.R'
'bricks-from-tables.R'
'build-bricks.R'
'build-bricks-rgl.R'
'build-instructions.R'
'build-mosaic.R'

View File

@@ -4,10 +4,8 @@ export("%>%")
export(bricks_from_coords)
export(bricks_from_excel)
export(bricks_from_mosaic)
export(bricks_from_rayshader)
export(bricks_from_table)
export(build_bricks)
export(build_bricks_rayshader)
export(build_colors)
export(build_instructions)
export(build_mosaic)

26
NEWS.md
View File

@@ -1,12 +1,32 @@
# Current dev version
# Current version
##brickr 0.2.0.9003
# brickr 0.3.0 - a.k.a. [Pirate ship]()
* An overall leaner package to ensure optimal performance and remove experimental features.
* Updated documentation to increase accessibility and usability.
## 3D Models
* Optional new coordinate system to allow for varying piece shape and 1-height plates & pieces. (Most bricks are 3-height)
* New shapes! Plates, cheese slopes, round 1x1 bricks, conical 1x1 bricks.
* Removed bricks_from_rayshader() and build_bricks_rayshader() to decrease the complexity of package.
## ggplot Extension
* Removed from brickr. Will be rewritten as its own package.
----
# brickr 0.2.0.9003
* Issues after updating to [farver 2.0](https://github.com/thomasp85/farver). Temporarily set color method back to 'brickr_classic'.
----
# brickr 0.2.0 - a.k.a. [Castle]()
# brickr 0.2.0 - a.k.a. [Castle](https://twitter.com/ryantimpe/status/1191354410124709892)
* Lots of bug fixes. More to come.

View File

@@ -11,15 +11,19 @@ NULL
if(getRversion() >= "2.15.1") {
utils::globalVariables(c(".", ".value", "aes", "alpha", "area_act", "area_tar", "B", "B_lego",
"brick_name", "Brick_size", "brick_type", "brickr_themes", "brickrID",
"brick_area", "brick_width", "brick_height",
"channel", "col2rgb", "color", "Color", "color_hex", "dist",
"elevation", "G", "G_lego",
"ggproto", "height", "hex", "layer",
"lego", "Lego_color", "LEGO_color", "lego_colors",
"Lego_name", "Level", "lum", "Lum", "median", "n",
"offset_x", "offset_y", "Palette",
"Lego_name", "Level", "lum", "Lum",
"median", "mid_level", "n",
"offset_x", "offset_y",
"Palette", "piece_type", "Piece",
"R", "rgb", "R_lego", "shade", "shade_bw", "size1", "size2",
"stud", "stud_id", "studs",
"theme", "Tr", "Trans_lego", "TYPE", "user_color", "ww",
"temp_level", "theme", "Tr", "Trans_lego", "TYPE",
"user_color", "ww",
"value",
"x", "x_comp", "x_mid", "x_scaled",
"xg", "xmax", "xmin", "xx",

View File

@@ -3,15 +3,15 @@
#' @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.
#' @return A list with elements \code{Img_lego} to pass to \code{collect_bricks()}.
#' @family 3D Models
#' @export
#'
bricks_from_mosaic <- function(mosaic_list, mosaic_height = 6, highest_el = "light"){
#Get previous data
in_list <- mosaic_list
BrickIDs <- in_list$ID_bricks
img_lego <- in_list$Img_lego
@@ -43,7 +43,9 @@ bricks_from_mosaic <- function(mosaic_list, mosaic_height = 6, highest_el = "lig
dplyr::mutate(Lego_name = ifelse(is.na(Lego_name), as.character(most_common_color[1, "Lego_name"]), Lego_name),
Lego_color = ifelse(is.na(Lego_color), as.character(most_common_color[1, "Lego_color"]), Lego_color)) %>%
dplyr::select(-color) %>%
dplyr::rename(color = Lego_name, z = Level)
dplyr::rename(color = Lego_name, z = Level) %>%
dplyr::mutate(mid_level = (z-1) %% 3,
z = (z-1) %/% 3 +1)
})
return(img_all_levels %>% bricks_from_coords() )

View File

@@ -1,72 +0,0 @@
#' 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.
#' @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.
#' Use an array of two values for a rectangular image \code{c(width, height)}.
#' @param max_height Maximum height of plot in LEGO bricks or plates.
#' @return A list with elements \code{threed_elevation} and \code{threed_hillshade} to created 3D mosiacs with the \code{rayshader} package.
#' @family 3D Models
#' @export
#'
bricks_from_rayshader <- function(hillshade, heightmap, max_height = 12, img_size = 48){
#Convert RGB matrix into a mosaic. Nothing special here.
#Users can do the same to make 2D rayshader map
in_list <- hillshade %>%
image_to_mosaic(img_size)
BrickIDs <- in_list$ID_bricks
img_lego <- in_list$Img_lego
#Bad hack to scale heightmap the same way
hghtmp_list <- (array(c(heightmap, heightmap, heightmap), dim = c(nrow(heightmap), ncol(heightmap), 3)) / max(heightmap)) %>%
image_to_scaled(img_size)
hghtmp <- hghtmp_list[[1]] %>%
dplyr::select(x, y, height = R) %>%
dplyr::mutate(Level = round(height * (max_height))+1) %>%
dplyr::select(-height) %>%
dplyr::mutate(ww = max(x) - x,
x = max(y) - y,
y = ww) %>%
dplyr::select(-ww)
#New levels for the image
img_sorted_by_lum <- in_list$Img_lego %>%
dplyr::select(-Level) %>%
dplyr::left_join(hghtmp, by = c("x", "y")) %>%
dplyr::group_by(y) %>%
tidyr::fill(Level) %>%
tidyr::fill(Level, .direction = "up") %>%
dplyr::ungroup() %>% dplyr::group_by(x) %>%
tidyr::fill(Level) %>%
tidyr::fill(Level, .direction = "up") %>%
dplyr::ungroup()
#For each Level, create a full based mosaic Level
img_all_levels <- 1:max_height %>%
purrr::map_df(function(lvl){
dat <- img_sorted_by_lum %>%
#Only get colors at or above the current level
dplyr::filter(Level >= lvl & Level <= (lvl + 2)) %>%
#Replace any higher levels with colors in this level
dplyr::mutate(Lego_name = ifelse(Level > lvl, NA_character_, Lego_name),
Lego_color = ifelse(is.na(Lego_name), NA_character_, Lego_color),
Level = lvl)
most_common_color <- dat %>%
dplyr::filter(!is.na(Lego_name)) %>%
dplyr::count(Lego_name, Lego_color, sort = TRUE)
dat %>%
dplyr::mutate(Lego_name = ifelse(is.na(Lego_name), as.character(most_common_color[1, "Lego_name"]), Lego_name),
Lego_color = ifelse(is.na(Lego_color), as.character(most_common_color[1, "Lego_color"]), Lego_color)) %>%
dplyr::select(-color) %>%
dplyr::rename(color = Lego_name, z = Level)
})
return(img_all_levels %>% bricks_from_coords() )
}

View File

@@ -1,9 +1,12 @@
#' 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 matrix_table A data frame of a 3D brick model design. 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'.
#' @param piece_matrix A data frame in same shape as \code{matrix_table} with piece shape IDs.
#' @param use_bricks Array of brick sizes to use in mosaic. Defaults to \code{c('4x2', '3x2', '2x2', '3x1', '2x1', '1x1')}`.
#' @param .re_level Logical to reassign the Level/z dimension to layers in alphanumeric order. Set to FALSE to explicitly provide levels.
#' @param increment_level Default '0'. Use in animations. Shift Level/z dimension by an integer.
#' @param min_level Default '1'. Use in animations. Any Level/z values below this value will be cut off.
#' @param max_level Default 'Inf'. Use in animations. Any Level/z values above this value will be cut off.
#' @param increment_x Default '0'. Use in animations. Shift x dimension by an integer.
#' @param max_x Default 'Inf'. Use in animations. Any x values above this value will be cut off.
@@ -15,8 +18,11 @@
#' @family 3D Models
#' @export
#'
bricks_from_table <- function(matrix_table, color_guide = brickr::lego_colors, .re_level = TRUE,
increment_level = 0, max_level = Inf,
bricks_from_table <- function(matrix_table, color_guide = brickr::lego_colors,
piece_matrix = NULL,
use_bricks = NULL,
.re_level = TRUE,
increment_level = 0, min_level = 1, max_level = Inf,
increment_x = 0, max_x = Inf,
increment_y = 0, max_y = Inf,
exclude_color = NULL, exclude_level = NULL){
@@ -24,7 +30,32 @@ bricks_from_table <- function(matrix_table, color_guide = brickr::lego_colors, .
#Reformat input table to consistent format
bricks_raw <- matrix_table
names(bricks_raw)[1] <- "Level"
names(bricks_raw)[-1] <- paste0("X", seq_along(names(bricks_raw)[-1]))
if(names(bricks_raw)[2] %in% c("mid_level")){
excl_name = -1:-2
} else{
excl_name = -1
}
names(bricks_raw)[excl_name] <- paste0("X", seq_along(names(bricks_raw)[excl_name]))
#Add mid_level if not in there
if(!(names(bricks_raw)[2] %in% c("mid_level"))){
bricks_raw <- bricks_raw %>%
dplyr::mutate(mid_level = 0) %>%
dplyr::select(Level, mid_level, dplyr::everything())
}
if(!is.null(piece_matrix)){
pieces_raw <- piece_matrix
names(pieces_raw)[1] <- "Level"
names(pieces_raw)[excl_name] <- paste0("X", seq_along(names(pieces_raw)[excl_name]))
#Add mid_level if not in there
if(!(names(pieces_raw)[2] %in% c("mid_level"))){
pieces_raw <- pieces_raw %>%
dplyr::mutate(mid_level = 0) %>%
dplyr::select(Level, mid_level, dplyr::everything())
}
}
#Color mapping
color_guide_error_msg <- "Color guide should be a data frame with at least 2 columns: `.value` and `Color`.
@@ -43,7 +74,7 @@ bricks_from_table <- function(matrix_table, color_guide = brickr::lego_colors, .
# ))
#
# }
color_map <- color_guide %>%
dplyr::mutate(Color = as.character(Color)) %>%
dplyr::left_join(lego_colors, by = "Color")
@@ -53,33 +84,39 @@ bricks_from_table <- function(matrix_table, color_guide = brickr::lego_colors, .
}
#Literal levels or names
# This does not apply to mid_level, which can only be 0, 1, or 2 for now
if(.re_level){
bricks_raw <- bricks_raw %>%
dplyr::mutate(Level = as.numeric(as.factor(as.character(Level))))
if(!is.null(piece_matrix)){
pieces_raw <- pieces_raw %>%
dplyr::mutate(Level = as.numeric(as.factor(as.character(Level))))
}
}
#Clean up increments
incr_level <- as.numeric(increment_level)[1]
if(is.na(incr_level)){incr_level<-0}
if(is.na(incr_level)){incr_level <- 0}
incr_x <- as.numeric(increment_x)[1]
if(is.na(incr_x)){incr_x<-0}
if(is.na(incr_x)){incr_x <- 0}
incr_y <- as.numeric(increment_y)[1]
if(is.na(incr_y)){incr_y<-0}
if(is.na(incr_y)){incr_y < -0}
brick_set <- bricks_raw %>%
dplyr::mutate_all(dplyr::funs(ifelse(is.na(.), 0, .))) %>%
dplyr::group_by(Level) %>%
dplyr::mutate_all(list(~ifelse(is.na(.), 0, .))) %>%
dplyr::group_by(Level, mid_level) %>%
dplyr::mutate(y = dplyr::n() - dplyr::row_number() + 1) %>%
dplyr::ungroup() %>%
dplyr::select(Level, y, dplyr::everything()) %>%
tidyr::gather(x, .value, 3:ncol(.)) %>%
dplyr::select(Level, mid_level, y, dplyr::everything()) %>%
tidyr::gather(x, .value, dplyr::starts_with("X")) %>%
dplyr::mutate(x = as.numeric(substr(x, 2, 20))) %>%
dplyr::arrange(Level, x, dplyr::desc(y)) %>%
tidyr::drop_na(.value) %>%
dplyr::left_join(color_map, by = ".value") %>%
dplyr::mutate_at(dplyr::vars(dplyr::contains("_lego")), dplyr::funs(ifelse(is.na(.), 0, .))) %>%
dplyr::mutate_at(dplyr::vars(dplyr::contains("_lego")), list(~ifelse(is.na(.), 0, .))) %>%
dplyr::mutate(Lego_color = grDevices::rgb(R_lego, G_lego, B_lego)) %>%
dplyr::mutate(Lego_color = ifelse(is.na(Color),NA, Lego_color)) %>%
dplyr::mutate(Lego_color = ifelse(is.na(Color), NA, Lego_color)) %>%
dplyr::rename(Lego_name = Color) %>%
dplyr::arrange(Level) %>%
#Exclusions
@@ -88,31 +125,67 @@ bricks_from_table <- function(matrix_table, color_guide = brickr::lego_colors, .
#Increment coordinates
dplyr::mutate(Level = Level + incr_level,
x = x + incr_x, y = y + incr_y) %>%
dplyr::filter(Level >= 1, Level <= max_level,
dplyr::filter(Level >= min_level & Level <= max_level,
x >= 1, x <= max_x,
y >= 1, y <= max_y) %>%
#In the end, drop empty levels
dplyr::group_by(Level) %>%
dplyr::group_by(Level, mid_level) %>%
dplyr::filter(!all(is.na(Lego_color))) %>%
dplyr::ungroup()
dplyr::ungroup() %>%
tidyr::drop_na(Lego_color)
#Piece tables
if(is.null(piece_matrix)){
brick_set <- brick_set %>%
dplyr::mutate(piece_type = "b")
} else {
pieces_set <- pieces_raw %>%
dplyr::mutate_all(list(~ifelse(is.na(.), 0, .))) %>%
dplyr::group_by(Level, mid_level) %>%
dplyr::mutate(y = dplyr::n() - dplyr::row_number() + 1) %>%
dplyr::ungroup() %>%
dplyr::select(Level, mid_level, y, dplyr::everything()) %>%
tidyr::gather(x, piece_type, dplyr::starts_with("X")) %>%
dplyr::mutate(x = as.numeric(substr(x, 2, 20))) %>%
dplyr::arrange(Level, x, dplyr::desc(y)) %>%
tidyr::drop_na(piece_type) %>%
dplyr::filter(piece_type != "0") %>%
#Exclusions
dplyr::filter(!(Level %in% exclude_level)) %>%
#Increment coordinates
dplyr::mutate(Level = Level + incr_level,
x = x + incr_x, y = y + incr_y) %>%
dplyr::filter(Level >= min_level & Level <= max_level,
x >= 1, x <= max_x,
y >= 1, y <= max_y)
brick_set <- brick_set %>%
dplyr::left_join(pieces_set, by = c("Level", "mid_level", "y", "x"))
}
#Return an object from collect_bricks()
return(
list(Img_lego = brick_set,
brickr_object = "3dmodel") %>% collect_bricks
brickr_object = "3dmodel") %>% collect_bricks(use_bricks = use_bricks)
)
}
#' 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 piece_table Sheet identical in shape to \code{excel_table} with piece shape IDs.
#' @param use_bricks Array of brick sizes to use in mosaic. Defaults to \code{c('4x2', '3x2', '2x2', '3x1', '2x1', '1x1')}`.
#' @param repeat_levels How many times to repeat a level. Can save time in model planning. Default is 1.
#' @inheritParams bricks_from_table
#' @return A list with elements \code{Img_lego} to pass to \code{collect_bricks()}.
#' @family 3D Models
#' @export
#'
bricks_from_excel <- function(excel_table, repeat_levels = 1,
increment_level = 0, max_level = Inf,
bricks_from_excel <- function(excel_table,
piece_table = NULL,
use_bricks = NULL,
repeat_levels = 1,
increment_level = 0, min_level = 1, max_level = Inf,
increment_x = 0, max_x = Inf,
increment_y = 0, max_y = Inf,
exclude_color = NULL, exclude_level = NULL){
@@ -120,13 +193,12 @@ bricks_from_excel <- function(excel_table, repeat_levels = 1,
columns_meta_start <- max(which(grepl("^\\d", names(excel_table))))
#Set Instructions
instructions <- excel_table %>%
dplyr::select(1:columns_meta_start) %>%
instructions <- excel_table[1:columns_meta_start] %>%
dplyr::rename(Level = 1) %>%
dplyr::filter(Level != "Level")
dplyr::filter(!(Level %in% c("Level")))
#Repeat levels.
#TODO: DO this for x and y too
# Super niche case for lazy people, like me
if(is.numeric(repeat_levels)){
rep_levels <- max(round(repeat_levels), 1)
@@ -139,6 +211,50 @@ bricks_from_excel <- function(excel_table, repeat_levels = 1,
}
}
#Is 'mid_level' in instructions?
if(!("mid_level" %in% names(instructions))){
instructions <- instructions %>%
dplyr::mutate(mid_level = 0) %>%
dplyr::select(Level, mid_level, dplyr::everything())
} else {
instructions <- instructions %>%
dplyr::mutate(mid_level = as.numeric(mid_level))
}
if(!is.null(piece_table)){
#Set Instructions
instructions_p <- piece_table[1:columns_meta_start] %>%
dplyr::rename(Level = 1) %>%
dplyr::filter(Level != "Level") %>%
dplyr::mutate_at(dplyr::vars(dplyr::matches("^\\d")),
list(~ifelse(grepl("^[A-Za-z]", .)|is.na(.), ., "b")))
#Repeat levels.
if(is.numeric(repeat_levels)){
rep_levels <- max(round(repeat_levels), 1)
if(rep_levels == 1){instructions_p <- instructions_p}
else{
instructions_p <- 1:rep_levels %>%
purrr::map_df(
~dplyr::mutate(instructions_p, Level = paste0(Level, .x))
)
}
}
#Is 'mid_level' in instructions_p?
if(!("mid_level" %in% names(instructions_p))){
instructions_p <- instructions_p %>%
dplyr::mutate(mid_level = 0) %>%
dplyr::select(Level, mid_level, dplyr::everything())
} else{
instructions_p <- instructions_p %>%
dplyr::mutate(mid_level = as.numeric(mid_level))
}
} else{
instructions_p = NULL
}
#Color Instructions
colors_user <- excel_table %>%
dplyr::select(.value = user_color, Color = LEGO_color) %>%
@@ -147,8 +263,11 @@ bricks_from_excel <- function(excel_table, repeat_levels = 1,
#Render as brickr output
brickr_out <- instructions %>%
bricks_from_table(color_guide = colors_user,
piece_matrix = instructions_p,
use_bricks = use_bricks,
.re_level = TRUE,
increment_level = increment_level, max_level = max_level,
increment_level = increment_level,
min_level = min_level, max_level = max_level,
increment_x = increment_x, max_x = max_x,
increment_y = increment_y, max_y = max_y,
exclude_color = exclude_color, exclude_level = exclude_level)
@@ -157,8 +276,12 @@ bricks_from_excel <- function(excel_table, repeat_levels = 1,
#' 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 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()}. Optional column 'piece_type' for shapes other than rectangular bricks.
#' Optional column ' mid_Level' with values 0, 1, or 2 (default 0) for 1-height placement of bricks.
#' @param use_bricks Array of brick sizes to use in mosaic. Defaults to \code{c('4x2', '3x2', '2x2', '3x1', '2x1', '1x1')}`.
#' @param increment_level Default '0'. Use in animations. Shift Level/z dimension by an integer.
#' @param min_level Default '1'. Use in animations. Any Level/z values below this value will be cut off.
#' @param max_level Default 'Inf'. Use in animations. Any Level/z values above this value will be cut off.
#' @param increment_x Default '0'. Use in animations. Shift x dimension by an integer.
#' @param max_x Default 'Inf'. Use in animations. Any x values above this value will be cut off.
@@ -171,10 +294,11 @@ bricks_from_excel <- function(excel_table, repeat_levels = 1,
#' @export
#'
bricks_from_coords <- function(coord_table,
increment_level = 0, max_level = Inf,
increment_x = 0, max_x = Inf,
increment_y = 0, max_y = Inf,
exclude_color = NULL, exclude_level = NULL){
use_bricks = NULL,
increment_level = 0, min_level = 1, max_level = Inf,
increment_x = 0, max_x = Inf,
increment_y = 0, max_y = Inf,
exclude_color = NULL, exclude_level = NULL){
#Reformat input table to consistent format
bricks_raw <- coord_table
@@ -187,10 +311,19 @@ bricks_from_coords <- function(coord_table,
stop("Input 'coord_table' must include the columns x, y, z, and Color. z should be >1. Color uses offical brick color names. See build_colors().")
}
#Set mid_level = 0 if not in data
if(!("mid_level" %in% names(bricks_raw))){
bricks_raw <- bricks_raw %>%
dplyr::mutate(mid_level = 0)
}
if(!any(unique(bricks_raw$mid_level) %in% 0:2)){
stop("Column 'mid_level' must be equal to 0, 1, or 2. 0 is the default base level, 1 is the middle of the level, and 2 is the top of the level. Exclude column unless necessary.")
}
#x, y, z, must be whole numbers and unique
bricks_raw <- bricks_raw %>%
dplyr::mutate_at(dplyr::vars("x", "y", "z"), round) %>%
dplyr::group_by(x, y, z) %>%
dplyr::group_by(x, y, z, mid_level) %>%
dplyr::filter(dplyr::row_number() == 1) %>%
dplyr::ungroup()
@@ -233,9 +366,14 @@ bricks_from_coords <- function(coord_table,
dplyr::filter(!all(is.na(Lego_color))) %>%
dplyr::ungroup()
if(!("piece_type" %in% names(brick_set))){
brick_set <- brick_set %>%
dplyr::mutate(piece_type = "b")
}
#Return an object from collect_bricks()
return(
list(Img_lego = brick_set,
brickr_object = "3dmodel") %>% collect_bricks
list(Img_lego = brick_set,
brickr_object = "3dmodel") %>% collect_bricks(use_bricks = use_bricks)
)
}

View File

@@ -52,7 +52,6 @@ build_bricks <- function(brick_list,
# For use inside brick drawing functions below
nudge = 0.01 #Space between bricks
scale = 1 #Reduce to unit size
# trans_alpha = 0.5 #Alpha of transparent bricks
height_scale = 9.6/7.8
color_outline = "black"
@@ -62,32 +61,48 @@ build_bricks <- function(brick_list,
contrast_lum = 0.2
knob_diameter = 5/8
brick_diameter = 96/100
outline_bricks = outline_bricks
suppress_knobs = TRUE
suppress_knobs = TRUE #this won't draw 'hidden' knobs
pieces_knobbed = c("B", "P")
pieces_knobbed = c(pieces_knobbed, tolower(pieces_knobbed))
#For now, use the current collect_bricks output.
#This was designed for rayshader, and I don't want to drop rayshader just yet.
#Bricks without knobs ----
#Bricks & pieces without knobs ----
rgl_bricks_base <- list(
# x & y are the CENTERS of bricks. rgl scales shapes from center
x = img_bricks$xmin + 0.5 + (img_bricks$xmax - img_bricks$xmin)/2 ,
y = img_bricks$ymin + 0.5 + (img_bricks$ymax - img_bricks$ymin)/2 ,
z = img_bricks$Level,
z = img_bricks$Level + (img_bricks$mid_level/3),
color = img_bricks$Lego_color,
trans = img_bricks$Trans_lego,
lum = img_bricks$lum,
#Grab brick size from brick type id
width = as.numeric(substr(img_bricks$brick_type, 2, 2)),
length = as.numeric(substr(img_bricks$brick_type, 4, 4))
width = as.numeric(img_bricks$brick_width),
length = as.numeric(img_bricks$brick_height),
piece = tolower(img_bricks$piece_type)
) %>%
purrr::transpose()
rgl_bricks_base_list <- rgl_bricks_base %>%
purrr::map(function(this_brick){
if(!(this_brick$piece %in% pieces_knobbed)){return(NULL)}
this_height = switch(this_brick$piece,
b = 1,
p = 1/3
)
z_drop = switch(this_brick$piece,
b = 0,
p = -1/3
)
#Solid brick ----
brk_fill <- rgl::cube3d(col = this_brick$color,
@@ -96,8 +111,8 @@ build_bricks <- function(brick_list,
brk_fill$vb[4,] <- brk_fill$vb[4,]/scale*2 + nudge
brk_fill2 <- brk_fill %>%
rgl::scale3d(this_brick$width, this_brick$length, height_scale) %>% #Increase height
rgl::translate3d(this_brick$x, this_brick$y, this_brick$z * height_scale)
rgl::scale3d(this_brick$width, this_brick$length, height_scale*this_height) %>% #Increase height
rgl::translate3d(this_brick$x, this_brick$y, this_brick$z * height_scale + z_drop*height_scale)
if(outline_bricks){
# Brick Outline ----
@@ -111,8 +126,8 @@ build_bricks <- function(brick_list,
brk_out$material$back <- 'line'
brk_out2 <- brk_out %>%
rgl::scale3d(this_brick$width, this_brick$length, height_scale) %>% #Increase height
rgl::translate3d(this_brick$x, this_brick$y, this_brick$z * height_scale)
rgl::scale3d(this_brick$width, this_brick$length, height_scale*this_height) %>% #Increase height
rgl::translate3d(this_brick$x, this_brick$y, this_brick$z * height_scale + z_drop*height_scale)
out_list <- list(brk_fill2, brk_out2)
} else {
@@ -124,20 +139,232 @@ build_bricks <- function(brick_list,
return(out_list)
}) %>%
purrr::discard(is.null) %>%
purrr::transpose()
rgl_bricks_wedge_list <- rgl_bricks_base %>%
purrr::map(function(this_brick){
if(!(this_brick$piece %in% paste0("w", 1:4))){return(NULL)}
#Solid brick ----
brk_fill <- rgl::cube3d(col = this_brick$color,
alpha = if(this_brick$trans){trans_alpha}else{1})
#Turn it into a wedge
w_lhs <- switch(this_brick$piece,
w1 = c(7, 8),
w2 = c(6, 8),
w3 = c(5, 6),
w4 = c(5, 7))
w_rhs <- switch(this_brick$piece,
w1 = c(3, 4),
w2 = c(2, 4),
w3 = c(1, 2),
w4 = c(1, 3))
w_ratio = 1.2/4
brk_fill$vb[, w_lhs] <- brk_fill$vb[, w_rhs] * (1-w_ratio) + brk_fill$vb[, w_lhs] * w_ratio
brk_fill$vb[4,] <- brk_fill$vb[4,]/scale*2 + nudge
brk_fill2 <- brk_fill %>%
rgl::scale3d(this_brick$width, this_brick$length, height_scale * 2/3) %>% #Increase height
rgl::translate3d(this_brick$x, this_brick$y,
this_brick$z * height_scale - height_scale*(1-2/3)/2)
if(outline_bricks){
# Brick Outline ----
brk_out <- rgl::cube3d(col = if(this_brick$trans){colorspace::lighten(this_brick$color)}
else{color_outline})
#Turn it into a wedge
brk_out$vb[, w_lhs] <- brk_out$vb[, w_rhs] * (1-w_ratio) + brk_out$vb[, w_lhs] * w_ratio
brk_out$vb[4,] <- brk_out$vb[4,]/scale*2 + nudge
brk_out$material$lwd <- 1
brk_out$material$front <- 'line'
brk_out$material$back <- 'line'
brk_out2 <- brk_out %>%
rgl::scale3d(this_brick$width, this_brick$length, height_scale * 2/3) %>% #Increase height
rgl::translate3d(this_brick$x, this_brick$y,
this_brick$z * height_scale - height_scale*(1-2/3)/2)
out_list <- list(brk_fill2, brk_out2)
} else {
brk_out2 <- NULL
out_list <- list(brk_fill2, brk_out2)
}
#Save ----
return(out_list)
}) %>%
purrr::discard(is.null) %>%
purrr::transpose()
rgl_bricks_cyln_list <- rgl_bricks_base %>%
purrr::map(function(this_brick){
if(!(this_brick$piece %in% c("c", paste0("c", 1:2)))){return(NULL)}
this_piece = tolower(this_brick$piece)
bottom_diameter = 12/16
bottom_gap = height_scale/6
cyl_scale = 2
#Solid brick ----
# Base
# Between c/c1 (cylinder) and c2 (cone), only base is different
cyl_base_diameter = switch(
this_piece,
c = brick_diameter,
c1 = brick_diameter,
c2 = c(brick_diameter, (brick_diameter+knob_diameter)/2, knob_diameter)
)
cyl_base <- rgl::cylinder3d(matrix(c(rep(1, 3), rep(1, 3))/cyl_scale, ncol=2, byrow = TRUE),
sides = 32,
radius = cyl_base_diameter,
closed = -2)
cyl_base$material$color <- this_brick$color
cyl_base$material$alpha <- if(this_brick$trans){trans_alpha}else{1}
cyl_base$vb[4,] <- cyl_base$vb[4,]/scale*2 + nudge
cyl_base2 <- cyl_base %>%
rgl::rotate3d(pi/2, 0, 1, 0) %>%
rgl::scale3d(1, 1, height_scale - bottom_gap) %>%
rgl::translate3d(0.25, -0.25, -height_scale + bottom_gap*1.5) %>%
rgl::translate3d(this_brick$x, this_brick$y,
this_brick$z * height_scale)
# Knob
cyl_knob <- rgl::cylinder3d(matrix(c(rep(1, 3), rep(1, 3))/cyl_scale, ncol=2, byrow = TRUE),
sides = 32,
radius = knob_diameter,
closed = -2)
cyl_knob$material$color <- this_brick$color
cyl_knob$material$alpha <- if(this_brick$trans){trans_alpha}else{1}
cyl_knob$vb[4,] <- cyl_knob$vb[4,]/scale*2 + nudge
cyl_knob2 <- cyl_knob %>%
rgl::rotate3d(pi/2, 0, 1, 0) %>%
rgl::scale3d(1, 1, height_scale) %>%
rgl::translate3d(0.25, -0.25, -height_scale + bottom_gap - 0.02 + (1.7/9.6)/2 - 0.02) %>%
rgl::translate3d(this_brick$x, this_brick$y, this_brick$z * height_scale)
# Bottom
cyl_bttm <- rgl::cylinder3d(matrix(c(rep(1, 3), rep(1, 3))/cyl_scale, ncol=2, byrow = TRUE),
sides = 32,
radius = bottom_diameter,
closed = -2)
cyl_bttm$material$color <- this_brick$color
cyl_bttm$material$alpha <- if(this_brick$trans){trans_alpha}else{1}
cyl_bttm$vb[4,] <- cyl_bttm$vb[4,]/scale*2 + nudge
cyl_bttm2 <- cyl_bttm %>%
rgl::rotate3d(pi/2, 0, 1, 0) %>%
rgl::scale3d(1, 1, bottom_gap) %>%
rgl::translate3d(0.25, -0.25, -bottom_gap*3.5) %>%
rgl::translate3d(this_brick$x, this_brick$y, this_brick$z * height_scale)
#Outlines ----
if(outline_bricks){
cyl_ot_diameter = switch(
this_piece,
c = brick_diameter,
c1 = brick_diameter,
c2 = knob_diameter
)
# These are 2-dimensional cylinders
#Base, top ----
cyl_base_ot_prep <- rgl::cylinder3d(matrix(c(rep(1, 3), rep(1, 3))/2, ncol=2, byrow = TRUE),
sides = 32,
radius = cyl_ot_diameter*1.015) #Conditional on cone or cylinder
cyl_base_ot_prep$vb[4,] <- cyl_base_ot_prep$vb[4,]/scale*2 + nudge
cyl_base_ot_prep$material$color <- if(this_brick$trans){colorspace::lighten(this_brick$color)}
else{color_outline}
cyl_base_ot <- cyl_base_ot_prep %>%
rgl::rotate3d(pi/2, 0, 1, 0) %>%
rgl::scale3d(1, 1, 0.01) %>% #Make the height super short
rgl::translate3d(0.25, -0.25, height_scale/2 - 0.02) %>%
rgl::translate3d(this_brick$x, this_brick$y, this_brick$z * height_scale)
#Base, bottom ---
cyl_bttm_ot_prep <- rgl::cylinder3d(matrix(c(rep(1, 3), rep(1, 3))/2, ncol=2, byrow = TRUE),
sides = 32,
radius = brick_diameter*1.015)
cyl_bttm_ot_prep$vb[4,] <- cyl_bttm_ot_prep$vb[4,]/scale*2 + nudge
cyl_bttm_ot_prep$material$color <- if(this_brick$trans){colorspace::lighten(this_brick$color)}
else{color_outline}
cyl_bttm_ot <- cyl_bttm_ot_prep %>%
rgl::rotate3d(pi/2, 0, 1, 0) %>%
rgl::scale3d(1, 1, 0.01) %>% #Make the height super short
rgl::translate3d(0.25, -0.25, height_scale/2) %>%
rgl::translate3d(this_brick$x, this_brick$y, this_brick$z * height_scale) %>%
rgl::translate3d(0, 0, -1*(height_scale - bottom_gap))
#Knob ----
cyl_knob_ot_prep <- rgl::cylinder3d(matrix(c(rep(1, 3), rep(1, 3))/2, ncol=2, byrow = TRUE),
sides = 32,
radius = knob_diameter*1.015)
cyl_knob_ot_prep$vb[4,] <- cyl_knob_ot_prep$vb[4,]/scale*2 + nudge
cyl_knob_ot_prep$material$color <- if(this_brick$trans){colorspace::lighten(this_brick$color)}
else{color_outline}
cyl_knob_ot <- cyl_knob_ot_prep %>%
rgl::rotate3d(pi/2, 0, 1, 0) %>%
rgl::scale3d(1, 1, 0.01) %>% #Make the height super short
rgl::translate3d(0.25, -0.25, height_scale/2) %>%
rgl::translate3d(this_brick$x, this_brick$y, this_brick$z * height_scale) %>%
rgl::translate3d(0, 0, 0.22)
} else {
cyl_base_ot <- NULL
cyl_bttm_ot <- NULL
cyl_knob_ot <- NULL
}
out_list <- list(cyl_base2, cyl_bttm2, cyl_knob2,
cyl_base_ot, cyl_bttm_ot, cyl_knob_ot)
#Save ----
return(out_list)
}) %>%
purrr::discard(is.null) %>%
purrr::transpose()
#Bricks knobs ----
if(suppress_knobs){
img_lego <- img_lego %>%
dplyr::mutate(temp_level = Level*3 + mid_level,
piece_type = tolower(piece_type)) %>%
dplyr::group_by(x, y) %>%
dplyr::filter(
#Keep knobs when next level is not right above it
(dplyr::lead(Level, order_by = Level) != Level + 1) |
#Bricks: Keep knobs when next level is not right above it, 3 1-height units
((dplyr::lead(temp_level, order_by = temp_level) > (temp_level + 3)) & piece_type == "b") |
#Plates: Keep knobs when next level is not right above it, 1 1-height unit
((dplyr::lead(temp_level, order_by = temp_level) > (temp_level + 1)) & piece_type %in% c("p", "s")) |
#Or next level is na
is.na(dplyr::lead(Level, order_by = Level)) |
is.na(dplyr::lead(temp_level, order_by = temp_level)) |
# Or this or next level is transparent
dplyr::lead(Trans_lego, order_by = Level) | Trans_lego
dplyr::lead(Trans_lego, order_by = temp_level) | Trans_lego
) %>%
dplyr::ungroup()
}
@@ -145,15 +372,32 @@ build_bricks <- function(brick_list,
rgl_bricks_knobs <- list(
x = img_lego$x,
y = img_lego$y,
z = img_lego$Level,
z = img_lego$Level + (img_lego$mid_level/3),
color = img_lego$Lego_color,
trans = img_lego$Trans_lego,
lum = img_lego$lum
lum = img_lego$lum,
piece = tolower(img_lego$piece_type)
) %>%
purrr::transpose()
rgl_bricks_knobs_list <- rgl_bricks_knobs %>%
purrr::map(function(this_brick){
if(!(this_brick$piece %in% pieces_knobbed)){return(NULL)}
adj_height = switch(this_brick$piece,
b = 1,
p = 1/3
)
z_drop = switch(this_brick$piece,
b = 0,
p = 1/3
)
cap_drop = switch(this_brick$piece,
b = 0,
p = -2/3
)
# Brick knob ----
brk_knob <- rgl::cylinder3d(matrix(c(rep(1, 3), rep(1, 3))/2, ncol=2, byrow = TRUE),
@@ -180,9 +424,9 @@ build_bricks <- function(brick_list,
brk_knob2 <- brk_knob %>%
rgl::rotate3d(pi/2, 0, 1, 0) %>%
rgl::scale3d(1, 1, height_scale + 1.7/9.6) %>%
rgl::scale3d(1, 1, (height_scale*adj_height) + 1.7/9.6) %>%
rgl::translate3d(0.25, -0.25, -height_scale-0.02) %>%
rgl::translate3d(this_brick$x, this_brick$y, this_brick$z * height_scale)
rgl::translate3d(this_brick$x, this_brick$y, this_brick$z * height_scale + z_drop*height_scale)
# Brick knob outlines ----
# These are 2-dimensional cylinders
@@ -199,8 +443,8 @@ build_bricks <- function(brick_list,
brk_knob_ot <- brk_knob_ot_prep %>%
rgl::rotate3d(pi/2, 0, 1, 0) %>%
rgl::scale3d(1, 1, 0.01) %>% #Make the height super short
rgl::translate3d(0.25, -0.25, 0.62) %>%
rgl::translate3d(this_brick$x, this_brick$y, this_brick$z * height_scale)
rgl::translate3d(0.25, -0.25, height_scale/2) %>%
rgl::translate3d(this_brick$x, this_brick$y, this_brick$z * height_scale + cap_drop*height_scale)
#Top of the knob
brk_knob_ot2 <- brk_knob_ot %>%
@@ -231,8 +475,8 @@ build_bricks <- function(brick_list,
brk_knob_top2 <- brk_knob_top %>%
rgl::rotate3d(pi/2, 0, 1, 0) %>%
rgl::scale3d(1, 1, 0.01) %>%
rgl::translate3d(0.25, -0.25, 0.62+0.22+0.01) %>%
rgl::translate3d(this_brick$x, this_brick$y, this_brick$z * height_scale)
rgl::translate3d(0.25, -0.25, height_scale/2+0.22+0.01) %>%
rgl::translate3d(this_brick$x, this_brick$y, this_brick$z * height_scale + cap_drop*height_scale)
out_list[[4]] <- brk_knob_top2
} else{
@@ -244,11 +488,13 @@ build_bricks <- function(brick_list,
return(out_list)
}) %>%
purrr::discard(is.null) %>%
purrr::transpose()
#Draw
shapelist <- c(rgl_bricks_base_list[[1]]
, rgl_bricks_base_list[[2]]
shapelist <- c( purrr::flatten(rgl_bricks_base_list)
, purrr::flatten(rgl_bricks_wedge_list)
, purrr::flatten(rgl_bricks_cyln_list)
, purrr::flatten(rgl_bricks_knobs_list)
)

View File

@@ -1,233 +0,0 @@
#' Display a brickr object as a 3D model
#'
#' @param brick_list A 3D brickr object from a bricks_from_*() function..
#' @param brick_type Either a 3-height "brick" (default) or 1-height "plate"
#' @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. Enter a value for a custom resolution. High resolutions take
#' longer to render.
#' @return A list with elements \code{threed_elevation} and
#' \code{threed_hillshade} to created 3D mosiacs with the \code{rayshader}
#' package.
#' @keywords internal
layer_from_bricks <- function(brick_list, brick_type = "brick", lev=1, brick_res = "sd"){
#Get previous data
in_list <- brick_list
BrickIDs <- in_list$ID_bricks%>%
dplyr::filter(Level == lev)
img_lego <- in_list$Img_lego %>%
dplyr::filter(Level == lev)
if(brick_type == 'plate'){
brick_depth = 1L
} else {
brick_depth = 3L
}
#Increment elevation - a brick is 3 plates tall
up_el = (lev-1)*brick_depth
#Number of 'pixels' on a side of a single-stud brick. Set by brick_res.
if(is.numeric(brick_res)){
if(brick_res > 100) warning("brick_res capped at 100px per brick.")
ex_size <- min(100, abs(round(brick_res)))
} else {
if(!(brick_res %in% c('sd', 'hd', 'uhd'))) stop("brick_res must be 'sd', 'hd', 'uhd', or a number.")
ex_size <- switch(brick_res,
sd = 18,
hd = 30,
uhd = 60)
}
#Use below is edge calculation
# Optimized color only in HD bricks >20 pixels
if(ex_size >= 20){
edge_offset <- 0:1
} else {
edge_offset <- 0
}
#Increase data frame into the correct resolution
lego_expand <- img_lego %>%
dplyr::select(Level, x, y, Lego_name, Lego_color) %>%
dplyr::mutate(stud_id = dplyr::row_number())
lego_expand2 <- expand.grid(x = (min(lego_expand$x)*ex_size):(max(lego_expand$x+1)*ex_size),
y = (min(lego_expand$y)*ex_size):(max(lego_expand$y+1)*ex_size)) %>%
dplyr::mutate(x_comp = x %/% ex_size,
y_comp = y %/% ex_size) %>%
dplyr::left_join(lego_expand %>% dplyr::rename(x_comp = x, y_comp = y),
by = c("x_comp", "y_comp")) %>%
dplyr::left_join(BrickIDs %>% dplyr::select(brick_name, x_comp = x, y_comp = y),
by = c("x_comp", "y_comp")) %>%
dplyr::select(-x_comp, -y_comp) %>%
dplyr::left_join(lego_colors %>% dplyr::select(Lego_name = Color, R_lego, G_lego, B_lego),
by = "Lego_name") %>%
#Round elevation to nearest 1/height
dplyr::mutate(elevation = ifelse(is.na(brick_name),NA, brick_depth + up_el),
elevation = ifelse(is.na(Lego_name),NA, elevation)) %>%
#Create the edges of bricks... Brick base begins at 0.01 to avoid complete overlap with previous brick
dplyr::group_by(brick_name) %>%
dplyr::mutate(elevation = dplyr::case_when(
x %in% (min(x) + edge_offset) ~ 0.01+up_el,
x %in% (max(x) - edge_offset) ~ 0.01+up_el,
y %in% (min(y) + edge_offset) ~ 0.01+up_el,
y %in% (max(y) - edge_offset) ~ 0.01+up_el,
TRUE ~ elevation
)) %>%
#Remove the bottom corners of brick for bricks with an offset
# dplyr::do(
# if(ex_size >= 20){
# dplyr::filter(., !((x %in% c(min(x), max(x))) & (y %in% c(min(y), max(y)))))
# } else {.}
# ) %>%
dplyr::ungroup() %>%
dplyr::mutate(y = max(y)-y) %>%
#Calculate stud placement... radius of 5/8 * (1/2) and height of 0.5 plate
dplyr::group_by(stud_id) %>%
dplyr::mutate(x_mid = median(x), y_mid = median(y),
stud = ((x-x_mid)^2 + (y-y_mid)^2)^(1/2) <= (ex_size * (5/8 * (1/2))),
stud_color = dplyr::between(((x-x_mid)^2 + (y-y_mid)^2)^(1/2),
(ex_size * (5/8 * (1/2))) - 1,
(ex_size * (5/8 * (1/2))) + 1
)) %>%
dplyr::ungroup() %>%
dplyr::mutate(elevation = ifelse(stud, elevation+0.5, elevation)) %>%
#Change color of the stude sics
dplyr::mutate_at(dplyr::vars(R_lego, G_lego, B_lego),
list(~ifelse(stud_color, .-0.1, .))) %>%
dplyr::mutate_at(dplyr::vars(R_lego, G_lego, B_lego), list(~ifelse(. < 0, 0, .)))
#Elevation Matrix
lego_elmat <- lego_expand2 %>%
dplyr::mutate(elevation = ifelse(is.na(Lego_name), NA, elevation)) %>%
dplyr::select(x, y, elevation) %>%
tidyr::spread(y, elevation) %>%
dplyr::select(-x) %>%
as.matrix()
#Hillshade matrix
lego_hillshade_m <- array(dim = c(length(unique(lego_expand2$y)),
length(unique(lego_expand2$x)),
3))
lego_expand_color <- lego_expand2 %>%
dplyr::group_by(brick_name) %>%
#This darkens the edge of each brick, to look like they are separated
# The higher the resolution, the dark this should be
dplyr::mutate_at(dplyr::vars(R_lego, G_lego, B_lego),
list(~ifelse((x == min(x) | y == min(y) | x == max(x) | y == max(y)),
. - 0.1, .))) %>%
#Darken the upper edge of the bricks. This is important for the HD and UHD
dplyr::do(
if(ex_size >= 20){
dplyr::mutate_at(.,
dplyr::vars(R_lego, G_lego, B_lego),
list(~ifelse((x == min(x)+(edge_offset+1) | y == min(y)+(edge_offset+1) |
x == max(x)-(edge_offset+1) | y == max(y)-(edge_offset+1)),
. - 0.05, .)))
}else{.}) %>%
dplyr::mutate_at(dplyr::vars(R_lego, G_lego, B_lego),
list(~ifelse(. < 0, 0, .))) %>%
dplyr::ungroup()
lego_hillshade_m[,,1] <- lego_expand_color %>%
dplyr::select(x, y, R_lego) %>%
tidyr::spread(x, R_lego) %>%
dplyr::select(-y) %>%
as.matrix()
lego_hillshade_m[,,2] <- lego_expand_color %>%
dplyr::select(x, y, G_lego) %>%
tidyr::spread(x, G_lego) %>%
dplyr::select(-y) %>%
as.matrix()
lego_hillshade_m[,,3] <- lego_expand_color %>%
dplyr::select(x, y, B_lego) %>%
tidyr::spread(x, B_lego) %>%
dplyr::select(-y) %>%
as.matrix()
#Return
in_list[["threed_elevation"]] <- lego_elmat
in_list[["threed_hillshade"]] <- lego_hillshade_m
in_list[["brick_resolution"]] <- ex_size
return(in_list)
}
#' Build 3D brick model with rayshader.
#'
#' @param brick_list List output from collect_bricks(). Contains an element \code{Img_lego}.
#' @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 view_levels Numeric array of Levels/z values to display. Leave as \code{NULL} to include all.
#' @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.
#' Enter a value for a custom resolution. High resolutions take longer to render.
#' @param solidcolor Hex color of mosaic base. Only renders on bottom.
#' @param water Default 'FALSE'. If 'TRUE', a water layer is rendered.
#' @param waterdepth Default '0'. Water level.
#' @param ... All other inputs from rayshader::plot_3d() EXCEPT \code{hillshade}, \code{soliddepth}, \code{zscale}, and \code{shadow}.
#' @examples \dontrun{
#' #This is a brick
#'brick <- data.frame(
#' Level="A",
#' X1 = rep(3,4), #The number 3 is the brickrID for 'bright red'
#' X2 = rep(3,4)
#')
#'
#'brick %>%
#' bricks_from_table() %>%
#' build_bricks()
#' }
#' @return 3D brick model rendered in the 'rayshader' package.
#' @family 3D Models
#' @export
#'
build_bricks_rayshader <- function(brick_list, brick_type = "brick", brick_res = "sd",
view_levels = NULL, solidcolor = "#a3a2a4",
water = FALSE, waterdepth = 0, ...){
#Requires Rayshader
if (!requireNamespace("rayshader", quietly = TRUE)) {
stop("Package \"rayshader\" needed for this function to work. Please install it.",
call. = FALSE)
}
#Get previous data
in_list <- brick_list
BrickIDs <- in_list$ID_bricks
img_lego <- in_list$Img_lego
if(is.null(view_levels)){
view_levels <- unique(img_lego$Level)
}
for(ii in view_levels){
brick_layer <- brick_list %>%
layer_from_bricks(ii, brick_type = brick_type, brick_res = brick_res)
if(ii == min(view_levels) & water){
brick_layer$`threed_hillshade`%>%
rayshader::plot_3d(brick_layer$`threed_elevation`, zscale=0.167*(15/brick_layer$`brick_resolution`),
solid = FALSE,
solidcolor=solidcolor, shadow = FALSE,
water = TRUE, waterdepth = waterdepth * 3, ...)
} else {
brick_layer$`threed_hillshade`%>%
rayshader::plot_3d(brick_layer$`threed_elevation`, zscale=0.167*(15/brick_layer$`brick_resolution`),
solid = FALSE,
solidcolor=solidcolor, shadow = FALSE,
water = FALSE, waterdepth = 0, ...)
}
}
}

View File

@@ -1,18 +1,32 @@
#' 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 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')}`.
#' @param default_piece_type Piece type to use in absence of piece_type column.
#' @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.
#' @keywords internal
collect_bricks <- function(image_list, use_bricks = NULL){
collect_bricks <- function(image_list, use_bricks = NULL,
default_piece_type = "b"){
in_list <- image_list
img_lego <- in_list$Img_lego
#If no mid_level (as in a mosaic), add it
if(!("mid_level" %in% names(img_lego))){
img_lego <- img_lego %>%
dplyr::mutate(mid_level = 0)
}
#Same with piece_type
if(!("piece_type" %in% names(img_lego))){
img_lego <- img_lego %>%
dplyr::mutate(piece_type = default_piece_type)
}
#Allowed bricks ----
if(is.null(use_bricks)){
use_bricks <- c('4x2', '2x2', '4x1', '3x1', '2x1', '1x1')
use_bricks <- c('4x2', '2x2', '4x1', '3x2', '3x1', '2x1', '1x1')
} else {
#Must contain 1x1... duplicated gets dropped
use_bricks <- c(use_bricks, '1x1')
@@ -24,12 +38,12 @@ collect_bricks <- function(image_list, use_bricks = NULL){
brick_sizes2 <- dplyr::bind_rows(
brick_sizes,
brick_sizes %>% dplyr::rename(yy=1, xx=2)
brick_sizes %>% dplyr::rename(yy=1, xx=2) #Rotate the brick
) %>%
dplyr::distinct() %>%
dplyr::mutate(offset_x = purrr::map(xx, ~.x:1 -1)) %>%
dplyr::mutate(offset_x = ifelse(xx <=10, purrr::map(xx, ~.x:1 -1), 0)) %>%
tidyr::unnest_legacy() %>%
dplyr::mutate(offset_y = purrr::map(yy, ~.x:1 -1)) %>%
dplyr::mutate(offset_y = ifelse(yy <=10, purrr::map(yy, ~.x:1 -1), 0)) %>%
tidyr::unnest_legacy() %>%
dplyr::arrange(dplyr::desc(xx*yy), #Start with bricks with most area
xx+yy, #Then smaller perimeter... so 2x2 is before 1x4,
@@ -39,32 +53,47 @@ collect_bricks <- function(image_list, use_bricks = NULL){
# Brick looping ----
multidim_bricks <- c("B", "P")
multidim_bricks <- c(multidim_bricks, tolower(multidim_bricks))
# Does any xx*yy space contain all the same color?
img <- (1:nrow(brick_sizes2)) %>%
# Only "brick" shapes will get sizes greater than 1x1
img_multi <- (1:nrow(brick_sizes2)) %>%
purrr::map_dfr(function(aa){
xx <- brick_sizes2$xx[aa]
yy <- brick_sizes2$yy[aa]
offset_x <- brick_sizes2$offset_x[aa]
offset_y <- brick_sizes2$offset_y[aa]
in_list$Img_lego %>%
#Weird bug when resetting the level
dplyr::select(Level, x, y, Lego_name, Lego_color) %>%
# dplyr::mutate(Level = ifelse(!is.numeric(lll), as.numeric(as.factor(lll)), lll)) %>%
# dplyr::select(-lll) %>%
dplyr::group_by(Level,
xg = (x + offset_x -1 + Level -1) %/% xx,
yg = (y + offset_y -1 + Level -1) %/% yy) %>%
img_lego %>%
dplyr::filter(piece_type %in% multidim_bricks) %>%
dplyr::select(Level, mid_level, piece_type, x, y, Lego_name, Lego_color) %>%
dplyr::group_by(Level, mid_level, piece_type,
xg = (x + offset_x -1 + Level -1 + mid_level) %/% xx,
yg = (y + offset_y -1 + Level -1 + mid_level) %/% yy) %>%
dplyr::mutate(brick_type = paste0("x", xx, "y", yy, "_offx", offset_x, "_offy", offset_y)) %>%
dplyr::mutate(brick_name = ifelse(length(unique(Lego_name)) == 1 & dplyr::n() == (xx*yy),
paste0("brick_", "x", min(x), "_y", min(y), "_", Level), NA)) %>%
paste0("brick_", "x", min(x), "_y", min(y), "_",
Level, "_", mid_level, "_", piece_type), NA),
brick_area = xx*yy, brick_height = yy, brick_width = xx) %>%
dplyr::ungroup() %>%
dplyr::select(-xg, -yg) %>%
dplyr::filter(!is.na(Lego_name))
}
)
img_single <- img_lego %>%
dplyr::filter(!(piece_type %in% multidim_bricks)) %>%
dplyr::select(Level, mid_level, piece_type, x, y, Lego_name, Lego_color) %>%
dplyr::mutate(brick_type = paste0("x", 1, "y", 1, "_offx", 0, "_offy", 0)) %>%
dplyr::mutate(brick_name = paste0("brick_", "x", x, "_y", y, "_",
Level, "_", mid_level, "_", piece_type),
brick_area = 1, brick_height = 1, brick_width = 1) %>%
dplyr::filter(!is.na(Lego_name))
#Combine multi- and single- bricks
img <- dplyr::bind_rows(list(img_multi, img_single))
#Output of all brick types... size * layout
bricks <- unique(img$brick_type)
@@ -77,15 +106,13 @@ collect_bricks <- function(image_list, use_bricks = NULL){
dat <- img %>%
dplyr::filter(brick_type == bb) %>%
tidyr::drop_na(brick_name) %>%
dplyr::anti_join(bricks_df, by = c("Level", "x", "y")) %>%
#Necessary Area
dplyr::mutate(area_tar = as.numeric(substr(brick_type, 2,2)) * as.numeric(substr(brick_type, 4,4))) %>%
dplyr::anti_join(bricks_df, by = c("Level", "mid_level", "x", "y")) %>%
#Actual Area
dplyr::group_by(brick_name) %>%
dplyr::mutate(area_act = dplyr::n()) %>%
dplyr::ungroup() %>%
#Drop rows where the areas don't match
dplyr::filter(area_act == area_tar) %>%
dplyr::filter(area_act == brick_area) %>%
dplyr::select(-dplyr::starts_with("area"))
bricks_df <- bricks_df %>%
@@ -94,7 +121,8 @@ collect_bricks <- function(image_list, use_bricks = NULL){
img2 <- bricks_df %>%
# min/max coord for geom_rect()
dplyr::group_by(Level, brick_type, brick_name, Lego_color, Lego_name) %>%
dplyr::group_by(Level, mid_level, piece_type, brick_type, brick_name,
Lego_color, Lego_name, brick_width, brick_height) %>%
dplyr::summarise(xmin = min(x)-0.5, xmax = max(x)+0.5,
ymin = min(y)-0.5, ymax = max(y)+0.5) %>%
dplyr::ungroup()
@@ -102,12 +130,14 @@ collect_bricks <- function(image_list, use_bricks = NULL){
# Pieces ----
# This is very brute-force. Probably a much cleaner way to do this
pcs <- img2 %>%
dplyr::select(Level, brick_type, brick_name, Lego_name, Lego_color) %>%
dplyr::select(Level, mid_level, piece_type, brick_type, brick_name,
Lego_name, Lego_color, brick_width, brick_height) %>%
dplyr::distinct() %>%
dplyr::mutate(size1 = as.numeric(substr(brick_type, 2, 2)),
size2 = as.numeric(substr(brick_type, 4, 4))) %>%
dplyr::mutate(size1 = brick_width,
size2 = brick_height) %>%
dplyr::mutate(Brick_size = ifelse(size1>size2, paste(size1, "x", size2), paste(size2, "x" , size1))) %>%
dplyr::count(Brick_size, Lego_name, Lego_color)
dplyr::mutate(Piece = tolower(substr(piece_type, 1, 1))) %>%
dplyr::count(Brick_size, Piece, Lego_name, Lego_color)
in_list[["Img_bricks"]] <- img2
in_list[["ID_bricks"]] <- bricks_df

View File

@@ -7,7 +7,9 @@
#' @return A table and ggplot of brick colors & ID numbers.
#' @examples
#' #Generate plot of colors
#' \dontrun{
#' build_colors()
#' }
#'
#' #Print list of colors
#' build_colors(TRUE)
@@ -33,7 +35,7 @@ build_colors <- function(.names_only = FALSE, include_transparent = TRUE){
use_columns <- 9
}
tidyr::crossing(x=1:2, y=1:2, color = use_colors) %>%
tidyr::crossing(x=1, y=1, color = use_colors) %>%
dplyr::left_join(lego_colors %>%
dplyr::select(color = Color, color_hex = hex, Trans_lego), by = "color") %>%
dplyr::mutate(color = factor(gsub('(.{1,8})(\\s|$)', '\\1\n', color),
@@ -41,10 +43,8 @@ build_colors <- function(.names_only = FALSE, include_transparent = TRUE){
alpha = ifelse(Trans_lego, 0.5, 1)) %>%
ggplot2::ggplot(ggplot2::aes(x=x, y=y, group=color)) +
ggplot2::labs(title = "Brick colors available in {brickr}") +
brickr::geom_brick_rect(ggplot2::aes(fill = color_hex, alpha = alpha), label_scale = 0.1,
#Including the use_bricks inputs greatly increases the speed of this.
use_bricks = c("2x2")) +
ggplot2::coord_fixed(x=c(0.5, 2.5), y=c(0.5, 2.5)) +
ggplot2::geom_raster(ggplot2::aes(fill = color_hex, alpha = alpha)) +
ggplot2::coord_fixed() +
ggplot2::scale_fill_identity() +
ggplot2::scale_alpha_identity()+
ggplot2::facet_wrap(~color, ncol = use_columns) +

View File

@@ -1,4 +1,4 @@
#' Brickr colors avaiable for mosaics & 3D models
#' Brickr colors available for mosaics & 3D models
#'
#' A dataset containing the 54 colors available in brickr, along with metadata
#'

View File

@@ -20,7 +20,7 @@
#' @export
#'
image_to_mosaic <- function(img, img_size = 48, color_table = NULL,
method = "brickr_classic",
method = "cie94",
color_palette = c("universal", "generic", "special"),
dithering = FALSE, contrast = 1,
use_bricks = NULL,
@@ -30,7 +30,7 @@ image_to_mosaic <- function(img, img_size = 48, color_table = NULL,
image_to_scaled(img_size = img_size, brightness = brightness, warhol = warhol) %>%
scaled_to_colors(method = method,
color_table = color_table, color_palette = color_palette,
dithering = dithering, contrast = contrast) %>%
dithering = dithering, contrast = contrast, default_piece_type = "p") %>%
collect_bricks(use_bricks = use_bricks)
return(in_list)

View File

@@ -95,24 +95,26 @@ image_to_scaled <- function(image, img_size = 48, brightness = 1, warhol = 1:3){
#' Convert image output from scale_image() to bricks
#'
#' @param image_list List output from scale_image(). Contains an element \code{Img_scaled}.
#' @param method The method to use for comparison. Either 'brickr_classic', 'euclidean', 'cie1976', 'cie94', 'cie2000', or 'cmc'.
#' @param method Default 'cie94'. The method to use for comparison. Either 'brickr_classic', 'euclidean', 'cie1976', 'cie94', 'cie2000', or 'cmc'.
#' 'brickr_classic' is an explicit euclidean distance formula, but yield different results than 'euclidean' in {farver}.
#' See \code{farver::compare_colour}.
#' @param color_table Defaults to \code{lego_colors}. Data frame of brick colors to map onto image. Must contain Name and R, G, B channels.
#' See attached data \code{lego_colors} as examples.
#' @param color_palette Brick color rarity to use. Defaults to all colors: 'universal' (most common), 'generic', and 'special' (least common). This is useful when trying to build the mosaic out of real bricks.
#' @param color_palette Brick color rarity to use. Defaults to all colors: 'universal' (most common), 'generic', and 'special' (least common).
#' This is useful when trying to build the mosaic out of real bricks.
#' Use "bw" for only grayscale bricks. Ignored if a \code{color_table} is supplied.
#' @param dithering Improves color of large, photo-realistic mosaics.
#' @param contrast For \code{color_palette = "bw"}. A value >1 will increase the contrast of the image while a positive value <1 will decrease the contrast.
#' @param default_piece_type Piece type to use in absence of piece_type column.
#' @format NULL
#' @usage NULL
#' @keywords internal
#' @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).
scaled_to_colors <- function(image_list, method = "brickr_classic",
scaled_to_colors <- function(image_list, method = "cie94",
color_table = NULL,
color_palette = c("universal", "generic", "special"),
dithering = FALSE,
contrast = 1){
contrast = 1, default_piece_type = "b"){
in_list <- image_list
#Brick colors to use ----
@@ -155,7 +157,7 @@ scaled_to_colors <- function(image_list, method = "brickr_classic",
#Return output....
in_list[["Img_lego"]] <- img %>%
dplyr::mutate(Level = 1)
dplyr::mutate(Level = 1, piece_type = default_piece_type)
in_list[["brickr_object"]] <- "mosaic"

View File

@@ -26,34 +26,30 @@ library(tidyverse)
## Overview
**brickr** is a package for bringing the LEGO&reg; experience into the R and [tidyverse](https://www.tidyverse.org/) ecosystem.
The package is divided into 3 separate systems:
The package is divided into 2 systems:
- [**Mosaics**](#mosaics): Convert image files into mosaics that could be built using LEGO&reg; bricks.
- [**3D Models**](#3d-models): Build 3D LEGO&reg; models from data tables using [rgl](https://cran.r-project.org/web/packages/rgl/index.html).
- [**Charts**](#charts): COMING SOON: A [ggplot2](https://ggplot2.tidyverse.org/) extension to generate plots that resemble LEGO&reg; bricks.
- [**Mosaics**](#mosaics): Convert image files into mosaics that could be built using LEGO bricks.
- [**3D Models**](#3d-models): Build 3D LEGO models from data tables using [rgl](https://cran.r-project.org/web/packages/rgl/index.html).
brickr also includes tools help users create the Mosaics and 3D model output using real LEGO&reg; elements.
brickr also includes tools help users create the Mosaics and 3D model output using real LEGO elements.
Check out [brickr.org](http://brickr.org) for more detail!
### What's the point?
The goal of **brickr** is to provide a series of tools to integrate the LEGO&reg; system with R by:
The goal of **brickr** is to provide a series of tools to integrate the LEGO system with R by:
- Enhancing a real world building experience with mosaics, generated instructions, and piece counts.
- Generating interest in R and coding for new audiences with easy-to-create 3D models.
- or just embracing pure novelty.
- Embracing pure novelty.
*brickr is developed under the [Fair Play](https://www.lego.com/en-us/legal/notices-and-policies/fair-play/) policy using publicly available information about LEGO&reg; products. brickr is not affiliated with The LEGO Group.*
*brickr is developed under the [Fair Play](https://www.lego.com/en-us/legal/notices-and-policies/fair-play/) policy using publicly available information about LEGO products. brickr is not affiliated with The LEGO Group.*
## Installation
``` r
# To install the latest version from Github:
# install.packages("devtools")
devtools::install_github("ryantimpe/brickr")
#For 3D features, rayshader is also required.
install.packages("rayshader")
# install.packages("remotes")
remotes::install_github("ryantimpe/brickr")
```
## Mosaics
@@ -89,12 +85,12 @@ The `bricks_from_*` series of functions creates 3D models of LEGO bricks from a
- `bricks_from_table()` & `bricks_from_excel()` convert a matrix-shaped table of integers into LEGO bricks. For simple models, this table can be made manually using `data.frame()` or `tibble::tribble()`. For more advanced models, it's recommended you use MS Excel or a .csv file. The left-most column in the table is associated with the Level or z-axis of the model. `bricks_from_excel()` is a wrapper function to more easily build models designed using a Microsoft Excel template. Please see this repo: [brickr toybox](https://github.com/ryantimpe/brickr_toybox).
- `bricks_from_coords()` takes a data frame with `x`, `y`, & `z` integer values, and `Color` columns, where each combination of x, y, & z is a point in 3-dimensional space. Color must be an official LEGO color name from `build_colors()`. This format is much more flexible than `bricks_from_table()` and allows the programmatic development of 3D models.
- `bricks_from_coords()` takes a data frame with `x`, `y`, & `z` integer values, and `Color` columns, where each combination of x, y, & z is a point in 3-dimensional space. Color must be an official LEGO color name from `build_colors()`. This format is much more flexible than `bricks_from_table()` and allows the programmatic development of 3D models. For other options, see the "Piece type in 3D Models" vignette.
- `bricks_from_mosaic()` converts a 2D [mosaic](#mosaics) object from an image into 3D LEGO models, respectively. `bricks_from_rayshader()` creates a LEGO model from the same input as `rayshader::plot_3d()`.
- `bricks_from_mosaic()` converts a 2D [mosaic](#mosaics) object from an image into 3D LEGO models, respectively.
Pass the output from any `bricks_from_*()` function to `build_bricks()` to see the 3D model.
Models are currently rendered in **rgl**. Previous versions of brickr use [Tyler Morgan-Wall](https://twitter.com/tylermorganwall)'s [rayshader](https://www.rayshader.com/) package. This option is still available by passing the output from any `bricks_from_*()` function to `build_bricks_rayshader()`. Rayshader can still be used for saving snapshots and creating animations.
Models are rendered in **rgl**.
```{r bricks_1, rgl=TRUE, dev='png', echo=TRUE, warning=FALSE, message=FALSE, fig.width=3, fig.height=3}
library(brickr)
@@ -195,9 +191,7 @@ The option `outline_bricks = TRUE` adds a black outline around the edges of the
More examples using `bricks_from_table()` and `bricks_from_coords()` can be found at the links below.
- [**Get started**](https://gist.github.com/ryantimpe/a784beaa4f798f57010369329d46ce71) with the framework for building a brick from scratch.
- [**Build an owl**](https://gist.github.com/ryantimpe/ceab2ed6b8a4737077280fc9b0d1c886) with `bricks_from_table()` by manually placing each brick.
- Generate a punny [**random forest model**](https://gist.github.com/ryantimpe/a7363a5e99dceabada150a43925beec7) using `bricks_from_coords()` and {purrr}.
- [**Baby Yoda**](https://gist.github.com/ryantimpe/3893fdd0f94138d027bae35bf38b57c7) example using `bricks_from_excel()` with an animation.
- [**brickr toybox**](https://github.com/ryantimpe/brickr_toybox) repo for tools and resources to get started.
## IRL
@@ -219,3 +213,9 @@ Use `build_pieces()` to generate a graphic and count of all required plates or b
```{r m1_pieces, fig.width = 8, fig.height=7, message = FALSE, warning = FALSE}
mosaic1 %>% build_pieces()
```
## Acknowledgments
3D models in brickr would not exist without [Tyler Morgan-Wall](https://twitter.com/tylermorganwall) and his [rayshader](https://www.rayshader.com/) package. If you're interested in creating 3D models of literally *anything* R, check out his [rayrender](https://www.rayrender.net/) package.
All functions in brickr are created with the [tidyverse](https://www.tidyverse.org/) and [rgl](https://cran.r-project.org/web/packages/rgl/index.html).

View File

@@ -16,46 +16,40 @@ status](https://travis-ci.org/ryantimpe/brickr.svg?branch=master)](https://travi
**brickr** is a package for bringing the LEGO® experience into the R and
[tidyverse](https://www.tidyverse.org/) ecosystem.
The package is divided into 3 separate systems:
The package is divided into 2 systems:
- [**Mosaics**](#mosaics): Convert image files into mosaics that could
be built using LEGO® bricks.
- [**3D Models**](#3d-models): Build 3D LEGO® models from data tables
be built using LEGO bricks.
- [**3D Models**](#3d-models): Build 3D LEGO models from data tables
using [rgl](https://cran.r-project.org/web/packages/rgl/index.html).
- [**Charts**](#charts): COMING SOON: A
[ggplot2](https://ggplot2.tidyverse.org/) extension to generate
plots that resemble LEGO® bricks.
brickr also includes tools help users create the Mosaics and 3D model
output using real LEGO® elements.
output using real LEGO elements.
Check out [brickr.org](http://brickr.org) for more detail\!
### Whats the point?
The goal of **brickr** is to provide a series of tools to integrate the
LEGO® system with R by:
LEGO system with R by:
- Enhancing a real world building experience with mosaics, generated
instructions, and piece counts.
- Generating interest in R and coding for new audiences with
easy-to-create 3D models.
- or just embracing pure novelty.
- Embracing pure novelty.
*brickr is developed under the [Fair
Play](https://www.lego.com/en-us/legal/notices-and-policies/fair-play/)
policy using publicly available information about LEGO® products. brickr
policy using publicly available information about LEGO products. brickr
is not affiliated with The LEGO Group.*
## Installation
``` r
# To install the latest version from Github:
# install.packages("devtools")
devtools::install_github("ryantimpe/brickr")
#For 3D features, rayshader is also required.
install.packages("rayshader")
# install.packages("remotes")
remotes::install_github("ryantimpe/brickr")
```
## Mosaics
@@ -121,21 +115,14 @@ from a variety of input formats.
& z is a point in 3-dimensional space. Color must be an official
LEGO color name from `build_colors()`. This format is much more
flexible than `bricks_from_table()` and allows the programmatic
development of 3D models.
development of 3D models. For other options, see the “Piece type in
3D Models” vignette.
- `bricks_from_mosaic()` converts a 2D [mosaic](#mosaics) object from
an image into 3D LEGO models, respectively.
`bricks_from_rayshader()` creates a LEGO model from the same input
as `rayshader::plot_3d()`.
Pass the output from any `bricks_from_*()` function to `build_bricks()`
to see the 3D model. Models are currently rendered in **rgl**. Previous
versions of brickr use [Tyler
Morgan-Wall](https://twitter.com/tylermorganwall)s
[rayshader](https://www.rayshader.com/) package. This option is still
available by passing the output from any `bricks_from_*()` function to
`build_bricks_rayshader()`. Rayshader can still be used for saving
snapshots and creating animations.
to see the 3D model. Models are rendered in **rgl**.
``` r
library(brickr)
@@ -251,15 +238,9 @@ more cartoon fashion.
More examples using `bricks_from_table()` and `bricks_from_coords()` can
be found at the links below.
- [**Get
started**](https://gist.github.com/ryantimpe/a784beaa4f798f57010369329d46ce71)
with the framework for building a brick from scratch.
- [**Build an
owl**](https://gist.github.com/ryantimpe/ceab2ed6b8a4737077280fc9b0d1c886)
with `bricks_from_table()` by manually placing each brick.
- Generate a punny [**random forest
model**](https://gist.github.com/ryantimpe/a7363a5e99dceabada150a43925beec7)
using `bricks_from_coords()` and {purrr}.
- [**Baby
Yoda**](https://gist.github.com/ryantimpe/3893fdd0f94138d027bae35bf38b57c7)
example using `bricks_from_excel()` with an animation.
- [**brickr toybox**](https://github.com/ryantimpe/brickr_toybox) repo
for tools and resources to get started.
@@ -294,3 +275,15 @@ mosaic1 %>% build_pieces()
```
![](README_files/figure-gfm/m1_pieces-1.png)<!-- -->
## Acknowledgments
3D models in brickr would not exist without [Tyler
Morgan-Wall](https://twitter.com/tylermorganwall) and his
[rayshader](https://www.rayshader.com/) package. If youre interested in
creating 3D models of literally *anything* R, check out his
[rayrender](https://www.rayrender.net/) package.
All functions in brickr are created with the
[tidyverse](https://www.tidyverse.org/) and
[rgl](https://cran.r-project.org/web/packages/rgl/index.html).

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.6 KiB

After

Width:  |  Height:  |  Size: 9.8 KiB

View File

@@ -1,192 +0,0 @@
#' Build 3D brick model with rgl
#'
#' @param brick_list List output from collect_bricks(). Contains an element \code{Img_lego}.
#' @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 background_color Default 'white'. Color of the background.
#' @param rgl_lit Default 'TRUE'. Include RGL lighting features in rendering.
#' @param outline_bricks Default 'FALSE'. Include black outlines around brick edges.
#' Set to 'TRUE' and rgl_lit='FALSE' for cartoon-looking bricks.
#' @param trans_alpha Default 0.5. Alpha level for transparent bricks.
#' @param view_levels Numeric array of Levels/z values to display. Leave as 'NULL' to include all.
#' @examples \dontrun{
#' #This is a brick
#'brick <- data.frame(
#' Level="A",
#' X1 = rep(3,4), #The number 3 is the brickrID for 'bright red'
#' X2 = rep(3,4)
#')
#'
#'brick %>%
#' bricks_from_table() %>%
#' build_bricks()
#' }
#' @return 3D brick model rendered in the 'rgl' package.
#' @family 3D Models
#' @export
#'
build_double_mosaic <- function(brick_list, brick_list2,
background_color = "white", rgl_lit = TRUE,
outline_bricks = FALSE,
trans_alpha = 0.5,
view_levels = NULL){
#Mosaic 1 ----
in_list <- brick_list
img_bricks <- in_list$Img_bricks%>%
tidyr::drop_na()%>%
dplyr::left_join(lego_colors %>%
dplyr::select(Lego_name = Color, Trans_lego, lum),
by = c("Lego_name"))
if(is.null(view_levels)){
view_levels <- unique(img_bricks$Level)
}
#Mosaic 2 ----
in_list2 <- brick_list2
img_bricks2 <- in_list2$Img_bricks%>%
tidyr::drop_na()%>%
dplyr::left_join(lego_colors %>%
dplyr::select(Lego_name = Color, Trans_lego, lum),
by = c("Lego_name"))
if(is.null(view_levels)){
view_levels2 <- unique(img_bricks2$Level)
}
#SET PARAMETERS ----
# For use inside brick drawing functions below
nudge = 0.01 #Space between bricks
scale = 1 #Reduce to unit size
# trans_alpha = 0.5 #Alpha of transparent bricks
# height_scale = 9.6/7.8 * (2/3)
height_scale = 1
color_outline = "black"
color_outline_trans = "white"
contrast_knobs = TRUE
contrast_lum = 0.2
knob_diameter = 5/8
outline_bricks = outline_bricks
suppress_knobs = TRUE
#For now, use the current collect_bricks output.
#This was designed for rayshader, and I don't want to drop rayshader just yet.
# MOSAIC 1 ----
max_x = max(img_bricks$xmax) - 0.5
rgl_bricks_base <- list(
# x & y are the CENTERS of bricks. rgl scales shapes from center
x = (img_bricks$xmin + 0.5 + (img_bricks$xmax - img_bricks$xmin)/2) * 2,
z = img_bricks$ymin + 0.5 + (img_bricks$ymax - img_bricks$ymin)/2 ,
y = img_bricks$Level,
color = img_bricks$Lego_color,
trans = img_bricks$Trans_lego,
lum = img_bricks$lum,
#Grab brick size from brick type id
width = as.numeric(substr(img_bricks$brick_type, 2, 2)),
length = as.numeric(substr(img_bricks$brick_type, 4, 4))
) %>%
purrr::transpose()
rgl_bricks_base_list <- rgl_bricks_base %>%
purrr::map(function(this_brick){
#Solid brick ----
brk_fill <- rgl::cube3d(col = this_brick$color,
alpha = if(this_brick$trans){trans_alpha}else{1})
# brk_fill$vb[, c(5, 7)] <- brk_fill$vb[, c(1, 3)] * 2/3
brk_fill$vb[, c(1, 5)] <- brk_fill$vb[, c(3, 7)] * 2/3
brk_fill$vb[4,] <- brk_fill$vb[4,]/scale*2 + nudge
brk_fill2 <- brk_fill %>%
rgl::scale3d(this_brick$width, this_brick$length, height_scale) %>% #Increase height
rgl::translate3d(this_brick$x, this_brick$y, this_brick$z * height_scale)
if(outline_bricks){
} else {
brk_out2 <- NULL
out_list <- list(brk_fill2, brk_out2)
}
#Save ----
return(out_list)
}) %>%
purrr::transpose()
# MOSAIC 2 ----
max_x = max(img_bricks2$xmax) - 0.5
rgl_bricks_base2 <- list(
# x & y are the CENTERS of bricks. rgl scales shapes from center
x = (img_bricks2$xmin + 0.5 + (img_bricks2$xmax - img_bricks2$xmin)/2) * 2 -7,
z = img_bricks2$ymin + 0.5 + (img_bricks$ymax - img_bricks2$ymin)/2 ,
y = img_bricks2$Level,
color = img_bricks2$Lego_color,
trans = img_bricks2$Trans_lego,
lum = img_bricks2$lum,
#Grab brick size from brick type id
width = as.numeric(substr(img_bricks2$brick_type, 2, 2)),
length = as.numeric(substr(img_bricks2$brick_type, 4, 4))
) %>%
purrr::transpose()
rgl_bricks_base_list2 <- rgl_bricks_base2 %>%
purrr::map(function(this_brick){
#Solid brick ----
brk_fill <- rgl::cube3d(col = this_brick$color,
alpha = if(this_brick$trans){trans_alpha}else{1})
# brk_fill$vb[, c(6, 8)] <- brk_fill$vb[, c(2, 4)] * 2/3
brk_fill$vb[, c(2, 6)] <- brk_fill$vb[, c(4, 8)] * 2/3
brk_fill$vb[4,] <- brk_fill$vb[4,]/scale*2 + nudge
brk_fill2 <- brk_fill %>%
rgl::scale3d(this_brick$width, this_brick$length, height_scale) %>% #Increase height
rgl::translate3d(this_brick$x, this_brick$y, this_brick$z * height_scale)
if(outline_bricks){
} else {
brk_out2 <- NULL
out_list <- list(brk_fill2, brk_out2)
}
#Save ----
return(out_list)
}) %>%
purrr::transpose()
#Draw
shapelist <- c(rgl_bricks_base_list[[1]]
, rgl_bricks_base_list[[2]]
, rgl_bricks_base_list2[[1]]
, rgl_bricks_base_list2[[2]]
)
shapelist[sapply(shapelist, is.null)] <- NULL
shapelist %>%
rgl::shapelist3d(lit=rgl_lit, shininess = 100, specular = "black")
rgl::bg3d(color = background_color)
rgl::rgl.viewpoint(userMatrix = rgl::rotate3d(rgl::par3d("userMatrix"), 0, 0, 0 ,1) ,
fov=0) #All bricks, regardless of Z, are perceived as same size
}

View File

@@ -11,14 +11,6 @@ reference:
contents:
- starts_with("bricks_")
- build_bricks
- build_bricks_rayshader
- title: ggplot Extension
desc: Brick bar charts in ggplot
contents:
- starts_with("coord_")
- starts_with("geom_")
- starts_with("scale_")
- starts_with("theme_")
- title: Bricks IRL
desc: Helper functions to create bricks and build them IRL.
contents:
@@ -35,10 +27,8 @@ articles:
- title: 3D Models
desc: Creating 3D LEGO models.
contents:
- models-from-other
- models-from-program
- models-from-tables
- title: Charts
desc: ggplot2 brickr extension
contents:
- graphs
- models-from-program
- models-from-other
- models-piece-type

View File

@@ -78,7 +78,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="http://brickr.org/index.html">brickr</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.2.0</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.3.0</span>
</span>
</div>
@@ -101,10 +101,7 @@
</a>
<ul class="dropdown-menu" role="menu">
<li>
<a href="articles/graphs.html">ggplot with brickr</a>
</li>
<li>
<a href="articles/models-from-other.html">3D Models from mosaics &amp; rayshader</a>
<a href="articles/models-from-other.html">3D Models from mosaics</a>
</li>
<li>
<a href="articles/models-from-program.html">3D Models programmatically</a>
@@ -112,6 +109,9 @@
<li>
<a href="articles/models-from-tables.html">3D models from tables</a>
</li>
<li>
<a href="articles/models-piece-type.html">Piece type in 3D Models</a>
</li>
<li>
<a href="articles/mosaics.html">Mosaics with brickr</a>
</li>

View File

@@ -78,7 +78,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="index.html">brickr</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.2.0.9003</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.3.0</span>
</span>
</div>
@@ -101,10 +101,7 @@
</a>
<ul class="dropdown-menu" role="menu">
<li>
<a href="articles/graphs.html">ggplot with brickr</a>
</li>
<li>
<a href="articles/models-from-other.html">3D Models from mosaics &amp; rayshader</a>
<a href="articles/models-from-other.html">3D Models from mosaics</a>
</li>
<li>
<a href="articles/models-from-program.html">3D Models programmatically</a>
@@ -112,6 +109,9 @@
<li>
<a href="articles/models-from-tables.html">3D models from tables</a>
</li>
<li>
<a href="articles/models-piece-type.html">Piece type in 3D Models</a>
</li>
<li>
<a href="articles/mosaics.html">Mosaics with brickr</a>
</li>
@@ -144,7 +144,7 @@
<h1>License</h1>
</div>
<pre>YEAR: 2019
<pre>YEAR: 2020
COPYRIGHT HOLDER: Ryan Timpe
</pre>

View File

@@ -6,7 +6,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>GNU General Public License • brickr</title>
<title>MIT License • brickr</title>
<!-- favicons -->
<link rel="icon" type="image/png" sizes="16x16" href="favicon-16x16.png">
@@ -44,7 +44,7 @@
<link href="extra.css" rel="stylesheet">
<meta property="og:title" content="GNU General Public License" />
<meta property="og:title" content="MIT License" />
<meta property="og:image" content="http://brickr.org/logo.png" />
<meta name="twitter:card" content="summary" />
@@ -78,7 +78,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="index.html">brickr</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.2.0.9003</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.3.0</span>
</span>
</div>
@@ -101,10 +101,7 @@
</a>
<ul class="dropdown-menu" role="menu">
<li>
<a href="articles/graphs.html">ggplot with brickr</a>
</li>
<li>
<a href="articles/models-from-other.html">3D Models from mosaics &amp; rayshader</a>
<a href="articles/models-from-other.html">3D Models from mosaics</a>
</li>
<li>
<a href="articles/models-from-program.html">3D Models programmatically</a>
@@ -112,6 +109,9 @@
<li>
<a href="articles/models-from-tables.html">3D models from tables</a>
</li>
<li>
<a href="articles/models-piece-type.html">Piece type in 3D Models</a>
</li>
<li>
<a href="articles/mosaics.html">Mosaics with brickr</a>
</li>
@@ -141,231 +141,15 @@
<div class="row">
<div class="contents col-md-9">
<div class="page-header">
<h1>GNU General Public License</h1>
<h1>MIT License</h1>
</div>
<div id="gnu-general-public-license" class="section level1">
<div id="mit-license" class="section level1">
<p><em>Version 3, 29 June 2007</em><br><em>Copyright © 2007 Free Software Foundation, Inc. &lt;<a href="http://fsf.org/" class="uri">http://fsf.org/</a>&gt;</em></p>
<p>Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.</p>
<div id="preamble" class="section level2">
<h2 class="hasAnchor">
<a href="#preamble" class="anchor"></a>Preamble</h2>
<p>The GNU General Public License is a free, copyleft license for software and other kinds of works.</p>
<p>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 programto 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.</p>
<p>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.</p>
<p>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.</p>
<p>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.</p>
<p>Developers that use the GNU GPL protect your rights with two steps: <strong>(1)</strong> assert copyright on the software, and <strong>(2)</strong> offer you this License giving you legal permission to copy, distribute and/or modify it.</p>
<p>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.</p>
<p>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.</p>
<p>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.</p>
<p>The precise terms and conditions for copying, distribution and modification follow.</p>
</div>
<div id="terms-and-conditions" class="section level2">
<h2 class="hasAnchor">
<a href="#terms-and-conditions" class="anchor"></a>TERMS AND CONDITIONS</h2>
<div id="0-definitions" class="section level3">
<h3 class="hasAnchor">
<a href="#0-definitions" class="anchor"></a>0. Definitions</h3>
<p>“This License” refers to version 3 of the GNU General Public License.</p>
<p>“Copyright” also means copyright-like laws that apply to other kinds of works, such as semiconductor masks.</p>
<p>“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.</p>
<p>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.</p>
<p>A “covered work” means either the unmodified Program or a work based on the Program.</p>
<p>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.</p>
<p>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.</p>
<p>An interactive user interface displays “Appropriate Legal Notices” to the extent that it includes a convenient and prominently visible feature that <strong>(1)</strong> displays an appropriate copyright notice, and <strong>(2)</strong> 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.</p>
</div>
<div id="1-source-code" class="section level3">
<h3 class="hasAnchor">
<a href="#1-source-code" class="anchor"></a>1. Source Code</h3>
<p>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.</p>
<p>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.</p>
<p>The “System Libraries” of an executable work include anything, other than the work as a whole, that <strong>(a)</strong> is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and <strong>(b)</strong> 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.</p>
<p>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 works 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.</p>
<p>The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source.</p>
<p>The Corresponding Source for a work in source code form is that same work.</p>
</div>
<div id="2-basic-permissions" class="section level3">
<h3 class="hasAnchor">
<a href="#2-basic-permissions" class="anchor"></a>2. Basic Permissions</h3>
<p>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.</p>
<p>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.</p>
<p>Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary.</p>
</div>
<div id="3-protecting-users-legal-rights-from-anti-circumvention-law" class="section level3">
<h3 class="hasAnchor">
<a href="#3-protecting-users-legal-rights-from-anti-circumvention-law" class="anchor"></a>3. Protecting Users Legal Rights From Anti-Circumvention Law</h3>
<p>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.</p>
<p>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 works users, your or third parties legal rights to forbid circumvention of technological measures.</p>
</div>
<div id="4-conveying-verbatim-copies" class="section level3">
<h3 class="hasAnchor">
<a href="#4-conveying-verbatim-copies" class="anchor"></a>4. Conveying Verbatim Copies</h3>
<p>You may convey verbatim copies of the Programs 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.</p>
<p>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.</p>
</div>
<div id="5-conveying-modified-source-versions" class="section level3">
<h3 class="hasAnchor">
<a href="#5-conveying-modified-source-versions" class="anchor"></a>5. Conveying Modified Source Versions</h3>
<p>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:</p>
<ul>
<li>
<strong>a)</strong> The work must carry prominent notices stating that you modified it, and giving a relevant date.</li>
<li>
<strong>b)</strong> The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to “keep intact all notices”.</li>
<li>
<strong>c)</strong> You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it.</li>
<li>
<strong>d)</strong> If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so.</li>
</ul>
<p>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 compilations 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.</p>
</div>
<div id="6-conveying-non-source-forms" class="section level3">
<h3 class="hasAnchor">
<a href="#6-conveying-non-source-forms" class="anchor"></a>6. Conveying Non-Source Forms</h3>
<p>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:</p>
<ul>
<li>
<strong>a)</strong> Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange.</li>
<li>
<strong>b)</strong> Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either <strong>(1)</strong> a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or <strong>(2)</strong> access to copy the Corresponding Source from a network server at no charge.</li>
<li>
<strong>c)</strong> Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b.</li>
<li>
<strong>d)</strong> Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements.</li>
<li>
<strong>e)</strong> Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d.</li>
</ul>
<p>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.</p>
<p>A “User Product” is either <strong>(1)</strong> a “consumer product”, which means any tangible personal property which is normally used for personal, family, or household purposes, or <strong>(2)</strong> 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.</p>
<p>“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.</p>
<p>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).</p>
<p>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.</p>
<p>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.</p>
</div>
<div id="7-additional-terms" class="section level3">
<h3 class="hasAnchor">
<a href="#7-additional-terms" class="anchor"></a>7. Additional Terms</h3>
<p>“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.</p>
<p>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.</p>
<p>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:</p>
<ul>
<li>
<strong>a)</strong> Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or</li>
<li>
<strong>b)</strong> Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or</li>
<li>
<strong>c)</strong> Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or</li>
<li>
<strong>d)</strong> Limiting the use for publicity purposes of names of licensors or authors of the material; or</li>
<li>
<strong>e)</strong> Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or</li>
<li>
<strong>f)</strong> Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors.</li>
</ul>
<p>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.</p>
<p>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.</p>
<p>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.</p>
</div>
<div id="8-termination" class="section level3">
<h3 class="hasAnchor">
<a href="#8-termination" class="anchor"></a>8. Termination</h3>
<p>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).</p>
<p>However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated <strong>(a)</strong> provisionally, unless and until the copyright holder explicitly and finally terminates your license, and <strong>(b)</strong> permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation.</p>
<p>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.</p>
<p>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.</p>
</div>
<div id="9-acceptance-not-required-for-having-copies" class="section level3">
<h3 class="hasAnchor">
<a href="#9-acceptance-not-required-for-having-copies" class="anchor"></a>9. Acceptance Not Required for Having Copies</h3>
<p>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.</p>
</div>
<div id="10-automatic-licensing-of-downstream-recipients" class="section level3">
<h3 class="hasAnchor">
<a href="#10-automatic-licensing-of-downstream-recipients" class="anchor"></a>10. Automatic Licensing of Downstream Recipients</h3>
<p>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.</p>
<p>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 partys 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.</p>
<p>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.</p>
</div>
<div id="11-patents" class="section level3">
<h3 class="hasAnchor">
<a href="#11-patents" class="anchor"></a>11. Patents</h3>
<p>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 contributors “contributor version”.</p>
<p>A contributors “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.</p>
<p>Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributors essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version.</p>
<p>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.</p>
<p>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 <strong>(1)</strong> cause the Corresponding Source to be so available, or <strong>(2)</strong> arrange to deprive yourself of the benefit of the patent license for this particular work, or <strong>(3)</strong> 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 recipients 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.</p>
<p>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.</p>
<p>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 <strong>(a)</strong> in connection with copies of the covered work conveyed by you (or copies made from those copies), or <strong>(b)</strong> 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.</p>
<p>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.</p>
</div>
<div id="12-no-surrender-of-others-freedom" class="section level3">
<h3 class="hasAnchor">
<a href="#12-no-surrender-of-others-freedom" class="anchor"></a>12. No Surrender of Others Freedom</h3>
<p>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.</p>
</div>
<div id="13-use-with-the-gnu-affero-general-public-license" class="section level3">
<h3 class="hasAnchor">
<a href="#13-use-with-the-gnu-affero-general-public-license" class="anchor"></a>13. Use with the GNU Affero General Public License</h3>
<p>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.</p>
</div>
<div id="14-revised-versions-of-this-license" class="section level3">
<h3 class="hasAnchor">
<a href="#14-revised-versions-of-this-license" class="anchor"></a>14. Revised Versions of this License</h3>
<p>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.</p>
<p>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.</p>
<p>If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxys public statement of acceptance of a version permanently authorizes you to choose that version for the Program.</p>
<p>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.</p>
</div>
<div id="15-disclaimer-of-warranty" class="section level3">
<h3 class="hasAnchor">
<a href="#15-disclaimer-of-warranty" class="anchor"></a>15. Disclaimer of Warranty</h3>
<p>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.</p>
</div>
<div id="16-limitation-of-liability" class="section level3">
<h3 class="hasAnchor">
<a href="#16-limitation-of-liability" class="anchor"></a>16. Limitation of Liability</h3>
<p>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.</p>
</div>
<div id="17-interpretation-of-sections-15-and-16" class="section level3">
<h3 class="hasAnchor">
<a href="#17-interpretation-of-sections-15-and-16" class="anchor"></a>17. Interpretation of Sections 15 and 16</h3>
<p>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.</p>
<p><em>END OF TERMS AND CONDITIONS</em></p>
</div>
</div>
<div id="how-to-apply-these-terms-to-your-new-programs" class="section level2">
<h2 class="hasAnchor">
<a href="#how-to-apply-these-terms-to-your-new-programs" class="anchor"></a>How to Apply These Terms to Your New Programs</h2>
<p>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.</p>
<p>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.</p>
<div class="sourceCode" id="cb1"><pre class="sourceCode R"><code class="sourceCode r"><a class="sourceLine" id="cb1-1" title="1"><span class="op">&lt;</span>one line to give the program<span class="st">'s name and a brief idea of what it does.&gt;</span></a>
<a class="sourceLine" id="cb1-2" title="2"><span class="st">Copyright (C) 2019 Ryan Timpe</span></a>
<a class="sourceLine" id="cb1-3" title="3"></a>
<a class="sourceLine" id="cb1-4" title="4"><span class="st">This program is free software: you can redistribute it and/or modify</span></a>
<a class="sourceLine" id="cb1-5" title="5"><span class="st">it under the terms of the GNU General Public License as published by</span></a>
<a class="sourceLine" id="cb1-6" title="6"><span class="st">the Free Software Foundation, either version 3 of the License, or</span></a>
<a class="sourceLine" id="cb1-7" title="7"><span class="st">(at your option) any later version.</span></a>
<a class="sourceLine" id="cb1-8" title="8"></a>
<a class="sourceLine" id="cb1-9" title="9"><span class="st">This program is distributed in the hope that it will be useful,</span></a>
<a class="sourceLine" id="cb1-10" title="10"><span class="st">but WITHOUT ANY WARRANTY; without even the implied warranty of</span></a>
<a class="sourceLine" id="cb1-11" title="11"><span class="st">MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span></a>
<a class="sourceLine" id="cb1-12" title="12"><span class="st">GNU General Public License for more details.</span></a>
<a class="sourceLine" id="cb1-13" title="13"></a>
<a class="sourceLine" id="cb1-14" title="14"><span class="st">You should have received a copy of the GNU General Public License</span></a>
<a class="sourceLine" id="cb1-15" title="15"><span class="st">along with this program. If not, see &lt;http://www.gnu.org/licenses/&gt;.</span></a></code></pre></div>
<p>Also add information on how to contact you by electronic and paper mail.</p>
<p>If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode:</p>
<div class="sourceCode" id="cb2"><pre class="sourceCode R"><code class="sourceCode r"><a class="sourceLine" id="cb2-1" title="1">brickr <span class="kw">Copyright</span> (C) <span class="dv">2019</span> Ryan Timpe</a>
<a class="sourceLine" id="cb2-2" title="2">This program comes with ABSOLUTELY NO WARRANTY; <span class="cf">for</span> details type <span class="st">'show w'</span>.</a>
<a class="sourceLine" id="cb2-3" title="3">This is free software, and you are welcome to redistribute it</a>
<a class="sourceLine" id="cb2-4" title="4">under certain conditions; type <span class="st">'show c'</span> <span class="cf">for</span> details.</a></code></pre></div>
<p>The hypothetical commands <code>show w</code> and <code>show c</code> should show the appropriate parts of the General Public License. Of course, your programs commands might be different; for a GUI interface, you would use an “about box”.</p>
<p>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 &lt;<a href="http://www.gnu.org/licenses/" class="uri">http://www.gnu.org/licenses/</a>&gt;.</p>
<p>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 &lt;<a href="http://www.gnu.org/philosophy/why-not-lgpl.html" class="uri">http://www.gnu.org/philosophy/why-not-lgpl.html</a>&gt;.</p>
</div>
<p>Copyright (c) 2020 Ryan Timpe</p>
<p>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:</p>
<p>The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.</p>
<p>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.</p>
</div>
</div>

View File

@@ -78,7 +78,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">brickr</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.2.0</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.3.0</span>
</span>
</div>
@@ -101,10 +101,7 @@
</a>
<ul class="dropdown-menu" role="menu">
<li>
<a href="../articles/graphs.html">ggplot with brickr</a>
</li>
<li>
<a href="../articles/models-from-other.html">3D Models from mosaics &amp; rayshader</a>
<a href="../articles/models-from-other.html">3D Models from mosaics</a>
</li>
<li>
<a href="../articles/models-from-program.html">3D Models programmatically</a>
@@ -112,6 +109,9 @@
<li>
<a href="../articles/models-from-tables.html">3D models from tables</a>
</li>
<li>
<a href="../articles/models-piece-type.html">Piece type in 3D Models</a>
</li>
<li>
<a href="../articles/mosaics.html">Mosaics with brickr</a>
</li>
@@ -157,17 +157,10 @@
<p class="section-desc"><p>Creating 3D LEGO models.</p></p>
<ul>
<li><a href="models-from-other.html">3D Models from mosaics &amp; rayshader</a></li>
<li><a href="models-from-program.html">3D Models programmatically</a></li>
<li><a href="models-from-tables.html">3D models from tables</a></li>
</ul>
</div>
<div class="section ">
<h3>Charts</h3>
<p class="section-desc"><p>ggplot2 brickr extension</p></p>
<ul>
<li><a href="graphs.html">ggplot with brickr</a></li>
<li><a href="models-from-program.html">3D Models programmatically</a></li>
<li><a href="models-from-other.html">3D Models from mosaics</a></li>
<li><a href="models-piece-type.html">Piece type in 3D Models</a></li>
</ul>
</div>
</div>

View File

@@ -5,7 +5,7 @@
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>3D Models from mosaics &amp; rayshader • brickr</title>
<title>3D Models from mosaics • brickr</title>
<!-- favicons --><link rel="icon" type="image/png" sizes="16x16" href="../favicon-16x16.png">
<link rel="icon" type="image/png" sizes="32x32" href="../favicon-32x32.png">
<link rel="apple-touch-icon" type="image/png" sizes="180x180" href="../apple-touch-icon.png">
@@ -17,7 +17,7 @@
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.7.1/css/v4-shims.min.css" integrity="sha256-6qHlizsOWFskGlwVOKuns+D1nB6ssZrHQrNj1wGplHc=" crossorigin="anonymous">
<!-- clipboard.js --><script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.4/clipboard.min.js" integrity="sha256-FiZwavyI2V6+EXO1U+xzLG3IKldpiTFf3153ea9zikQ=" crossorigin="anonymous"></script><!-- headroom.js --><script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.9.4/headroom.min.js" integrity="sha256-DJFC1kqIhelURkuza0AvYal5RxMtpzLjFhsnVIeuk+U=" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.9.4/jQuery.headroom.min.js" integrity="sha256-ZX/yNShbjqsohH1k95liqY9Gd8uOiE1S4vZc+9KQ1K4=" crossorigin="anonymous"></script><!-- pkgdown --><link href="../pkgdown.css" rel="stylesheet">
<script src="../pkgdown.js"></script><link href="../extra.css" rel="stylesheet">
<meta property="og:title" content="3D Models from mosaics &amp; rayshader">
<meta property="og:title" content="3D Models from mosaics">
<meta property="og:description" content="">
<meta property="og:image" content="http://brickr.org/logo.png">
<meta name="twitter:card" content="summary">
@@ -39,7 +39,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">brickr</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.2.0</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.3.0</span>
</span>
</div>
@@ -62,10 +62,7 @@
</a>
<ul class="dropdown-menu" role="menu">
<li>
<a href="../articles/graphs.html">ggplot with brickr</a>
</li>
<li>
<a href="../articles/models-from-other.html">3D Models from mosaics &amp; rayshader</a>
<a href="../articles/models-from-other.html">3D Models from mosaics</a>
</li>
<li>
<a href="../articles/models-from-program.html">3D Models programmatically</a>
@@ -73,6 +70,9 @@
<li>
<a href="../articles/models-from-tables.html">3D models from tables</a>
</li>
<li>
<a href="../articles/models-piece-type.html">Piece type in 3D Models</a>
</li>
<li>
<a href="../articles/mosaics.html">Mosaics with brickr</a>
</li>
@@ -102,7 +102,7 @@
</header><div class="row">
<div class="col-md-9 contents">
<div class="page-header toc-ignore">
<h1>3D Models from mosaics &amp; rayshader</h1>
<h1>3D Models from mosaics</h1>
<small class="dont-index">Source: <a href="https://github.com/ryantimpe/brickr/blob/master/vignettes/models-from-other.Rmd"><code>vignettes/models-from-other.Rmd</code></a></small>
@@ -145,56 +145,6 @@
<a class="sourceLine" id="cb2-8" title="8"></a>
<a class="sourceLine" id="cb2-9" title="9">rgl<span class="op">::</span><span class="kw"><a href="https://rdrr.io/pkg/rgl/man/par3d.html">par3d</a></span>(<span class="dt">userMatrix =</span> rgl<span class="op">::</span><span class="kw"><a href="https://rdrr.io/pkg/rgl/man/matrices.html">rotate3d</a></span>(custom_rotation, <span class="dv">0</span>, <span class="dv">0</span>, pi<span class="op">/</span><span class="dv">4</span> ,<span class="dv">1</span>))</a></code></pre></div>
<p><img src="models-from-other_files/figure-html/bricks_6a-1.png" width="384"></p>
</div>
<div id="models-from-rayshader" class="section level2">
<h2 class="hasAnchor">
<a href="#models-from-rayshader" class="anchor"></a>Models from rayshader</h2>
<p><a href="https://www.rayshader.com/">rayshader</a> by <a href="https://twitter.com/tylermorganwall">Tyler Morgan-Wall</a> is an open source package for producing 2D and 3D data visualizations in R. rayshader uses elevation data in a base R matrix and a combination of raytracing, spherical texture mapping, overlays, and ambient occlusion to generate beautiful topographic 2D and 3D maps. (Note: text lifted straight from <a href="https://www.rayshader.com/">rayshader.com</a>.)</p>
<p>3D models in <strong>brickr</strong> are rendered using the functions in <strong>rayshader</strong>. Using <code><a href="../reference/bricks_from_rayshader.html">bricks_from_rayshader()</a></code>, you can convert rayshader map output into a brickr model. This function takes three inputs:</p>
<ul>
<li>
<code>hillshade</code> is topographic image matrix with an RGB channel (much like the mosaics).</li>
<li>
<code>heightmap</code> is a two-dimensional matrix specifiying the height of the image at each location.</li>
<li>
<code>max_height</code> is the number of bricks stacked at the mosaics highest point. The default is 12.</li>
<li>
<code>img_size</code> is the number of bricks on each side of the model. The default is 48.</li>
</ul>
<div class="sourceCode" id="cb3"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb3-1" title="1"><span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span>(rayshader)</a>
<a class="sourceLine" id="cb3-2" title="2"></a>
<a class="sourceLine" id="cb3-3" title="3"><span class="co">#Example from rayshader.com</span></a>
<a class="sourceLine" id="cb3-4" title="4"></a>
<a class="sourceLine" id="cb3-5" title="5"><span class="co">#Here, I load a map with the raster package.</span></a>
<a class="sourceLine" id="cb3-6" title="6">loadzip =<span class="st"> </span><span class="kw"><a href="https://rdrr.io/r/base/tempfile.html">tempfile</a></span>() </a>
<a class="sourceLine" id="cb3-7" title="7"><span class="kw"><a href="https://rdrr.io/r/utils/download.file.html">download.file</a></span>(<span class="st">"https://tylermw.com/data/dem_01.tif.zip"</span>, loadzip)</a>
<a class="sourceLine" id="cb3-8" title="8">localtif =<span class="st"> </span>raster<span class="op">::</span><span class="kw"><a href="https://rdrr.io/pkg/raster/man/raster.html">raster</a></span>(<span class="kw"><a href="https://rdrr.io/r/utils/unzip.html">unzip</a></span>(loadzip, <span class="st">"dem_01.tif"</span>))</a>
<a class="sourceLine" id="cb3-9" title="9"><span class="kw"><a href="https://rdrr.io/r/base/unlink.html">unlink</a></span>(loadzip)</a>
<a class="sourceLine" id="cb3-10" title="10"></a>
<a class="sourceLine" id="cb3-11" title="11"><span class="co">#And convert it to a matrix:</span></a>
<a class="sourceLine" id="cb3-12" title="12">elmat =<span class="st"> </span><span class="kw"><a href="https://rdrr.io/r/base/matrix.html">matrix</a></span>(raster<span class="op">::</span><span class="kw"><a href="https://rdrr.io/pkg/raster/man/extract.html">extract</a></span>(localtif, raster<span class="op">::</span><span class="kw"><a href="https://rdrr.io/pkg/raster/man/extent.html">extent</a></span>(localtif), <span class="dt">buffer =</span> <span class="dv">1000</span>),</a>
<a class="sourceLine" id="cb3-13" title="13"> <span class="dt">nrow =</span> <span class="kw"><a href="https://rdrr.io/r/base/nrow.html">ncol</a></span>(localtif), <span class="dt">ncol =</span> <span class="kw"><a href="https://rdrr.io/r/base/nrow.html">nrow</a></span>(localtif))</a>
<a class="sourceLine" id="cb3-14" title="14"></a>
<a class="sourceLine" id="cb3-15" title="15">rayshader_object &lt;-<span class="st"> </span>elmat <span class="op">%&gt;%</span></a>
<a class="sourceLine" id="cb3-16" title="16"><span class="st"> </span><span class="kw">sphere_shade</span>(<span class="dt">texture =</span> <span class="st">"desert"</span>) <span class="op">%&gt;%</span></a>
<a class="sourceLine" id="cb3-17" title="17"><span class="st"> </span><span class="kw">add_water</span>(<span class="kw">detect_water</span>(elmat), <span class="dt">color =</span> <span class="st">"desert"</span>) <span class="op">%&gt;%</span></a>
<a class="sourceLine" id="cb3-18" title="18"><span class="st"> </span><span class="kw">add_shadow</span>(<span class="kw">ray_shade</span>(elmat, <span class="dt">zscale =</span> <span class="dv">3</span>, <span class="dt">maxsearch =</span> <span class="dv">300</span>), <span class="fl">0.5</span>) </a>
<a class="sourceLine" id="cb3-19" title="19"></a>
<a class="sourceLine" id="cb3-20" title="20"><span class="co">#Plot with rayshader</span></a>
<a class="sourceLine" id="cb3-21" title="21">rayshader_object <span class="op">%&gt;%</span></a>
<a class="sourceLine" id="cb3-22" title="22"><span class="st"> </span><span class="kw">plot_3d</span>(elmat, <span class="dt">zscale =</span> <span class="dv">10</span>, <span class="dt">fov =</span> <span class="dv">0</span>, <span class="dt">theta =</span> <span class="dv">135</span>, <span class="dt">zoom =</span> <span class="fl">0.75</span>, <span class="dt">phi =</span> <span class="dv">45</span>, <span class="dt">windowsize =</span> <span class="kw"><a href="https://rdrr.io/r/base/c.html">c</a></span>(<span class="dv">1000</span>, <span class="dv">800</span>))</a>
<a class="sourceLine" id="cb3-23" title="23"></a>
<a class="sourceLine" id="cb3-24" title="24">rayshader<span class="op">::</span><span class="kw"><a href="https://rdrr.io/pkg/rayshader/man/render_snapshot.html">render_snapshot</a></span>(<span class="dt">clear =</span> <span class="ot">TRUE</span>)</a></code></pre></div>
<p><img src="models-from-other_files/figure-html/bricks_rayshader-1.png" width="384"></p>
<div class="sourceCode" id="cb4"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb4-1" title="1"></a>
<a class="sourceLine" id="cb4-2" title="2"><span class="co">#Plot as bricks</span></a>
<a class="sourceLine" id="cb4-3" title="3">rayshader_object <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb4-4" title="4"><span class="st"> </span><span class="kw"><a href="../reference/bricks_from_rayshader.html">bricks_from_rayshader</a></span>(elmat) <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb4-5" title="5"><span class="st"> </span><span class="kw"><a href="../reference/build_bricks_rayshader.html">build_bricks_rayshader</a></span>(<span class="dt">theta =</span> <span class="dv">135</span>, <span class="dt">phi =</span> <span class="dv">45</span>)</a>
<a class="sourceLine" id="cb4-6" title="6"></a>
<a class="sourceLine" id="cb4-7" title="7">rayshader<span class="op">::</span><span class="kw"><a href="https://rdrr.io/pkg/rayshader/man/render_snapshot.html">render_snapshot</a></span>(<span class="dt">clear =</span> <span class="ot">TRUE</span>)</a></code></pre></div>
<p><img src="models-from-other_files/figure-html/bricks_rayshader-2.png" width="384"></p>
<p>This example is rendered using <code><a href="../reference/build_bricks_rayshader.html">build_bricks_rayshader()</a></code>, which a bit faster for very large sets.</p>
</div>
</div>
@@ -206,7 +156,6 @@
<ul class="nav nav-pills nav-stacked">
<li><a href="#getting-started">Getting started</a></li>
<li><a href="#d-mosaics">3D mosaics</a></li>
<li><a href="#models-from-rayshader">Models from rayshader</a></li>
</ul>
</div>
</div>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 44 KiB

After

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 173 KiB

After

Width:  |  Height:  |  Size: 190 KiB

View File

@@ -39,7 +39,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">brickr</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.2.0</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.3.0</span>
</span>
</div>
@@ -62,10 +62,7 @@
</a>
<ul class="dropdown-menu" role="menu">
<li>
<a href="../articles/graphs.html">ggplot with brickr</a>
</li>
<li>
<a href="../articles/models-from-other.html">3D Models from mosaics &amp; rayshader</a>
<a href="../articles/models-from-other.html">3D Models from mosaics</a>
</li>
<li>
<a href="../articles/models-from-program.html">3D Models programmatically</a>
@@ -73,6 +70,9 @@
<li>
<a href="../articles/models-from-tables.html">3D models from tables</a>
</li>
<li>
<a href="../articles/models-piece-type.html">Piece type in 3D Models</a>
</li>
<li>
<a href="../articles/mosaics.html">Mosaics with brickr</a>
</li>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 50 KiB

After

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 29 KiB

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 62 KiB

After

Width:  |  Height:  |  Size: 65 KiB

View File

@@ -39,7 +39,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">brickr</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.2.0</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.3.0</span>
</span>
</div>
@@ -62,10 +62,7 @@
</a>
<ul class="dropdown-menu" role="menu">
<li>
<a href="../articles/graphs.html">ggplot with brickr</a>
</li>
<li>
<a href="../articles/models-from-other.html">3D Models from mosaics &amp; rayshader</a>
<a href="../articles/models-from-other.html">3D Models from mosaics</a>
</li>
<li>
<a href="../articles/models-from-program.html">3D Models programmatically</a>
@@ -73,6 +70,9 @@
<li>
<a href="../articles/models-from-tables.html">3D models from tables</a>
</li>
<li>
<a href="../articles/models-piece-type.html">Piece type in 3D Models</a>
</li>
<li>
<a href="../articles/mosaics.html">Mosaics with brickr</a>
</li>
@@ -204,26 +204,6 @@
<a class="sourceLine" id="cb3-43" title="43"></a>
<a class="sourceLine" id="cb3-44" title="44">rgl<span class="op">::</span><span class="kw"><a href="https://rdrr.io/pkg/rgl/man/par3d.html">par3d</a></span>(<span class="dt">userMatrix =</span> rgl<span class="op">::</span><span class="kw"><a href="https://rdrr.io/pkg/rgl/man/matrices.html">rotate3d</a></span>(rgl<span class="op">::</span><span class="kw"><a href="https://rdrr.io/pkg/rgl/man/par3d.html">par3d</a></span>(<span class="st">"userMatrix"</span>), <span class="fl">1.1</span><span class="op">*</span>pi<span class="op">/</span><span class="dv">4</span>, <span class="dv">0</span>, <span class="dv">0</span> ,<span class="dv">1</span>))</a></code></pre></div>
<p><img src="models-from-tables_files/figure-html/bricks_5-1.png" width="384"></p>
<div id="plates-instead-of-bricks" class="section level3">
<h3 class="hasAnchor">
<a href="#plates-instead-of-bricks" class="anchor"></a>Plates instead of bricks</h3>
<p><strong>Currently unavailable in <code><a href="../reference/build_bricks.html">build_bricks()</a></code>. Use <code><a href="../reference/build_bricks_rayshader.html">build_bricks_rayshader()</a></code></strong></p>
<p>Thats clearly a tree, right? Why is the data frame called tree_or_mushroom?</p>
<p>Use the input brick_type=“plate” to render the 3D model using LEGO plates rather than bricks, which are 1/3 as tall.</p>
<div class="sourceCode" id="cb4"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb4-1" title="1">brick_colors &lt;-<span class="st"> </span>tibble<span class="op">::</span><span class="kw"><a href="https://tibble.tidyverse.org/reference/tribble.html">tribble</a></span>(</a>
<a class="sourceLine" id="cb4-2" title="2"> <span class="op">~</span><span class="st">`</span><span class="dt">.value</span><span class="st">`</span>, <span class="op">~</span>Color,</a>
<a class="sourceLine" id="cb4-3" title="3"> <span class="dv">1</span>, <span class="st">"Dark green"</span>,</a>
<a class="sourceLine" id="cb4-4" title="4"> <span class="dv">2</span>, <span class="st">"Light nougat"</span>,</a>
<a class="sourceLine" id="cb4-5" title="5"> <span class="dv">3</span>, <span class="st">"Bright red"</span></a>
<a class="sourceLine" id="cb4-6" title="6">)</a>
<a class="sourceLine" id="cb4-7" title="7"> </a>
<a class="sourceLine" id="cb4-8" title="8">tree_or_mushroom <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb4-9" title="9"><span class="st"> </span><span class="kw"><a href="../reference/bricks_from_table.html">bricks_from_table</a></span>(brick_colors) <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb4-10" title="10"><span class="st"> </span><span class="kw"><a href="../reference/build_bricks_rayshader.html">build_bricks_rayshader</a></span>(<span class="dt">theta =</span> <span class="dv">210</span>, <span class="dt">phi =</span> <span class="dv">10</span>, <span class="dt">brick_res =</span> <span class="st">"hd"</span>, <span class="dt">brick_type=</span><span class="st">"plate"</span>)</a>
<a class="sourceLine" id="cb4-11" title="11"></a>
<a class="sourceLine" id="cb4-12" title="12">rayshader<span class="op">::</span><span class="kw"><a href="https://rdrr.io/pkg/rayshader/man/render_snapshot.html">render_snapshot</a></span>(<span class="dt">clear =</span> <span class="ot">TRUE</span>)</a></code></pre></div>
<p><img src="models-from-tables_files/figure-html/bricks_5a-1.png" width="384"></p>
</div>
</div>
<div id="bricks-from-excel" class="section level2">
<h2 class="hasAnchor">

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 27 KiB

View File

@@ -0,0 +1,423 @@
<!DOCTYPE html>
<!-- Generated by pkgdown: do not edit by hand --><html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Piece type in 3D Models • brickr</title>
<!-- favicons --><link rel="icon" type="image/png" sizes="16x16" href="../favicon-16x16.png">
<link rel="icon" type="image/png" sizes="32x32" href="../favicon-32x32.png">
<link rel="apple-touch-icon" type="image/png" sizes="180x180" href="../apple-touch-icon.png">
<link rel="apple-touch-icon" type="image/png" sizes="120x120" href="../apple-touch-icon-120x120.png">
<link rel="apple-touch-icon" type="image/png" sizes="76x76" href="../apple-touch-icon-76x76.png">
<link rel="apple-touch-icon" type="image/png" sizes="60x60" href="../apple-touch-icon-60x60.png">
<!-- jquery --><script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script><!-- Bootstrap --><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha256-916EbMg70RQy9LHiGkXzG8hSg9EdNy97GazNG/aiY1w=" crossorigin="anonymous">
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha256-U5ZEeKfGNOja007MMD3YBI0A3OSZOQbeG6z2f2Y0hu8=" crossorigin="anonymous"></script><!-- Font Awesome icons --><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.7.1/css/all.min.css" integrity="sha256-nAmazAk6vS34Xqo0BSrTb+abbtFlgsFK7NKSi6o7Y78=" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.7.1/css/v4-shims.min.css" integrity="sha256-6qHlizsOWFskGlwVOKuns+D1nB6ssZrHQrNj1wGplHc=" crossorigin="anonymous">
<!-- clipboard.js --><script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.4/clipboard.min.js" integrity="sha256-FiZwavyI2V6+EXO1U+xzLG3IKldpiTFf3153ea9zikQ=" crossorigin="anonymous"></script><!-- headroom.js --><script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.9.4/headroom.min.js" integrity="sha256-DJFC1kqIhelURkuza0AvYal5RxMtpzLjFhsnVIeuk+U=" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.9.4/jQuery.headroom.min.js" integrity="sha256-ZX/yNShbjqsohH1k95liqY9Gd8uOiE1S4vZc+9KQ1K4=" crossorigin="anonymous"></script><!-- pkgdown --><link href="../pkgdown.css" rel="stylesheet">
<script src="../pkgdown.js"></script><link href="../extra.css" rel="stylesheet">
<meta property="og:title" content="Piece type in 3D Models">
<meta property="og:description" content="">
<meta property="og:image" content="http://brickr.org/logo.png">
<meta name="twitter:card" content="summary">
<!-- mathjax --><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js" integrity="sha256-nvJJv9wWKEm88qvoQl9ekL2J+k/RWIsaSScxxlsrv8k=" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/config/TeX-AMS-MML_HTMLorMML.js" integrity="sha256-84DKXVJXs0/F8OTMzX4UR909+jtl4G7SPypPavF+GfA=" crossorigin="anonymous"></script><!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div class="container template-article">
<header><div class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">brickr</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.3.0</span>
</span>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li>
<a href="../index.html">
<span class="fas fa fas fa-home fa-lg"></span>
</a>
</li>
<li>
<a href="../reference/index.html">Reference</a>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
Articles
<span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
<li>
<a href="../articles/models-from-other.html">3D Models from mosaics</a>
</li>
<li>
<a href="../articles/models-from-program.html">3D Models programmatically</a>
</li>
<li>
<a href="../articles/models-from-tables.html">3D models from tables</a>
</li>
<li>
<a href="../articles/models-piece-type.html">Piece type in 3D Models</a>
</li>
<li>
<a href="../articles/mosaics.html">Mosaics with brickr</a>
</li>
</ul>
</li>
<li>
<a href="../news/index.html">Changelog</a>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li>
<a href="https://github.com/ryantimpe/brickr">
<span class="fab fa fab fa-github fa-lg"></span>
</a>
</li>
</ul>
</div>
<!--/.nav-collapse -->
</div>
<!--/.container -->
</div>
<!--/.navbar -->
</header><div class="row">
<div class="col-md-9 contents">
<div class="page-header toc-ignore">
<h1>Piece type in 3D Models</h1>
<small class="dont-index">Source: <a href="https://github.com/ryantimpe/brickr/blob/master/vignettes/models-piece-type.Rmd"><code>vignettes/models-piece-type.Rmd</code></a></small>
<div class="hidden name"><code>models-piece-type.Rmd</code></div>
</div>
<div id="getting-started" class="section level2">
<h2 class="hasAnchor">
<a href="#getting-started" class="anchor"></a>Getting started</h2>
<p>Models in brickr default to rendering rectangular LEGO bricks. Other LEGO shapes are possible in both <code><a href="../reference/bricks_from_coords.html">bricks_from_coords()</a></code> and <code><a href="../reference/bricks_from_table.html">bricks_from_table()</a></code> or <code><a href="../reference/bricks_from_excel.html">bricks_from_excel()</a></code>.</p>
<p>Piece shapes in models are driven the <code>piece_type</code> ID.</p>
</div>
<div id="all-piece-options" class="section level2">
<h2 class="hasAnchor">
<a href="#all-piece-options" class="anchor"></a>All piece options</h2>
<p>Currently there are 5 unique piece shapes in brickr. Some shapes can have different orientations, which is also determined by the <code>piece_type</code> column.</p>
<table class="table">
<thead><tr class="header">
<th align="left">Piece</th>
<th align="left">piece_type</th>
<th align="left">Area</th>
<th align="left">Height</th>
<th align="left">Orientation</th>
</tr></thead>
<tbody>
<tr class="odd">
<td align="left">Brick (classic)</td>
<td align="left">b</td>
<td align="left">any</td>
<td align="left">1</td>
<td align="left"></td>
</tr>
<tr class="even">
<td align="left">Plate (flat brick)</td>
<td align="left">p</td>
<td align="left">any</td>
<td align="left">1/3</td>
<td align="left"></td>
</tr>
<tr class="odd">
<td align="left">Round 1x1 (cylinder)</td>
<td align="left">c1</td>
<td align="left">1</td>
<td align="left">1</td>
<td align="left"></td>
</tr>
<tr class="even">
<td align="left">Round 1x1 (cone)</td>
<td align="left">c2</td>
<td align="left">1</td>
<td align="left">1</td>
<td align="left"></td>
</tr>
<tr class="odd">
<td align="left">Cheese slope</td>
<td align="left">w1</td>
<td align="left">1</td>
<td align="left">2/3</td>
<td align="left">north</td>
</tr>
<tr class="even">
<td align="left">Cheese slope</td>
<td align="left">w2</td>
<td align="left">1</td>
<td align="left">2/3</td>
<td align="left">east</td>
</tr>
<tr class="odd">
<td align="left">Cheese slope</td>
<td align="left">w3</td>
<td align="left">1</td>
<td align="left">2/3</td>
<td align="left">south</td>
</tr>
<tr class="even">
<td align="left">Cheese slope</td>
<td align="left">w4</td>
<td align="left">1</td>
<td align="left">2/3</td>
<td align="left">west</td>
</tr>
</tbody>
</table>
<div class="sourceCode" id="cb1"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb1-1" title="1"></a>
<a class="sourceLine" id="cb1-2" title="2"><span class="kw"><a href="https://rdrr.io/r/base/expand.grid.html">expand.grid</a></span>(</a>
<a class="sourceLine" id="cb1-3" title="3"> <span class="dt">x =</span> <span class="dv">1</span><span class="op">:</span><span class="dv">4</span> <span class="op">*</span><span class="st"> </span><span class="dv">2</span>,</a>
<a class="sourceLine" id="cb1-4" title="4"> <span class="dt">y =</span> <span class="dv">1</span><span class="op">:</span><span class="dv">2</span> <span class="op">*</span><span class="st"> </span><span class="dv">2</span>,</a>
<a class="sourceLine" id="cb1-5" title="5"> <span class="dt">z =</span> <span class="dv">1</span>) <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb1-6" title="6"><span class="st"> </span>dplyr<span class="op">::</span><span class="kw"><a href="https://dplyr.tidyverse.org/reference/mutate.html">mutate</a></span>(<span class="dt">Color =</span> <span class="kw"><a href="https://rdrr.io/r/utils/head.html">head</a></span>(lego_colors<span class="op">$</span>Color, <span class="dv">8</span>),</a>
<a class="sourceLine" id="cb1-7" title="7"> <span class="dt">piece_type =</span> <span class="kw"><a href="https://rdrr.io/r/base/c.html">c</a></span>(<span class="st">"b"</span>, <span class="st">"p"</span>, <span class="st">"c1"</span>, <span class="st">"c2"</span>, <span class="st">"w1"</span>, <span class="st">"w2"</span>, <span class="st">"w3"</span>, <span class="st">"w4"</span>)) <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb1-8" title="8"><span class="st"> </span><span class="kw"><a href="../reference/bricks_from_coords.html">bricks_from_coords</a></span>() <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb1-9" title="9"><span class="st"> </span><span class="kw"><a href="../reference/build_bricks.html">build_bricks</a></span>(<span class="dt">rgl_lit =</span> <span class="ot">FALSE</span>, <span class="dt">outline_bricks =</span> <span class="ot">TRUE</span>)</a>
<a class="sourceLine" id="cb1-10" title="10"></a>
<a class="sourceLine" id="cb1-11" title="11">rgl<span class="op">::</span><span class="kw"><a href="https://rdrr.io/pkg/rgl/man/par3d.html">par3d</a></span>(<span class="dt">userMatrix =</span> rgl<span class="op">::</span><span class="kw"><a href="https://rdrr.io/pkg/rgl/man/matrices.html">rotate3d</a></span>(rgl<span class="op">::</span><span class="kw"><a href="https://rdrr.io/pkg/rgl/man/par3d.html">par3d</a></span>(<span class="st">"userMatrix"</span>), <span class="fl">1.1</span><span class="op">*</span>pi, <span class="dv">0</span>, <span class="dv">0</span> ,<span class="dv">1</span>))</a></code></pre></div>
<p><img src="models-piece-type_files/figure-html/bricks_2a-1.png" width="384"></p>
</div>
<div id="bricks-from-coordinates" class="section level2">
<h2 class="hasAnchor">
<a href="#bricks-from-coordinates" class="anchor"></a>Bricks from coordinates</h2>
<p>Changing the piece type in <code><a href="../reference/bricks_from_coords.html">bricks_from_coords()</a></code> is the most straight-forward, so lets begin there.</p>
<div id="changing-the-default-brick" class="section level3">
<h3 class="hasAnchor">
<a href="#changing-the-default-brick" class="anchor"></a>Changing the default brick</h3>
<p>Start with a simple programmed model to create a classic 2x4 red brick.</p>
<div class="sourceCode" id="cb2"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb2-1" title="1"></a>
<a class="sourceLine" id="cb2-2" title="2"><span class="kw"><a href="https://rdrr.io/r/base/expand.grid.html">expand.grid</a></span>(</a>
<a class="sourceLine" id="cb2-3" title="3"> <span class="dt">x =</span> <span class="dv">1</span><span class="op">:</span><span class="dv">4</span>,</a>
<a class="sourceLine" id="cb2-4" title="4"> <span class="dt">y =</span> <span class="dv">1</span><span class="op">:</span><span class="dv">2</span>,</a>
<a class="sourceLine" id="cb2-5" title="5"> <span class="dt">z =</span> <span class="dv">1</span>,</a>
<a class="sourceLine" id="cb2-6" title="6"> <span class="dt">Color =</span> <span class="st">"Bright red"</span></a>
<a class="sourceLine" id="cb2-7" title="7">) <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb2-8" title="8"><span class="st"> </span><span class="kw"><a href="../reference/bricks_from_coords.html">bricks_from_coords</a></span>() <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb2-9" title="9"><span class="st"> </span><span class="kw"><a href="../reference/build_bricks.html">build_bricks</a></span>()</a>
<a class="sourceLine" id="cb2-10" title="10"></a>
<a class="sourceLine" id="cb2-11" title="11">rgl<span class="op">::</span><span class="kw"><a href="https://rdrr.io/pkg/rgl/man/par3d.html">par3d</a></span>(<span class="dt">userMatrix =</span> rgl<span class="op">::</span><span class="kw"><a href="https://rdrr.io/pkg/rgl/man/matrices.html">rotate3d</a></span>(rgl<span class="op">::</span><span class="kw"><a href="https://rdrr.io/pkg/rgl/man/par3d.html">par3d</a></span>(<span class="st">"userMatrix"</span>), <span class="fl">1.1</span><span class="op">*</span>pi<span class="op">/</span><span class="dv">4</span>, <span class="dv">0</span>, <span class="dv">0</span> ,<span class="dv">1</span>))</a></code></pre></div>
<p><img src="models-piece-type_files/figure-html/bricks_1-1.png" width="384"></p>
<p>Add a new column, <code>piece_type</code>, you can change this default shape. Set <code>piece_type = "p"</code> to create a 2x4 plate instead. A LEGO plate is 1/3 the height of a brick.</p>
<div class="sourceCode" id="cb3"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb3-1" title="1"></a>
<a class="sourceLine" id="cb3-2" title="2"><span class="kw"><a href="https://rdrr.io/r/base/expand.grid.html">expand.grid</a></span>(</a>
<a class="sourceLine" id="cb3-3" title="3"> <span class="dt">x =</span> <span class="dv">1</span><span class="op">:</span><span class="dv">4</span>,</a>
<a class="sourceLine" id="cb3-4" title="4"> <span class="dt">y =</span> <span class="dv">1</span><span class="op">:</span><span class="dv">2</span>,</a>
<a class="sourceLine" id="cb3-5" title="5"> <span class="dt">z =</span> <span class="dv">1</span>,</a>
<a class="sourceLine" id="cb3-6" title="6"> <span class="dt">Color =</span> <span class="st">"Bright red"</span></a>
<a class="sourceLine" id="cb3-7" title="7">) <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb3-8" title="8"><span class="st"> </span>dplyr<span class="op">::</span><span class="kw"><a href="https://dplyr.tidyverse.org/reference/mutate.html">mutate</a></span>(<span class="dt">piece_type =</span> <span class="st">"p"</span>) <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb3-9" title="9"><span class="st"> </span><span class="kw"><a href="../reference/bricks_from_coords.html">bricks_from_coords</a></span>() <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb3-10" title="10"><span class="st"> </span><span class="kw"><a href="../reference/build_bricks.html">build_bricks</a></span>()</a>
<a class="sourceLine" id="cb3-11" title="11"></a>
<a class="sourceLine" id="cb3-12" title="12">rgl<span class="op">::</span><span class="kw"><a href="https://rdrr.io/pkg/rgl/man/par3d.html">par3d</a></span>(<span class="dt">userMatrix =</span> rgl<span class="op">::</span><span class="kw"><a href="https://rdrr.io/pkg/rgl/man/matrices.html">rotate3d</a></span>(rgl<span class="op">::</span><span class="kw"><a href="https://rdrr.io/pkg/rgl/man/par3d.html">par3d</a></span>(<span class="st">"userMatrix"</span>), <span class="fl">1.1</span><span class="op">*</span>pi<span class="op">/</span><span class="dv">4</span>, <span class="dv">0</span>, <span class="dv">0</span> ,<span class="dv">1</span>))</a></code></pre></div>
<p><img src="models-piece-type_files/figure-html/bricks_2-1.png" width="384"></p>
</div>
</div>
<div id="bricks-from-tables" class="section level2">
<h2 class="hasAnchor">
<a href="#bricks-from-tables" class="anchor"></a>Bricks from tables</h2>
<p>Including piece options in <code><a href="../reference/bricks_from_table.html">bricks_from_table()</a></code> or <code><a href="../reference/bricks_from_excel.html">bricks_from_excel()</a></code> is slightly more involved because the input tables are two-dimensional for easier drawing.</p>
<p>In these functions, use the input <code>piece_table</code> to supply an identically shaped table with optional <code>piece_type</code> ids instead of numbers.</p>
<p>Start with this data frame called tree_or_mushroom.</p>
<div class="sourceCode" id="cb4"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb4-1" title="1">tree_or_mushroom &lt;-<span class="st"> </span>tibble<span class="op">::</span><span class="kw"><a href="https://tibble.tidyverse.org/reference/tribble.html">tribble</a></span>(</a>
<a class="sourceLine" id="cb4-2" title="2"> <span class="op">~</span>Level, <span class="op">~</span>X1, <span class="op">~</span>X2, <span class="op">~</span>X3, <span class="op">~</span>X4, <span class="op">~</span>X5, <span class="op">~</span>X6,</a>
<a class="sourceLine" id="cb4-3" title="3"> <span class="st">"A"</span>, <span class="dv">1</span>, <span class="dv">1</span>, <span class="dv">1</span>, <span class="dv">1</span>, <span class="dv">1</span>, <span class="dv">1</span>, </a>
<a class="sourceLine" id="cb4-4" title="4"> <span class="st">"A"</span>, <span class="dv">1</span>, <span class="dv">1</span>, <span class="dv">1</span>, <span class="dv">1</span>, <span class="dv">1</span>, <span class="dv">1</span>, </a>
<a class="sourceLine" id="cb4-5" title="5"> <span class="st">"A"</span>, <span class="dv">1</span>, <span class="dv">1</span>, <span class="dv">1</span>, <span class="dv">1</span>, <span class="dv">1</span>, <span class="dv">1</span>, </a>
<a class="sourceLine" id="cb4-6" title="6"> <span class="st">"A"</span>, <span class="dv">1</span>, <span class="dv">1</span>, <span class="dv">1</span>, <span class="dv">1</span>, <span class="dv">1</span>, <span class="dv">1</span>, </a>
<a class="sourceLine" id="cb4-7" title="7"> <span class="st">"B"</span>, <span class="dv">0</span>, <span class="dv">0</span>, <span class="dv">0</span>, <span class="dv">0</span>, <span class="dv">0</span>, <span class="dv">0</span>, </a>
<a class="sourceLine" id="cb4-8" title="8"> <span class="st">"B"</span>, <span class="dv">0</span>, <span class="dv">0</span>, <span class="dv">2</span>, <span class="dv">2</span>, <span class="dv">0</span>, <span class="dv">0</span>,</a>
<a class="sourceLine" id="cb4-9" title="9"> <span class="st">"B"</span>, <span class="dv">0</span>, <span class="dv">0</span>, <span class="dv">2</span>, <span class="dv">2</span>, <span class="dv">0</span>, <span class="dv">0</span>, </a>
<a class="sourceLine" id="cb4-10" title="10"> <span class="st">"B"</span>, <span class="dv">0</span>, <span class="dv">0</span>, <span class="dv">0</span>, <span class="dv">0</span>, <span class="dv">0</span>, <span class="dv">0</span>, </a>
<a class="sourceLine" id="cb4-11" title="11"> <span class="st">"C"</span>, <span class="dv">0</span>, <span class="dv">0</span>, <span class="dv">0</span>, <span class="dv">0</span>, <span class="dv">0</span>, <span class="dv">0</span>, </a>
<a class="sourceLine" id="cb4-12" title="12"> <span class="st">"C"</span>, <span class="dv">0</span>, <span class="dv">0</span>, <span class="dv">2</span>, <span class="dv">2</span>, <span class="dv">0</span>, <span class="dv">0</span>,</a>
<a class="sourceLine" id="cb4-13" title="13"> <span class="st">"C"</span>, <span class="dv">0</span>, <span class="dv">0</span>, <span class="dv">2</span>, <span class="dv">2</span>, <span class="dv">0</span>, <span class="dv">0</span>, </a>
<a class="sourceLine" id="cb4-14" title="14"> <span class="st">"C"</span>, <span class="dv">0</span>, <span class="dv">0</span>, <span class="dv">0</span>, <span class="dv">0</span>, <span class="dv">0</span>, <span class="dv">0</span>, </a>
<a class="sourceLine" id="cb4-15" title="15"> <span class="st">"D"</span>, <span class="dv">0</span>, <span class="dv">3</span>, <span class="dv">3</span>, <span class="dv">3</span>, <span class="dv">3</span>, <span class="dv">0</span>, </a>
<a class="sourceLine" id="cb4-16" title="16"> <span class="st">"D"</span>, <span class="dv">0</span>, <span class="dv">3</span>, <span class="dv">3</span>, <span class="dv">3</span>, <span class="dv">3</span>, <span class="dv">0</span>,</a>
<a class="sourceLine" id="cb4-17" title="17"> <span class="st">"D"</span>, <span class="dv">0</span>, <span class="dv">3</span>, <span class="dv">3</span>, <span class="dv">3</span>, <span class="dv">3</span>, <span class="dv">0</span>, </a>
<a class="sourceLine" id="cb4-18" title="18"> <span class="st">"D"</span>, <span class="dv">0</span>, <span class="dv">3</span>, <span class="dv">3</span>, <span class="dv">3</span>, <span class="dv">3</span>, <span class="dv">0</span>,</a>
<a class="sourceLine" id="cb4-19" title="19"> <span class="st">"E"</span>, <span class="dv">0</span>, <span class="dv">0</span>, <span class="dv">3</span>, <span class="dv">3</span>, <span class="dv">0</span>, <span class="dv">0</span>, </a>
<a class="sourceLine" id="cb4-20" title="20"> <span class="st">"E"</span>, <span class="dv">0</span>, <span class="dv">3</span>, <span class="dv">3</span>, <span class="dv">3</span>, <span class="dv">3</span>, <span class="dv">0</span>,</a>
<a class="sourceLine" id="cb4-21" title="21"> <span class="st">"E"</span>, <span class="dv">0</span>, <span class="dv">3</span>, <span class="dv">3</span>, <span class="dv">3</span>, <span class="dv">3</span>, <span class="dv">0</span>, </a>
<a class="sourceLine" id="cb4-22" title="22"> <span class="st">"E"</span>, <span class="dv">0</span>, <span class="dv">0</span>, <span class="dv">3</span>, <span class="dv">3</span>, <span class="dv">0</span>, <span class="dv">0</span>,</a>
<a class="sourceLine" id="cb4-23" title="23"> <span class="st">"F"</span>, <span class="dv">0</span>, <span class="dv">0</span>, <span class="dv">0</span>, <span class="dv">0</span>, <span class="dv">0</span>, <span class="dv">0</span>, </a>
<a class="sourceLine" id="cb4-24" title="24"> <span class="st">"F"</span>, <span class="dv">0</span>, <span class="dv">0</span>, <span class="dv">3</span>, <span class="dv">3</span>, <span class="dv">0</span>, <span class="dv">0</span>,</a>
<a class="sourceLine" id="cb4-25" title="25"> <span class="st">"F"</span>, <span class="dv">0</span>, <span class="dv">0</span>, <span class="dv">3</span>, <span class="dv">3</span>, <span class="dv">0</span>, <span class="dv">0</span>, </a>
<a class="sourceLine" id="cb4-26" title="26"> <span class="st">"F"</span>, <span class="dv">0</span>, <span class="dv">0</span>, <span class="dv">0</span>, <span class="dv">0</span>, <span class="dv">0</span>, <span class="dv">0</span>,</a>
<a class="sourceLine" id="cb4-27" title="27"> <span class="st">"G"</span>, <span class="dv">0</span>, <span class="dv">0</span>, <span class="dv">0</span>, <span class="dv">0</span>, <span class="dv">0</span>, <span class="dv">0</span>, </a>
<a class="sourceLine" id="cb4-28" title="28"> <span class="st">"G"</span>, <span class="dv">0</span>, <span class="dv">0</span>, <span class="dv">3</span>, <span class="dv">0</span>, <span class="dv">0</span>, <span class="dv">0</span>,</a>
<a class="sourceLine" id="cb4-29" title="29"> <span class="st">"G"</span>, <span class="dv">0</span>, <span class="dv">0</span>, <span class="dv">0</span>, <span class="dv">3</span>, <span class="dv">0</span>, <span class="dv">0</span>, </a>
<a class="sourceLine" id="cb4-30" title="30"> <span class="st">"G"</span>, <span class="dv">0</span>, <span class="dv">0</span>, <span class="dv">0</span>, <span class="dv">0</span>, <span class="dv">0</span>, <span class="dv">0</span></a>
<a class="sourceLine" id="cb4-31" title="31">)</a>
<a class="sourceLine" id="cb4-32" title="32"></a>
<a class="sourceLine" id="cb4-33" title="33">brick_colors &lt;-<span class="st"> </span>tibble<span class="op">::</span><span class="kw"><a href="https://tibble.tidyverse.org/reference/tribble.html">tribble</a></span>(</a>
<a class="sourceLine" id="cb4-34" title="34"> <span class="op">~</span><span class="st">`</span><span class="dt">.value</span><span class="st">`</span>, <span class="op">~</span>Color,</a>
<a class="sourceLine" id="cb4-35" title="35"> <span class="dv">1</span>, <span class="st">"Bright green"</span>,</a>
<a class="sourceLine" id="cb4-36" title="36"> <span class="dv">2</span>, <span class="st">"Dark orange"</span>,</a>
<a class="sourceLine" id="cb4-37" title="37"> <span class="dv">3</span>, <span class="st">"Dark green"</span></a>
<a class="sourceLine" id="cb4-38" title="38">)</a>
<a class="sourceLine" id="cb4-39" title="39"></a>
<a class="sourceLine" id="cb4-40" title="40">tree_or_mushroom <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb4-41" title="41"><span class="st"> </span><span class="kw"><a href="../reference/bricks_from_table.html">bricks_from_table</a></span>(brick_colors) <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb4-42" title="42"><span class="st"> </span><span class="kw"><a href="../reference/build_bricks.html">build_bricks</a></span>()</a>
<a class="sourceLine" id="cb4-43" title="43"></a>
<a class="sourceLine" id="cb4-44" title="44">rgl<span class="op">::</span><span class="kw"><a href="https://rdrr.io/pkg/rgl/man/par3d.html">par3d</a></span>(<span class="dt">userMatrix =</span> rgl<span class="op">::</span><span class="kw"><a href="https://rdrr.io/pkg/rgl/man/matrices.html">rotate3d</a></span>(rgl<span class="op">::</span><span class="kw"><a href="https://rdrr.io/pkg/rgl/man/par3d.html">par3d</a></span>(<span class="st">"userMatrix"</span>), <span class="fl">1.1</span><span class="op">*</span>pi<span class="op">/</span><span class="dv">4</span>, <span class="dv">0</span>, <span class="dv">0</span> ,<span class="dv">1</span>))</a></code></pre></div>
<p><img src="models-piece-type_files/figure-html/bricks_5-1.png" width="384"></p>
<p>If you want more a tree with more texture, you can change all the “leaves” from rectangular bricks into cylinder bricks.</p>
<div class="sourceCode" id="cb5"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb5-1" title="1">tree_or_mushroom_pieces &lt;-<span class="st"> </span>tree_or_mushroom <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb5-2" title="2"><span class="st"> </span>dplyr<span class="op">::</span><span class="kw"><a href="https://dplyr.tidyverse.org/reference/mutate_all.html">mutate_at</a></span>(dplyr<span class="op">::</span><span class="kw"><a href="https://dplyr.tidyverse.org/reference/vars.html">vars</a></span>(dplyr<span class="op">::</span><span class="kw"><a href="https://dplyr.tidyverse.org/reference/reexports.html">starts_with</a></span>(<span class="st">"X"</span>)), </a>
<a class="sourceLine" id="cb5-3" title="3"> <span class="op">~</span><span class="kw"><a href="https://rdrr.io/r/base/ifelse.html">ifelse</a></span>(.<span class="op">==</span><span class="dv">3</span>, <span class="st">"c2"</span>, <span class="st">"b"</span>)) <span class="co">#If the color is the dark green, make a cone, else brick</span></a>
<a class="sourceLine" id="cb5-4" title="4"></a>
<a class="sourceLine" id="cb5-5" title="5">tree_or_mushroom <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb5-6" title="6"><span class="st"> </span><span class="kw"><a href="../reference/bricks_from_table.html">bricks_from_table</a></span>(brick_colors,</a>
<a class="sourceLine" id="cb5-7" title="7"> <span class="dt">piece_matrix =</span> tree_or_mushroom_pieces) <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb5-8" title="8"><span class="st"> </span><span class="kw"><a href="../reference/build_bricks.html">build_bricks</a></span>()</a>
<a class="sourceLine" id="cb5-9" title="9"></a>
<a class="sourceLine" id="cb5-10" title="10">rgl<span class="op">::</span><span class="kw"><a href="https://rdrr.io/pkg/rgl/man/par3d.html">par3d</a></span>(<span class="dt">userMatrix =</span> rgl<span class="op">::</span><span class="kw"><a href="https://rdrr.io/pkg/rgl/man/matrices.html">rotate3d</a></span>(rgl<span class="op">::</span><span class="kw"><a href="https://rdrr.io/pkg/rgl/man/par3d.html">par3d</a></span>(<span class="st">"userMatrix"</span>), <span class="fl">1.1</span><span class="op">*</span>pi<span class="op">/</span><span class="dv">4</span>, <span class="dv">0</span>, <span class="dv">0</span> ,<span class="dv">1</span>))</a></code></pre></div>
<p><img src="models-piece-type_files/figure-html/bricks_6-1.png" width="384"></p>
<div id="bricks-from-excel" class="section level3">
<h3 class="hasAnchor">
<a href="#bricks-from-excel" class="anchor"></a>Bricks from Excel</h3>
<p>For <code><a href="../reference/bricks_from_excel.html">bricks_from_excel()</a></code>, you only have to supply <code>piece_type</code> ids when you do NOT want the classic brick. The best option here is to create your model in the Excel template in <a href="https://github.com/ryantimpe/brickr_toybox">the brickr toybox</a> GitHub repo. Once complete, duplicate the sheet and change any color values to piece_type IDs.</p>
</div>
</div>
<div id="mid-level-bricks" class="section level2">
<h2 class="hasAnchor">
<a href="#mid-level-bricks" class="anchor"></a>Mid-level bricks</h2>
<p>Because different piece types have different heights, your models might have unintentional gaps when using pieces that are less than 1-unit tall.</p>
<p>Start with this LEGO cube.</p>
<div class="sourceCode" id="cb6"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb6-1" title="1"></a>
<a class="sourceLine" id="cb6-2" title="2"><span class="kw"><a href="https://rdrr.io/r/base/expand.grid.html">expand.grid</a></span>(</a>
<a class="sourceLine" id="cb6-3" title="3"> <span class="dt">x =</span> <span class="dv">1</span><span class="op">:</span><span class="dv">3</span>,</a>
<a class="sourceLine" id="cb6-4" title="4"> <span class="dt">y =</span> <span class="dv">1</span><span class="op">:</span><span class="dv">3</span>,</a>
<a class="sourceLine" id="cb6-5" title="5"> <span class="dt">z =</span> <span class="dv">1</span><span class="op">:</span><span class="dv">3</span>,</a>
<a class="sourceLine" id="cb6-6" title="6"> <span class="dt">color =</span> <span class="st">"Bright blue"</span></a>
<a class="sourceLine" id="cb6-7" title="7">) <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb6-8" title="8"><span class="st"> </span>dplyr<span class="op">::</span><span class="kw"><a href="https://dplyr.tidyverse.org/reference/mutate.html">mutate</a></span>(<span class="dt">color =</span> <span class="kw"><a href="https://rdrr.io/r/base/ifelse.html">ifelse</a></span>(z<span class="op">==</span><span class="dv">2</span>, <span class="st">"Bright red"</span>, <span class="kw"><a href="https://rdrr.io/r/base/character.html">as.character</a></span>(color))) <span class="op">%&gt;%</span></a>
<a class="sourceLine" id="cb6-9" title="9"><span class="st"> </span><span class="kw"><a href="../reference/bricks_from_coords.html">bricks_from_coords</a></span>() <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb6-10" title="10"><span class="st"> </span><span class="kw"><a href="../reference/build_bricks.html">build_bricks</a></span>()</a>
<a class="sourceLine" id="cb6-11" title="11"></a>
<a class="sourceLine" id="cb6-12" title="12">rgl<span class="op">::</span><span class="kw"><a href="https://rdrr.io/pkg/rgl/man/par3d.html">par3d</a></span>(<span class="dt">userMatrix =</span> rgl<span class="op">::</span><span class="kw"><a href="https://rdrr.io/pkg/rgl/man/matrices.html">rotate3d</a></span>(rgl<span class="op">::</span><span class="kw"><a href="https://rdrr.io/pkg/rgl/man/par3d.html">par3d</a></span>(<span class="st">"userMatrix"</span>), <span class="fl">1.1</span><span class="op">*</span>pi<span class="op">/</span><span class="dv">4</span>, <span class="dv">0</span>, <span class="dv">0</span> ,<span class="dv">1</span>))</a></code></pre></div>
<p><img src="models-piece-type_files/figure-html/bricks_10-1.png" width="384"></p>
<p>A problem arises when we change these bricks to plates. Each z (Level) continues to be drawn at the same height and the plates are no longer stacked together.</p>
<div class="sourceCode" id="cb7"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb7-1" title="1"></a>
<a class="sourceLine" id="cb7-2" title="2"><span class="kw"><a href="https://rdrr.io/r/base/expand.grid.html">expand.grid</a></span>(</a>
<a class="sourceLine" id="cb7-3" title="3"> <span class="dt">x =</span> <span class="dv">1</span><span class="op">:</span><span class="dv">3</span>,</a>
<a class="sourceLine" id="cb7-4" title="4"> <span class="dt">y =</span> <span class="dv">1</span><span class="op">:</span><span class="dv">3</span>,</a>
<a class="sourceLine" id="cb7-5" title="5"> <span class="dt">z =</span> <span class="dv">1</span><span class="op">:</span><span class="dv">3</span>,</a>
<a class="sourceLine" id="cb7-6" title="6"> <span class="dt">color =</span> <span class="st">"Bright blue"</span></a>
<a class="sourceLine" id="cb7-7" title="7">) <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb7-8" title="8"><span class="st"> </span>dplyr<span class="op">::</span><span class="kw"><a href="https://dplyr.tidyverse.org/reference/mutate.html">mutate</a></span>(<span class="dt">color =</span> <span class="kw"><a href="https://rdrr.io/r/base/ifelse.html">ifelse</a></span>(z<span class="op">==</span><span class="dv">2</span>, <span class="st">"Bright red"</span>, <span class="kw"><a href="https://rdrr.io/r/base/character.html">as.character</a></span>(color)),</a>
<a class="sourceLine" id="cb7-9" title="9"> <span class="dt">piece_type =</span> <span class="st">"p"</span>) <span class="op">%&gt;%</span></a>
<a class="sourceLine" id="cb7-10" title="10"><span class="st"> </span><span class="kw"><a href="../reference/bricks_from_coords.html">bricks_from_coords</a></span>() <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb7-11" title="11"><span class="st"> </span><span class="kw"><a href="../reference/build_bricks.html">build_bricks</a></span>()</a>
<a class="sourceLine" id="cb7-12" title="12"></a>
<a class="sourceLine" id="cb7-13" title="13">rgl<span class="op">::</span><span class="kw"><a href="https://rdrr.io/pkg/rgl/man/par3d.html">par3d</a></span>(<span class="dt">userMatrix =</span> rgl<span class="op">::</span><span class="kw"><a href="https://rdrr.io/pkg/rgl/man/matrices.html">rotate3d</a></span>(rgl<span class="op">::</span><span class="kw"><a href="https://rdrr.io/pkg/rgl/man/par3d.html">par3d</a></span>(<span class="st">"userMatrix"</span>), <span class="fl">1.1</span><span class="op">*</span>pi<span class="op">/</span><span class="dv">4</span>, <span class="dv">0</span>, <span class="dv">0</span> ,<span class="dv">1</span>))</a></code></pre></div>
<p><img src="models-piece-type_files/figure-html/bricks_11-1.png" width="384"></p>
<p>Each z (Level) is the height of a brick, but plates and cheese slopes have height less than a brick. To stack consecutive bricks that are now all full height, youll need to use a new column, <code>mid_level</code>. The <code>mid_level</code> column can be added anywhere in a <code><a href="../reference/bricks_from_coords.html">bricks_from_coords()</a></code> input or as the 2nd column after <code>Level</code> in the <code>matrix_table</code> input in <code><a href="../reference/bricks_from_table.html">bricks_from_table()</a></code> or <code><a href="../reference/bricks_from_excel.html">bricks_from_excel()</a></code>.</p>
<p>By default, all bricks and pieces are located at <code>mid_level = 0</code>, which is the base of the z (Level). All z (Level) values have 3 possible mid_level values: 0, 1, 2.</p>
<p>Using integer division and mods, you can convert all levels uniformly to Level + mid_levels. In future versions of brickr, there will be helper functions.</p>
<div class="sourceCode" id="cb8"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb8-1" title="1"></a>
<a class="sourceLine" id="cb8-2" title="2"><span class="kw"><a href="https://rdrr.io/r/base/expand.grid.html">expand.grid</a></span>(</a>
<a class="sourceLine" id="cb8-3" title="3"> <span class="dt">x =</span> <span class="dv">1</span><span class="op">:</span><span class="dv">3</span>,</a>
<a class="sourceLine" id="cb8-4" title="4"> <span class="dt">y =</span> <span class="dv">1</span><span class="op">:</span><span class="dv">3</span>,</a>
<a class="sourceLine" id="cb8-5" title="5"> <span class="dt">z =</span> <span class="dv">1</span><span class="op">:</span><span class="dv">3</span>,</a>
<a class="sourceLine" id="cb8-6" title="6"> <span class="dt">color =</span> <span class="st">"Bright blue"</span></a>
<a class="sourceLine" id="cb8-7" title="7">) <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb8-8" title="8"><span class="st"> </span>dplyr<span class="op">::</span><span class="kw"><a href="https://dplyr.tidyverse.org/reference/mutate.html">mutate</a></span>(<span class="dt">color =</span> <span class="kw"><a href="https://rdrr.io/r/base/ifelse.html">ifelse</a></span>(z<span class="op">==</span><span class="dv">2</span>, <span class="st">"Bright red"</span>, <span class="kw"><a href="https://rdrr.io/r/base/character.html">as.character</a></span>(color)),</a>
<a class="sourceLine" id="cb8-9" title="9"> <span class="dt">piece_type =</span> <span class="st">"p"</span>) <span class="op">%&gt;%</span></a>
<a class="sourceLine" id="cb8-10" title="10"><span class="st"> </span>dplyr<span class="op">::</span><span class="kw"><a href="https://dplyr.tidyverse.org/reference/mutate.html">mutate</a></span>(<span class="dt">mid_level =</span> (z<span class="dv">-1</span>) <span class="op">%%</span><span class="st"> </span><span class="dv">3</span>,</a>
<a class="sourceLine" id="cb8-11" title="11"> <span class="dt">z =</span> (z<span class="dv">-1</span>) <span class="op">%/%</span><span class="st"> </span><span class="dv">3</span> <span class="op">+</span><span class="dv">1</span>) <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb8-12" title="12"><span class="st"> </span><span class="kw"><a href="../reference/bricks_from_coords.html">bricks_from_coords</a></span>() <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb8-13" title="13"><span class="st"> </span><span class="kw"><a href="../reference/build_bricks.html">build_bricks</a></span>()</a>
<a class="sourceLine" id="cb8-14" title="14"></a>
<a class="sourceLine" id="cb8-15" title="15">rgl<span class="op">::</span><span class="kw"><a href="https://rdrr.io/pkg/rgl/man/par3d.html">par3d</a></span>(<span class="dt">userMatrix =</span> rgl<span class="op">::</span><span class="kw"><a href="https://rdrr.io/pkg/rgl/man/matrices.html">rotate3d</a></span>(rgl<span class="op">::</span><span class="kw"><a href="https://rdrr.io/pkg/rgl/man/par3d.html">par3d</a></span>(<span class="st">"userMatrix"</span>), <span class="fl">1.1</span><span class="op">*</span>pi<span class="op">/</span><span class="dv">4</span>, <span class="dv">0</span>, <span class="dv">0</span> ,<span class="dv">1</span>))</a></code></pre></div>
<p><img src="models-piece-type_files/figure-html/bricks_12-1.png" width="384"></p>
<p>Its also possible to mix and match different z (Level) and mid_level combinations to stack plates with bricks. There are various ways to do this, depending on the complexity and your comfort with tidyverse data manipulation.</p>
<div class="sourceCode" id="cb9"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb9-1" title="1"></a>
<a class="sourceLine" id="cb9-2" title="2"><span class="kw"><a href="https://rdrr.io/r/base/expand.grid.html">expand.grid</a></span>(</a>
<a class="sourceLine" id="cb9-3" title="3"> <span class="dt">x =</span> <span class="dv">1</span><span class="op">:</span><span class="dv">3</span>,</a>
<a class="sourceLine" id="cb9-4" title="4"> <span class="dt">y =</span> <span class="dv">1</span><span class="op">:</span><span class="dv">3</span>,</a>
<a class="sourceLine" id="cb9-5" title="5"> <span class="dt">z =</span> <span class="dv">1</span><span class="op">:</span><span class="dv">3</span>,</a>
<a class="sourceLine" id="cb9-6" title="6"> <span class="dt">color =</span> <span class="st">"Bright blue"</span></a>
<a class="sourceLine" id="cb9-7" title="7">) <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb9-8" title="8"><span class="st"> </span>dplyr<span class="op">::</span><span class="kw"><a href="https://dplyr.tidyverse.org/reference/mutate.html">mutate</a></span>(<span class="dt">color =</span> <span class="kw"><a href="https://rdrr.io/r/base/ifelse.html">ifelse</a></span>(z<span class="op">==</span><span class="dv">2</span>, <span class="st">"Bright red"</span>, <span class="kw"><a href="https://rdrr.io/r/base/character.html">as.character</a></span>(color)),</a>
<a class="sourceLine" id="cb9-9" title="9"> <span class="dt">piece_type =</span> <span class="kw"><a href="https://rdrr.io/r/base/ifelse.html">ifelse</a></span>(z<span class="op">==</span><span class="dv">2</span>, <span class="st">"p"</span>, <span class="st">"b"</span>)) <span class="op">%&gt;%</span></a>
<a class="sourceLine" id="cb9-10" title="10"><span class="st"> </span>dplyr<span class="op">::</span><span class="kw"><a href="https://dplyr.tidyverse.org/reference/mutate.html">mutate</a></span>(</a>
<a class="sourceLine" id="cb9-11" title="11"> <span class="dt">mid_level =</span> dplyr<span class="op">::</span><span class="kw"><a href="https://dplyr.tidyverse.org/reference/case_when.html">case_when</a></span>(</a>
<a class="sourceLine" id="cb9-12" title="12"> z <span class="op">%in%</span><span class="st"> </span><span class="dv">1</span><span class="op">:</span><span class="dv">2</span> <span class="op">~</span><span class="st"> </span><span class="dv">0</span>, </a>
<a class="sourceLine" id="cb9-13" title="13"> z <span class="op">==</span><span class="st"> </span><span class="dv">3</span> <span class="op">~</span><span class="st"> </span><span class="dv">1</span></a>
<a class="sourceLine" id="cb9-14" title="14"> ), </a>
<a class="sourceLine" id="cb9-15" title="15"> <span class="dt">z =</span> dplyr<span class="op">::</span><span class="kw"><a href="https://dplyr.tidyverse.org/reference/case_when.html">case_when</a></span>(</a>
<a class="sourceLine" id="cb9-16" title="16"> z <span class="op">%in%</span><span class="st"> </span><span class="dv">2</span><span class="op">:</span><span class="dv">3</span> <span class="op">~</span><span class="st"> </span><span class="dv">2</span>,</a>
<a class="sourceLine" id="cb9-17" title="17"> <span class="ot">TRUE</span> <span class="op">~</span><span class="st"> </span><span class="dv">1</span></a>
<a class="sourceLine" id="cb9-18" title="18"> )) <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb9-19" title="19"><span class="st"> </span><span class="kw"><a href="../reference/bricks_from_coords.html">bricks_from_coords</a></span>() <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb9-20" title="20"><span class="st"> </span><span class="kw"><a href="../reference/build_bricks.html">build_bricks</a></span>()</a>
<a class="sourceLine" id="cb9-21" title="21"></a>
<a class="sourceLine" id="cb9-22" title="22">rgl<span class="op">::</span><span class="kw"><a href="https://rdrr.io/pkg/rgl/man/par3d.html">par3d</a></span>(<span class="dt">userMatrix =</span> rgl<span class="op">::</span><span class="kw"><a href="https://rdrr.io/pkg/rgl/man/matrices.html">rotate3d</a></span>(rgl<span class="op">::</span><span class="kw"><a href="https://rdrr.io/pkg/rgl/man/par3d.html">par3d</a></span>(<span class="st">"userMatrix"</span>), <span class="fl">1.1</span><span class="op">*</span>pi<span class="op">/</span><span class="dv">4</span>, <span class="dv">0</span>, <span class="dv">0</span> ,<span class="dv">1</span>))</a></code></pre></div>
<p><img src="models-piece-type_files/figure-html/bricks_13-1.png" width="384"></p>
</div>
</div>
<div class="col-md-3 hidden-xs hidden-sm" id="sidebar">
<div id="tocnav">
<h2 class="hasAnchor">
<a href="#tocnav" class="anchor"></a>Contents</h2>
<ul class="nav nav-pills nav-stacked">
<li><a href="#getting-started">Getting started</a></li>
<li><a href="#all-piece-options">All piece options</a></li>
<li><a href="#bricks-from-coordinates">Bricks from coordinates</a></li>
<li><a href="#bricks-from-tables">Bricks from tables</a></li>
<li><a href="#mid-level-bricks">Mid-level bricks</a></li>
</ul>
</div>
</div>
</div>
<footer><div class="copyright">
<p>Developed by Ryan Timpe.</p>
</div>
<div class="pkgdown">
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.4.1.</p>
</div>
</footer>
</div>
</body>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

View File

@@ -0,0 +1,423 @@
<!DOCTYPE html>
<!-- Generated by pkgdown: do not edit by hand --><html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Piece type in 3D Models • brickr</title>
<!-- favicons --><link rel="icon" type="image/png" sizes="16x16" href="../favicon-16x16.png">
<link rel="icon" type="image/png" sizes="32x32" href="../favicon-32x32.png">
<link rel="apple-touch-icon" type="image/png" sizes="180x180" href="../apple-touch-icon.png">
<link rel="apple-touch-icon" type="image/png" sizes="120x120" href="../apple-touch-icon-120x120.png">
<link rel="apple-touch-icon" type="image/png" sizes="76x76" href="../apple-touch-icon-76x76.png">
<link rel="apple-touch-icon" type="image/png" sizes="60x60" href="../apple-touch-icon-60x60.png">
<!-- jquery --><script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script><!-- Bootstrap --><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha256-916EbMg70RQy9LHiGkXzG8hSg9EdNy97GazNG/aiY1w=" crossorigin="anonymous">
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha256-U5ZEeKfGNOja007MMD3YBI0A3OSZOQbeG6z2f2Y0hu8=" crossorigin="anonymous"></script><!-- Font Awesome icons --><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.7.1/css/all.min.css" integrity="sha256-nAmazAk6vS34Xqo0BSrTb+abbtFlgsFK7NKSi6o7Y78=" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.7.1/css/v4-shims.min.css" integrity="sha256-6qHlizsOWFskGlwVOKuns+D1nB6ssZrHQrNj1wGplHc=" crossorigin="anonymous">
<!-- clipboard.js --><script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.4/clipboard.min.js" integrity="sha256-FiZwavyI2V6+EXO1U+xzLG3IKldpiTFf3153ea9zikQ=" crossorigin="anonymous"></script><!-- headroom.js --><script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.9.4/headroom.min.js" integrity="sha256-DJFC1kqIhelURkuza0AvYal5RxMtpzLjFhsnVIeuk+U=" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.9.4/jQuery.headroom.min.js" integrity="sha256-ZX/yNShbjqsohH1k95liqY9Gd8uOiE1S4vZc+9KQ1K4=" crossorigin="anonymous"></script><!-- pkgdown --><link href="../pkgdown.css" rel="stylesheet">
<script src="../pkgdown.js"></script><link href="../extra.css" rel="stylesheet">
<meta property="og:title" content="Piece type in 3D Models">
<meta property="og:description" content="">
<meta property="og:image" content="http://brickr.org/logo.png">
<meta name="twitter:card" content="summary">
<!-- mathjax --><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js" integrity="sha256-nvJJv9wWKEm88qvoQl9ekL2J+k/RWIsaSScxxlsrv8k=" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/config/TeX-AMS-MML_HTMLorMML.js" integrity="sha256-84DKXVJXs0/F8OTMzX4UR909+jtl4G7SPypPavF+GfA=" crossorigin="anonymous"></script><!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div class="container template-article">
<header><div class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">brickr</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.2.9.9215</span>
</span>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li>
<a href="../index.html">
<span class="fas fa fas fa-home fa-lg"></span>
</a>
</li>
<li>
<a href="../reference/index.html">Reference</a>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
Articles
<span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
<li>
<a href="../articles/models-from-other.html">3D Models from mosaics</a>
</li>
<li>
<a href="../articles/models-from-program.html">3D Models programmatically</a>
</li>
<li>
<a href="../articles/models-from-tables.html">3D models from tables</a>
</li>
<li>
<a href="../articles/models-pieces-type.html">Piece type in 3D Models</a>
</li>
<li>
<a href="../articles/mosaics.html">Mosaics with brickr</a>
</li>
</ul>
</li>
<li>
<a href="../news/index.html">Changelog</a>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li>
<a href="https://github.com/ryantimpe/brickr">
<span class="fab fa fab fa-github fa-lg"></span>
</a>
</li>
</ul>
</div>
<!--/.nav-collapse -->
</div>
<!--/.container -->
</div>
<!--/.navbar -->
</header><div class="row">
<div class="col-md-9 contents">
<div class="page-header toc-ignore">
<h1>Piece type in 3D Models</h1>
<small class="dont-index">Source: <a href="https://github.com/ryantimpe/brickr/blob/master/vignettes/models-pieces-type.Rmd"><code>vignettes/models-pieces-type.Rmd</code></a></small>
<div class="hidden name"><code>models-pieces-type.Rmd</code></div>
</div>
<div id="getting-started" class="section level2">
<h2 class="hasAnchor">
<a href="#getting-started" class="anchor"></a>Getting started</h2>
<p>Models in brickr default to rendering rectangular LEGO bricks. Other LEGO shapes are possible in both <code><a href="../reference/bricks_from_coords.html">bricks_from_coords()</a></code> and <code><a href="../reference/bricks_from_table.html">bricks_from_table()</a></code> or <code><a href="../reference/bricks_from_excel.html">bricks_from_excel()</a></code>.</p>
<p>Piece shapes in models are driven the <code>piece_type</code> ID.</p>
</div>
<div id="all-piece-options" class="section level2">
<h2 class="hasAnchor">
<a href="#all-piece-options" class="anchor"></a>All piece options</h2>
<p>Currently there are 5 unique piece shapes in brickr. Some shapes can have different orientations, which is also determined by the <code>piece_type</code> column.</p>
<table class="table">
<thead><tr class="header">
<th align="left">Piece</th>
<th align="left">piece_type</th>
<th align="left">Area</th>
<th align="left">Height</th>
<th align="left">Orientation</th>
</tr></thead>
<tbody>
<tr class="odd">
<td align="left">Brick (classic)</td>
<td align="left">b</td>
<td align="left">any</td>
<td align="left">1</td>
<td align="left"></td>
</tr>
<tr class="even">
<td align="left">Plate (flat brick)</td>
<td align="left">p</td>
<td align="left">any</td>
<td align="left">1/3</td>
<td align="left"></td>
</tr>
<tr class="odd">
<td align="left">Round 1x1 (cylinder)</td>
<td align="left">c1</td>
<td align="left">1</td>
<td align="left">1</td>
<td align="left"></td>
</tr>
<tr class="even">
<td align="left">Round 1x1 (cone)</td>
<td align="left">c2</td>
<td align="left">1</td>
<td align="left">1</td>
<td align="left"></td>
</tr>
<tr class="odd">
<td align="left">Cheese slope</td>
<td align="left">w1</td>
<td align="left">1</td>
<td align="left">2/3</td>
<td align="left">north</td>
</tr>
<tr class="even">
<td align="left">Cheese slope</td>
<td align="left">w2</td>
<td align="left">1</td>
<td align="left">2/3</td>
<td align="left">east</td>
</tr>
<tr class="odd">
<td align="left">Cheese slope</td>
<td align="left">w3</td>
<td align="left">1</td>
<td align="left">2/3</td>
<td align="left">south</td>
</tr>
<tr class="even">
<td align="left">Cheese slope</td>
<td align="left">w4</td>
<td align="left">1</td>
<td align="left">2/3</td>
<td align="left">west</td>
</tr>
</tbody>
</table>
<div class="sourceCode" id="cb1"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb1-1" title="1"></a>
<a class="sourceLine" id="cb1-2" title="2"><span class="kw"><a href="https://rdrr.io/r/base/expand.grid.html">expand.grid</a></span>(</a>
<a class="sourceLine" id="cb1-3" title="3"> <span class="dt">x =</span> <span class="dv">1</span><span class="op">:</span><span class="dv">4</span> <span class="op">*</span><span class="st"> </span><span class="dv">2</span>,</a>
<a class="sourceLine" id="cb1-4" title="4"> <span class="dt">y =</span> <span class="dv">1</span><span class="op">:</span><span class="dv">2</span> <span class="op">*</span><span class="st"> </span><span class="dv">2</span>,</a>
<a class="sourceLine" id="cb1-5" title="5"> <span class="dt">z =</span> <span class="dv">1</span>) <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb1-6" title="6"><span class="st"> </span>dplyr<span class="op">::</span><span class="kw"><a href="https://dplyr.tidyverse.org/reference/mutate.html">mutate</a></span>(<span class="dt">Color =</span> <span class="kw"><a href="https://rdrr.io/r/utils/head.html">head</a></span>(lego_colors<span class="op">$</span>Color, <span class="dv">8</span>),</a>
<a class="sourceLine" id="cb1-7" title="7"> <span class="dt">piece_type =</span> <span class="kw"><a href="https://rdrr.io/r/base/c.html">c</a></span>(<span class="st">"b"</span>, <span class="st">"p"</span>, <span class="st">"c1"</span>, <span class="st">"c2"</span>, <span class="st">"w1"</span>, <span class="st">"w2"</span>, <span class="st">"w3"</span>, <span class="st">"w4"</span>)) <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb1-8" title="8"><span class="st"> </span><span class="kw"><a href="../reference/bricks_from_coords.html">bricks_from_coords</a></span>() <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb1-9" title="9"><span class="st"> </span><span class="kw"><a href="../reference/build_bricks.html">build_bricks</a></span>(<span class="dt">rgl_lit =</span> <span class="ot">FALSE</span>, <span class="dt">outline_bricks =</span> <span class="ot">TRUE</span>)</a>
<a class="sourceLine" id="cb1-10" title="10"></a>
<a class="sourceLine" id="cb1-11" title="11">rgl<span class="op">::</span><span class="kw"><a href="https://rdrr.io/pkg/rgl/man/par3d.html">par3d</a></span>(<span class="dt">userMatrix =</span> rgl<span class="op">::</span><span class="kw"><a href="https://rdrr.io/pkg/rgl/man/matrices.html">rotate3d</a></span>(rgl<span class="op">::</span><span class="kw"><a href="https://rdrr.io/pkg/rgl/man/par3d.html">par3d</a></span>(<span class="st">"userMatrix"</span>), <span class="fl">1.1</span><span class="op">*</span>pi, <span class="dv">0</span>, <span class="dv">0</span> ,<span class="dv">1</span>))</a></code></pre></div>
<p><img src="models-pieces-type_files/figure-html/bricks_2a-1.png" width="384"></p>
</div>
<div id="bricks-from-coordinates" class="section level2">
<h2 class="hasAnchor">
<a href="#bricks-from-coordinates" class="anchor"></a>Bricks from coordinates</h2>
<p>Changing the piece type in <code><a href="../reference/bricks_from_coords.html">bricks_from_coords()</a></code> is the most straight-forward, so lets begin there.</p>
<div id="changing-the-default-brick" class="section level3">
<h3 class="hasAnchor">
<a href="#changing-the-default-brick" class="anchor"></a>Changing the default brick</h3>
<p>Start with a simple programmed model to create a classic 2x4 red brick.</p>
<div class="sourceCode" id="cb2"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb2-1" title="1"></a>
<a class="sourceLine" id="cb2-2" title="2"><span class="kw"><a href="https://rdrr.io/r/base/expand.grid.html">expand.grid</a></span>(</a>
<a class="sourceLine" id="cb2-3" title="3"> <span class="dt">x =</span> <span class="dv">1</span><span class="op">:</span><span class="dv">4</span>,</a>
<a class="sourceLine" id="cb2-4" title="4"> <span class="dt">y =</span> <span class="dv">1</span><span class="op">:</span><span class="dv">2</span>,</a>
<a class="sourceLine" id="cb2-5" title="5"> <span class="dt">z =</span> <span class="dv">1</span>,</a>
<a class="sourceLine" id="cb2-6" title="6"> <span class="dt">Color =</span> <span class="st">"Bright red"</span></a>
<a class="sourceLine" id="cb2-7" title="7">) <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb2-8" title="8"><span class="st"> </span><span class="kw"><a href="../reference/bricks_from_coords.html">bricks_from_coords</a></span>() <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb2-9" title="9"><span class="st"> </span><span class="kw"><a href="../reference/build_bricks.html">build_bricks</a></span>()</a>
<a class="sourceLine" id="cb2-10" title="10"></a>
<a class="sourceLine" id="cb2-11" title="11">rgl<span class="op">::</span><span class="kw"><a href="https://rdrr.io/pkg/rgl/man/par3d.html">par3d</a></span>(<span class="dt">userMatrix =</span> rgl<span class="op">::</span><span class="kw"><a href="https://rdrr.io/pkg/rgl/man/matrices.html">rotate3d</a></span>(rgl<span class="op">::</span><span class="kw"><a href="https://rdrr.io/pkg/rgl/man/par3d.html">par3d</a></span>(<span class="st">"userMatrix"</span>), <span class="fl">1.1</span><span class="op">*</span>pi<span class="op">/</span><span class="dv">4</span>, <span class="dv">0</span>, <span class="dv">0</span> ,<span class="dv">1</span>))</a></code></pre></div>
<p><img src="models-pieces-type_files/figure-html/bricks_1-1.png" width="384"></p>
<p>Add a new column, <code>piece_type</code>, you can change this default shape. Set <code>piece_type = "p"</code> to create a 2x4 plate instead. A LEGO plate is 1/3 the height of a brick.</p>
<div class="sourceCode" id="cb3"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb3-1" title="1"></a>
<a class="sourceLine" id="cb3-2" title="2"><span class="kw"><a href="https://rdrr.io/r/base/expand.grid.html">expand.grid</a></span>(</a>
<a class="sourceLine" id="cb3-3" title="3"> <span class="dt">x =</span> <span class="dv">1</span><span class="op">:</span><span class="dv">4</span>,</a>
<a class="sourceLine" id="cb3-4" title="4"> <span class="dt">y =</span> <span class="dv">1</span><span class="op">:</span><span class="dv">2</span>,</a>
<a class="sourceLine" id="cb3-5" title="5"> <span class="dt">z =</span> <span class="dv">1</span>,</a>
<a class="sourceLine" id="cb3-6" title="6"> <span class="dt">Color =</span> <span class="st">"Bright red"</span></a>
<a class="sourceLine" id="cb3-7" title="7">) <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb3-8" title="8"><span class="st"> </span>dplyr<span class="op">::</span><span class="kw"><a href="https://dplyr.tidyverse.org/reference/mutate.html">mutate</a></span>(<span class="dt">piece_type =</span> <span class="st">"p"</span>) <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb3-9" title="9"><span class="st"> </span><span class="kw"><a href="../reference/bricks_from_coords.html">bricks_from_coords</a></span>() <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb3-10" title="10"><span class="st"> </span><span class="kw"><a href="../reference/build_bricks.html">build_bricks</a></span>()</a>
<a class="sourceLine" id="cb3-11" title="11"></a>
<a class="sourceLine" id="cb3-12" title="12">rgl<span class="op">::</span><span class="kw"><a href="https://rdrr.io/pkg/rgl/man/par3d.html">par3d</a></span>(<span class="dt">userMatrix =</span> rgl<span class="op">::</span><span class="kw"><a href="https://rdrr.io/pkg/rgl/man/matrices.html">rotate3d</a></span>(rgl<span class="op">::</span><span class="kw"><a href="https://rdrr.io/pkg/rgl/man/par3d.html">par3d</a></span>(<span class="st">"userMatrix"</span>), <span class="fl">1.1</span><span class="op">*</span>pi<span class="op">/</span><span class="dv">4</span>, <span class="dv">0</span>, <span class="dv">0</span> ,<span class="dv">1</span>))</a></code></pre></div>
<p><img src="models-pieces-type_files/figure-html/bricks_2-1.png" width="384"></p>
</div>
</div>
<div id="bricks-from-tables" class="section level2">
<h2 class="hasAnchor">
<a href="#bricks-from-tables" class="anchor"></a>Bricks from tables</h2>
<p>Including piece options in <code><a href="../reference/bricks_from_table.html">bricks_from_table()</a></code> or <code><a href="../reference/bricks_from_excel.html">bricks_from_excel()</a></code> is slightly more involved because the input tables are two-dimensional for easier drawing.</p>
<p>In these functions, use the input <code>piece_table</code> to supply an identically shaped table with optional <code>piece_type</code> ids instead of numbers.</p>
<p>Start with this data frame called tree_or_mushroom.</p>
<div class="sourceCode" id="cb4"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb4-1" title="1">tree_or_mushroom &lt;-<span class="st"> </span>tibble<span class="op">::</span><span class="kw"><a href="https://tibble.tidyverse.org/reference/tribble.html">tribble</a></span>(</a>
<a class="sourceLine" id="cb4-2" title="2"> <span class="op">~</span>Level, <span class="op">~</span>X1, <span class="op">~</span>X2, <span class="op">~</span>X3, <span class="op">~</span>X4, <span class="op">~</span>X5, <span class="op">~</span>X6,</a>
<a class="sourceLine" id="cb4-3" title="3"> <span class="st">"A"</span>, <span class="dv">1</span>, <span class="dv">1</span>, <span class="dv">1</span>, <span class="dv">1</span>, <span class="dv">1</span>, <span class="dv">1</span>, </a>
<a class="sourceLine" id="cb4-4" title="4"> <span class="st">"A"</span>, <span class="dv">1</span>, <span class="dv">1</span>, <span class="dv">1</span>, <span class="dv">1</span>, <span class="dv">1</span>, <span class="dv">1</span>, </a>
<a class="sourceLine" id="cb4-5" title="5"> <span class="st">"A"</span>, <span class="dv">1</span>, <span class="dv">1</span>, <span class="dv">1</span>, <span class="dv">1</span>, <span class="dv">1</span>, <span class="dv">1</span>, </a>
<a class="sourceLine" id="cb4-6" title="6"> <span class="st">"A"</span>, <span class="dv">1</span>, <span class="dv">1</span>, <span class="dv">1</span>, <span class="dv">1</span>, <span class="dv">1</span>, <span class="dv">1</span>, </a>
<a class="sourceLine" id="cb4-7" title="7"> <span class="st">"B"</span>, <span class="dv">0</span>, <span class="dv">0</span>, <span class="dv">0</span>, <span class="dv">0</span>, <span class="dv">0</span>, <span class="dv">0</span>, </a>
<a class="sourceLine" id="cb4-8" title="8"> <span class="st">"B"</span>, <span class="dv">0</span>, <span class="dv">0</span>, <span class="dv">2</span>, <span class="dv">2</span>, <span class="dv">0</span>, <span class="dv">0</span>,</a>
<a class="sourceLine" id="cb4-9" title="9"> <span class="st">"B"</span>, <span class="dv">0</span>, <span class="dv">0</span>, <span class="dv">2</span>, <span class="dv">2</span>, <span class="dv">0</span>, <span class="dv">0</span>, </a>
<a class="sourceLine" id="cb4-10" title="10"> <span class="st">"B"</span>, <span class="dv">0</span>, <span class="dv">0</span>, <span class="dv">0</span>, <span class="dv">0</span>, <span class="dv">0</span>, <span class="dv">0</span>, </a>
<a class="sourceLine" id="cb4-11" title="11"> <span class="st">"C"</span>, <span class="dv">0</span>, <span class="dv">0</span>, <span class="dv">0</span>, <span class="dv">0</span>, <span class="dv">0</span>, <span class="dv">0</span>, </a>
<a class="sourceLine" id="cb4-12" title="12"> <span class="st">"C"</span>, <span class="dv">0</span>, <span class="dv">0</span>, <span class="dv">2</span>, <span class="dv">2</span>, <span class="dv">0</span>, <span class="dv">0</span>,</a>
<a class="sourceLine" id="cb4-13" title="13"> <span class="st">"C"</span>, <span class="dv">0</span>, <span class="dv">0</span>, <span class="dv">2</span>, <span class="dv">2</span>, <span class="dv">0</span>, <span class="dv">0</span>, </a>
<a class="sourceLine" id="cb4-14" title="14"> <span class="st">"C"</span>, <span class="dv">0</span>, <span class="dv">0</span>, <span class="dv">0</span>, <span class="dv">0</span>, <span class="dv">0</span>, <span class="dv">0</span>, </a>
<a class="sourceLine" id="cb4-15" title="15"> <span class="st">"D"</span>, <span class="dv">0</span>, <span class="dv">3</span>, <span class="dv">3</span>, <span class="dv">3</span>, <span class="dv">3</span>, <span class="dv">0</span>, </a>
<a class="sourceLine" id="cb4-16" title="16"> <span class="st">"D"</span>, <span class="dv">0</span>, <span class="dv">3</span>, <span class="dv">3</span>, <span class="dv">3</span>, <span class="dv">3</span>, <span class="dv">0</span>,</a>
<a class="sourceLine" id="cb4-17" title="17"> <span class="st">"D"</span>, <span class="dv">0</span>, <span class="dv">3</span>, <span class="dv">3</span>, <span class="dv">3</span>, <span class="dv">3</span>, <span class="dv">0</span>, </a>
<a class="sourceLine" id="cb4-18" title="18"> <span class="st">"D"</span>, <span class="dv">0</span>, <span class="dv">3</span>, <span class="dv">3</span>, <span class="dv">3</span>, <span class="dv">3</span>, <span class="dv">0</span>,</a>
<a class="sourceLine" id="cb4-19" title="19"> <span class="st">"E"</span>, <span class="dv">0</span>, <span class="dv">0</span>, <span class="dv">3</span>, <span class="dv">3</span>, <span class="dv">0</span>, <span class="dv">0</span>, </a>
<a class="sourceLine" id="cb4-20" title="20"> <span class="st">"E"</span>, <span class="dv">0</span>, <span class="dv">3</span>, <span class="dv">3</span>, <span class="dv">3</span>, <span class="dv">3</span>, <span class="dv">0</span>,</a>
<a class="sourceLine" id="cb4-21" title="21"> <span class="st">"E"</span>, <span class="dv">0</span>, <span class="dv">3</span>, <span class="dv">3</span>, <span class="dv">3</span>, <span class="dv">3</span>, <span class="dv">0</span>, </a>
<a class="sourceLine" id="cb4-22" title="22"> <span class="st">"E"</span>, <span class="dv">0</span>, <span class="dv">0</span>, <span class="dv">3</span>, <span class="dv">3</span>, <span class="dv">0</span>, <span class="dv">0</span>,</a>
<a class="sourceLine" id="cb4-23" title="23"> <span class="st">"F"</span>, <span class="dv">0</span>, <span class="dv">0</span>, <span class="dv">0</span>, <span class="dv">0</span>, <span class="dv">0</span>, <span class="dv">0</span>, </a>
<a class="sourceLine" id="cb4-24" title="24"> <span class="st">"F"</span>, <span class="dv">0</span>, <span class="dv">0</span>, <span class="dv">3</span>, <span class="dv">3</span>, <span class="dv">0</span>, <span class="dv">0</span>,</a>
<a class="sourceLine" id="cb4-25" title="25"> <span class="st">"F"</span>, <span class="dv">0</span>, <span class="dv">0</span>, <span class="dv">3</span>, <span class="dv">3</span>, <span class="dv">0</span>, <span class="dv">0</span>, </a>
<a class="sourceLine" id="cb4-26" title="26"> <span class="st">"F"</span>, <span class="dv">0</span>, <span class="dv">0</span>, <span class="dv">0</span>, <span class="dv">0</span>, <span class="dv">0</span>, <span class="dv">0</span>,</a>
<a class="sourceLine" id="cb4-27" title="27"> <span class="st">"G"</span>, <span class="dv">0</span>, <span class="dv">0</span>, <span class="dv">0</span>, <span class="dv">0</span>, <span class="dv">0</span>, <span class="dv">0</span>, </a>
<a class="sourceLine" id="cb4-28" title="28"> <span class="st">"G"</span>, <span class="dv">0</span>, <span class="dv">0</span>, <span class="dv">3</span>, <span class="dv">0</span>, <span class="dv">0</span>, <span class="dv">0</span>,</a>
<a class="sourceLine" id="cb4-29" title="29"> <span class="st">"G"</span>, <span class="dv">0</span>, <span class="dv">0</span>, <span class="dv">0</span>, <span class="dv">3</span>, <span class="dv">0</span>, <span class="dv">0</span>, </a>
<a class="sourceLine" id="cb4-30" title="30"> <span class="st">"G"</span>, <span class="dv">0</span>, <span class="dv">0</span>, <span class="dv">0</span>, <span class="dv">0</span>, <span class="dv">0</span>, <span class="dv">0</span></a>
<a class="sourceLine" id="cb4-31" title="31">)</a>
<a class="sourceLine" id="cb4-32" title="32"></a>
<a class="sourceLine" id="cb4-33" title="33">brick_colors &lt;-<span class="st"> </span>tibble<span class="op">::</span><span class="kw"><a href="https://tibble.tidyverse.org/reference/tribble.html">tribble</a></span>(</a>
<a class="sourceLine" id="cb4-34" title="34"> <span class="op">~</span><span class="st">`</span><span class="dt">.value</span><span class="st">`</span>, <span class="op">~</span>Color,</a>
<a class="sourceLine" id="cb4-35" title="35"> <span class="dv">1</span>, <span class="st">"Bright green"</span>,</a>
<a class="sourceLine" id="cb4-36" title="36"> <span class="dv">2</span>, <span class="st">"Dark orange"</span>,</a>
<a class="sourceLine" id="cb4-37" title="37"> <span class="dv">3</span>, <span class="st">"Dark green"</span></a>
<a class="sourceLine" id="cb4-38" title="38">)</a>
<a class="sourceLine" id="cb4-39" title="39"></a>
<a class="sourceLine" id="cb4-40" title="40">tree_or_mushroom <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb4-41" title="41"><span class="st"> </span><span class="kw"><a href="../reference/bricks_from_table.html">bricks_from_table</a></span>(brick_colors) <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb4-42" title="42"><span class="st"> </span><span class="kw"><a href="../reference/build_bricks.html">build_bricks</a></span>()</a>
<a class="sourceLine" id="cb4-43" title="43"></a>
<a class="sourceLine" id="cb4-44" title="44">rgl<span class="op">::</span><span class="kw"><a href="https://rdrr.io/pkg/rgl/man/par3d.html">par3d</a></span>(<span class="dt">userMatrix =</span> rgl<span class="op">::</span><span class="kw"><a href="https://rdrr.io/pkg/rgl/man/matrices.html">rotate3d</a></span>(rgl<span class="op">::</span><span class="kw"><a href="https://rdrr.io/pkg/rgl/man/par3d.html">par3d</a></span>(<span class="st">"userMatrix"</span>), <span class="fl">1.1</span><span class="op">*</span>pi<span class="op">/</span><span class="dv">4</span>, <span class="dv">0</span>, <span class="dv">0</span> ,<span class="dv">1</span>))</a></code></pre></div>
<p><img src="models-pieces-type_files/figure-html/bricks_5-1.png" width="384"></p>
<p>If you want more a tree with more texture, you can change all the “leaves” from rectangular bricks into cylinder bricks.</p>
<div class="sourceCode" id="cb5"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb5-1" title="1">tree_or_mushroom_pieces &lt;-<span class="st"> </span>tree_or_mushroom <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb5-2" title="2"><span class="st"> </span>dplyr<span class="op">::</span><span class="kw"><a href="https://dplyr.tidyverse.org/reference/mutate_all.html">mutate_at</a></span>(dplyr<span class="op">::</span><span class="kw"><a href="https://dplyr.tidyverse.org/reference/vars.html">vars</a></span>(dplyr<span class="op">::</span><span class="kw"><a href="https://dplyr.tidyverse.org/reference/reexports.html">starts_with</a></span>(<span class="st">"X"</span>)), </a>
<a class="sourceLine" id="cb5-3" title="3"> <span class="op">~</span><span class="kw"><a href="https://rdrr.io/r/base/ifelse.html">ifelse</a></span>(.<span class="op">==</span><span class="dv">3</span>, <span class="st">"c2"</span>, <span class="st">"b"</span>)) <span class="co">#If the color is the dark green, make a cone, else brick</span></a>
<a class="sourceLine" id="cb5-4" title="4"></a>
<a class="sourceLine" id="cb5-5" title="5">tree_or_mushroom <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb5-6" title="6"><span class="st"> </span><span class="kw"><a href="../reference/bricks_from_table.html">bricks_from_table</a></span>(brick_colors,</a>
<a class="sourceLine" id="cb5-7" title="7"> <span class="dt">piece_matrix =</span> tree_or_mushroom_pieces) <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb5-8" title="8"><span class="st"> </span><span class="kw"><a href="../reference/build_bricks.html">build_bricks</a></span>()</a>
<a class="sourceLine" id="cb5-9" title="9"></a>
<a class="sourceLine" id="cb5-10" title="10">rgl<span class="op">::</span><span class="kw"><a href="https://rdrr.io/pkg/rgl/man/par3d.html">par3d</a></span>(<span class="dt">userMatrix =</span> rgl<span class="op">::</span><span class="kw"><a href="https://rdrr.io/pkg/rgl/man/matrices.html">rotate3d</a></span>(rgl<span class="op">::</span><span class="kw"><a href="https://rdrr.io/pkg/rgl/man/par3d.html">par3d</a></span>(<span class="st">"userMatrix"</span>), <span class="fl">1.1</span><span class="op">*</span>pi<span class="op">/</span><span class="dv">4</span>, <span class="dv">0</span>, <span class="dv">0</span> ,<span class="dv">1</span>))</a></code></pre></div>
<p><img src="models-pieces-type_files/figure-html/bricks_6-1.png" width="384"></p>
<div id="bricks-from-excel" class="section level3">
<h3 class="hasAnchor">
<a href="#bricks-from-excel" class="anchor"></a>Bricks from Excel</h3>
<p>For <code><a href="../reference/bricks_from_excel.html">bricks_from_excel()</a></code>, you only have to supply <code>piece_type</code> ids when you do NOT want the classic brick. The best option here is to create your model in the Excel template in <a href="https://github.com/ryantimpe/brickr_toybox">the brickr toybox</a> GitHub repo. Once complete, duplicate the sheet and change any color values to piece_type IDs.</p>
</div>
</div>
<div id="mid-level-bricks" class="section level2">
<h2 class="hasAnchor">
<a href="#mid-level-bricks" class="anchor"></a>Mid-level bricks</h2>
<p>Because different piece types have different heights, your models might have unintentional gaps when using pieces that are less than 1-unit tall.</p>
<p>Start with this LEGO cube.</p>
<div class="sourceCode" id="cb6"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb6-1" title="1"></a>
<a class="sourceLine" id="cb6-2" title="2"><span class="kw"><a href="https://rdrr.io/r/base/expand.grid.html">expand.grid</a></span>(</a>
<a class="sourceLine" id="cb6-3" title="3"> <span class="dt">x =</span> <span class="dv">1</span><span class="op">:</span><span class="dv">3</span>,</a>
<a class="sourceLine" id="cb6-4" title="4"> <span class="dt">y =</span> <span class="dv">1</span><span class="op">:</span><span class="dv">3</span>,</a>
<a class="sourceLine" id="cb6-5" title="5"> <span class="dt">z =</span> <span class="dv">1</span><span class="op">:</span><span class="dv">3</span>,</a>
<a class="sourceLine" id="cb6-6" title="6"> <span class="dt">color =</span> <span class="st">"Bright blue"</span></a>
<a class="sourceLine" id="cb6-7" title="7">) <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb6-8" title="8"><span class="st"> </span>dplyr<span class="op">::</span><span class="kw"><a href="https://dplyr.tidyverse.org/reference/mutate.html">mutate</a></span>(<span class="dt">color =</span> <span class="kw"><a href="https://rdrr.io/r/base/ifelse.html">ifelse</a></span>(z<span class="op">==</span><span class="dv">2</span>, <span class="st">"Bright red"</span>, <span class="kw"><a href="https://rdrr.io/r/base/character.html">as.character</a></span>(color))) <span class="op">%&gt;%</span></a>
<a class="sourceLine" id="cb6-9" title="9"><span class="st"> </span><span class="kw"><a href="../reference/bricks_from_coords.html">bricks_from_coords</a></span>() <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb6-10" title="10"><span class="st"> </span><span class="kw"><a href="../reference/build_bricks.html">build_bricks</a></span>()</a>
<a class="sourceLine" id="cb6-11" title="11"></a>
<a class="sourceLine" id="cb6-12" title="12">rgl<span class="op">::</span><span class="kw"><a href="https://rdrr.io/pkg/rgl/man/par3d.html">par3d</a></span>(<span class="dt">userMatrix =</span> rgl<span class="op">::</span><span class="kw"><a href="https://rdrr.io/pkg/rgl/man/matrices.html">rotate3d</a></span>(rgl<span class="op">::</span><span class="kw"><a href="https://rdrr.io/pkg/rgl/man/par3d.html">par3d</a></span>(<span class="st">"userMatrix"</span>), <span class="fl">1.1</span><span class="op">*</span>pi<span class="op">/</span><span class="dv">4</span>, <span class="dv">0</span>, <span class="dv">0</span> ,<span class="dv">1</span>))</a></code></pre></div>
<p><img src="models-pieces-type_files/figure-html/bricks_10-1.png" width="384"></p>
<p>A problem arises when we change these bricks to plates. Each z (Level) continues to be drawn at the same height and the plates are no longer stacked together.</p>
<div class="sourceCode" id="cb7"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb7-1" title="1"></a>
<a class="sourceLine" id="cb7-2" title="2"><span class="kw"><a href="https://rdrr.io/r/base/expand.grid.html">expand.grid</a></span>(</a>
<a class="sourceLine" id="cb7-3" title="3"> <span class="dt">x =</span> <span class="dv">1</span><span class="op">:</span><span class="dv">3</span>,</a>
<a class="sourceLine" id="cb7-4" title="4"> <span class="dt">y =</span> <span class="dv">1</span><span class="op">:</span><span class="dv">3</span>,</a>
<a class="sourceLine" id="cb7-5" title="5"> <span class="dt">z =</span> <span class="dv">1</span><span class="op">:</span><span class="dv">3</span>,</a>
<a class="sourceLine" id="cb7-6" title="6"> <span class="dt">color =</span> <span class="st">"Bright blue"</span></a>
<a class="sourceLine" id="cb7-7" title="7">) <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb7-8" title="8"><span class="st"> </span>dplyr<span class="op">::</span><span class="kw"><a href="https://dplyr.tidyverse.org/reference/mutate.html">mutate</a></span>(<span class="dt">color =</span> <span class="kw"><a href="https://rdrr.io/r/base/ifelse.html">ifelse</a></span>(z<span class="op">==</span><span class="dv">2</span>, <span class="st">"Bright red"</span>, <span class="kw"><a href="https://rdrr.io/r/base/character.html">as.character</a></span>(color)),</a>
<a class="sourceLine" id="cb7-9" title="9"> <span class="dt">piece_type =</span> <span class="st">"p"</span>) <span class="op">%&gt;%</span></a>
<a class="sourceLine" id="cb7-10" title="10"><span class="st"> </span><span class="kw"><a href="../reference/bricks_from_coords.html">bricks_from_coords</a></span>() <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb7-11" title="11"><span class="st"> </span><span class="kw"><a href="../reference/build_bricks.html">build_bricks</a></span>()</a>
<a class="sourceLine" id="cb7-12" title="12"></a>
<a class="sourceLine" id="cb7-13" title="13">rgl<span class="op">::</span><span class="kw"><a href="https://rdrr.io/pkg/rgl/man/par3d.html">par3d</a></span>(<span class="dt">userMatrix =</span> rgl<span class="op">::</span><span class="kw"><a href="https://rdrr.io/pkg/rgl/man/matrices.html">rotate3d</a></span>(rgl<span class="op">::</span><span class="kw"><a href="https://rdrr.io/pkg/rgl/man/par3d.html">par3d</a></span>(<span class="st">"userMatrix"</span>), <span class="fl">1.1</span><span class="op">*</span>pi<span class="op">/</span><span class="dv">4</span>, <span class="dv">0</span>, <span class="dv">0</span> ,<span class="dv">1</span>))</a></code></pre></div>
<p><img src="models-pieces-type_files/figure-html/bricks_11-1.png" width="384"></p>
<p>Each z (Level) is the height of a brick, but plates and cheese slopes have height less than a brick. To stack consecutive bricks that are now all full height, youll need to use a new column, <code>mid_level</code>. The <code>mid_level</code> column can be added anywhere in a <code><a href="../reference/bricks_from_coords.html">bricks_from_coords()</a></code> input or as the 2nd column after <code>Level</code> in the <code>matrix_table</code> input in <code><a href="../reference/bricks_from_table.html">bricks_from_table()</a></code> or <code><a href="../reference/bricks_from_excel.html">bricks_from_excel()</a></code>.</p>
<p>By default, all bricks and pieces are located at <code>mid_level = 0</code>, which is the base of the z (Level). All z (Level) values have 3 possible mid_level values: 0, 1, 2.</p>
<p>Using integer division and mods, you can convert all levels uniformly to Level + mid_levels. In future versions of brickr, there will be helper functions.</p>
<div class="sourceCode" id="cb8"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb8-1" title="1"></a>
<a class="sourceLine" id="cb8-2" title="2"><span class="kw"><a href="https://rdrr.io/r/base/expand.grid.html">expand.grid</a></span>(</a>
<a class="sourceLine" id="cb8-3" title="3"> <span class="dt">x =</span> <span class="dv">1</span><span class="op">:</span><span class="dv">3</span>,</a>
<a class="sourceLine" id="cb8-4" title="4"> <span class="dt">y =</span> <span class="dv">1</span><span class="op">:</span><span class="dv">3</span>,</a>
<a class="sourceLine" id="cb8-5" title="5"> <span class="dt">z =</span> <span class="dv">1</span><span class="op">:</span><span class="dv">3</span>,</a>
<a class="sourceLine" id="cb8-6" title="6"> <span class="dt">color =</span> <span class="st">"Bright blue"</span></a>
<a class="sourceLine" id="cb8-7" title="7">) <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb8-8" title="8"><span class="st"> </span>dplyr<span class="op">::</span><span class="kw"><a href="https://dplyr.tidyverse.org/reference/mutate.html">mutate</a></span>(<span class="dt">color =</span> <span class="kw"><a href="https://rdrr.io/r/base/ifelse.html">ifelse</a></span>(z<span class="op">==</span><span class="dv">2</span>, <span class="st">"Bright red"</span>, <span class="kw"><a href="https://rdrr.io/r/base/character.html">as.character</a></span>(color)),</a>
<a class="sourceLine" id="cb8-9" title="9"> <span class="dt">piece_type =</span> <span class="st">"p"</span>) <span class="op">%&gt;%</span></a>
<a class="sourceLine" id="cb8-10" title="10"><span class="st"> </span>dplyr<span class="op">::</span><span class="kw"><a href="https://dplyr.tidyverse.org/reference/mutate.html">mutate</a></span>(<span class="dt">mid_level =</span> (z<span class="dv">-1</span>) <span class="op">%%</span><span class="st"> </span><span class="dv">3</span>,</a>
<a class="sourceLine" id="cb8-11" title="11"> <span class="dt">z =</span> (z<span class="dv">-1</span>) <span class="op">%/%</span><span class="st"> </span><span class="dv">3</span> <span class="op">+</span><span class="dv">1</span>) <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb8-12" title="12"><span class="st"> </span><span class="kw"><a href="../reference/bricks_from_coords.html">bricks_from_coords</a></span>() <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb8-13" title="13"><span class="st"> </span><span class="kw"><a href="../reference/build_bricks.html">build_bricks</a></span>()</a>
<a class="sourceLine" id="cb8-14" title="14"></a>
<a class="sourceLine" id="cb8-15" title="15">rgl<span class="op">::</span><span class="kw"><a href="https://rdrr.io/pkg/rgl/man/par3d.html">par3d</a></span>(<span class="dt">userMatrix =</span> rgl<span class="op">::</span><span class="kw"><a href="https://rdrr.io/pkg/rgl/man/matrices.html">rotate3d</a></span>(rgl<span class="op">::</span><span class="kw"><a href="https://rdrr.io/pkg/rgl/man/par3d.html">par3d</a></span>(<span class="st">"userMatrix"</span>), <span class="fl">1.1</span><span class="op">*</span>pi<span class="op">/</span><span class="dv">4</span>, <span class="dv">0</span>, <span class="dv">0</span> ,<span class="dv">1</span>))</a></code></pre></div>
<p><img src="models-pieces-type_files/figure-html/bricks_12-1.png" width="384"></p>
<p>Its also possible to mix and match different z (Level) and mid_level combinations to stack plates with bricks. There are various ways to do this, depending on the complexity and your comfort with tidyverse data manipulation.</p>
<div class="sourceCode" id="cb9"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb9-1" title="1"></a>
<a class="sourceLine" id="cb9-2" title="2"><span class="kw"><a href="https://rdrr.io/r/base/expand.grid.html">expand.grid</a></span>(</a>
<a class="sourceLine" id="cb9-3" title="3"> <span class="dt">x =</span> <span class="dv">1</span><span class="op">:</span><span class="dv">3</span>,</a>
<a class="sourceLine" id="cb9-4" title="4"> <span class="dt">y =</span> <span class="dv">1</span><span class="op">:</span><span class="dv">3</span>,</a>
<a class="sourceLine" id="cb9-5" title="5"> <span class="dt">z =</span> <span class="dv">1</span><span class="op">:</span><span class="dv">3</span>,</a>
<a class="sourceLine" id="cb9-6" title="6"> <span class="dt">color =</span> <span class="st">"Bright blue"</span></a>
<a class="sourceLine" id="cb9-7" title="7">) <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb9-8" title="8"><span class="st"> </span>dplyr<span class="op">::</span><span class="kw"><a href="https://dplyr.tidyverse.org/reference/mutate.html">mutate</a></span>(<span class="dt">color =</span> <span class="kw"><a href="https://rdrr.io/r/base/ifelse.html">ifelse</a></span>(z<span class="op">==</span><span class="dv">2</span>, <span class="st">"Bright red"</span>, <span class="kw"><a href="https://rdrr.io/r/base/character.html">as.character</a></span>(color)),</a>
<a class="sourceLine" id="cb9-9" title="9"> <span class="dt">piece_type =</span> <span class="kw"><a href="https://rdrr.io/r/base/ifelse.html">ifelse</a></span>(z<span class="op">==</span><span class="dv">2</span>, <span class="st">"p"</span>, <span class="st">"b"</span>)) <span class="op">%&gt;%</span></a>
<a class="sourceLine" id="cb9-10" title="10"><span class="st"> </span>dplyr<span class="op">::</span><span class="kw"><a href="https://dplyr.tidyverse.org/reference/mutate.html">mutate</a></span>(</a>
<a class="sourceLine" id="cb9-11" title="11"> <span class="dt">mid_level =</span> dplyr<span class="op">::</span><span class="kw"><a href="https://dplyr.tidyverse.org/reference/case_when.html">case_when</a></span>(</a>
<a class="sourceLine" id="cb9-12" title="12"> z <span class="op">%in%</span><span class="st"> </span><span class="dv">1</span><span class="op">:</span><span class="dv">2</span> <span class="op">~</span><span class="st"> </span><span class="dv">0</span>, </a>
<a class="sourceLine" id="cb9-13" title="13"> z <span class="op">==</span><span class="st"> </span><span class="dv">3</span> <span class="op">~</span><span class="st"> </span><span class="dv">1</span></a>
<a class="sourceLine" id="cb9-14" title="14"> ), </a>
<a class="sourceLine" id="cb9-15" title="15"> <span class="dt">z =</span> dplyr<span class="op">::</span><span class="kw"><a href="https://dplyr.tidyverse.org/reference/case_when.html">case_when</a></span>(</a>
<a class="sourceLine" id="cb9-16" title="16"> z <span class="op">%in%</span><span class="st"> </span><span class="dv">2</span><span class="op">:</span><span class="dv">3</span> <span class="op">~</span><span class="st"> </span><span class="dv">2</span>,</a>
<a class="sourceLine" id="cb9-17" title="17"> <span class="ot">TRUE</span> <span class="op">~</span><span class="st"> </span><span class="dv">1</span></a>
<a class="sourceLine" id="cb9-18" title="18"> )) <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb9-19" title="19"><span class="st"> </span><span class="kw"><a href="../reference/bricks_from_coords.html">bricks_from_coords</a></span>() <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb9-20" title="20"><span class="st"> </span><span class="kw"><a href="../reference/build_bricks.html">build_bricks</a></span>()</a>
<a class="sourceLine" id="cb9-21" title="21"></a>
<a class="sourceLine" id="cb9-22" title="22">rgl<span class="op">::</span><span class="kw"><a href="https://rdrr.io/pkg/rgl/man/par3d.html">par3d</a></span>(<span class="dt">userMatrix =</span> rgl<span class="op">::</span><span class="kw"><a href="https://rdrr.io/pkg/rgl/man/matrices.html">rotate3d</a></span>(rgl<span class="op">::</span><span class="kw"><a href="https://rdrr.io/pkg/rgl/man/par3d.html">par3d</a></span>(<span class="st">"userMatrix"</span>), <span class="fl">1.1</span><span class="op">*</span>pi<span class="op">/</span><span class="dv">4</span>, <span class="dv">0</span>, <span class="dv">0</span> ,<span class="dv">1</span>))</a></code></pre></div>
<p><img src="models-pieces-type_files/figure-html/bricks_13-1.png" width="384"></p>
</div>
</div>
<div class="col-md-3 hidden-xs hidden-sm" id="sidebar">
<div id="tocnav">
<h2 class="hasAnchor">
<a href="#tocnav" class="anchor"></a>Contents</h2>
<ul class="nav nav-pills nav-stacked">
<li><a href="#getting-started">Getting started</a></li>
<li><a href="#all-piece-options">All piece options</a></li>
<li><a href="#bricks-from-coordinates">Bricks from coordinates</a></li>
<li><a href="#bricks-from-tables">Bricks from tables</a></li>
<li><a href="#mid-level-bricks">Mid-level bricks</a></li>
</ul>
</div>
</div>
</div>
<footer><div class="copyright">
<p>Developed by Ryan Timpe.</p>
</div>
<div class="pkgdown">
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.4.1.</p>
</div>
</footer>
</div>
</body>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

View File

@@ -39,7 +39,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">brickr</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.2.0</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.3.0</span>
</span>
</div>
@@ -62,10 +62,7 @@
</a>
<ul class="dropdown-menu" role="menu">
<li>
<a href="../articles/graphs.html">ggplot with brickr</a>
</li>
<li>
<a href="../articles/models-from-other.html">3D Models from mosaics &amp; rayshader</a>
<a href="../articles/models-from-other.html">3D Models from mosaics</a>
</li>
<li>
<a href="../articles/models-from-program.html">3D Models programmatically</a>
@@ -73,6 +70,9 @@
<li>
<a href="../articles/models-from-tables.html">3D models from tables</a>
</li>
<li>
<a href="../articles/models-piece-type.html">Piece type in 3D Models</a>
</li>
<li>
<a href="../articles/mosaics.html">Mosaics with brickr</a>
</li>
@@ -134,7 +134,7 @@
<div id="colors" class="section level2">
<h2 class="hasAnchor">
<a href="#colors" class="anchor"></a>Colors</h2>
<p>A key feature in <code><a href="../reference/image_to_mosaic.html">image_to_mosaic()</a></code> is the conversion of the original image into colors produced by LEGO. The default is to map each individual pixel to any of the 41 solid brick colors currently produced by LEGO useing the <a href="https://en.wikipedia.org/wiki/Color_difference#CIE94">CIE94</a> algorithm. These defaults can be changed.</p>
<p>A key feature in <code><a href="../reference/image_to_mosaic.html">image_to_mosaic()</a></code> is the conversion of the original image into colors produced by LEGO. The default is to map each individual pixel to any of the 41 solid brick colors currently produced by LEGO using the <a href="https://en.wikipedia.org/wiki/Color_difference#CIE94">CIE94</a> algorithm. These defaults can be changed.</p>
<div id="color-palettes" class="section level3">
<h3 class="hasAnchor">
<a href="#color-palettes" class="anchor"></a>Color palettes</h3>
@@ -224,11 +224,11 @@
<div id="d-mosaics" class="section level2">
<h2 class="hasAnchor">
<a href="#d-mosaics" class="anchor"></a>3D Mosaics</h2>
<p>With <a href="https://www.rayshader.com/">rayshader</a> installed, passing the mosaic object to <code><a href="../reference/bricks_from_mosaic.html">bricks_from_mosaic()</a></code> 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 <code>highest_el = 'dark'</code> option.</p>
<p>Passing the mosaic object to <code><a href="../reference/bricks_from_mosaic.html">bricks_from_mosaic()</a></code> 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 <code>highest_el = 'dark'</code> option.</p>
<div class="sourceCode" id="cb8"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb8-1" title="1">png<span class="op">::</span><span class="kw"><a href="https://rdrr.io/pkg/png/man/readPNG.html">readPNG</a></span>(demo_img) <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb8-2" title="2"><span class="st"> </span><span class="kw"><a href="../reference/image_to_mosaic.html">image_to_mosaic</a></span>(<span class="dv">32</span>) <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb8-3" title="3"><span class="st"> </span><span class="kw"><a href="../reference/bricks_from_mosaic.html">bricks_from_mosaic</a></span>(<span class="dt">highest_el =</span> <span class="st">"dark"</span>) <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb8-4" title="4"><span class="st"> </span><span class="kw"><a href="../reference/build_bricks.html">build_bricks</a></span>()</a>
<a class="sourceLine" id="cb8-4" title="4"><span class="st"> </span><span class="kw"><a href="../reference/build_bricks.html">build_bricks</a></span>(<span class="dt">outline_bricks =</span> <span class="ot">TRUE</span>, <span class="dt">rgl_lit =</span> <span class="ot">FALSE</span>)</a>
<a class="sourceLine" id="cb8-5" title="5"></a>
<a class="sourceLine" id="cb8-6" title="6"><span class="co">#From dput(round(rgl::par3d("userMatrix"),1)) after manual rotation</span></a>
<a class="sourceLine" id="cb8-7" title="7">custom_rotation &lt;-<span class="st"> </span><span class="kw"><a href="https://rdrr.io/r/base/structure.html">structure</a></span>(<span class="kw"><a href="https://rdrr.io/r/base/c.html">c</a></span>(<span class="fl">0.9</span>, <span class="fl">0.3</span>, <span class="fl">-0.3</span>, <span class="dv">0</span>, <span class="fl">-0.3</span>, <span class="fl">0.9</span>, <span class="fl">-0.3</span>, </a>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 49 KiB

After

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 53 KiB

After

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 171 KiB

After

Width:  |  Height:  |  Size: 174 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 222 KiB

After

Width:  |  Height:  |  Size: 188 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 43 KiB

After

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 171 KiB

After

Width:  |  Height:  |  Size: 183 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 56 KiB

After

Width:  |  Height:  |  Size: 59 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 61 KiB

After

Width:  |  Height:  |  Size: 63 KiB

View File

@@ -78,7 +78,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="index.html">brickr</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.2.0.9003</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.3.0</span>
</span>
</div>
@@ -101,10 +101,7 @@
</a>
<ul class="dropdown-menu" role="menu">
<li>
<a href="articles/graphs.html">ggplot with brickr</a>
</li>
<li>
<a href="articles/models-from-other.html">3D Models from mosaics &amp; rayshader</a>
<a href="articles/models-from-other.html">3D Models from mosaics</a>
</li>
<li>
<a href="articles/models-from-program.html">3D Models programmatically</a>
@@ -112,6 +109,9 @@
<li>
<a href="articles/models-from-tables.html">3D models from tables</a>
</li>
<li>
<a href="articles/models-piece-type.html">Piece type in 3D Models</a>
</li>
<li>
<a href="articles/mosaics.html">Mosaics with brickr</a>
</li>

View File

@@ -5,7 +5,7 @@
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Tools to emulate the LEGO® System in R • brickr</title>
<title>Tools to Emulate the LEGO® System in R • brickr</title>
<!-- favicons --><link rel="icon" type="image/png" sizes="16x16" href="favicon-16x16.png">
<link rel="icon" type="image/png" sizes="32x32" href="favicon-32x32.png">
<link rel="apple-touch-icon" type="image/png" sizes="180x180" href="apple-touch-icon.png">
@@ -17,10 +17,11 @@
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.7.1/css/v4-shims.min.css" integrity="sha256-6qHlizsOWFskGlwVOKuns+D1nB6ssZrHQrNj1wGplHc=" crossorigin="anonymous">
<!-- clipboard.js --><script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.4/clipboard.min.js" integrity="sha256-FiZwavyI2V6+EXO1U+xzLG3IKldpiTFf3153ea9zikQ=" crossorigin="anonymous"></script><!-- headroom.js --><script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.9.4/headroom.min.js" integrity="sha256-DJFC1kqIhelURkuza0AvYal5RxMtpzLjFhsnVIeuk+U=" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.9.4/jQuery.headroom.min.js" integrity="sha256-ZX/yNShbjqsohH1k95liqY9Gd8uOiE1S4vZc+9KQ1K4=" crossorigin="anonymous"></script><!-- pkgdown --><link href="pkgdown.css" rel="stylesheet">
<script src="pkgdown.js"></script><link href="extra.css" rel="stylesheet">
<meta property="og:title" content="Tools to emulate the LEGO® System in R">
<meta property="og:title" content="Tools to Emulate the LEGO® System in R">
<meta property="og:description" content="
Generate digital LEGO-esque models using tidyverse functions. Convert image files into 2D and 3D mosaics, along with piece counts and instructions.
Build 3D models using data frames with rgl. Create brick bar charts with ggplot2.">
Generate digital LEGO models using tidyverse functions.
Convert image files into 2D and 3D LEGO mosaics, complete with piece counts and instructions.
Render 3D models using simple data frame instructions.">
<meta property="og:image" content="http://brickr.org/logo.png">
<meta name="twitter:card" content="summary">
<!-- mathjax --><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js" integrity="sha256-nvJJv9wWKEm88qvoQl9ekL2J+k/RWIsaSScxxlsrv8k=" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/config/TeX-AMS-MML_HTMLorMML.js" integrity="sha256-84DKXVJXs0/F8OTMzX4UR909+jtl4G7SPypPavF+GfA=" crossorigin="anonymous"></script><!--[if lt IE 9]>
@@ -41,7 +42,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="index.html">brickr</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.2.0.9003</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.3.0</span>
</span>
</div>
@@ -64,10 +65,7 @@
</a>
<ul class="dropdown-menu" role="menu">
<li>
<a href="articles/graphs.html">ggplot with brickr</a>
</li>
<li>
<a href="articles/models-from-other.html">3D Models from mosaics &amp; rayshader</a>
<a href="articles/models-from-other.html">3D Models from mosaics</a>
</li>
<li>
<a href="articles/models-from-program.html">3D Models programmatically</a>
@@ -75,6 +73,9 @@
<li>
<a href="articles/models-from-tables.html">3D models from tables</a>
</li>
<li>
<a href="articles/models-piece-type.html">Piece type in 3D Models</a>
</li>
<li>
<a href="articles/mosaics.html">Mosaics with brickr</a>
</li>
@@ -118,38 +119,33 @@
<h2 class="hasAnchor">
<a href="#overview" class="anchor"></a>Overview</h2>
<p><strong>brickr</strong> is a package for bringing the LEGO® experience into the R and <a href="https://www.tidyverse.org/">tidyverse</a> ecosystem.</p>
<p>The package is divided into 3 separate systems:</p>
<p>The package is divided into 2 systems:</p>
<ul>
<li>
<a href="#mosaics"><strong>Mosaics</strong></a>: Convert image files into mosaics that could be built using LEGO® bricks.</li>
<a href="#mosaics"><strong>Mosaics</strong></a>: Convert image files into mosaics that could be built using LEGO bricks.</li>
<li>
<a href="#3d-models"><strong>3D Models</strong></a>: Build 3D LEGO® models from data tables using <a href="https://cran.r-project.org/web/packages/rgl/index.html">rgl</a>.</li>
<li>
<a href="#charts"><strong>Charts</strong></a>: A <a href="https://ggplot2.tidyverse.org/">ggplot2</a> extension to generate plots that resemble LEGO® bricks.</li>
<a href="#3d-models"><strong>3D Models</strong></a>: Build 3D LEGO models from data tables using <a href="https://cran.r-project.org/web/packages/rgl/index.html">rgl</a>.</li>
</ul>
<p>brickr also includes tools help users create the Mosaics and 3D model output using real LEGO® elements.</p>
<p>brickr also includes tools help users create the Mosaics and 3D model output using real LEGO elements.</p>
<p>Check out <a href="http://brickr.org">brickr.org</a> for more detail!</p>
<div id="whats-the-point" class="section level3">
<h3 class="hasAnchor">
<a href="#whats-the-point" class="anchor"></a>Whats the point?</h3>
<p>The goal of <strong>brickr</strong> is to provide a series of tools to integrate the LEGO® system with R by:</p>
<p>The goal of <strong>brickr</strong> is to provide a series of tools to integrate the LEGO system with R by:</p>
<ul>
<li>Enhancing a real world building experience with mosaics, generated instructions, and piece counts.</li>
<li>Generating interest in R and coding for new audiences with easy-to-create 3D models.</li>
<li>or just embracing pure novelty.</li>
<li>Embracing pure novelty.</li>
</ul>
<p><em>brickr is developed under the <a href="https://www.lego.com/en-us/legal/notices-and-policies/fair-play/">Fair Play</a> policy using publicly available information about LEGO® products. brickr is not affiliated with The LEGO Group.</em></p>
<p><em>brickr is developed under the <a href="https://www.lego.com/en-us/legal/notices-and-policies/fair-play/">Fair Play</a> policy using publicly available information about LEGO products. brickr is not affiliated with The LEGO Group.</em></p>
</div>
</div>
<div id="installation" class="section level2">
<h2 class="hasAnchor">
<a href="#installation" class="anchor"></a>Installation</h2>
<div class="sourceCode" id="cb1"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb1-1" title="1"><span class="co"># To install the latest version from Github:</span></a>
<a class="sourceLine" id="cb1-2" title="2"><span class="co"># install.packages("devtools")</span></a>
<a class="sourceLine" id="cb1-3" title="3">devtools<span class="op">::</span><span class="kw"><a href="https://rdrr.io/pkg/devtools/man/remote-reexports.html">install_github</a></span>(<span class="st">"ryantimpe/brickr"</span>)</a>
<a class="sourceLine" id="cb1-4" title="4"></a>
<a class="sourceLine" id="cb1-5" title="5"><span class="co">#For 3D features, rayshader is also required.</span></a>
<a class="sourceLine" id="cb1-6" title="6"><span class="kw"><a href="https://rdrr.io/r/utils/install.packages.html">install.packages</a></span>(<span class="st">"rayshader"</span>)</a></code></pre></div>
<a class="sourceLine" id="cb1-2" title="2"><span class="co"># install.packages("remotes")</span></a>
<a class="sourceLine" id="cb1-3" title="3">remotes<span class="op">::</span><span class="kw"><a href="https://rdrr.io/pkg/remotes/man/install_github.html">install_github</a></span>(<span class="st">"ryantimpe/brickr"</span>)</a></code></pre></div>
</div>
<div id="mosaics" class="section level2">
<h2 class="hasAnchor">
@@ -182,10 +178,10 @@
<p>The <code>bricks_from_*</code> series of functions creates 3D models of LEGO bricks from a variety of input formats.</p>
<ul>
<li><p><code><a href="reference/bricks_from_table.html">bricks_from_table()</a></code> &amp; <code><a href="reference/bricks_from_excel.html">bricks_from_excel()</a></code> convert a matrix-shaped table of integers into LEGO bricks. For simple models, this table can be made manually using <code><a href="https://rdrr.io/r/base/data.frame.html">data.frame()</a></code> or <code><a href="https://tibble.tidyverse.org/reference/tribble.html">tibble::tribble()</a></code>. For more advanced models, its recommended you use MS Excel or a .csv file. The left-most column in the table is associated with the Level or z-axis of the model. <code><a href="reference/bricks_from_excel.html">bricks_from_excel()</a></code> is a wrapper function to more easily build models designed using a Microsoft Excel template. Please see this repo: <a href="https://github.com/ryantimpe/brickr_toybox">brickr toybox</a>.</p></li>
<li><p><code><a href="reference/bricks_from_coords.html">bricks_from_coords()</a></code> takes a data frame with <code>x</code>, <code>y</code>, &amp; <code>z</code> integer values, and <code>Color</code> columns, where each combination of x, y, &amp; z is a point in 3-dimensional space. Color must be an official LEGO color name from <code><a href="reference/build_colors.html">build_colors()</a></code>. This format is much more flexible than <code><a href="reference/bricks_from_table.html">bricks_from_table()</a></code> and allows the programmatic development of 3D models.</p></li>
<li><p><code><a href="reference/bricks_from_mosaic.html">bricks_from_mosaic()</a></code> converts a 2D <a href="#mosaics">mosaic</a> object from an image into 3D LEGO models, respectively. <code><a href="reference/bricks_from_rayshader.html">bricks_from_rayshader()</a></code> creates a LEGO model from the same input as <code><a href="https://rdrr.io/pkg/rayshader/man/plot_3d.html">rayshader::plot_3d()</a></code>.</p></li>
<li><p><code><a href="reference/bricks_from_coords.html">bricks_from_coords()</a></code> takes a data frame with <code>x</code>, <code>y</code>, &amp; <code>z</code> integer values, and <code>Color</code> columns, where each combination of x, y, &amp; z is a point in 3-dimensional space. Color must be an official LEGO color name from <code><a href="reference/build_colors.html">build_colors()</a></code>. This format is much more flexible than <code><a href="reference/bricks_from_table.html">bricks_from_table()</a></code> and allows the programmatic development of 3D models. For other options, see the “Piece type in 3D Models” vignette.</p></li>
<li><p><code><a href="reference/bricks_from_mosaic.html">bricks_from_mosaic()</a></code> converts a 2D <a href="#mosaics">mosaic</a> object from an image into 3D LEGO models, respectively.</p></li>
</ul>
<p>Pass the output from any <code>bricks_from_*()</code> function to <code><a href="reference/build_bricks.html">build_bricks()</a></code> to see the 3D model. Models are currently rendered in <strong>rgl</strong>. Previous versions of brickr use <a href="https://twitter.com/tylermorganwall">Tyler Morgan-Wall</a>s <a href="https://www.rayshader.com/">rayshader</a> package. This option is still available by passing the output from any <code>bricks_from_*()</code> function to <code><a href="reference/build_bricks_rayshader.html">build_bricks_rayshader()</a></code>. Rayshader can still be used for saving snapshots and creating animations.</p>
<p>Pass the output from any <code>bricks_from_*()</code> function to <code><a href="reference/build_bricks.html">build_bricks()</a></code> to see the 3D model. Models are rendered in <strong>rgl</strong>.</p>
<div class="sourceCode" id="cb3"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb3-1" title="1"><span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span>(brickr)</a>
<a class="sourceLine" id="cb3-2" title="2"></a>
<a class="sourceLine" id="cb3-3" title="3"><span class="co">#This is a brick</span></a>
@@ -280,41 +276,12 @@
<p>More examples using <code><a href="reference/bricks_from_table.html">bricks_from_table()</a></code> and <code><a href="reference/bricks_from_coords.html">bricks_from_coords()</a></code> can be found at the links below.</p>
<ul>
<li>
<a href="https://gist.github.com/ryantimpe/a784beaa4f798f57010369329d46ce71"><strong>Get started</strong></a> with the framework for building a brick from scratch.</li>
<li>
<a href="https://gist.github.com/ryantimpe/ceab2ed6b8a4737077280fc9b0d1c886"><strong>Build an owl</strong></a> with <code><a href="reference/bricks_from_table.html">bricks_from_table()</a></code> by manually placing each brick.</li>
<li>Generate a punny <a href="https://gist.github.com/ryantimpe/a7363a5e99dceabada150a43925beec7"><strong>random forest model</strong></a> using <code><a href="reference/bricks_from_coords.html">bricks_from_coords()</a></code> and {purrr}.</li>
<a href="https://gist.github.com/ryantimpe/3893fdd0f94138d027bae35bf38b57c7"><strong>Baby Yoda</strong></a> example using <code><a href="reference/bricks_from_excel.html">bricks_from_excel()</a></code> with an animation.</li>
<li>
<a href="https://github.com/ryantimpe/brickr_toybox"><strong>brickr toybox</strong></a> repo for tools and resources to get started.</li>
</ul>
</div>
</div>
<div id="charts" class="section level2">
<h2 class="hasAnchor">
<a href="#charts" class="anchor"></a>Charts</h2>
<p>brickr includes functions to render <a href="https://ggplot2.tidyverse.org/">ggplot2</a> bar charts as bricks with LEGO color themes. The main function is <code><a href="reference/geom_brick_col.html">geom_brick_col()</a></code>, which is the brickr equivalent of <code>geom_col()</code>. Additional functions are highly recommended to ensure that proper the chart is rendered in the proper functions and proportions.</p>
<div class="sourceCode" id="cb6"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb6-1" title="1">df &lt;-<span class="st"> </span><span class="kw"><a href="https://rdrr.io/r/base/data.frame.html">data.frame</a></span>(<span class="dt">trt =</span> <span class="kw"><a href="https://rdrr.io/r/base/c.html">c</a></span>(<span class="st">"a"</span>, <span class="st">"b"</span>, <span class="st">"c"</span>), <span class="dt">outcome =</span> <span class="kw"><a href="https://rdrr.io/r/base/c.html">c</a></span>(<span class="fl">2.3</span>, <span class="fl">1.9</span>, <span class="fl">3.2</span>))</a>
<a class="sourceLine" id="cb6-2" title="2"></a>
<a class="sourceLine" id="cb6-3" title="3"><span class="co">#For official LEGO colors, use with scale_fill_brick and theme_brick.</span></a>
<a class="sourceLine" id="cb6-4" title="4"><span class="kw">ggplot</span>(df, <span class="kw">aes</span>(trt, outcome)) <span class="op">+</span></a>
<a class="sourceLine" id="cb6-5" title="5"><span class="st"> </span><span class="kw"><a href="reference/geom_brick_col.html">geom_brick_col</a></span>(<span class="kw">aes</span>(<span class="dt">fill =</span> trt)) <span class="op">+</span></a>
<a class="sourceLine" id="cb6-6" title="6"><span class="st"> </span><span class="kw"><a href="reference/scale_fill_brick.html">scale_fill_brick</a></span>() <span class="op">+</span></a>
<a class="sourceLine" id="cb6-7" title="7"><span class="st"> </span><span class="kw"><a href="reference/coord-brick.html">coord_brick</a></span>() <span class="op">+</span></a>
<a class="sourceLine" id="cb6-8" title="8"><span class="st"> </span><span class="kw"><a href="reference/theme_brick.html">theme_brick</a></span>()</a></code></pre></div>
<p><img src="README_files/figure-gfm/geom_brick-1.png"><!-- --></p>
<p>Both <code><a href="reference/scale_fill_brick.html">scale_fill_brick()</a></code> and <code><a href="reference/theme_brick.html">theme_brick()</a></code> take an input brick_theme, which ensures all colors match official LEGO brick colors. See <code><a href="reference/build_themes.html">build_themes()</a></code> for a sample of all available brick theme.</p>
<div class="sourceCode" id="cb7"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb7-1" title="1">df &lt;-<span class="st"> </span><span class="kw"><a href="https://rdrr.io/r/base/data.frame.html">data.frame</a></span>(<span class="dt">trt =</span> letters[<span class="dv">1</span><span class="op">:</span><span class="dv">6</span>], <span class="dt">outcome =</span> <span class="kw"><a href="https://rdrr.io/r/stats/Normal.html">rnorm</a></span>(<span class="dv">6</span>, <span class="dt">mean =</span> <span class="dv">5</span>, <span class="dt">sd =</span> <span class="dv">2</span>))</a>
<a class="sourceLine" id="cb7-2" title="2"></a>
<a class="sourceLine" id="cb7-3" title="3">use_theme &lt;-<span class="st"> "hp"</span></a>
<a class="sourceLine" id="cb7-4" title="4"></a>
<a class="sourceLine" id="cb7-5" title="5"><span class="kw">ggplot</span>(df, <span class="kw">aes</span>(trt, outcome)) <span class="op">+</span></a>
<a class="sourceLine" id="cb7-6" title="6"><span class="st"> </span><span class="kw"><a href="reference/geom_brick_col.html">geom_brick_col</a></span>(<span class="kw">aes</span>(<span class="dt">fill =</span> trt), <span class="dt">two_knob =</span> F) <span class="op">+</span></a>
<a class="sourceLine" id="cb7-7" title="7"><span class="st"> </span><span class="kw"><a href="reference/scale_fill_brick.html">scale_fill_brick</a></span>(use_theme) <span class="op">+</span></a>
<a class="sourceLine" id="cb7-8" title="8"><span class="st"> </span><span class="kw"><a href="reference/coord-brick.html">coord_brick_flip</a></span>() <span class="op">+</span></a>
<a class="sourceLine" id="cb7-9" title="9"><span class="st"> </span><span class="kw"><a href="reference/theme_brick.html">theme_brick</a></span>(use_theme) <span class="op">+</span></a>
<a class="sourceLine" id="cb7-10" title="10"><span class="st"> </span><span class="kw">theme</span>(<span class="dt">legend.position =</span> <span class="st">"none"</span>)</a></code></pre></div>
<p><img src="README_files/figure-gfm/geom_brick2-1.png"><!-- --></p>
</div>
<div id="irl" class="section level2">
<h2 class="hasAnchor">
<a href="#irl" class="anchor"></a>IRL</h2>
@@ -323,17 +290,23 @@
<h3 class="hasAnchor">
<a href="#instructions" class="anchor"></a>Instructions</h3>
<p>Use <code><a href="reference/build_instructions.html">build_instructions()</a></code> 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.</p>
<div class="sourceCode" id="cb8"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb8-1" title="1">mosaic1 <span class="op">%&gt;%</span><span class="st"> </span><span class="kw"><a href="reference/build_instructions.html">build_instructions</a></span>(<span class="dv">9</span>)</a></code></pre></div>
<div class="sourceCode" id="cb6"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb6-1" title="1">mosaic1 <span class="op">%&gt;%</span><span class="st"> </span><span class="kw"><a href="reference/build_instructions.html">build_instructions</a></span>(<span class="dv">9</span>)</a></code></pre></div>
<p><img src="README_files/figure-gfm/m1_instructions-1.png"><!-- --></p>
</div>
<div id="piece-list-and-count" class="section level3">
<h3 class="hasAnchor">
<a href="#piece-list-and-count" class="anchor"></a>Piece list and count</h3>
<p>Use <code><a href="reference/build_pieces.html">build_pieces()</a></code> 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.coms <a href="https://shop.lego.com/en-US/Pick-a-Brick">Pick-a-Brick</a> section using the advanced search option. Alternatively, use <code>table_pieces()</code> to produce a data frame table of all required bricks.</p>
<div class="sourceCode" id="cb9"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb9-1" title="1">mosaic1 <span class="op">%&gt;%</span><span class="st"> </span><span class="kw"><a href="reference/build_pieces.html">build_pieces</a></span>()</a></code></pre></div>
<div class="sourceCode" id="cb7"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb7-1" title="1">mosaic1 <span class="op">%&gt;%</span><span class="st"> </span><span class="kw"><a href="reference/build_pieces.html">build_pieces</a></span>()</a></code></pre></div>
<p><img src="README_files/figure-gfm/m1_pieces-1.png"><!-- --></p>
</div>
</div>
<div id="acknowledgments" class="section level2">
<h2 class="hasAnchor">
<a href="#acknowledgments" class="anchor"></a>Acknowledgments</h2>
<p>3D models in brickr would not exist without <a href="https://twitter.com/tylermorganwall">Tyler Morgan-Wall</a> and his <a href="https://www.rayshader.com/">rayshader</a> package. If youre interested in creating 3D models of literally <em>anything</em> R, check out his <a href="https://www.rayrender.net/">rayrender</a> package.</p>
<p>All functions in brickr are created with the <a href="https://www.tidyverse.org/">tidyverse</a> and <a href="https://cran.r-project.org/web/packages/rgl/index.html">rgl</a>.</p>
</div>
</div>
</div>
@@ -352,7 +325,7 @@
<h2>License</h2>
<ul class="list-unstyled">
<li><a href="LICENSE.html">Full license</a></li>
<li><small><a href="https://www.r-project.org/Licenses/GPL-3">GPL-3</a></small></li>
<li><small><a href="https://opensource.org/licenses/mit-license.php">MIT</a> + file <a href="LICENSE-text.html">LICENSE</a></small></li>
</ul>
</div>
<div class="developers">

View File

@@ -78,7 +78,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">brickr</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.2.0</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.3.0</span>
</span>
</div>
@@ -101,10 +101,7 @@
</a>
<ul class="dropdown-menu" role="menu">
<li>
<a href="../articles/graphs.html">ggplot with brickr</a>
</li>
<li>
<a href="../articles/models-from-other.html">3D Models from mosaics &amp; rayshader</a>
<a href="../articles/models-from-other.html">3D Models from mosaics</a>
</li>
<li>
<a href="../articles/models-from-program.html">3D Models programmatically</a>
@@ -112,6 +109,9 @@
<li>
<a href="../articles/models-from-tables.html">3D models from tables</a>
</li>
<li>
<a href="../articles/models-piece-type.html">Piece type in 3D Models</a>
</li>
<li>
<a href="../articles/mosaics.html">Mosaics with brickr</a>
</li>
@@ -145,9 +145,44 @@
<small>Source: <a href='https://github.com/ryantimpe/brickr/blob/master/NEWS.md'><code>NEWS.md</code></a></small>
</div>
<div id="brickr-020" class="section level1">
<div id="brickr-030---aka-pirate-ship" class="section level1">
<h1 class="page-header">
<a href="#brickr-020" class="anchor"></a>brickr 0.2.0</h1>
<a href="#brickr-030---aka-pirate-ship" class="anchor"></a>brickr 0.3.0 - a.k.a. <a href="">Pirate ship</a>
</h1>
<ul>
<li><p>An overall leaner package to ensure optimal performance and remove experimental features.</p></li>
<li><p>Updated documentation to increase accessibility and usability.</p></li>
</ul>
<div id="3d-models" class="section level2">
<h2 class="hasAnchor">
<a href="<a href='https://github.com/ryantimpe/brickr/issues/3'>#3</a>d-models" class="anchor"></a>3D Models</h2>
<ul>
<li><p>Optional new coordinate system to allow for varying piece shape and 1-height plates &amp; pieces. (Most bricks are 3-height)</p></li>
<li><p>New shapes! Plates, cheese slopes, round 1x1 bricks, conical 1x1 bricks.</p></li>
<li><p>Removed bricks_from_rayshader() and build_bricks_rayshader() to decrease the complexity of package.</p></li>
</ul>
</div>
<div id="ggplot-extension" class="section level2">
<h2 class="hasAnchor">
<a href="#ggplot-extension" class="anchor"></a>ggplot Extension</h2>
<ul>
<li>Removed from brickr. Will be rewritten as its own package.</li>
</ul>
<hr>
</div>
</div>
<div id="brickr-0209003" class="section level1">
<h1 class="page-header">
<a href="#brickr-0209003" class="anchor"></a>brickr 0.2.0.9003</h1>
<ul>
<li>Issues after updating to <a href="https://github.com/thomasp85/farver">farver 2.0</a>. Temporarily set color method back to brickr_classic.</li>
</ul>
<hr>
</div>
<div id="brickr-020---aka-castle" class="section level1">
<h1 class="page-header">
<a href="#brickr-020---aka-castle" class="anchor"></a>brickr 0.2.0 - a.k.a. <a href="https://twitter.com/ryantimpe/status/1191354410124709892">Castle</a>
</h1>
<ul>
<li>Lots of bug fixes. More to come.</li>
</ul>
@@ -158,9 +193,9 @@
<li>Issues and bugs are now actively tracked on <a href="https://github.com/ryantimpe/brickr/issues">GitHub Issues</a>.</li>
</ul>
</div>
<div id="3d-models" class="section level2">
<div id="3d-models-1" class="section level2">
<h2 class="hasAnchor">
<a href="<a href='https://github.com/ryantimpe/brickr/issues/3'>#3</a>d-models" class="anchor"></a>3D Models</h2>
<a href="<a href='https://github.com/ryantimpe/brickr/issues/3'>#3</a>d-models-1" class="anchor"></a>3D Models</h2>
<ul>
<li>
<code><a href="../reference/build_bricks.html">build_bricks()</a></code> now renders models in {rgl}, rather than {rayshader}. Most options for the rendering have changed. Use <code>build_brick_rayshader()</code> for previous output.</li>
@@ -169,9 +204,10 @@
<hr>
</div>
</div>
<div id="brickr-011" class="section level1">
<div id="brickr-011---aka-brickr-house" class="section level1">
<h1 class="page-header">
<a href="#brickr-011" class="anchor"></a>brickr 0.1.1</h1>
<a href="#brickr-011---aka-brickr-house" class="anchor"></a>brickr 0.1.1 - a.k.a. <a href="https://twitter.com/ryantimpe/status/1106572408918605824?s=20">brickr House</a>
</h1>
<ul>
<li><p><strong>Breaking:</strong> Pretty much <em>EVERY</em> function. Seriously, check out the README and start fresh.</p></li>
<li><p><strong>Breaking:</strong> Data “lego_colors.rda” has been updated with more accurate RGB values and new <code>brickrID</code> numbers. This will impact previously created mosaics and 3D models.</p></li>
@@ -196,14 +232,14 @@
<li>3D mosaics have been rewritten as 3D models using plates with <code><a href="../reference/bricks_from_mosaic.html">bricks_from_mosaic()</a></code>.</li>
</ul>
</div>
<div id="3d-models-1" class="section level2">
<div id="3d-models-2" class="section level2">
<h2 class="hasAnchor">
<a href="<a href='https://github.com/ryantimpe/brickr/issues/3'>#3</a>d-models-1" class="anchor"></a>3D Models</h2>
<a href="<a href='https://github.com/ryantimpe/brickr/issues/3'>#3</a>d-models-2" class="anchor"></a>3D Models</h2>
<ul>
<li>
<code>brick_res</code> input options to render models in higher definition (sd, hd, uhd)</li>
<li>
<code><a href="../reference/bricks_from_rayshader.html">bricks_from_rayshader()</a></code> to render LEGO models from rayshader plot_3d() input.</li>
<code>bricks_from_rayshader()</code> to render LEGO models from rayshader plot_3d() input.</li>
<li>Option to use plates rather than bricks. Combining the two involves some hacking.</li>
<li>Updated brick collection algorithm to allow for custom brick input.</li>
<li>Updated brick collection algorithm staggers bricks over layer, though still prioritizes larger bricks.</li>
@@ -211,9 +247,9 @@
<code>build_instructions</code> generates building instructions for 3D models, as well as mosaics.</li>
</ul>
</div>
<div id="ggplot-extension" class="section level2">
<div id="ggplot-extension-1" class="section level2">
<h2 class="hasAnchor">
<a href="#ggplot-extension" class="anchor"></a>ggplot Extension</h2>
<a href="#ggplot-extension-1" class="anchor"></a>ggplot Extension</h2>
<ul>
<li>
<code>geom_brick_col</code> for bar charts in the shape of bricks. Negative values are fine, but <code>position = stack</code> is not available.</li>
@@ -250,8 +286,10 @@
<div id="tocnav">
<h2>Contents</h2>
<ul class="nav nav-pills nav-stacked">
<li><a href="#brickr-020">0.2.0</a></li>
<li><a href="#brickr-011">0.1.1</a></li>
<li><a href="#brickr-030---aka-pirate-ship">0.3.0</a></li>
<li><a href="#brickr-0209003">0.2.0.9003</a></li>
<li><a href="#brickr-020---aka-castle">0.2.0</a></li>
<li><a href="#brickr-011---aka-brickr-house">0.1.1</a></li>
<li><a href="#brickr-0009200">0.0.0.9200</a></li>
<li><a href="#brickr-0009150">0.0.0.9150</a></li>
</ul>

View File

@@ -1,11 +1,11 @@
pandoc: '2.7'
pandoc: 2.7.2
pkgdown: 1.4.1
pkgdown_sha: ~
articles:
graphs: graphs.html
models-from-other: models-from-other.html
models-from-program: models-from-program.html
models-from-tables: models-from-tables.html
models-piece-type: models-piece-type.html
mosaics: mosaics.html
urls:
reference: http://brickr.org/reference

View File

@@ -6,7 +6,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>GeomBrick — CoordBrick • brickr</title>
<title>GeomBrick — GeomBrick • brickr</title>
<!-- favicons -->
<link rel="icon" type="image/png" sizes="16x16" href="../favicon-16x16.png">
@@ -44,7 +44,7 @@
<link href="../extra.css" rel="stylesheet">
<meta property="og:title" content="GeomBrick — CoordBrick" />
<meta property="og:title" content="GeomBrick — GeomBrick" />
<meta property="og:description" content="ggproto for brickr geoms" />
<meta property="og:image" content="http://brickr.org/logo.png" />
<meta name="twitter:card" content="summary" />
@@ -79,7 +79,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">brickr</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.2.0</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.3.0</span>
</span>
</div>
@@ -102,10 +102,7 @@
</a>
<ul class="dropdown-menu" role="menu">
<li>
<a href="../articles/graphs.html">ggplot with brickr</a>
</li>
<li>
<a href="../articles/models-from-other.html">3D Models from mosaics &amp; rayshader</a>
<a href="../articles/models-from-other.html">3D Models from mosaics</a>
</li>
<li>
<a href="../articles/models-from-program.html">3D Models programmatically</a>
@@ -113,6 +110,9 @@
<li>
<a href="../articles/models-from-tables.html">3D models from tables</a>
</li>
<li>
<a href="../articles/models-piece-type.html">Piece type in 3D Models</a>
</li>
<li>
<a href="../articles/mosaics.html">Mosaics with brickr</a>
</li>
@@ -143,7 +143,7 @@
<div class="col-md-9 contents">
<div class="page-header">
<h1>GeomBrick</h1>
<small class="dont-index">Source: <a href='https://github.com/ryantimpe/brickr/blob/master/R/coord-brick.R'><code>R/coord-brick.R</code></a>, <a href='https://github.com/ryantimpe/brickr/blob/master/R/draw-key.R'><code>R/draw-key.R</code></a>, <a href='https://github.com/ryantimpe/brickr/blob/master/R/geom-brick-col.R'><code>R/geom-brick-col.R</code></a>, and 2 more</small>
<small class="dont-index">Source: <a href='https://github.com/ryantimpe/brickr/blob/master/R/geom-brick-rect.R'><code>R/geom-brick-rect.R</code></a></small>
<div class="hidden name"><code>brickr-ggproto.Rd</code></div>
</div>
@@ -151,7 +151,6 @@
<p>ggproto for brickr geoms</p>
</div>
<pre class="usage"><span class='fu'>draw_key_brick</span>(<span class='no'>data</span>, <span class='no'>params</span>, <span class='no'>size</span>)</pre>

View File

@@ -45,7 +45,7 @@
<meta property="og:title" content="<code>brickr</code> package — brickr" />
<meta property="og:description" content="Google spreadsheets R API" />
<meta property="og:description" content="Tools to emulate the LEGO® System in R" />
<meta property="og:image" content="http://brickr.org/logo.png" />
<meta name="twitter:card" content="summary" />
@@ -79,7 +79,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">brickr</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.2.0</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.3.0</span>
</span>
</div>
@@ -102,10 +102,7 @@
</a>
<ul class="dropdown-menu" role="menu">
<li>
<a href="../articles/graphs.html">ggplot with brickr</a>
</li>
<li>
<a href="../articles/models-from-other.html">3D Models from mosaics &amp; rayshader</a>
<a href="../articles/models-from-other.html">3D Models from mosaics</a>
</li>
<li>
<a href="../articles/models-from-program.html">3D Models programmatically</a>
@@ -113,6 +110,9 @@
<li>
<a href="../articles/models-from-tables.html">3D models from tables</a>
</li>
<li>
<a href="../articles/models-piece-type.html">Piece type in 3D Models</a>
</li>
<li>
<a href="../articles/mosaics.html">Mosaics with brickr</a>
</li>
@@ -148,7 +148,7 @@
</div>
<div class="ref-description">
<p>Google spreadsheets R API</p>
<p>Tools to emulate the LEGO® System in R</p>
</div>

View File

@@ -79,7 +79,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">brickr</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.2.0</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.3.0</span>
</span>
</div>
@@ -102,10 +102,7 @@
</a>
<ul class="dropdown-menu" role="menu">
<li>
<a href="../articles/graphs.html">ggplot with brickr</a>
</li>
<li>
<a href="../articles/models-from-other.html">3D Models from mosaics &amp; rayshader</a>
<a href="../articles/models-from-other.html">3D Models from mosaics</a>
</li>
<li>
<a href="../articles/models-from-program.html">3D Models programmatically</a>
@@ -113,6 +110,9 @@
<li>
<a href="../articles/models-from-tables.html">3D models from tables</a>
</li>
<li>
<a href="../articles/models-piece-type.html">Piece type in 3D Models</a>
</li>
<li>
<a href="../articles/mosaics.html">Mosaics with brickr</a>
</li>
@@ -151,21 +151,41 @@
<p>Convert a data frame with x, y, z &amp; Color columns into a brickr 3D object</p>
</div>
<pre class="usage"><span class='fu'>bricks_from_coords</span>(<span class='no'>coord_table</span>, <span class='kw'>increment_level</span> <span class='kw'>=</span> <span class='fl'>0</span>, <span class='kw'>max_level</span> <span class='kw'>=</span> <span class='fl'>Inf</span>,
<span class='kw'>increment_x</span> <span class='kw'>=</span> <span class='fl'>0</span>, <span class='kw'>max_x</span> <span class='kw'>=</span> <span class='fl'>Inf</span>, <span class='kw'>increment_y</span> <span class='kw'>=</span> <span class='fl'>0</span>, <span class='kw'>max_y</span> <span class='kw'>=</span> <span class='fl'>Inf</span>,
<span class='kw'>exclude_color</span> <span class='kw'>=</span> <span class='kw'>NULL</span>, <span class='kw'>exclude_level</span> <span class='kw'>=</span> <span class='kw'>NULL</span>)</pre>
<pre class="usage"><span class='fu'>bricks_from_coords</span>(
<span class='no'>coord_table</span>,
<span class='kw'>use_bricks</span> <span class='kw'>=</span> <span class='kw'>NULL</span>,
<span class='kw'>increment_level</span> <span class='kw'>=</span> <span class='fl'>0</span>,
<span class='kw'>min_level</span> <span class='kw'>=</span> <span class='fl'>1</span>,
<span class='kw'>max_level</span> <span class='kw'>=</span> <span class='fl'>Inf</span>,
<span class='kw'>increment_x</span> <span class='kw'>=</span> <span class='fl'>0</span>,
<span class='kw'>max_x</span> <span class='kw'>=</span> <span class='fl'>Inf</span>,
<span class='kw'>increment_y</span> <span class='kw'>=</span> <span class='fl'>0</span>,
<span class='kw'>max_y</span> <span class='kw'>=</span> <span class='fl'>Inf</span>,
<span class='kw'>exclude_color</span> <span class='kw'>=</span> <span class='kw'>NULL</span>,
<span class='kw'>exclude_level</span> <span class='kw'>=</span> <span class='kw'>NULL</span>
)</pre>
<h2 class="hasAnchor" id="arguments"><a class="anchor" href="#arguments"></a>Arguments</h2>
<table class="ref-arguments">
<colgroup><col class="name" /><col class="desc" /></colgroup>
<tr>
<th>coord_table</th>
<td><p>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><a href='build_colors.html'>build_colors()</a></code>.</p></td>
<td><p>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><a href='build_colors.html'>build_colors()</a></code>. Optional column 'piece_type' for shapes other than rectangular bricks.
Optional column ' mid_Level' with values 0, 1, or 2 (default 0) for 1-height placement of bricks.</p></td>
</tr>
<tr>
<th>use_bricks</th>
<td><p>Array of brick sizes to use in mosaic. Defaults to <code><a href='https://rdrr.io/r/base/c.html'>c('4x2', '3x2', '2x2', '3x1', '2x1', '1x1')</a></code>`.</p></td>
</tr>
<tr>
<th>increment_level</th>
<td><p>Default '0'. Use in animations. Shift Level/z dimension by an integer.</p></td>
</tr>
<tr>
<th>min_level</th>
<td><p>Default '1'. Use in animations. Any Level/z values below this value will be cut off.</p></td>
</tr>
<tr>
<th>max_level</th>
<td><p>Default 'Inf'. Use in animations. Any Level/z values above this value will be cut off.</p></td>
@@ -201,12 +221,11 @@
<p>A list with elements <code>Img_lego</code> to pass to <code><a href='collect_bricks.html'>collect_bricks()</a></code>.</p>
<h2 class="hasAnchor" id="see-also"><a class="anchor" href="#see-also"></a>See also</h2>
<div class='dont-index'><p>Other 3D Models: <code><a href='bricks_from_excel.html'>bricks_from_excel</a></code>,
<code><a href='bricks_from_mosaic.html'>bricks_from_mosaic</a></code>,
<code><a href='bricks_from_rayshader.html'>bricks_from_rayshader</a></code>,
<code><a href='bricks_from_table.html'>bricks_from_table</a></code>,
<code><a href='build_bricks_rayshader.html'>build_bricks_rayshader</a></code>,
<code><a href='build_bricks.html'>build_bricks</a></code></p></div>
<div class='dont-index'><p>Other 3D Models:
<code><a href='bricks_from_excel.html'>bricks_from_excel</a>()</code>,
<code><a href='bricks_from_mosaic.html'>bricks_from_mosaic</a>()</code>,
<code><a href='bricks_from_table.html'>bricks_from_table</a>()</code>,
<code><a href='build_bricks.html'>build_bricks</a>()</code></p></div>
</div>
<div class="col-md-3 hidden-xs hidden-sm" id="sidebar">

View File

@@ -79,7 +79,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">brickr</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.2.0</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.3.0</span>
</span>
</div>
@@ -102,10 +102,7 @@
</a>
<ul class="dropdown-menu" role="menu">
<li>
<a href="../articles/graphs.html">ggplot with brickr</a>
</li>
<li>
<a href="../articles/models-from-other.html">3D Models from mosaics &amp; rayshader</a>
<a href="../articles/models-from-other.html">3D Models from mosaics</a>
</li>
<li>
<a href="../articles/models-from-program.html">3D Models programmatically</a>
@@ -113,6 +110,9 @@
<li>
<a href="../articles/models-from-tables.html">3D models from tables</a>
</li>
<li>
<a href="../articles/models-piece-type.html">Piece type in 3D Models</a>
</li>
<li>
<a href="../articles/mosaics.html">Mosaics with brickr</a>
</li>
@@ -151,9 +151,21 @@
<p>Convert an Excel brickr template into a brickr 3D object</p>
</div>
<pre class="usage"><span class='fu'>bricks_from_excel</span>(<span class='no'>excel_table</span>, <span class='kw'>repeat_levels</span> <span class='kw'>=</span> <span class='fl'>1</span>, <span class='kw'>increment_level</span> <span class='kw'>=</span> <span class='fl'>0</span>,
<span class='kw'>max_level</span> <span class='kw'>=</span> <span class='fl'>Inf</span>, <span class='kw'>increment_x</span> <span class='kw'>=</span> <span class='fl'>0</span>, <span class='kw'>max_x</span> <span class='kw'>=</span> <span class='fl'>Inf</span>, <span class='kw'>increment_y</span> <span class='kw'>=</span> <span class='fl'>0</span>,
<span class='kw'>max_y</span> <span class='kw'>=</span> <span class='fl'>Inf</span>, <span class='kw'>exclude_color</span> <span class='kw'>=</span> <span class='kw'>NULL</span>, <span class='kw'>exclude_level</span> <span class='kw'>=</span> <span class='kw'>NULL</span>)</pre>
<pre class="usage"><span class='fu'>bricks_from_excel</span>(
<span class='no'>excel_table</span>,
<span class='kw'>piece_table</span> <span class='kw'>=</span> <span class='kw'>NULL</span>,
<span class='kw'>use_bricks</span> <span class='kw'>=</span> <span class='kw'>NULL</span>,
<span class='kw'>repeat_levels</span> <span class='kw'>=</span> <span class='fl'>1</span>,
<span class='kw'>increment_level</span> <span class='kw'>=</span> <span class='fl'>0</span>,
<span class='kw'>min_level</span> <span class='kw'>=</span> <span class='fl'>1</span>,
<span class='kw'>max_level</span> <span class='kw'>=</span> <span class='fl'>Inf</span>,
<span class='kw'>increment_x</span> <span class='kw'>=</span> <span class='fl'>0</span>,
<span class='kw'>max_x</span> <span class='kw'>=</span> <span class='fl'>Inf</span>,
<span class='kw'>increment_y</span> <span class='kw'>=</span> <span class='fl'>0</span>,
<span class='kw'>max_y</span> <span class='kw'>=</span> <span class='fl'>Inf</span>,
<span class='kw'>exclude_color</span> <span class='kw'>=</span> <span class='kw'>NULL</span>,
<span class='kw'>exclude_level</span> <span class='kw'>=</span> <span class='kw'>NULL</span>
)</pre>
<h2 class="hasAnchor" id="arguments"><a class="anchor" href="#arguments"></a>Arguments</h2>
<table class="ref-arguments">
@@ -162,6 +174,14 @@
<th>excel_table</th>
<td><p>Sheet imported from a brickr Excel template to build model. Contains stud placement and colors.</p></td>
</tr>
<tr>
<th>piece_table</th>
<td><p>Sheet identical in shape to <code>excel_table</code> with piece shape IDs.</p></td>
</tr>
<tr>
<th>use_bricks</th>
<td><p>Array of brick sizes to use in mosaic. Defaults to <code><a href='https://rdrr.io/r/base/c.html'>c('4x2', '3x2', '2x2', '3x1', '2x1', '1x1')</a></code>`.</p></td>
</tr>
<tr>
<th>repeat_levels</th>
<td><p>How many times to repeat a level. Can save time in model planning. Default is 1.</p></td>
@@ -170,6 +190,10 @@
<th>increment_level</th>
<td><p>Default '0'. Use in animations. Shift Level/z dimension by an integer.</p></td>
</tr>
<tr>
<th>min_level</th>
<td><p>Default '1'. Use in animations. Any Level/z values below this value will be cut off.</p></td>
</tr>
<tr>
<th>max_level</th>
<td><p>Default 'Inf'. Use in animations. Any Level/z values above this value will be cut off.</p></td>
@@ -205,12 +229,11 @@
<p>A list with elements <code>Img_lego</code> to pass to <code><a href='collect_bricks.html'>collect_bricks()</a></code>.</p>
<h2 class="hasAnchor" id="see-also"><a class="anchor" href="#see-also"></a>See also</h2>
<div class='dont-index'><p>Other 3D Models: <code><a href='bricks_from_coords.html'>bricks_from_coords</a></code>,
<code><a href='bricks_from_mosaic.html'>bricks_from_mosaic</a></code>,
<code><a href='bricks_from_rayshader.html'>bricks_from_rayshader</a></code>,
<code><a href='bricks_from_table.html'>bricks_from_table</a></code>,
<code><a href='build_bricks_rayshader.html'>build_bricks_rayshader</a></code>,
<code><a href='build_bricks.html'>build_bricks</a></code></p></div>
<div class='dont-index'><p>Other 3D Models:
<code><a href='bricks_from_coords.html'>bricks_from_coords</a>()</code>,
<code><a href='bricks_from_mosaic.html'>bricks_from_mosaic</a>()</code>,
<code><a href='bricks_from_table.html'>bricks_from_table</a>()</code>,
<code><a href='build_bricks.html'>build_bricks</a>()</code></p></div>
</div>
<div class="col-md-3 hidden-xs hidden-sm" id="sidebar">

View File

@@ -79,7 +79,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">brickr</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.2.0</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.3.0</span>
</span>
</div>
@@ -102,10 +102,7 @@
</a>
<ul class="dropdown-menu" role="menu">
<li>
<a href="../articles/graphs.html">ggplot with brickr</a>
</li>
<li>
<a href="../articles/models-from-other.html">3D Models from mosaics &amp; rayshader</a>
<a href="../articles/models-from-other.html">3D Models from mosaics</a>
</li>
<li>
<a href="../articles/models-from-program.html">3D Models programmatically</a>
@@ -113,6 +110,9 @@
<li>
<a href="../articles/models-from-tables.html">3D models from tables</a>
</li>
<li>
<a href="../articles/models-piece-type.html">Piece type in 3D Models</a>
</li>
<li>
<a href="../articles/mosaics.html">Mosaics with brickr</a>
</li>
@@ -151,8 +151,7 @@
<p>Convert a 2D LEGO mosaic into a brickr 3D object</p>
</div>
<pre class="usage"><span class='fu'>bricks_from_mosaic</span>(<span class='no'>mosaic_list</span>, <span class='kw'>mosaic_height</span> <span class='kw'>=</span> <span class='fl'>6</span>,
<span class='kw'>highest_el</span> <span class='kw'>=</span> <span class='st'>"light"</span>)</pre>
<pre class="usage"><span class='fu'>bricks_from_mosaic</span>(<span class='no'>mosaic_list</span>, <span class='kw'>mosaic_height</span> <span class='kw'>=</span> <span class='fl'>6</span>, <span class='kw'>highest_el</span> <span class='kw'>=</span> <span class='st'>"light"</span>)</pre>
<h2 class="hasAnchor" id="arguments"><a class="anchor" href="#arguments"></a>Arguments</h2>
<table class="ref-arguments">
@@ -173,15 +172,14 @@
<h2 class="hasAnchor" id="value"><a class="anchor" href="#value"></a>Value</h2>
<p>A list with elements <code>threed_elevation</code> and <code>threed_hillshade</code> to created 3D mosiacs with the <code>rayshader</code> package.</p>
<p>A list with elements <code>Img_lego</code> to pass to <code><a href='collect_bricks.html'>collect_bricks()</a></code>.</p>
<h2 class="hasAnchor" id="see-also"><a class="anchor" href="#see-also"></a>See also</h2>
<div class='dont-index'><p>Other 3D Models: <code><a href='bricks_from_coords.html'>bricks_from_coords</a></code>,
<code><a href='bricks_from_excel.html'>bricks_from_excel</a></code>,
<code><a href='bricks_from_rayshader.html'>bricks_from_rayshader</a></code>,
<code><a href='bricks_from_table.html'>bricks_from_table</a></code>,
<code><a href='build_bricks_rayshader.html'>build_bricks_rayshader</a></code>,
<code><a href='build_bricks.html'>build_bricks</a></code></p></div>
<div class='dont-index'><p>Other 3D Models:
<code><a href='bricks_from_coords.html'>bricks_from_coords</a>()</code>,
<code><a href='bricks_from_excel.html'>bricks_from_excel</a>()</code>,
<code><a href='bricks_from_table.html'>bricks_from_table</a>()</code>,
<code><a href='build_bricks.html'>build_bricks</a>()</code></p></div>
</div>
<div class="col-md-3 hidden-xs hidden-sm" id="sidebar">

View File

@@ -79,7 +79,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">brickr</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.2.0</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.3.0</span>
</span>
</div>
@@ -102,10 +102,7 @@
</a>
<ul class="dropdown-menu" role="menu">
<li>
<a href="../articles/graphs.html">ggplot with brickr</a>
</li>
<li>
<a href="../articles/models-from-other.html">3D Models from mosaics &amp; rayshader</a>
<a href="../articles/models-from-other.html">3D Models from mosaics</a>
</li>
<li>
<a href="../articles/models-from-program.html">3D Models programmatically</a>
@@ -113,6 +110,9 @@
<li>
<a href="../articles/models-from-tables.html">3D models from tables</a>
</li>
<li>
<a href="../articles/models-piece-type.html">Piece type in 3D Models</a>
</li>
<li>
<a href="../articles/mosaics.html">Mosaics with brickr</a>
</li>
@@ -151,22 +151,42 @@
<p>Convert a matrix table into a brickr 3D object</p>
</div>
<pre class="usage"><span class='fu'>bricks_from_table</span>(<span class='no'>matrix_table</span>, <span class='kw'>color_guide</span> <span class='kw'>=</span> <span class='kw pkg'>brickr</span><span class='kw ns'>::</span><span class='no'>lego_colors</span>,
<span class='kw'>.re_level</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>, <span class='kw'>increment_level</span> <span class='kw'>=</span> <span class='fl'>0</span>, <span class='kw'>max_level</span> <span class='kw'>=</span> <span class='fl'>Inf</span>,
<span class='kw'>increment_x</span> <span class='kw'>=</span> <span class='fl'>0</span>, <span class='kw'>max_x</span> <span class='kw'>=</span> <span class='fl'>Inf</span>, <span class='kw'>increment_y</span> <span class='kw'>=</span> <span class='fl'>0</span>, <span class='kw'>max_y</span> <span class='kw'>=</span> <span class='fl'>Inf</span>,
<span class='kw'>exclude_color</span> <span class='kw'>=</span> <span class='kw'>NULL</span>, <span class='kw'>exclude_level</span> <span class='kw'>=</span> <span class='kw'>NULL</span>)</pre>
<pre class="usage"><span class='fu'>bricks_from_table</span>(
<span class='no'>matrix_table</span>,
<span class='kw'>color_guide</span> <span class='kw'>=</span> <span class='kw pkg'>brickr</span><span class='kw ns'>::</span><span class='no'><a href='https://rdrr.io/pkg/brickr/man/lego_colors.html'>lego_colors</a></span>,
<span class='kw'>piece_matrix</span> <span class='kw'>=</span> <span class='kw'>NULL</span>,
<span class='kw'>use_bricks</span> <span class='kw'>=</span> <span class='kw'>NULL</span>,
<span class='kw'>.re_level</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>,
<span class='kw'>increment_level</span> <span class='kw'>=</span> <span class='fl'>0</span>,
<span class='kw'>min_level</span> <span class='kw'>=</span> <span class='fl'>1</span>,
<span class='kw'>max_level</span> <span class='kw'>=</span> <span class='fl'>Inf</span>,
<span class='kw'>increment_x</span> <span class='kw'>=</span> <span class='fl'>0</span>,
<span class='kw'>max_x</span> <span class='kw'>=</span> <span class='fl'>Inf</span>,
<span class='kw'>increment_y</span> <span class='kw'>=</span> <span class='fl'>0</span>,
<span class='kw'>max_y</span> <span class='kw'>=</span> <span class='fl'>Inf</span>,
<span class='kw'>exclude_color</span> <span class='kw'>=</span> <span class='kw'>NULL</span>,
<span class='kw'>exclude_level</span> <span class='kw'>=</span> <span class='kw'>NULL</span>
)</pre>
<h2 class="hasAnchor" id="arguments"><a class="anchor" href="#arguments"></a>Arguments</h2>
<table class="ref-arguments">
<colgroup><col class="name" /><col class="desc" /></colgroup>
<tr>
<th>matrix_table</th>
<td><p>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</code> for ease.</p></td>
<td><p>A data frame of a 3D brick model design. Left-most column is level/height/z dimension, with rows as Y axis and columns as X axis. See example. Use <code>tribble</code> for ease.</p></td>
</tr>
<tr>
<th>color_guide</th>
<td><p>A data frame linking numeric <code>.value</code> in <code>matrix_table</code> to official LEGO color names. Defaults to data frame 'lego_colors'.</p></td>
</tr>
<tr>
<th>piece_matrix</th>
<td><p>A data frame in same shape as <code>matrix_table</code> with piece shape IDs.</p></td>
</tr>
<tr>
<th>use_bricks</th>
<td><p>Array of brick sizes to use in mosaic. Defaults to <code><a href='https://rdrr.io/r/base/c.html'>c('4x2', '3x2', '2x2', '3x1', '2x1', '1x1')</a></code>`.</p></td>
</tr>
<tr>
<th>.re_level</th>
<td><p>Logical to reassign the Level/z dimension to layers in alphanumeric order. Set to FALSE to explicitly provide levels.</p></td>
@@ -175,6 +195,10 @@
<th>increment_level</th>
<td><p>Default '0'. Use in animations. Shift Level/z dimension by an integer.</p></td>
</tr>
<tr>
<th>min_level</th>
<td><p>Default '1'. Use in animations. Any Level/z values below this value will be cut off.</p></td>
</tr>
<tr>
<th>max_level</th>
<td><p>Default 'Inf'. Use in animations. Any Level/z values above this value will be cut off.</p></td>
@@ -210,12 +234,11 @@
<p>A list with elements <code>Img_lego</code> to pass to <code><a href='collect_bricks.html'>collect_bricks()</a></code>.</p>
<h2 class="hasAnchor" id="see-also"><a class="anchor" href="#see-also"></a>See also</h2>
<div class='dont-index'><p>Other 3D Models: <code><a href='bricks_from_coords.html'>bricks_from_coords</a></code>,
<code><a href='bricks_from_excel.html'>bricks_from_excel</a></code>,
<code><a href='bricks_from_mosaic.html'>bricks_from_mosaic</a></code>,
<code><a href='bricks_from_rayshader.html'>bricks_from_rayshader</a></code>,
<code><a href='build_bricks_rayshader.html'>build_bricks_rayshader</a></code>,
<code><a href='build_bricks.html'>build_bricks</a></code></p></div>
<div class='dont-index'><p>Other 3D Models:
<code><a href='bricks_from_coords.html'>bricks_from_coords</a>()</code>,
<code><a href='bricks_from_excel.html'>bricks_from_excel</a>()</code>,
<code><a href='bricks_from_mosaic.html'>bricks_from_mosaic</a>()</code>,
<code><a href='build_bricks.html'>build_bricks</a>()</code></p></div>
</div>
<div class="col-md-3 hidden-xs hidden-sm" id="sidebar">

View File

@@ -79,7 +79,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">brickr</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.2.0</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.3.0</span>
</span>
</div>
@@ -102,10 +102,7 @@
</a>
<ul class="dropdown-menu" role="menu">
<li>
<a href="../articles/graphs.html">ggplot with brickr</a>
</li>
<li>
<a href="../articles/models-from-other.html">3D Models from mosaics &amp; rayshader</a>
<a href="../articles/models-from-other.html">3D Models from mosaics</a>
</li>
<li>
<a href="../articles/models-from-program.html">3D Models programmatically</a>
@@ -113,6 +110,9 @@
<li>
<a href="../articles/models-from-tables.html">3D models from tables</a>
</li>
<li>
<a href="../articles/models-piece-type.html">Piece type in 3D Models</a>
</li>
<li>
<a href="../articles/mosaics.html">Mosaics with brickr</a>
</li>
@@ -151,8 +151,14 @@
<p>Build 3D brick model with rgl</p>
</div>
<pre class="usage"><span class='fu'>build_bricks</span>(<span class='no'>brick_list</span>, <span class='kw'>background_color</span> <span class='kw'>=</span> <span class='st'>"white"</span>, <span class='kw'>rgl_lit</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>,
<span class='kw'>outline_bricks</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>, <span class='kw'>trans_alpha</span> <span class='kw'>=</span> <span class='fl'>0.5</span>, <span class='kw'>view_levels</span> <span class='kw'>=</span> <span class='kw'>NULL</span>)</pre>
<pre class="usage"><span class='fu'>build_bricks</span>(
<span class='no'>brick_list</span>,
<span class='kw'>background_color</span> <span class='kw'>=</span> <span class='st'>"white"</span>,
<span class='kw'>rgl_lit</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>,
<span class='kw'>outline_bricks</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>,
<span class='kw'>trans_alpha</span> <span class='kw'>=</span> <span class='fl'>0.5</span>,
<span class='kw'>view_levels</span> <span class='kw'>=</span> <span class='kw'>NULL</span>
)</pre>
<h2 class="hasAnchor" id="arguments"><a class="anchor" href="#arguments"></a>Arguments</h2>
<table class="ref-arguments">
@@ -182,10 +188,6 @@ Set to 'TRUE' and rgl_lit='FALSE' for cartoon-looking bricks.</p></td>
<th>view_levels</th>
<td><p>Numeric array of Levels/z values to display. Leave as 'NULL' to include all.</p></td>
</tr>
<tr>
<th>brick_type</th>
<td><p>Type of brick to use. Default is 'brick'. Other option is 'plate', which is 1/3 the height of a brick.</p></td>
</tr>
</table>
<h2 class="hasAnchor" id="value"><a class="anchor" href="#value"></a>Value</h2>
@@ -193,12 +195,11 @@ Set to 'TRUE' and rgl_lit='FALSE' for cartoon-looking bricks.</p></td>
<p>3D brick model rendered in the 'rgl' package.</p>
<h2 class="hasAnchor" id="see-also"><a class="anchor" href="#see-also"></a>See also</h2>
<div class='dont-index'><p>Other 3D Models: <code><a href='bricks_from_coords.html'>bricks_from_coords</a></code>,
<code><a href='bricks_from_excel.html'>bricks_from_excel</a></code>,
<code><a href='bricks_from_mosaic.html'>bricks_from_mosaic</a></code>,
<code><a href='bricks_from_rayshader.html'>bricks_from_rayshader</a></code>,
<code><a href='bricks_from_table.html'>bricks_from_table</a></code>,
<code><a href='build_bricks_rayshader.html'>build_bricks_rayshader</a></code></p></div>
<div class='dont-index'><p>Other 3D Models:
<code><a href='bricks_from_coords.html'>bricks_from_coords</a>()</code>,
<code><a href='bricks_from_excel.html'>bricks_from_excel</a>()</code>,
<code><a href='bricks_from_mosaic.html'>bricks_from_mosaic</a>()</code>,
<code><a href='bricks_from_table.html'>bricks_from_table</a>()</code></p></div>
<h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2>
<pre class="examples"><div class='input'><span class='kw'>if</span> (<span class='fl'>FALSE</span>) {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 106 KiB

After

Width:  |  Height:  |  Size: 105 KiB

View File

@@ -79,7 +79,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">brickr</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.2.0</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.3.0</span>
</span>
</div>
@@ -102,10 +102,7 @@
</a>
<ul class="dropdown-menu" role="menu">
<li>
<a href="../articles/graphs.html">ggplot with brickr</a>
</li>
<li>
<a href="../articles/models-from-other.html">3D Models from mosaics &amp; rayshader</a>
<a href="../articles/models-from-other.html">3D Models from mosaics</a>
</li>
<li>
<a href="../articles/models-from-program.html">3D Models programmatically</a>
@@ -113,6 +110,9 @@
<li>
<a href="../articles/models-from-tables.html">3D models from tables</a>
</li>
<li>
<a href="../articles/models-piece-type.html">Piece type in 3D Models</a>
</li>
<li>
<a href="../articles/mosaics.html">Mosaics with brickr</a>
</li>
@@ -171,13 +171,17 @@
<p>A table and ggplot of brick colors &amp; ID numbers.</p>
<h2 class="hasAnchor" id="see-also"><a class="anchor" href="#see-also"></a>See also</h2>
<div class='dont-index'><p>Other Resources: <code><a href='build_instructions.html'>build_instructions</a></code>,
<code><a href='build_pieces_table.html'>build_pieces_table</a></code>,
<code><a href='build_pieces.html'>build_pieces</a></code>, <code><a href='build_themes.html'>build_themes</a></code></p></div>
<div class='dont-index'><p>Other Resources:
<code><a href='build_instructions.html'>build_instructions</a>()</code>,
<code><a href='build_pieces_table.html'>build_pieces_table</a>()</code>,
<code><a href='build_pieces.html'>build_pieces</a>()</code></p></div>
<h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2>
<pre class="examples"><div class='input'><span class='co'>#Generate plot of colors</span>
<span class='fu'>build_colors</span>()</div><div class='output co'>#&gt; <span class='message'>Use View(lego_colors) to see these in a table format.</span></div><div class='output co'>#&gt; <span class='message'>Transparent colors are only used for 3D models, not color matching in mosaics or ggplot.</span></div><div class='img'><img src='build_colors-1.png' alt='' width='700' height='433' /></div><div class='input'>
<span class='kw'>if</span> (<span class='fl'>FALSE</span>) {
<span class='fu'>build_colors</span>()
}
<span class='co'>#Print list of colors</span>
<span class='fu'>build_colors</span>(<span class='fl'>TRUE</span>)</div><div class='output co'>#&gt; [1] "White" "Brick yellow" "Bright red"
#&gt; [4] "Bright blue" "Bright yellow" "Black"

View File

@@ -79,7 +79,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">brickr</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.2.0</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.3.0</span>
</span>
</div>
@@ -102,10 +102,7 @@
</a>
<ul class="dropdown-menu" role="menu">
<li>
<a href="../articles/graphs.html">ggplot with brickr</a>
</li>
<li>
<a href="../articles/models-from-other.html">3D Models from mosaics &amp; rayshader</a>
<a href="../articles/models-from-other.html">3D Models from mosaics</a>
</li>
<li>
<a href="../articles/models-from-program.html">3D Models programmatically</a>
@@ -113,6 +110,9 @@
<li>
<a href="../articles/models-from-tables.html">3D models from tables</a>
</li>
<li>
<a href="../articles/models-piece-type.html">Piece type in 3D Models</a>
</li>
<li>
<a href="../articles/mosaics.html">Mosaics with brickr</a>
</li>
@@ -168,9 +168,10 @@
<h2 class="hasAnchor" id="see-also"><a class="anchor" href="#see-also"></a>See also</h2>
<div class='dont-index'><p>Other Resources: <code><a href='build_colors.html'>build_colors</a></code>,
<code><a href='build_pieces_table.html'>build_pieces_table</a></code>,
<code><a href='build_pieces.html'>build_pieces</a></code>, <code><a href='build_themes.html'>build_themes</a></code></p></div>
<div class='dont-index'><p>Other Resources:
<code><a href='build_colors.html'>build_colors</a>()</code>,
<code><a href='build_pieces_table.html'>build_pieces_table</a>()</code>,
<code><a href='build_pieces.html'>build_pieces</a>()</code></p></div>
</div>
<div class="col-md-3 hidden-xs hidden-sm" id="sidebar">

View File

@@ -79,7 +79,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">brickr</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.2.0</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.3.0</span>
</span>
</div>
@@ -102,10 +102,7 @@
</a>
<ul class="dropdown-menu" role="menu">
<li>
<a href="../articles/graphs.html">ggplot with brickr</a>
</li>
<li>
<a href="../articles/models-from-other.html">3D Models from mosaics &amp; rayshader</a>
<a href="../articles/models-from-other.html">3D Models from mosaics</a>
</li>
<li>
<a href="../articles/models-from-program.html">3D Models programmatically</a>
@@ -113,6 +110,9 @@
<li>
<a href="../articles/models-from-tables.html">3D models from tables</a>
</li>
<li>
<a href="../articles/models-piece-type.html">Piece type in 3D Models</a>
</li>
<li>
<a href="../articles/mosaics.html">Mosaics with brickr</a>
</li>
@@ -168,7 +168,8 @@
<h2 class="hasAnchor" id="see-also"><a class="anchor" href="#see-also"></a>See also</h2>
<div class='dont-index'><p>Other Mosaics: <code><a href='image_to_mosaic.html'>image_to_mosaic</a></code></p></div>
<div class='dont-index'><p>Other Mosaics:
<code><a href='image_to_mosaic.html'>image_to_mosaic</a>()</code></p></div>
</div>
<div class="col-md-3 hidden-xs hidden-sm" id="sidebar">

View File

@@ -79,7 +79,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">brickr</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.2.0</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.3.0</span>
</span>
</div>
@@ -102,10 +102,7 @@
</a>
<ul class="dropdown-menu" role="menu">
<li>
<a href="../articles/graphs.html">ggplot with brickr</a>
</li>
<li>
<a href="../articles/models-from-other.html">3D Models from mosaics &amp; rayshader</a>
<a href="../articles/models-from-other.html">3D Models from mosaics</a>
</li>
<li>
<a href="../articles/models-from-program.html">3D Models programmatically</a>
@@ -113,6 +110,9 @@
<li>
<a href="../articles/models-from-tables.html">3D models from tables</a>
</li>
<li>
<a href="../articles/models-piece-type.html">Piece type in 3D Models</a>
</li>
<li>
<a href="../articles/mosaics.html">Mosaics with brickr</a>
</li>
@@ -167,10 +167,10 @@
<p>Plot object of required bricks by color and size.</p>
<h2 class="hasAnchor" id="see-also"><a class="anchor" href="#see-also"></a>See also</h2>
<div class='dont-index'><p>Other Resources: <code><a href='build_colors.html'>build_colors</a></code>,
<code><a href='build_instructions.html'>build_instructions</a></code>,
<code><a href='build_pieces_table.html'>build_pieces_table</a></code>,
<code><a href='build_themes.html'>build_themes</a></code></p></div>
<div class='dont-index'><p>Other Resources:
<code><a href='build_colors.html'>build_colors</a>()</code>,
<code><a href='build_instructions.html'>build_instructions</a>()</code>,
<code><a href='build_pieces_table.html'>build_pieces_table</a>()</code></p></div>
</div>
<div class="col-md-3 hidden-xs hidden-sm" id="sidebar">

View File

@@ -79,7 +79,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">brickr</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.2.0</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.3.0</span>
</span>
</div>
@@ -102,10 +102,7 @@
</a>
<ul class="dropdown-menu" role="menu">
<li>
<a href="../articles/graphs.html">ggplot with brickr</a>
</li>
<li>
<a href="../articles/models-from-other.html">3D Models from mosaics &amp; rayshader</a>
<a href="../articles/models-from-other.html">3D Models from mosaics</a>
</li>
<li>
<a href="../articles/models-from-program.html">3D Models programmatically</a>
@@ -113,6 +110,9 @@
<li>
<a href="../articles/models-from-tables.html">3D models from tables</a>
</li>
<li>
<a href="../articles/models-piece-type.html">Piece type in 3D Models</a>
</li>
<li>
<a href="../articles/mosaics.html">Mosaics with brickr</a>
</li>
@@ -167,9 +167,10 @@
<p>Data frame of piece counts by LEGO color name and size.</p>
<h2 class="hasAnchor" id="see-also"><a class="anchor" href="#see-also"></a>See also</h2>
<div class='dont-index'><p>Other Resources: <code><a href='build_colors.html'>build_colors</a></code>,
<code><a href='build_instructions.html'>build_instructions</a></code>,
<code><a href='build_pieces.html'>build_pieces</a></code>, <code><a href='build_themes.html'>build_themes</a></code></p></div>
<div class='dont-index'><p>Other Resources:
<code><a href='build_colors.html'>build_colors</a>()</code>,
<code><a href='build_instructions.html'>build_instructions</a>()</code>,
<code><a href='build_pieces.html'>build_pieces</a>()</code></p></div>
</div>
<div class="col-md-3 hidden-xs hidden-sm" id="sidebar">

View File

@@ -79,7 +79,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">brickr</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.2.0</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.3.0</span>
</span>
</div>
@@ -102,10 +102,7 @@
</a>
<ul class="dropdown-menu" role="menu">
<li>
<a href="../articles/graphs.html">ggplot with brickr</a>
</li>
<li>
<a href="../articles/models-from-other.html">3D Models from mosaics &amp; rayshader</a>
<a href="../articles/models-from-other.html">3D Models from mosaics</a>
</li>
<li>
<a href="../articles/models-from-program.html">3D Models programmatically</a>
@@ -113,6 +110,9 @@
<li>
<a href="../articles/models-from-tables.html">3D models from tables</a>
</li>
<li>
<a href="../articles/models-piece-type.html">Piece type in 3D Models</a>
</li>
<li>
<a href="../articles/mosaics.html">Mosaics with brickr</a>
</li>
@@ -151,19 +151,23 @@
<p>Consolidate 1x1 bricks into larger ones of the same color. Internal function.</p>
</div>
<pre class="usage"><span class='fu'>collect_bricks</span>(<span class='no'>image_list</span>, <span class='kw'>use_bricks</span> <span class='kw'>=</span> <span class='kw'>NULL</span>)</pre>
<pre class="usage"><span class='fu'>collect_bricks</span>(<span class='no'>image_list</span>, <span class='kw'>use_bricks</span> <span class='kw'>=</span> <span class='kw'>NULL</span>, <span class='kw'>default_piece_type</span> <span class='kw'>=</span> <span class='st'>"b"</span>)</pre>
<h2 class="hasAnchor" id="arguments"><a class="anchor" href="#arguments"></a>Arguments</h2>
<table class="ref-arguments">
<colgroup><col class="name" /><col class="desc" /></colgroup>
<tr>
<th>image_list</th>
<td><p>List output from legoize(). Contains an element <code>Img_lego</code>.</p></td>
<td><p>List output from legoize(). Contains an element <code>Img_lego</code>.</p></td>
</tr>
<tr>
<th>use_bricks</th>
<td><p>Array of brick sizes to use in mosaic. Defaults to <code><a href='https://rdrr.io/r/base/c.html'>c('4x2', '2x2', '3x1', '2x1', '1x1')</a></code>`.</p></td>
</tr>
<tr>
<th>default_piece_type</th>
<td><p>Piece type to use in absence of piece_type column.</p></td>
</tr>
</table>
<h2 class="hasAnchor" id="value"><a class="anchor" href="#value"></a>Value</h2>

View File

@@ -79,7 +79,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">brickr</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.2.0</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.3.0</span>
</span>
</div>
@@ -102,10 +102,7 @@
</a>
<ul class="dropdown-menu" role="menu">
<li>
<a href="../articles/graphs.html">ggplot with brickr</a>
</li>
<li>
<a href="../articles/models-from-other.html">3D Models from mosaics &amp; rayshader</a>
<a href="../articles/models-from-other.html">3D Models from mosaics</a>
</li>
<li>
<a href="../articles/models-from-program.html">3D Models programmatically</a>
@@ -113,6 +110,9 @@
<li>
<a href="../articles/models-from-tables.html">3D models from tables</a>
</li>
<li>
<a href="../articles/models-piece-type.html">Piece type in 3D Models</a>
</li>
<li>
<a href="../articles/mosaics.html">Mosaics with brickr</a>
</li>
@@ -151,19 +151,29 @@
<p><code>geom_rect</code>, except bars look like LEGO(R) bricks.</p>
</div>
<pre class="usage"><span class='fu'>geom_brick_rect</span>(<span class='kw'>mapping</span> <span class='kw'>=</span> <span class='kw'>NULL</span>, <span class='kw'>data</span> <span class='kw'>=</span> <span class='kw'>NULL</span>, <span class='kw'>stat</span> <span class='kw'>=</span> <span class='st'>"identity"</span>,
<span class='kw'>position</span> <span class='kw'>=</span> <span class='st'>"identity"</span>, <span class='no'>...</span>, <span class='kw'>label</span> <span class='kw'>=</span> <span class='st'>"brickr"</span>,
<span class='kw'>simplified_threshold</span> <span class='kw'>=</span> <span class='fl'>24</span> * <span class='fl'>24</span>, <span class='kw'>label_scale</span> <span class='kw'>=</span> <span class='fl'>1</span>, <span class='kw'>use_bricks</span> <span class='kw'>=</span> <span class='kw'>NULL</span>,
<span class='kw'>linejoin</span> <span class='kw'>=</span> <span class='st'>"mitre"</span>, <span class='kw'>na.rm</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>, <span class='kw'>show.legend</span> <span class='kw'>=</span> <span class='fl'>NA</span>,
<span class='kw'>inherit.aes</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>)</pre>
<pre class="usage"><span class='fu'>geom_brick_rect</span>(
<span class='kw'>mapping</span> <span class='kw'>=</span> <span class='kw'>NULL</span>,
<span class='kw'>data</span> <span class='kw'>=</span> <span class='kw'>NULL</span>,
<span class='kw'>stat</span> <span class='kw'>=</span> <span class='st'>"identity"</span>,
<span class='kw'>position</span> <span class='kw'>=</span> <span class='st'>"identity"</span>,
<span class='no'>...</span>,
<span class='kw'>label</span> <span class='kw'>=</span> <span class='st'>"brickr"</span>,
<span class='kw'>simplified_threshold</span> <span class='kw'>=</span> <span class='fl'>24</span> * <span class='fl'>24</span>,
<span class='kw'>label_scale</span> <span class='kw'>=</span> <span class='fl'>1</span>,
<span class='kw'>use_bricks</span> <span class='kw'>=</span> <span class='kw'>NULL</span>,
<span class='kw'>linejoin</span> <span class='kw'>=</span> <span class='st'>"mitre"</span>,
<span class='kw'>na.rm</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>,
<span class='kw'>show.legend</span> <span class='kw'>=</span> <span class='fl'>NA</span>,
<span class='kw'>inherit.aes</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>
)</pre>
<h2 class="hasAnchor" id="arguments"><a class="anchor" href="#arguments"></a>Arguments</h2>
<table class="ref-arguments">
<colgroup><col class="name" /><col class="desc" /></colgroup>
<tr>
<th>mapping</th>
<td><p>Set of aesthetic mappings created by <code>aes()</code> or
<code>aes_()</code>. If specified and <code>inherit.aes = TRUE</code> (the
<td><p>Set of aesthetic mappings created by <code><a href='https://ggplot2.tidyverse.org/reference/aes.html'>aes()</a></code> or
<code><a href='https://ggplot2.tidyverse.org/reference/aes_.html'>aes_()</a></code>. If specified and <code>inherit.aes = TRUE</code> (the
default), it is combined with the default mapping at the top level of the
plot. You must supply <code>mapping</code> if there is no plot mapping.</p></td>
</tr>
@@ -172,10 +182,10 @@ plot. You must supply <code>mapping</code> if there is no plot mapping.</p></td>
<td><p>The data to be displayed in this layer. There are three
options:</p>
<p>If <code>NULL</code>, the default, the data is inherited from the plot
data as specified in the call to <code>ggplot()</code>.</p>
data as specified in the call to <code><a href='https://ggplot2.tidyverse.org/reference/ggplot.html'>ggplot()</a></code>.</p>
<p>A <code>data.frame</code>, or other object, will override the plot
data. All objects will be fortified to produce a data frame. See
<code>fortify()</code> for which variables will be created.</p>
<code><a href='https://ggplot2.tidyverse.org/reference/fortify.html'>fortify()</a></code> for which variables will be created.</p>
<p>A <code>function</code> will be called with a single argument,
the plot data. The return value must be a <code>data.frame</code>, and
will be used as the layer data. A <code>function</code> can be created
@@ -193,7 +203,7 @@ a call to a position adjustment function.</p></td>
</tr>
<tr>
<th>...</th>
<td><p>Other arguments passed on to <code>layer()</code>. These are
<td><p>Other arguments passed on to <code><a href='https://ggplot2.tidyverse.org/reference/layer.html'>layer()</a></code>. These are
often aesthetics, used to set an aesthetic to a fixed value, like
<code>colour = "red"</code> or <code>size = 3</code>. They may also be parameters
to the paired geom/stat.</p></td>
@@ -236,22 +246,16 @@ display.</p></td>
<td><p>If <code>FALSE</code>, 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>borders()</code>.</p></td>
the default plot specification, e.g. <code><a href='https://ggplot2.tidyverse.org/reference/borders.html'>borders()</a></code>.</p></td>
</tr>
</table>
<h2 class="hasAnchor" id="see-also"><a class="anchor" href="#see-also"></a>See also</h2>
<div class='dont-index'><p>Other Graphs: <code><a href='coord-brick.html'>coord_brick</a></code>,
<code><a href='geom_brick_col.html'>geom_brick_col</a></code>,
<code><a href='scale_fill_brick.html'>scale_fill_brick</a></code>, <code><a href='theme_brick.html'>theme_brick</a></code></p></div>
</div>
<div class="col-md-3 hidden-xs hidden-sm" id="sidebar">
<h2>Contents</h2>
<ul class="nav nav-pills nav-stacked">
<li><a href="#arguments">Arguments</a></li>
<li><a href="#see-also">See also</a></li>
</ul>
</div>

View File

@@ -79,7 +79,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">brickr</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.2.0</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.3.0</span>
</span>
</div>
@@ -102,10 +102,7 @@
</a>
<ul class="dropdown-menu" role="menu">
<li>
<a href="../articles/graphs.html">ggplot with brickr</a>
</li>
<li>
<a href="../articles/models-from-other.html">3D Models from mosaics &amp; rayshader</a>
<a href="../articles/models-from-other.html">3D Models from mosaics</a>
</li>
<li>
<a href="../articles/models-from-program.html">3D Models programmatically</a>
@@ -113,6 +110,9 @@
<li>
<a href="../articles/models-from-tables.html">3D models from tables</a>
</li>
<li>
<a href="../articles/models-piece-type.html">Piece type in 3D Models</a>
</li>
<li>
<a href="../articles/mosaics.html">Mosaics with brickr</a>
</li>
@@ -151,10 +151,18 @@
<p>Create a 2D LEGO mosaic from an image array</p>
</div>
<pre class="usage"><span class='fu'>image_to_mosaic</span>(<span class='no'>img</span>, <span class='kw'>img_size</span> <span class='kw'>=</span> <span class='fl'>48</span>, <span class='kw'>color_table</span> <span class='kw'>=</span> <span class='kw'>NULL</span>,
<span class='kw'>method</span> <span class='kw'>=</span> <span class='st'>"cie94"</span>, <span class='kw'>color_palette</span> <span class='kw'>=</span> <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span>(<span class='st'>"universal"</span>, <span class='st'>"generic"</span>,
<span class='st'>"special"</span>), <span class='kw'>dithering</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>, <span class='kw'>contrast</span> <span class='kw'>=</span> <span class='fl'>1</span>, <span class='kw'>use_bricks</span> <span class='kw'>=</span> <span class='kw'>NULL</span>,
<span class='kw'>brightness</span> <span class='kw'>=</span> <span class='fl'>1</span>, <span class='kw'>warhol</span> <span class='kw'>=</span> <span class='fl'>1</span>:<span class='fl'>3</span>)</pre>
<pre class="usage"><span class='fu'>image_to_mosaic</span>(
<span class='no'>img</span>,
<span class='kw'>img_size</span> <span class='kw'>=</span> <span class='fl'>48</span>,
<span class='kw'>color_table</span> <span class='kw'>=</span> <span class='kw'>NULL</span>,
<span class='kw'>method</span> <span class='kw'>=</span> <span class='st'>"cie94"</span>,
<span class='kw'>color_palette</span> <span class='kw'>=</span> <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span>(<span class='st'>"universal"</span>, <span class='st'>"generic"</span>, <span class='st'>"special"</span>),
<span class='kw'>dithering</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>,
<span class='kw'>contrast</span> <span class='kw'>=</span> <span class='fl'>1</span>,
<span class='kw'>use_bricks</span> <span class='kw'>=</span> <span class='kw'>NULL</span>,
<span class='kw'>brightness</span> <span class='kw'>=</span> <span class='fl'>1</span>,
<span class='kw'>warhol</span> <span class='kw'>=</span> <span class='fl'>1</span>:<span class='fl'>3</span>
)</pre>
<h2 class="hasAnchor" id="arguments"><a class="anchor" href="#arguments"></a>Arguments</h2>
<table class="ref-arguments">
@@ -177,7 +185,7 @@ See attached data <code>lego_colors</code> as examples.</p></td>
<th>method</th>
<td><p>The method to use for comparison. Either 'brickr_classic', 'euclidean', 'cie1976', 'cie94', 'cie2000', or 'cmc'.
'brickr_classic' is an explicit euclidean distance formula, but yield different results than 'euclidean' in farver.
See <code><a href='https://rdrr.io/pkg/farver/man/compare_colour.html'>farver::compare_colour</a></code>.</p></td>
See <code><a href='https://farver.data-imaginist.com/reference/compare_colour.html'>farver::compare_colour</a></code>.</p></td>
</tr>
<tr>
<th>color_palette</th>
@@ -211,7 +219,8 @@ Use "bw" for only grayscale bricks. Ignored if a <code>color_table</code> is sup
<p>A list with element <code>Img_lego</code> containing a data frame of the x- &amp; y-coordinates, R, G, B channels, and mapped color of each brick (pixel).</p>
<h2 class="hasAnchor" id="see-also"><a class="anchor" href="#see-also"></a>See also</h2>
<div class='dont-index'><p>Other Mosaics: <code><a href='build_mosaic.html'>build_mosaic</a></code></p></div>
<div class='dont-index'><p>Other Mosaics:
<code><a href='build_mosaic.html'>build_mosaic</a>()</code></p></div>
</div>
<div class="col-md-3 hidden-xs hidden-sm" id="sidebar">

View File

@@ -79,7 +79,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">brickr</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.2.0</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.3.0</span>
</span>
</div>
@@ -102,10 +102,7 @@
</a>
<ul class="dropdown-menu" role="menu">
<li>
<a href="../articles/graphs.html">ggplot with brickr</a>
</li>
<li>
<a href="../articles/models-from-other.html">3D Models from mosaics &amp; rayshader</a>
<a href="../articles/models-from-other.html">3D Models from mosaics</a>
</li>
<li>
<a href="../articles/models-from-program.html">3D Models programmatically</a>
@@ -113,6 +110,9 @@
<li>
<a href="../articles/models-from-tables.html">3D models from tables</a>
</li>
<li>
<a href="../articles/models-piece-type.html">Piece type in 3D Models</a>
</li>
<li>
<a href="../articles/mosaics.html">Mosaics with brickr</a>
</li>

View File

@@ -78,7 +78,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">brickr</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.2.0</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.3.0</span>
</span>
</div>
@@ -101,10 +101,7 @@
</a>
<ul class="dropdown-menu" role="menu">
<li>
<a href="../articles/graphs.html">ggplot with brickr</a>
</li>
<li>
<a href="../articles/models-from-other.html">3D Models from mosaics &amp; rayshader</a>
<a href="../articles/models-from-other.html">3D Models from mosaics</a>
</li>
<li>
<a href="../articles/models-from-program.html">3D Models programmatically</a>
@@ -112,6 +109,9 @@
<li>
<a href="../articles/models-from-tables.html">3D models from tables</a>
</li>
<li>
<a href="../articles/models-piece-type.html">Piece type in 3D Models</a>
</li>
<li>
<a href="../articles/mosaics.html">Mosaics with brickr</a>
</li>
@@ -199,12 +199,6 @@
<td><p>Convert a 2D LEGO mosaic into a brickr 3D object</p></td>
</tr><tr>
<td>
<p><code><a href="bricks_from_rayshader.html">bricks_from_rayshader()</a></code> </p>
</td>
<td><p>Build a brickr 3D object from rayshader hillshade &amp; heightmap matrices</p></td>
</tr><tr>
<td>
<p><code><a href="bricks_from_table.html">bricks_from_table()</a></code> </p>
</td>
@@ -215,50 +209,6 @@
<p><code><a href="build_bricks.html">build_bricks()</a></code> </p>
</td>
<td><p>Build 3D brick model with rgl</p></td>
</tr><tr>
<td>
<p><code><a href="build_bricks_rayshader.html">build_bricks_rayshader()</a></code> </p>
</td>
<td><p>Build 3D brick model with rayshader.</p></td>
</tr>
</tbody><tbody>
<tr>
<th colspan="2">
<h2 id="section-ggplot-extension" class="hasAnchor"><a href="#section-ggplot-extension" class="anchor"></a>ggplot Extension</h2>
<p class="section-desc"><p>Brick bar charts in ggplot</p></p>
</th>
</tr>
<tr>
<td>
<p><code><a href="coord-brick.html">coord_brick()</a></code> <code><a href="coord-brick.html">coord_brick_flip()</a></code> </p>
</td>
<td><p>Cartesian coordinates for bricks - ggplot2 extension</p></td>
</tr><tr>
<td>
<p><code><a href="geom_brick_col.html">geom_brick_col()</a></code> </p>
</td>
<td><p>Bar charts with bricks - ggplot2 extension</p></td>
</tr><tr>
<td>
<p><code><a href="geom_brick_rect.html">geom_brick_rect()</a></code> </p>
</td>
<td><p>Tile charts as Bricks - ggplot2 extension</p></td>
</tr><tr>
<td>
<p><code><a href="scale_fill_brick.html">scale_fill_brick()</a></code> </p>
</td>
<td><p>Color scales for bricks - ggplot2 extension</p></td>
</tr><tr>
<td>
<p><code><a href="theme_brick.html">theme_brick()</a></code> </p>
</td>
<td><p>Brick color themes - ggplot2 extension</p></td>
</tr>
</tbody><tbody>
<tr>
@@ -291,12 +241,6 @@
<p><code><a href="build_pieces_table.html">build_pieces_table()</a></code> </p>
</td>
<td><p>Generate required bricks as a data frame.</p></td>
</tr><tr>
<td>
<p><code><a href="build_themes.html">build_themes()</a></code> </p>
</td>
<td><p>Display available brick themes for ggplot feature scale_fill_brick()</p></td>
</tr>
</tbody>
</table>
@@ -307,7 +251,6 @@
<ul class="nav nav-pills nav-stacked">
<li><a href="#section-mosaics">Mosaics</a></li>
<li><a href="#section--d-models">3D Models</a></li>
<li><a href="#section-ggplot-extension">ggplot Extension</a></li>
<li><a href="#section-bricks-irl">Bricks IRL</a></li>
</ul>
</div>

View File

@@ -0,0 +1,206 @@
<!-- Generated by pkgdown: do not edit by hand -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Brickr colors available for mosaics &amp; 3D models — lego_colors • brickr</title>
<!-- favicons -->
<link rel="icon" type="image/png" sizes="16x16" href="../favicon-16x16.png">
<link rel="icon" type="image/png" sizes="32x32" href="../favicon-32x32.png">
<link rel="apple-touch-icon" type="image/png" sizes="180x180" href="../apple-touch-icon.png" />
<link rel="apple-touch-icon" type="image/png" sizes="120x120" href="../apple-touch-icon-120x120.png" />
<link rel="apple-touch-icon" type="image/png" sizes="76x76" href="../apple-touch-icon-76x76.png" />
<link rel="apple-touch-icon" type="image/png" sizes="60x60" href="../apple-touch-icon-60x60.png" />
<!-- jquery -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
<!-- Bootstrap -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha256-916EbMg70RQy9LHiGkXzG8hSg9EdNy97GazNG/aiY1w=" crossorigin="anonymous" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha256-U5ZEeKfGNOja007MMD3YBI0A3OSZOQbeG6z2f2Y0hu8=" crossorigin="anonymous"></script>
<!-- Font Awesome icons -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.7.1/css/all.min.css" integrity="sha256-nAmazAk6vS34Xqo0BSrTb+abbtFlgsFK7NKSi6o7Y78=" crossorigin="anonymous" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.7.1/css/v4-shims.min.css" integrity="sha256-6qHlizsOWFskGlwVOKuns+D1nB6ssZrHQrNj1wGplHc=" crossorigin="anonymous" />
<!-- clipboard.js -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.4/clipboard.min.js" integrity="sha256-FiZwavyI2V6+EXO1U+xzLG3IKldpiTFf3153ea9zikQ=" crossorigin="anonymous"></script>
<!-- headroom.js -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.9.4/headroom.min.js" integrity="sha256-DJFC1kqIhelURkuza0AvYal5RxMtpzLjFhsnVIeuk+U=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.9.4/jQuery.headroom.min.js" integrity="sha256-ZX/yNShbjqsohH1k95liqY9Gd8uOiE1S4vZc+9KQ1K4=" crossorigin="anonymous"></script>
<!-- pkgdown -->
<link href="../pkgdown.css" rel="stylesheet">
<script src="../pkgdown.js"></script>
<link href="../extra.css" rel="stylesheet">
<meta property="og:title" content="Brickr colors available for mosaics &amp; 3D models — lego_colors" />
<meta property="og:description" content="A dataset containing the 54 colors available in brickr, along with metadata" />
<meta property="og:image" content="http://brickr.org/logo.png" />
<meta name="twitter:card" content="summary" />
<!-- mathjax -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js" integrity="sha256-nvJJv9wWKEm88qvoQl9ekL2J+k/RWIsaSScxxlsrv8k=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/config/TeX-AMS-MML_HTMLorMML.js" integrity="sha256-84DKXVJXs0/F8OTMzX4UR909+jtl4G7SPypPavF+GfA=" crossorigin="anonymous"></script>
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div class="container template-reference-topic">
<header>
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">brickr</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.3.0</span>
</span>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li>
<a href="../index.html">
<span class="fas fa fas fa-home fa-lg"></span>
</a>
</li>
<li>
<a href="../reference/index.html">Reference</a>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
Articles
<span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
<li>
<a href="../articles/models-from-other.html">3D Models from mosaics</a>
</li>
<li>
<a href="../articles/models-from-program.html">3D Models programmatically</a>
</li>
<li>
<a href="../articles/models-from-tables.html">3D models from tables</a>
</li>
<li>
<a href="../articles/models-piece-type.html">Piece type in 3D Models</a>
</li>
<li>
<a href="../articles/mosaics.html">Mosaics with brickr</a>
</li>
</ul>
</li>
<li>
<a href="../news/index.html">Changelog</a>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li>
<a href="https://github.com/ryantimpe/brickr">
<span class="fab fa fab fa-github fa-lg"></span>
</a>
</li>
</ul>
</div><!--/.nav-collapse -->
</div><!--/.container -->
</div><!--/.navbar -->
</header>
<div class="row">
<div class="col-md-9 contents">
<div class="page-header">
<h1>Brickr colors available for mosaics &amp; 3D models</h1>
<small class="dont-index">Source: <a href='https://github.com/ryantimpe/brickr/blob/master/R/data.R'><code>R/data.R</code></a></small>
<div class="hidden name"><code>lego_colors.Rd</code></div>
</div>
<div class="ref-description">
<p>A dataset containing the 54 colors available in brickr, along with metadata</p>
</div>
<pre class="usage"><span class='no'>lego_colors</span></pre>
<h2 class="hasAnchor" id="format"><a class="anchor" href="#format"></a>Format</h2>
<p>A data frame with 54 rows and 10 variables:</p><dl class='dl-horizontal'>
<dt>brickrID</dt><dd><p>integer, simple color number for use in mosaic creation</p></dd>
<dt>Color</dt><dd><p>color name</p></dd>
<dt>LEGONo</dt><dd><p>integer, color number according to The LEGO Group</p></dd>
<dt>Palette</dt><dd><p>Name of palette, either Universal, Generic, or Special</p></dd>
<dt>R_lego</dt><dd><p>Red channel, (0-1)</p></dd>
<dt>G_lego</dt><dd><p>Green channel, (0-1)</p></dd>
<dt>B_lego</dt><dd><p>Blue channel, (0-1)</p></dd>
<dt>Trans_lego</dt><dd><p>Transparent color, TRUE or FALSE</p></dd>
<dt>hex</dt><dd><p>Color hex code</p></dd>
<dt>lum</dt><dd><p>Color brightness, (0-1)</p></dd>
</dl>
<h2 class="hasAnchor" id="source"><a class="anchor" href="#source"></a>Source</h2>
<p><a href='https://brickarchitect.com/color/'>https://brickarchitect.com/color/</a></p>
</div>
<div class="col-md-3 hidden-xs hidden-sm" id="sidebar">
<h2>Contents</h2>
<ul class="nav nav-pills nav-stacked">
<li><a href="#format">Format</a></li>
<li><a href="#source">Source</a></li>
</ul>
</div>
</div>
<footer>
<div class="copyright">
<p>Developed by Ryan Timpe.</p>
</div>
<div class="pkgdown">
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.4.1.</p>
</div>
</footer>
</div>
</body>
</html>

View File

@@ -79,7 +79,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">brickr</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.2.0</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.3.0</span>
</span>
</div>
@@ -102,10 +102,7 @@
</a>
<ul class="dropdown-menu" role="menu">
<li>
<a href="../articles/graphs.html">ggplot with brickr</a>
</li>
<li>
<a href="../articles/models-from-other.html">3D Models from mosaics &amp; rayshader</a>
<a href="../articles/models-from-other.html">3D Models from mosaics</a>
</li>
<li>
<a href="../articles/models-from-program.html">3D Models programmatically</a>
@@ -113,6 +110,9 @@
<li>
<a href="../articles/models-from-tables.html">3D models from tables</a>
</li>
<li>
<a href="../articles/models-piece-type.html">Piece type in 3D Models</a>
</li>
<li>
<a href="../articles/mosaics.html">Mosaics with brickr</a>
</li>

View File

@@ -79,7 +79,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">brickr</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.2.0</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.3.0</span>
</span>
</div>
@@ -102,10 +102,7 @@
</a>
<ul class="dropdown-menu" role="menu">
<li>
<a href="../articles/graphs.html">ggplot with brickr</a>
</li>
<li>
<a href="../articles/models-from-other.html">3D Models from mosaics &amp; rayshader</a>
<a href="../articles/models-from-other.html">3D Models from mosaics</a>
</li>
<li>
<a href="../articles/models-from-program.html">3D Models programmatically</a>
@@ -113,6 +110,9 @@
<li>
<a href="../articles/models-from-tables.html">3D models from tables</a>
</li>
<li>
<a href="../articles/models-piece-type.html">Piece type in 3D Models</a>
</li>
<li>
<a href="../articles/mosaics.html">Mosaics with brickr</a>
</li>
@@ -161,9 +161,9 @@
</tr>
<tr>
<th>method</th>
<td><p>The method to use for comparison. Either 'brickr_classic', 'euclidean', 'cie1976', 'cie94', 'cie2000', or 'cmc'.
<td><p>Default 'cie94'. The method to use for comparison. Either 'brickr_classic', 'euclidean', 'cie1976', 'cie94', 'cie2000', or 'cmc'.
'brickr_classic' is an explicit euclidean distance formula, but yield different results than 'euclidean' in farver.
See <code><a href='https://rdrr.io/pkg/farver/man/compare_colour.html'>farver::compare_colour</a></code>.</p></td>
See <code><a href='https://farver.data-imaginist.com/reference/compare_colour.html'>farver::compare_colour</a></code>.</p></td>
</tr>
<tr>
<th>color_table</th>
@@ -172,7 +172,8 @@ See attached data <code>lego_colors</code> as examples.</p></td>
</tr>
<tr>
<th>color_palette</th>
<td><p>Brick color rarity to use. Defaults to all colors: 'universal' (most common), 'generic', and 'special' (least common). This is useful when trying to build the mosaic out of real bricks.
<td><p>Brick color rarity to use. Defaults to all colors: 'universal' (most common), 'generic', and 'special' (least common).
This is useful when trying to build the mosaic out of real bricks.
Use "bw" for only grayscale bricks. Ignored if a <code>color_table</code> is supplied.</p></td>
</tr>
<tr>
@@ -183,6 +184,10 @@ Use "bw" for only grayscale bricks. Ignored if a <code>color_table</code> is sup
<th>contrast</th>
<td><p>For <code>color_palette = "bw"</code>. A value &gt;1 will increase the contrast of the image while a positive value &lt;1 will decrease the contrast.</p></td>
</tr>
<tr>
<th>default_piece_type</th>
<td><p>Piece type to use in absence of piece_type column.</p></td>
</tr>
</table>
<h2 class="hasAnchor" id="value"><a class="anchor" href="#value"></a>Value</h2>

View File

@@ -18,18 +18,12 @@
<url>
<loc>http://brickr.org/reference/bricks_from_mosaic.html</loc>
</url>
<url>
<loc>http://brickr.org/reference/bricks_from_rayshader.html</loc>
</url>
<url>
<loc>http://brickr.org/reference/bricks_from_table.html</loc>
</url>
<url>
<loc>http://brickr.org/reference/build_bricks.html</loc>
</url>
<url>
<loc>http://brickr.org/reference/build_bricks_rayshader.html</loc>
</url>
<url>
<loc>http://brickr.org/reference/build_colors.html</loc>
</url>
@@ -45,18 +39,9 @@
<url>
<loc>http://brickr.org/reference/build_pieces_table.html</loc>
</url>
<url>
<loc>http://brickr.org/reference/build_themes.html</loc>
</url>
<url>
<loc>http://brickr.org/reference/collect_bricks.html</loc>
</url>
<url>
<loc>http://brickr.org/reference/coord-brick.html</loc>
</url>
<url>
<loc>http://brickr.org/reference/geom_brick_col.html</loc>
</url>
<url>
<loc>http://brickr.org/reference/geom_brick_rect.html</loc>
</url>
@@ -67,7 +52,7 @@
<loc>http://brickr.org/reference/image_to_scaled.html</loc>
</url>
<url>
<loc>http://brickr.org/reference/layer_from_bricks.html</loc>
<loc>http://brickr.org/reference/lego_colors.html</loc>
</url>
<url>
<loc>http://brickr.org/reference/pipe.html</loc>
@@ -75,15 +60,6 @@
<url>
<loc>http://brickr.org/reference/scaled_to_colors.html</loc>
</url>
<url>
<loc>http://brickr.org/reference/scale_fill_brick.html</loc>
</url>
<url>
<loc>http://brickr.org/reference/theme_brick.html</loc>
</url>
<url>
<loc>http://brickr.org/articles/graphs.html</loc>
</url>
<url>
<loc>http://brickr.org/articles/models-from-other.html</loc>
</url>
@@ -93,6 +69,9 @@
<url>
<loc>http://brickr.org/articles/models-from-tables.html</loc>
</url>
<url>
<loc>http://brickr.org/articles/models-piece-type.html</loc>
</url>
<url>
<loc>http://brickr.org/articles/mosaics.html</loc>
</url>

View File

@@ -6,7 +6,9 @@
\usage{
bricks_from_coords(
coord_table,
use_bricks = NULL,
increment_level = 0,
min_level = 1,
max_level = Inf,
increment_x = 0,
max_x = Inf,
@@ -17,10 +19,16 @@ bricks_from_coords(
)
}
\arguments{
\item{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()}.}
\item{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()}. Optional column 'piece_type' for shapes other than rectangular bricks.
Optional column ' mid_Level' with values 0, 1, or 2 (default 0) for 1-height placement of bricks.}
\item{use_bricks}{Array of brick sizes to use in mosaic. Defaults to \code{c('4x2', '3x2', '2x2', '3x1', '2x1', '1x1')}`.}
\item{increment_level}{Default '0'. Use in animations. Shift Level/z dimension by an integer.}
\item{min_level}{Default '1'. Use in animations. Any Level/z values below this value will be cut off.}
\item{max_level}{Default 'Inf'. Use in animations. Any Level/z values above this value will be cut off.}
\item{increment_x}{Default '0'. Use in animations. Shift x dimension by an integer.}
@@ -45,9 +53,7 @@ Convert a data frame with x, y, z & Color columns into a brickr 3D object
Other 3D Models:
\code{\link{bricks_from_excel}()},
\code{\link{bricks_from_mosaic}()},
\code{\link{bricks_from_rayshader}()},
\code{\link{bricks_from_table}()},
\code{\link{build_bricks_rayshader}()},
\code{\link{build_bricks}()}
}
\concept{3D Models}

View File

@@ -6,8 +6,11 @@
\usage{
bricks_from_excel(
excel_table,
piece_table = NULL,
use_bricks = NULL,
repeat_levels = 1,
increment_level = 0,
min_level = 1,
max_level = Inf,
increment_x = 0,
max_x = Inf,
@@ -20,10 +23,16 @@ bricks_from_excel(
\arguments{
\item{excel_table}{Sheet imported from a brickr Excel template to build model. Contains stud placement and colors.}
\item{piece_table}{Sheet identical in shape to \code{excel_table} with piece shape IDs.}
\item{use_bricks}{Array of brick sizes to use in mosaic. Defaults to \code{c('4x2', '3x2', '2x2', '3x1', '2x1', '1x1')}`.}
\item{repeat_levels}{How many times to repeat a level. Can save time in model planning. Default is 1.}
\item{increment_level}{Default '0'. Use in animations. Shift Level/z dimension by an integer.}
\item{min_level}{Default '1'. Use in animations. Any Level/z values below this value will be cut off.}
\item{max_level}{Default 'Inf'. Use in animations. Any Level/z values above this value will be cut off.}
\item{increment_x}{Default '0'. Use in animations. Shift x dimension by an integer.}
@@ -48,9 +57,7 @@ Convert an Excel {brickr} template into a brickr 3D object
Other 3D Models:
\code{\link{bricks_from_coords}()},
\code{\link{bricks_from_mosaic}()},
\code{\link{bricks_from_rayshader}()},
\code{\link{bricks_from_table}()},
\code{\link{build_bricks_rayshader}()},
\code{\link{build_bricks}()}
}
\concept{3D Models}

View File

@@ -14,7 +14,7 @@ bricks_from_mosaic(mosaic_list, mosaic_height = 6, highest_el = "light")
\item{highest_el}{Brick height is determined by brightness of color. Use \code{highest_el = 'dark'} for darkest bricks to have \code{mosaic_height}.}
}
\value{
A list with elements \code{threed_elevation} and \code{threed_hillshade} to created 3D mosiacs with the \code{rayshader} package.
A list with elements \code{Img_lego} to pass to \code{collect_bricks()}.
}
\description{
Convert a 2D LEGO mosaic into a brickr 3D object
@@ -23,9 +23,7 @@ Convert a 2D LEGO mosaic into a brickr 3D object
Other 3D Models:
\code{\link{bricks_from_coords}()},
\code{\link{bricks_from_excel}()},
\code{\link{bricks_from_rayshader}()},
\code{\link{bricks_from_table}()},
\code{\link{build_bricks_rayshader}()},
\code{\link{build_bricks}()}
}
\concept{3D Models}

View File

@@ -1,34 +0,0 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/bricks-from-rayshader.R
\name{bricks_from_rayshader}
\alias{bricks_from_rayshader}
\title{Build a brickr 3D object from rayshader hillshade & heightmap matrices}
\usage{
bricks_from_rayshader(hillshade, heightmap, max_height = 12, img_size = 48)
}
\arguments{
\item{hillshade}{Same as \code{rayshader::plot_3d()}. Hillshade/image to be added to 3D surface map.}
\item{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.}
\item{max_height}{Maximum height of plot in LEGO bricks or plates.}
\item{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.
Use an array of two values for a rectangular image \code{c(width, height)}.}
}
\value{
A list with elements \code{threed_elevation} and \code{threed_hillshade} to created 3D mosiacs with the \code{rayshader} package.
}
\description{
Build a brickr 3D object from rayshader hillshade & heightmap matrices
}
\seealso{
Other 3D Models:
\code{\link{bricks_from_coords}()},
\code{\link{bricks_from_excel}()},
\code{\link{bricks_from_mosaic}()},
\code{\link{bricks_from_table}()},
\code{\link{build_bricks_rayshader}()},
\code{\link{build_bricks}()}
}
\concept{3D Models}

Some files were not shown because too many files have changed in this diff Show More