Fancy bricks passed CRAN check and new vignette

This commit is contained in:
ryantimpe
2020-03-25 09:42:12 -04:00
parent c76a282a62
commit 1e1ff81ae4
76 changed files with 1435 additions and 701 deletions
+3 -2
View File
@@ -1,13 +1,14 @@
Package: brickr
Title: Tools to emulate the LEGO® System in R
Version: 0.2.9.9111
Version: 0.2.9.9215
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.
Generate digital LEGO 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.
License: MIT + file LICENSE
Encoding: UTF-8
+7 -3
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",
+5 -3
View File
@@ -8,10 +8,10 @@
#' @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() )
+22 -15
View File
@@ -3,9 +3,10 @@
#' @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 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.
@@ -21,7 +22,7 @@ bricks_from_table <- function(matrix_table, color_guide = brickr::lego_colors,
piece_matrix = NULL,
use_bricks = NULL,
.re_level = TRUE,
increment_level = 0, max_level = Inf,
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){
@@ -124,7 +125,7 @@ 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
@@ -154,7 +155,7 @@ 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)
@@ -173,7 +174,7 @@ bricks_from_table <- function(matrix_table, color_guide = brickr::lego_colors,
#' 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 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()}.
@@ -184,7 +185,7 @@ bricks_from_excel <- function(excel_table,
piece_table = NULL,
use_bricks = NULL,
repeat_levels = 1,
increment_level = 0, max_level = Inf,
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){
@@ -192,10 +193,9 @@ bricks_from_excel <- function(excel_table,
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 %in% c("Level", "mid-level")))
dplyr::filter(!(Level %in% c("Level")))
#Repeat levels.
# Super niche case for lazy people, like me
@@ -216,16 +216,18 @@ bricks_from_excel <- function(excel_table,
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 %>%
dplyr::select(1:columns_meta_start) %>%
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")))
list(~ifelse(grepl("^[A-Za-z]", .)|is.na(.), ., "b")))
#Repeat levels.
if(is.numeric(repeat_levels)){
@@ -245,6 +247,9 @@ bricks_from_excel <- function(excel_table,
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
@@ -261,7 +266,8 @@ bricks_from_excel <- function(excel_table,
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)
@@ -275,6 +281,7 @@ bricks_from_excel <- function(excel_table,
#' 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.
@@ -288,7 +295,7 @@ bricks_from_excel <- function(excel_table,
#'
bricks_from_coords <- function(coord_table,
use_bricks = NULL,
increment_level = 0, max_level = Inf,
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){
@@ -309,7 +316,7 @@ bricks_from_coords <- function(coord_table,
bricks_raw <- bricks_raw %>%
dplyr::mutate(mid_level = 0)
}
if(!any(unique(brick_set$mid_level) %in% 0:2)){
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.")
}
+4 -3
View File
@@ -353,13 +353,14 @@ build_bricks <- function(brick_list,
if(suppress_knobs){
img_lego <- img_lego %>%
dplyr::mutate(temp_level = Level*3 + mid_level) %>%
dplyr::mutate(temp_level = Level*3 + mid_level,
piece_type = tolower(piece_type)) %>%
dplyr::group_by(x, y) %>%
dplyr::filter(
#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") |
((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 + 2) & piece_type %in% c("p", "s")) |
((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(temp_level, order_by = temp_level)) |
# Or this or next level is transparent
+17 -3
View File
@@ -2,12 +2,26 @@
#'
#' @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 absense 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 ----
@@ -51,7 +65,7 @@ collect_bricks <- function(image_list, use_bricks = NULL){
offset_x <- brick_sizes2$offset_x[aa]
offset_y <- brick_sizes2$offset_y[aa]
in_list$Img_lego %>%
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,
@@ -68,7 +82,7 @@ collect_bricks <- function(image_list, use_bricks = NULL){
}
)
img_single <- in_list$Img_lego %>%
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)) %>%
+1 -1
View File
@@ -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)
+3 -2
View File
@@ -104,6 +104,7 @@ image_to_scaled <- function(image, img_size = 48, brightness = 1, warhol = 1:3){
#' 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 absense of piece_type column.
#' @format NULL
#' @usage NULL
#' @keywords internal
@@ -112,7 +113,7 @@ scaled_to_colors <- function(image_list, method = "brickr_classic",
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 +156,7 @@ scaled_to_colors <- function(image_list, method = "brickr_classic",
#Return output....
in_list[["Img_lego"]] <- img %>%
dplyr::mutate(Level = 1, piece_type = "B")
dplyr::mutate(Level = 1, piece_type = default_piece_type)
in_list[["brickr_object"]] <- "mosaic"
+4 -6
View File
@@ -35,10 +35,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
+5 -5
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.2.9.9215</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-pieces-type.html">UNKNOWN TITLE</a>
</li>
<li>
<a href="articles/mosaics.html">Mosaics with brickr</a>
</li>
+6 -6
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.2.9.9215</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-pieces-type.html">UNKNOWN TITLE</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>
+13 -229
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.2.9.9215</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-pieces-type.html">UNKNOWN TITLE</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>
+7 -15
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.2.9.9215</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-pieces-type.html">UNKNOWN TITLE</a>
</li>
<li>
<a href="../articles/mosaics.html">Mosaics with brickr</a>
</li>
@@ -157,17 +157,9 @@
<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>
</ul>
</div>
</div>
+8 -59
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.2.9.9215</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-pieces-type.html">UNKNOWN TITLE</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: 46 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 173 KiB

After

Width:  |  Height:  |  Size: 188 KiB

+5 -5
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.2.9.9215</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-pieces-type.html">UNKNOWN TITLE</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: 48 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: 29 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 62 KiB

After

Width:  |  Height:  |  Size: 63 KiB

+5 -25
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.2.9.9215</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-pieces-type.html">UNKNOWN TITLE</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

+423
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

+7 -7
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.2.9.9215</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-pieces-type.html">UNKNOWN TITLE</a>
</li>
<li>
<a href="../articles/mosaics.html">Mosaics with brickr</a>
</li>
@@ -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: 57 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 171 KiB

After

Width:  |  Height:  |  Size: 179 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: 42 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 171 KiB

After

Width:  |  Height:  |  Size: 176 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 56 KiB

After

Width:  |  Height:  |  Size: 57 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 61 KiB

After

Width:  |  Height:  |  Size: 63 KiB

+5 -5
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.2.9.9215</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-pieces-type.html">UNKNOWN TITLE</a>
</li>
<li>
<a href="articles/mosaics.html">Mosaics with brickr</a>
</li>
+14 -39
View File
@@ -19,8 +19,9 @@
<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: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 mosaics, along with piece counts and instructions.
Build 3D models using data frames with rgl. ">
<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.2.9.9215</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-pieces-type.html">UNKNOWN TITLE</a>
</li>
<li>
<a href="articles/mosaics.html">Mosaics with brickr</a>
</li>
@@ -125,7 +126,7 @@
<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="#charts"><strong>Charts</strong></a>: COMING SOON: A <a href="https://ggplot2.tidyverse.org/">ggplot2</a> extension to generate plots that resemble LEGO® bricks.</li>
</ul>
<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>
@@ -183,9 +184,9 @@
<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_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>bricks_from_rayshader()</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>
</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 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>build_bricks_rayshader()</code>. Rayshader can still be used for saving snapshots and creating animations.</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>
@@ -289,32 +290,6 @@
</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,14 +298,14 @@
<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>
@@ -352,7 +327,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">
+20 -18
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.2.9.9215</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-pieces-type.html">UNKNOWN TITLE</a>
</li>
<li>
<a href="../articles/mosaics.html">Mosaics with brickr</a>
</li>
@@ -145,9 +145,10 @@
<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-020---aka-castle" class="section level1">
<h1 class="page-header">
<a href="#brickr-020" class="anchor"></a>brickr 0.2.0</h1>
<a href="#brickr-020---aka-castle" class="anchor"></a>brickr 0.2.0 - a.k.a. <a href="">Castle</a>
</h1>
<ul>
<li>Lots of bug fixes. More to come.</li>
</ul>
@@ -158,9 +159,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 +170,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 +198,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 +213,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 +252,8 @@
<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-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>
+2 -2
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-pieces-type: models-pieces-type.html
mosaics: mosaics.html
urls:
reference: http://brickr.org/reference
+8 -9
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.2.9.9215</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-pieces-type.html">UNKNOWN TITLE</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>
+7 -7
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.2.9.9215</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-pieces-type.html">UNKNOWN TITLE</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>
+34 -15
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.2.9.9215</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-pieces-type.html">UNKNOWN TITLE</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">
+37 -14
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.2.9.9215</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-pieces-type.html">UNKNOWN TITLE</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">
+12 -14
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.2.9.9215</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-pieces-type.html">UNKNOWN TITLE</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">
+39 -16
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.2.9.9215</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-pieces-type.html">UNKNOWN TITLE</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">
+18 -17
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.2.9.9215</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-pieces-type.html">UNKNOWN TITLE</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

+9 -8
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.2.9.9215</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-pieces-type.html">UNKNOWN TITLE</a>
</li>
<li>
<a href="../articles/mosaics.html">Mosaics with brickr</a>
</li>
@@ -171,9 +171,10 @@
<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>
+9 -8
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.2.9.9215</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-pieces-type.html">UNKNOWN TITLE</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">
+7 -6
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.2.9.9215</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-pieces-type.html">UNKNOWN TITLE</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">
+9 -9
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.2.9.9215</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-pieces-type.html">UNKNOWN TITLE</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">
+9 -8
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.2.9.9215</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-pieces-type.html">UNKNOWN TITLE</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">
+11 -7
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.2.9.9215</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-pieces-type.html">UNKNOWN TITLE</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 absense of piece_type column.</p></td>
</tr>
</table>
<h2 class="hasAnchor" id="value"><a class="anchor" href="#value"></a>Value</h2>
+26 -22
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.2.9.9215</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-pieces-type.html">UNKNOWN TITLE</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>
+20 -11
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.2.9.9215</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-pieces-type.html">UNKNOWN TITLE</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'>"brickr_classic"</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">
+5 -5
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.2.9.9215</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-pieces-type.html">UNKNOWN TITLE</a>
</li>
<li>
<a href="../articles/mosaics.html">Mosaics with brickr</a>
</li>
+77 -35
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.2.9.9215</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-pieces-type.html">UNKNOWN TITLE</a>
</li>
<li>
<a href="../articles/mosaics.html">Mosaics with brickr</a>
</li>
@@ -200,9 +200,53 @@
</tr><tr>
<td>
<p><code><a href="bricks_from_rayshader.html">bricks_from_rayshader()</a></code> </p>
<p><code><a href="bricks_from_table.html">bricks_from_table()</a></code> </p>
</td>
<td><p>Build a brickr 3D object from rayshader hillshade &amp; heightmap matrices</p></td>
<td><p>Convert a matrix table into a brickr 3D object</p></td>
</tr><tr>
<td>
<p><code><a href="build_bricks.html">build_bricks()</a></code> </p>
</td>
<td><p>Build 3D brick model with rgl</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="brickr-ggproto.html">GeomBrick</a></code> </p>
</td>
<td><p>GeomBrick</p></td>
</tr><tr>
<td>
<p><code><a href="brickr.html">brickr</a></code> </p>
</td>
<td><p><code>brickr</code> package</p></td>
</tr><tr>
<td>
<p><code><a href="bricks_from_coords.html">bricks_from_coords()</a></code> </p>
</td>
<td><p>Convert a data frame with x, y, z &amp; Color columns into a brickr 3D object</p></td>
</tr><tr>
<td>
<p><code><a href="bricks_from_excel.html">bricks_from_excel()</a></code> </p>
</td>
<td><p>Convert an Excel brickr template into a brickr 3D object</p></td>
</tr><tr>
<td>
<p><code><a href="bricks_from_mosaic.html">bricks_from_mosaic()</a></code> </p>
</td>
<td><p>Convert a 2D LEGO mosaic into a brickr 3D object</p></td>
</tr><tr>
<td>
@@ -218,29 +262,33 @@
</tr><tr>
<td>
<p><code><a href="build_bricks_rayshader.html">build_bricks_rayshader()</a></code> </p>
<p><code><a href="build_colors.html">build_colors()</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>
<td><p>Display available brick colors</p></td>
</tr><tr>
<td>
<p><code><a href="geom_brick_col.html">geom_brick_col()</a></code> </p>
<p><code><a href="build_instructions.html">build_instructions()</a></code> </p>
</td>
<td><p>Bar charts with bricks - ggplot2 extension</p></td>
<td><p>Create instruction manual for 2D image mosaics</p></td>
</tr><tr>
<td>
<p><code><a href="build_mosaic.html">build_mosaic()</a></code> </p>
</td>
<td><p>Display 2D LEGO mosaic as a plot image</p></td>
</tr><tr>
<td>
<p><code><a href="build_pieces.html">build_pieces()</a></code> </p>
</td>
<td><p>Display bricks required to build model or mosaic.</p></td>
</tr><tr>
<td>
<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>
@@ -250,15 +298,15 @@
</tr><tr>
<td>
<p><code><a href="scale_fill_brick.html">scale_fill_brick()</a></code> </p>
<p><code><a href="image_to_mosaic.html">image_to_mosaic()</a></code> </p>
</td>
<td><p>Color scales for bricks - ggplot2 extension</p></td>
<td><p>Create a 2D LEGO mosaic from an image array</p></td>
</tr><tr>
<td>
<p><code><a href="theme_brick.html">theme_brick()</a></code> </p>
<p><code><a href="lego_colors.html">lego_colors</a></code> </p>
</td>
<td><p>Brick color themes - ggplot2 extension</p></td>
<td><p>Brickr colors avaiable for mosaics &amp; 3D models</p></td>
</tr>
</tbody><tbody>
<tr>
@@ -291,12 +339,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>
+206
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 avaiable 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 avaiable 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.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">UNKNOWN TITLE</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 avaiable 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>
+5 -5
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.2.9.9215</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-pieces-type.html">UNKNOWN TITLE</a>
</li>
<li>
<a href="../articles/mosaics.html">Mosaics with brickr</a>
</li>
+10 -6
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.2.9.9215</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-pieces-type.html">UNKNOWN TITLE</a>
</li>
<li>
<a href="../articles/mosaics.html">Mosaics with brickr</a>
</li>
@@ -163,7 +163,7 @@
<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_table</th>
@@ -183,6 +183,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 absense of piece_type column.</p></td>
</tr>
</table>
<h2 class="hasAnchor" id="value"><a class="anchor" href="#value"></a>Value</h2>
+4 -25
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-pieces-type.html</loc>
</url>
<url>
<loc>http://brickr.org/articles/mosaics.html</loc>
</url>
+6
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,
@@ -21,8 +23,12 @@ bricks_from_coords(
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.}
+6
View File
@@ -7,8 +7,10 @@
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,
@@ -23,10 +25,14 @@ bricks_from_excel(
\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.}
+6
View File
@@ -8,8 +8,10 @@ bricks_from_table(
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,
@@ -26,10 +28,14 @@ bricks_from_table(
\item{piece_matrix}{A data frame in same shape as \code{matrix_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{.re_level}{Logical to reassign the Level/z dimension to layers in alphanumeric order. Set to FALSE to explicitly provide levels.}
\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.}
+3 -1
View File
@@ -4,12 +4,14 @@
\alias{collect_bricks}
\title{Consolidate 1x1 bricks into larger ones of the same color. Internal function.}
\usage{
collect_bricks(image_list, use_bricks = NULL)
collect_bricks(image_list, use_bricks = NULL, default_piece_type = "b")
}
\arguments{
\item{image_list}{List output from legoize(). Contains an element \code{Img_lego}.}
\item{use_bricks}{Array of brick sizes to use in mosaic. Defaults to \code{c('4x2', '2x2', '3x1', '2x1', '1x1')}`.}
\item{default_piece_type}{Piece type to use in absense of piece_type column.}
}
\value{
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.
+2
View File
@@ -19,6 +19,8 @@ Use "bw" for only grayscale bricks. Ignored if a \code{color_table} is supplied.
\item{dithering}{Improves color of large, photo-realistic mosaics.}
\item{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.}
\item{default_piece_type}{Piece type to use in absense of piece_type column.}
}
\value{
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).
+264
View File
@@ -0,0 +1,264 @@
---
title: "Piece type in 3D Models"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{models-piece-type}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>"
)
rgl::setupKnitr()
```
```{r setup, include = FALSE}
library(brickr)
```
## Getting started
Models in brickr default to rendering rectangular LEGO bricks. Other LEGO shapes are possible in both `bricks_from_coords()` and `bricks_from_table()` or `bricks_from_excel()`.
Piece shapes in models are driven the `piece_type` ID.
## All piece options
Currently there are 5 unique piece shapes in brickr. Some shapes can have different orientations, which is also determined by the `piece_type` column.
```{r piece_table, results='asis', echo=FALSE, warning=FALSE, message=FALSE}
tibble::tribble(
~Piece, ~piece_type, ~Area, ~Height, ~Orientation,
"Brick (classic)", "'b'", "any", "1", "--",
"Plate (flat brick)", "'p'", "any", "1/3", "--",
"Round 1x1 (cylinder)" , "'c1'", "1", "1", "--",
"Round 1x1 (cone)", "'c2'", "1", "1", "--",
"Cheese slope", "'w1'", "1", "2/3", "north",
"Cheese slope", "'w2'", "1", "2/3", "east",
"Cheese slope", "'w3'", "1", "2/3", "south",
"Cheese slope", "'w4'", "1", "2/3", "west"
) %>%
knitr::kable()
```
```{r bricks_2a, rgl=TRUE, dev='png', echo=TRUE, warning=FALSE, message=FALSE, fig.width=4, fig.height=4}
expand.grid(
x = 1:4 * 2,
y = 1:2 * 2,
z = 1) %>%
dplyr::mutate(Color = head(lego_colors$Color, 8),
piece_type = c("b", "p", "c1", "c2", "w1", "w2", "w3", "w4")) %>%
bricks_from_coords() %>%
build_bricks(rgl_lit = FALSE, outline_bricks = TRUE)
rgl::par3d(userMatrix = rgl::rotate3d(rgl::par3d("userMatrix"), 1.1*pi, 0, 0 ,1))
```
## Bricks from coordinates
Changing the piece type in `bricks_from_coords()` is the most straight-forward, so let's begin there.
### Changing the default brick
Start with a simple programmed model to create a classic 2x4 red brick.
```{r bricks_1, rgl=TRUE, dev='png', echo=TRUE, warning=FALSE, message=FALSE, fig.width=4, fig.height=4}
expand.grid(
x = 1:4,
y = 1:2,
z = 1,
Color = "Bright red"
) %>%
bricks_from_coords() %>%
build_bricks()
rgl::par3d(userMatrix = rgl::rotate3d(rgl::par3d("userMatrix"), 1.1*pi/4, 0, 0 ,1))
```
Add a new column, `piece_type`, you can change this default shape. Set `piece_type = "p"` to create a 2x4 plate instead. A LEGO plate is 1/3 the height of a brick.
```{r bricks_2, rgl=TRUE, dev='png', echo=TRUE, warning=FALSE, message=FALSE, fig.width=4, fig.height=4}
expand.grid(
x = 1:4,
y = 1:2,
z = 1,
Color = "Bright red"
) %>%
dplyr::mutate(piece_type = "p") %>%
bricks_from_coords() %>%
build_bricks()
rgl::par3d(userMatrix = rgl::rotate3d(rgl::par3d("userMatrix"), 1.1*pi/4, 0, 0 ,1))
```
## Bricks from tables
Including piece options in `bricks_from_table()` or `bricks_from_excel()` is slightly more involved because the input tables are two-dimensional for easier drawing.
In these functions, use the input `piece_table` to supply an identically shaped table with optional `piece_type` ids instead of numbers.
Start with this data frame called tree_or_mushroom.
```{r bricks_5, rgl=TRUE, dev='png', echo=TRUE, warning=FALSE, message=FALSE, fig.width=4, fig.height=4}
tree_or_mushroom <- tibble::tribble(
~Level, ~X1, ~X2, ~X3, ~X4, ~X5, ~X6,
"A", 1, 1, 1, 1, 1, 1,
"A", 1, 1, 1, 1, 1, 1,
"A", 1, 1, 1, 1, 1, 1,
"A", 1, 1, 1, 1, 1, 1,
"B", 0, 0, 0, 0, 0, 0,
"B", 0, 0, 2, 2, 0, 0,
"B", 0, 0, 2, 2, 0, 0,
"B", 0, 0, 0, 0, 0, 0,
"C", 0, 0, 0, 0, 0, 0,
"C", 0, 0, 2, 2, 0, 0,
"C", 0, 0, 2, 2, 0, 0,
"C", 0, 0, 0, 0, 0, 0,
"D", 0, 3, 3, 3, 3, 0,
"D", 0, 3, 3, 3, 3, 0,
"D", 0, 3, 3, 3, 3, 0,
"D", 0, 3, 3, 3, 3, 0,
"E", 0, 0, 3, 3, 0, 0,
"E", 0, 3, 3, 3, 3, 0,
"E", 0, 3, 3, 3, 3, 0,
"E", 0, 0, 3, 3, 0, 0,
"F", 0, 0, 0, 0, 0, 0,
"F", 0, 0, 3, 3, 0, 0,
"F", 0, 0, 3, 3, 0, 0,
"F", 0, 0, 0, 0, 0, 0,
"G", 0, 0, 0, 0, 0, 0,
"G", 0, 0, 3, 0, 0, 0,
"G", 0, 0, 0, 3, 0, 0,
"G", 0, 0, 0, 0, 0, 0
)
brick_colors <- tibble::tribble(
~`.value`, ~Color,
1, "Bright green",
2, "Dark orange",
3, "Dark green"
)
tree_or_mushroom %>%
bricks_from_table(brick_colors) %>%
build_bricks()
rgl::par3d(userMatrix = rgl::rotate3d(rgl::par3d("userMatrix"), 1.1*pi/4, 0, 0 ,1))
```
If you want more a tree with more texture, you can change all the "leaves" from rectangular bricks into cylinder bricks.
```{r bricks_6, rgl=TRUE, dev='png', echo=TRUE, warning=FALSE, message=FALSE, fig.width=4, fig.height=4}
tree_or_mushroom_pieces <- tree_or_mushroom %>%
dplyr::mutate_at(dplyr::vars(dplyr::starts_with("X")),
~ifelse(.==3, "c2", "b")) #If the color is the dark green, make a cone, else brick
tree_or_mushroom %>%
bricks_from_table(brick_colors,
piece_matrix = tree_or_mushroom_pieces) %>%
build_bricks()
rgl::par3d(userMatrix = rgl::rotate3d(rgl::par3d("userMatrix"), 1.1*pi/4, 0, 0 ,1))
```
### Bricks from Excel
For `bricks_from_excel()`, you only have to supply `piece_type` ids when you do NOT want the classic brick. The best option here is to create your model in the Excel template in [the brickr toybox](https://github.com/ryantimpe/brickr_toybox) GitHub repo. Once complete, duplicate the sheet and change any color values to piece_type IDs.
## Mid-level bricks
Because different piece types have different heights, your models might have unintentional gaps when using pieces that are less than 1-unit tall.
Start with this LEGO cube.
```{r bricks_10, rgl=TRUE, dev='png', echo=TRUE, warning=FALSE, message=FALSE, fig.width=4, fig.height=4}
expand.grid(
x = 1:3,
y = 1:3,
z = 1:3,
color = "Bright blue"
) %>%
dplyr::mutate(color = ifelse(z==2, "Bright red", as.character(color))) %>%
bricks_from_coords() %>%
build_bricks()
rgl::par3d(userMatrix = rgl::rotate3d(rgl::par3d("userMatrix"), 1.1*pi/4, 0, 0 ,1))
```
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.
```{r bricks_11, rgl=TRUE, dev='png', echo=TRUE, warning=FALSE, message=FALSE, fig.width=4, fig.height=4}
expand.grid(
x = 1:3,
y = 1:3,
z = 1:3,
color = "Bright blue"
) %>%
dplyr::mutate(color = ifelse(z==2, "Bright red", as.character(color)),
piece_type = "p") %>%
bricks_from_coords() %>%
build_bricks()
rgl::par3d(userMatrix = rgl::rotate3d(rgl::par3d("userMatrix"), 1.1*pi/4, 0, 0 ,1))
```
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, you'll need to use a new column, `mid_level`. The `mid_level` column can be added anywhere in a `bricks_from_coords()` input or as the 2nd column after `Level` in the `matrix_table` input in `bricks_from_table()` or `bricks_from_excel()`.
By default, all bricks and pieces are located at `mid_level = 0`, which is the base of the z (Level). All z (Level) values have 3 possible mid_level values: 0, 1, 2.
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.
```{r bricks_12, rgl=TRUE, dev='png', echo=TRUE, warning=FALSE, message=FALSE, fig.width=4, fig.height=4}
expand.grid(
x = 1:3,
y = 1:3,
z = 1:3,
color = "Bright blue"
) %>%
dplyr::mutate(color = ifelse(z==2, "Bright red", as.character(color)),
piece_type = "p") %>%
dplyr::mutate(mid_level = (z-1) %% 3,
z = (z-1) %/% 3 +1) %>%
bricks_from_coords() %>%
build_bricks()
rgl::par3d(userMatrix = rgl::rotate3d(rgl::par3d("userMatrix"), 1.1*pi/4, 0, 0 ,1))
```
It's 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.
```{r bricks_13, rgl=TRUE, dev='png', echo=TRUE, warning=FALSE, message=FALSE, fig.width=4, fig.height=4}
expand.grid(
x = 1:3,
y = 1:3,
z = 1:3,
color = "Bright blue"
) %>%
dplyr::mutate(color = ifelse(z==2, "Bright red", as.character(color)),
piece_type = ifelse(z==2, "p", "b")) %>%
dplyr::mutate(
mid_level = dplyr::case_when(
z %in% 1:2 ~ 0,
z == 3 ~ 1
),
z = dplyr::case_when(
z %in% 2:3 ~ 2,
TRUE ~ 1
)) %>%
bricks_from_coords() %>%
build_bricks()
rgl::par3d(userMatrix = rgl::rotate3d(rgl::par3d("userMatrix"), 1.1*pi/4, 0, 0 ,1))
```