From 0806223993dd7de17ae25fffa3646d9823283792 Mon Sep 17 00:00:00 2001 From: Ryan Timpe Date: Sun, 11 Aug 2019 12:03:41 -0400 Subject: [PATCH] Bricks from table vignette and other updates --- DESCRIPTION | 2 +- NEWS.md | 4 +- README.Rmd | 20 +-- README.md | 35 ++++-- README_files/figure-gfm/geom_brick2-1.png | Bin 4416 -> 4823 bytes vignettes/models-from-tables.Rmd | 142 ++++++++++++++++++++++ 6 files changed, 180 insertions(+), 23 deletions(-) create mode 100644 vignettes/models-from-tables.Rmd diff --git a/DESCRIPTION b/DESCRIPTION index dc93672..c132123 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: brickr Title: Tools to emulate the LEGO® System in R -Version: 0.1.0.9011 +Version: 0.1.0.9012 Authors@R: person(given = "Ryan", family = "Timpe", diff --git a/NEWS.md b/NEWS.md index cc7444f..511e514 100644 --- a/NEWS.md +++ b/NEWS.md @@ -4,11 +4,12 @@ * **Breaking:** Data "lego_colors.rda" has been updated with more accurate RGB values and new `brickrID` numbers. This will impact previously created mosaics and 3D models. -## Documentations +## Documentation * pkgdown site * Vignettes: - Mosaics + - ggplot extension ## Mosaics @@ -42,7 +43,6 @@ - 3D models from tables - 3D models from coords - 3D modesl from mosaics + rayshader - - ggplot - IRL * Website * Check() breaks at the size check diff --git a/README.Rmd b/README.Rmd index 2b559a4..3661c41 100644 --- a/README.Rmd +++ b/README.Rmd @@ -18,7 +18,7 @@ library(tidyverse) # brickr - [![Lifecycle: maturing](https://img.shields.io/badge/lifecycle-maturing-blue.svg)](https://www.tidyverse.org/lifecycle/#maturing) + [![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://www.tidyverse.org/lifecycle/#experimental) ## Overview @@ -32,6 +32,14 @@ The package is divided into 3 separate systems: brickr also includes tools help users create the Mosaics and 3D model output using real LEGO® elements. +### What's the point? + +The goal of {brickr} is to provide a series of tools to integrate the LEGO® system with R by: + + - Enhancing a real world building experience with mosaics, generated instructions, and piece counts. + - Generating interest in R and coding for new audiences with easy-to-create 3D models. + - or just embracing pure novelty. + *brickr is developed using publicly available information about LEGO® products and is not officially affiliated with The LEGO Group* ## Installation @@ -94,10 +102,7 @@ brick %>% bricks_from_table() %>% build_bricks(brick_res = "uhd") -rayshader::render_snapshot() -``` -```{r, echo=FALSE} - rgl::rgl.clear() +rayshader::render_snapshot( clear = TRUE) ``` ### Stacking bricks @@ -141,10 +146,7 @@ my_first_model %>% bricks_from_table(brick_colors) %>% build_bricks(theta = 210, brick_res = "hd") -rayshader::render_snapshot() -``` -```{r, echo=FALSE} - rgl::rgl.clear() +rayshader::render_snapshot(clear = TRUE) ``` ### Programmatically build models diff --git a/README.md b/README.md index 62fec12..ec3bad0 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ The LEGO® System in R [![Lifecycle: -maturing](https://img.shields.io/badge/lifecycle-maturing-blue.svg)](https://www.tidyverse.org/lifecycle/#maturing) +experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://www.tidyverse.org/lifecycle/#experimental) ## Overview @@ -26,8 +26,19 @@ The package is divided into 3 separate systems: brickr also includes tools help users create the Mosaics and 3D model output using real LEGO® elements. +### What’s the point? + +The goal of {brickr} is to provide a series of tools to integrate the +LEGO® system with R by: + + - Enhancing a real world building experience with mosaics, generated + instructions, and piece counts. + - Generating interest in R and coding for new audiences with + easy-to-create 3D models. + - or just embracing pure novelty. + *brickr is developed using publicly available information about LEGO® -products and is not officially affliated with The LEGO Group* +products and is not officially affiliated with The LEGO Group* ## Installation @@ -100,11 +111,12 @@ Morgan-Wall](https://twitter.com/tylermorganwall)’s integer values, and `Color` columns, where each combination of x, y, & z is a point in 3-dimensional space. Color must be an official LEGO color name from `build_colors()`. This format is much more - flexible than `bricks_from_table()` and allows the programatic + flexible than `bricks_from_table()` and allows the programmatic development of 3D models. -\-`bricks_from_mosaic()` & `bricks_from_image()` convert a 2D -[mosaic](#mosaics) object or an image into 3D LEGO models, respectively. +\-`bricks_from_mosaic()` converts a 2D [mosaic](#mosaics) object from an +image into 3D LEGO models, respectively. `bricks_from_rayshader()` +creates a LEGO model from the same input as `rayshader::plot_3d()`. Pass the output from any `bricks_from_*()` function to `build_bricks()` to see the 3D model. The `brick_res` option allows for higher resolution @@ -230,11 +242,12 @@ be found at the links below. ## Charts -brickr includes some elements for a [ggplot2]() extensions to convert -ggplot bar charts into bricks and LEGO themes. The main function is -`geom_brick_col()`, which is the brickr equivalent of `geom_col()`. -Additional functions are highly recommended to ensure that proper the -chart is rendered in the proper functions and proportions. +brickr includes functions to render +[ggplot2](https://ggplot2.tidyverse.org/) bar charts as bricks with LEGO +color themes. The main function is `geom_brick_col()`, which is the +brickr equivalent of `geom_col()`. Additional functions are highly +recommended to ensure that proper the chart is rendered in the proper +functions and proportions. ``` r df <- data.frame(trt = c("a", "b", "c"), outcome = c(2.3, 1.9, 3.2)) @@ -250,7 +263,7 @@ ggplot(df, aes(trt, outcome)) + ![](README_files/figure-gfm/geom_brick-1.png) Both `scale_fill_brick()` and `theme_brick()` take an input -‘brick\_theme’, which ensures all colors match offical LEGO brick +‘brick\_theme’, which ensures all colors match official LEGO brick colors. See `build_themes()` for a sample of all available brick theme. diff --git a/README_files/figure-gfm/geom_brick2-1.png b/README_files/figure-gfm/geom_brick2-1.png index 4a9c11fd97b434b5b34c04709a7553bb7bfd13cf..6fa750bd135f96e8f008a6ffb7637d5a9c57f44d 100644 GIT binary patch delta 4334 zcmaJ_2{@E%8-Bl;(ab2O2#swdr4&;lLS_n4k@?FOVG^Nim2A~~lNOa@Im(GFhbT+- zt+I}kbR;8^EhdzbW$ea`@qaqYb^iZc|3BCD%{<@rKF{-h@AJIhec$h}ls{~YR)N!K z=2j*E`IyK83mtHjB5oopj(ppj5va;UO?#qd5K%LhsP9EII!82-CEA-2?F)$~XhcS% zoSK&0PIEZ}tM!_PmDRO2SjcWTD!aknY=b*ZMbloz=$y)-z)fmen+&Wr89Qt{D!a{{ zrlD!C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e*9U&8=9kdkXcV*7e^=YU--D!{mq-YjRo}? z_F~4P^#?-+ggHCPOpUhCT*>$mkQwEv!H%;^;-7h4q&fGx=q9D={z~iAt4D4IJhFp= zxyxtjxg}U$UYz}Sf{+ruV0Ym1${k#xc?BxsGbO?EhXTx_59)QcV$Z_wNZt~*{eDtw z&2Vj?DaDL`lCa-vQ(Rl5dc!rEq;B0bJyWVittiNw>+3nBlCK9@k!JzG8_sjV+Xs`* zEa@|AkG_Z7rtb2oa(y&GeG;&jAF~@&dwN}V)4*zApIdi89nVIT(32Sl3AWJQ#`Hra z{)xqS+lQ;QXHizvK7^~m;5Cs2vCB1>3bw5@LK}0$SwoQg;X|R-zQZ*F)D1Rg zkR(ypb3!b#+4zhyC79V%*Y@VDhjj&#IjBP;<`|B?k1lTHx{)lpMr-CqtN1=dj&5Nt zGS969YCe3^%3zLi1^0U0KRL)?I^@N#-wELWjjE&-2GzT*_N9+=tHFn|z)^ncT@k}` zMlq}C-7$uo?v?Ezy{k;*JxS=hn=~z z+AT@XfP{S%92CEHERi9H2K3#hr5_7-bkEYGMY3;14G=bad!9KxbZ&k4v zZsR(8H905r8EuI34sCmNCB`Yjq){W3X22+wKwP_Hoeg^NrE132UVHnPDe|->$CJGg z+f|N&DAi7#N2?pxUP%|ToyJD|%L?lrKS;Vk0ujF&O7m~=FhV~`^@gd^FK(NEqkLH? zf7R%Gbo>xUb@J}Ue84*PtN!4jTgAX$SOHfWaCk|XWuG^bXT(0~8+<{IE|~vGv2#6s hOa9S+@20qf-FI6H_%0?+^Ztp=O|4CS{n6v%e*!xv-&+6x diff --git a/vignettes/models-from-tables.Rmd b/vignettes/models-from-tables.Rmd new file mode 100644 index 0000000..2ddea3b --- /dev/null +++ b/vignettes/models-from-tables.Rmd @@ -0,0 +1,142 @@ +--- +title: "3D models from tables" +output: rmarkdown::html_vignette +vignette: > + %\VignetteIndexEntry{graphs} + %\VignetteEngine{knitr::rmarkdown} + %\VignetteEncoding{UTF-8} +--- + +```{r, include = FALSE} +knitr::opts_chunk$set( +collapse = TRUE, +comment = "#>" +) +``` + +```{r setup, include = FALSE} +library(brickr) +``` + +## Getting started + +The `bricks_from_*` series of functions creates 3D models of LEGO bricks from a variety of input formats. These models are rendered using [Tyler Morgan-Wall](https://twitter.com/tylermorganwall)'s [rayshader](https://www.rayshader.com/) package. This package must be installed. + +`bricks_from_table()` converts a matrix-shaped table of integers into LEGO bricks, where most columns are x-coordinates, rows are y-coordinates, and a special `Level` column denotes the elevation of the row. For simple models, this table can be made manually using `data.frame()` or `tibble::tribble()`. + +For more advanced models, it's recommended you use MS Excel or a .csv file. `bricks_from_excel()` is a wrapper function to more easily build models designed using a Microsoft Excel template. Please see this repo: [brickr toybox](https://github.com/ryantimpe/brickr_toybox). + +Pass the output of any `bricks_from_*()` function to `build_bricks()` to render it as a 3D model. + +## Individual bricks + +Create a single 2x4 brick with a 2x4 data frame, with an additional column to specify the 'Level'. These can be letters or numbers. + +```{r bricks_1, echo=TRUE, warning=FALSE, message=FALSE, fig.width=3, fig.height=3} +#This is a 2 (columns) x 4 (rows) brick +(brick <- data.frame( + Level="A", + X1 = rep(3,4), #The number 3 is the brickrID for 'bright red' + X2 = rep(3,4) +)) + +brick %>% + bricks_from_table() %>% + build_bricks(brick_res = "hd") #Bricks available in standard def, high def, and ultra hd. + +rayshader::render_snapshot( clear = TRUE) +``` + +Stack many bricks by changing the 'Level' value in the data frame. The script below uses `purrr::map_df()` to avoid copying and pasting. Changing the numeric values inside the data frame for each level creates different colors. + +```{r bricks_2, echo=TRUE, warning=FALSE, message=FALSE, fig.width=3, fig.height=3} +1:10 %>% + purrr::map_df(~dplyr::mutate(brick, + Level = LETTERS[.x], + X1 = .x, + X2 = .x)) %>% + bricks_from_table() %>% + build_bricks(brick_res = "hd") + +rayshader::render_snapshot( clear = TRUE) +``` + +## Full models + +The most direct way to create a 3D model is to manually create a data frame. Below, we create a data frame using `tibble::tribble()` so we can more easily see the structure as it's written. + +The data frame has 3 numbers as input (values of 0 are void spaces in the model). Rather than use the default brickr colors for the values of 1, 2, and 3, we define another data frame 'brick_colors' + +```{r bricks_5, 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(theta = 210, phi = 20, brick_res = "hd") + +rayshader::render_snapshot(clear = TRUE) +``` + +### Plates instead of bricks + +That's clearly a tree, right? Why is the data frame called 'tree_or_mushroom'? + +Use the input 'brick_type="plate"' to render the 3D model using LEGO plates rather than bricks, which are 1/3 as tall. + +```{r bricks_5a, echo=TRUE, warning=FALSE, message=FALSE, fig.width=4, fig.height=4} +brick_colors <- tibble::tribble( + ~`.value`, ~Color, + 1, "Dark green", + 2, "Light nougat", + 3, "Bright red" +) + +tree_or_mushroom %>% + bricks_from_table(brick_colors) %>% + build_bricks(theta = 210, phi = 10, brick_res = "hd", brick_type="plate") + +rayshader::render_snapshot(clear = TRUE) +``` + +## Bricks from Excel + +When designing larger models, it is much easier to use a spreadsheet program to lay out the bricks for each level. + +See [the brickr toybox](https://github.com/ryantimpe/brickr_toybox) GitHub repo for some examples and templates. \ No newline at end of file