diff --git a/docs/404.html b/docs/404.html index a4c6302..f7674a8 100644 --- a/docs/404.html +++ b/docs/404.html @@ -78,7 +78,7 @@ diff --git a/docs/LICENSE-text.html b/docs/LICENSE-text.html index fc7f6c2..ed3c37e 100644 --- a/docs/LICENSE-text.html +++ b/docs/LICENSE-text.html @@ -78,7 +78,7 @@ diff --git a/docs/LICENSE.html b/docs/LICENSE.html index 874c3ea..31785e9 100644 --- a/docs/LICENSE.html +++ b/docs/LICENSE.html @@ -78,7 +78,7 @@ diff --git a/docs/articles/index.html b/docs/articles/index.html index 97e3b79..52a32da 100644 --- a/docs/articles/index.html +++ b/docs/articles/index.html @@ -78,7 +78,7 @@ diff --git a/docs/articles/models-from-other.html b/docs/articles/models-from-other.html index 6ea6c4b..ec28f2e 100644 --- a/docs/articles/models-from-other.html +++ b/docs/articles/models-from-other.html @@ -39,7 +39,7 @@ diff --git a/docs/articles/models-from-program.html b/docs/articles/models-from-program.html index c5c597c..f574aef 100644 --- a/docs/articles/models-from-program.html +++ b/docs/articles/models-from-program.html @@ -39,7 +39,7 @@ diff --git a/docs/articles/models-from-program_files/figure-html/bricks_6-1.png b/docs/articles/models-from-program_files/figure-html/bricks_6-1.png index 712aa94..bb06a17 100644 Binary files a/docs/articles/models-from-program_files/figure-html/bricks_6-1.png and b/docs/articles/models-from-program_files/figure-html/bricks_6-1.png differ diff --git a/docs/articles/models-from-program_files/figure-html/bricks_8-1.png b/docs/articles/models-from-program_files/figure-html/bricks_8-1.png index 1a53c5c..308dd22 100644 Binary files a/docs/articles/models-from-program_files/figure-html/bricks_8-1.png and b/docs/articles/models-from-program_files/figure-html/bricks_8-1.png differ diff --git a/docs/articles/models-from-program_files/figure-html/bricks_9-1.png b/docs/articles/models-from-program_files/figure-html/bricks_9-1.png index e1b3275..619fa1a 100644 Binary files a/docs/articles/models-from-program_files/figure-html/bricks_9-1.png and b/docs/articles/models-from-program_files/figure-html/bricks_9-1.png differ diff --git a/docs/articles/models-from-tables.html b/docs/articles/models-from-tables.html index f35e207..e06727b 100644 --- a/docs/articles/models-from-tables.html +++ b/docs/articles/models-from-tables.html @@ -39,7 +39,7 @@ diff --git a/docs/articles/models-piece-type.html b/docs/articles/models-piece-type.html index aac137d..a7c4286 100644 --- a/docs/articles/models-piece-type.html +++ b/docs/articles/models-piece-type.html @@ -39,7 +39,7 @@ @@ -215,7 +215,7 @@ x = 1:4, y = 1:2, z = 1, - Color = "Bright red" + Color = "Bright red", stringsAsFactors = FALSE ) %>% bricks_from_coords() %>% build_bricks() @@ -228,7 +228,7 @@ x = 1:4, y = 1:2, z = 1, - Color = "Bright red" + Color = "Bright red", stringsAsFactors = FALSE ) %>% dplyr::mutate(piece_type = "p") %>% bricks_from_coords() %>% diff --git a/docs/articles/mosaics.html b/docs/articles/mosaics.html index 7c17223..9e5e334 100644 --- a/docs/articles/mosaics.html +++ b/docs/articles/mosaics.html @@ -39,7 +39,7 @@ @@ -191,8 +191,8 @@
brickr uses the farver package to match image colors to the subset of LEGO colors. Technical details of the different algorithms can be found on Wikipedia.
The default algorithm is ‘cie94’, though the other farver options are available using the method input. The farver ‘euclidean’ is not very accurate, so ‘brickr_classic’ returns a manually calculated version for Euclidean RGB distance matching.
c("cie94", "cie2000", "euclidean", "brickr_classic") %>%
+The default algorithm is ‘cie94’, though the other farver options are available using the method input.
+c("cie94", "cie2000", "euclidean", "cmc") %>%
purrr::map(~png::readPNG(demo_img) %>%
image_to_mosaic(24, method =.x) %>%
build_mosaic(title = .x )) -> mosaics_by_method
@@ -204,16 +204,6 @@
Dithering
When rendering a mosaic from a photographic with many shades of similar colors, using dithering by setting dithering = TRUE will help to add texture to the mosaic and avoid large areas of the same color. This works particularly well for large mosaics, but is purely a stylist preference.
-gg_img = tempfile()
-download.file("http://ryantimpe.com/files/goldengirls.JPG", gg_img, mode="wb")
-
-c(FALSE, TRUE) %>%
- purrr::map(~jpeg::readJPEG(gg_img) %>%
- image_to_mosaic(dithering = .x) %>%
- build_mosaic(title = paste("dithering =", .x))) -> mosaics_by_dither
-
-gridExtra::grid.arrange(grobs = mosaics_by_dither, layout_matrix = matrix(c(1,2), ncol=2))
-
@@ -225,16 +215,16 @@
3D Mosaics
Passing the mosaic object to bricks_from_mosaic() will render a 3D object, stacking layers of bricks on each other to create an elevated mosaic. By default, the lightest color bricks will be on top, but this can be changed using the highest_el = 'dark' option.
-png::readPNG(demo_img) %>%
- image_to_mosaic(32) %>%
- bricks_from_mosaic(highest_el = "dark") %>%
- build_bricks(outline_bricks = TRUE, rgl_lit = FALSE)
-
-#From dput(round(rgl::par3d("userMatrix"),1)) after manual rotation
-custom_rotation <- structure(c(0.9, 0.3, -0.3, 0, -0.3, 0.9, -0.3,
- 0, 0.2, 0.4, 0.9, 0, 0, 0, 0, 1), .Dim = c(4L, 4L))
-
-rgl::par3d(userMatrix = rgl::rotate3d(custom_rotation, 0, 0, pi/4 ,1))
+png::readPNG(demo_img) %>%
+ image_to_mosaic(32) %>%
+ bricks_from_mosaic(highest_el = "dark") %>%
+ build_bricks(outline_bricks = TRUE, rgl_lit = FALSE)
+
+#From dput(round(rgl::par3d("userMatrix"),1)) after manual rotation
+custom_rotation <- structure(c(0.9, 0.3, -0.3, 0, -0.3, 0.9, -0.3,
+ 0, 0.2, 0.4, 0.9, 0, 0, 0, 0, 1), .Dim = c(4L, 4L))
+
+rgl::par3d(userMatrix = rgl::rotate3d(custom_rotation, 0, 0, pi/4 ,1))

NEWS.md
- An overall leaner package to ensure optimal performance and remove experimental features.
Updated documentation to increase accessibility and usability.
brickr package — brickr • brickrTools to emulate the LEGO® System in R
+Emulate LEGO Bricks in 2D and 3D
Convert a data frame with x, y, z & Color columns into a brickr 3D object
+Convert a data frame with x, y, z & Color columns into a 3D object
bricks_from_coords(
@@ -228,8 +228,7 @@ Optional column ' mid_Level' with values 0, 1, or 2 (default 0) for 1-height pla
build_bricks()@@ -142,13 +142,13 @@# \donttest{ -#This is a 1x4 yellow brick ++#Use different brick shapes by added a 'piece_type' column +bricks$piece_type <- "c1" #Make all the pieces cylinders + +# \donttest{ +bricks %>% + bricks_from_coords() %>% + build_bricks() + + rgl::clear3d() + # }#This is a 1x4 yellow brick brick <- data.frame( x = 1:4, y = 1, z=1, @@ -244,20 +243,31 @@ Optional column ' mid_Level' with values 0, 1, or 2 (default 0) for 1-height pla #This is a lot of bricks bricks <- expand.grid( -x = 1:8, -y = 1:4, +x = 1:4, +y = 1:2, z = 1:3) #Color them in sets of these 3 options -bricks$color <- rep(rep(c("Bright yellow", "Bright red", "Dark green"), each=4), 8) +bricks$color <- rep(rep(c("Bright yellow", "Bright red", "Tr. green"), each=4), 2) +# \donttest{ bricks %>% bricks_from_coords() %>% build_bricks() rgl::clear3d() + # } -# }
R/bricks-from-tables.R
bricks_from_excel.RdConvert am Excel template file into a 3D brick object.
+Build a 3D model from an Excel template. A single data frame includes both the instructions and the color guides.
bricks_from_excel( @@ -172,7 +172,8 @@excel_table -+ Sheet imported from a brickr Excel template to build model. Contains stud placement and colors.
Sheet imported from a brickr Excel template to build model. +This differs slightly from
bricks_from_tablebecause a single data frame has both the brick coordinates and color table.piece_table @@ -236,20 +237,30 @@build_bricks()Examples
-@@ -142,13 +143,14 @@# \donttest{ -#Demo table in same format as Excel template ++ +#To change the pieces, import a second table in the same shape, but with piece IDs. +demo_pieces <- tibble::tribble( +~Level, ~"1", ~"2", ~"3", + "A", "w4", "c1", "w2" +) + +demo_excel %>% + bricks_from_excel(piece_table = demo_pieces) %>% + build_bricks() + + rgl::clear3d()#Demo table in same format as Excel template #This creates a 1x3 red brick. -brick <- tibble::tribble( +demo_excel <- tibble::tribble( ~Level, ~"1", ~"2", ~"3", ~user_color, ~LEGO_color, "A", 1, 1, 1, 1, "Bright red" ) -brick %>% +demo_excel %>% bricks_from_excel() %>% build_bricks() rgl::clear3d() -# }@@ -142,13 +142,13 @@-Convert a 2D LEGO mosaic into a brickr 3D object
+Convert a 2D LEGO mosaic into a 'brickr' 3D object
Source:R/bricks-from-mosaic.Rbricks_from_mosaic.Rd-Stacks LEGO plates to create a 3D version of the 2D brick mosaics.
+Stacks LEGO plates to create a 3D version of the 2D brick mosaics. +Height of bricks determined by brightness of color.
bricks_from_mosaic(mosaic_list, mosaic_height = 6, highest_el = "light")@@ -173,9 +175,6 @@Value
A list with elements
-Img_legoto pass tobuild_bricks.Details
- -Height of bricks determined by brightness of color.
See also
Other 3D Models: @@ -185,25 +184,42 @@
build_bricks()Examples
-# \donttest{ -# Create a random 24x24 'image'. -# Otherwise, use a jpeg or png - demo_image = array(scales::rescale(runif(24*24*3), c(0, 1)), dim=c(24, 24, 3)) ++ #Pass the mosaic object to bricks_from_mosaic() to convert to 3D specifications + # \donttest{ + mosaic %>% + bricks_from_mosaic() %>% + build_bricks() + + rgl::clear3d() + # } + + #In this image, the background is a light color. + # Change the 'highest_el' to make dark colors highest + # Change mosaic height to change the number of layers + # \donttest{ + mosaic %>% + bricks_from_mosaic(mosaic_height = 3, highest_el = "dark") %>% + build_bricks() + + rgl::clear3d() + # }# Import a jpeg or png + demo_file <- system.file("extdata", "demo_img.jpg", + package = "brickr", mustWork = TRUE) + demo_image <- jpeg::readJPEG(demo_file) -demo_image %>% - image_to_mosaic(img_size = 24) %>% - bricks_from_mosaic() %>% - build_bricks() + #Begin with a 24x24 mosaic object + # \donttest{ + mosaic <- demo_image %>% + image_to_mosaic(24) + # } - rgl::clear3d() -# }-Convert a matrix table into a brickr 3D object
+Convert a table into a 'brickr' 3D object
Source:R/bricks-from-tables.Rbricks_from_table.Rd-Convert a data frame into a 3D brick object.
+Create a 3D brick object from a data frame. Left-most column is level/height/z dimension, with rows as Y axis and columns as X axis.
bricks_from_table( @@ -185,7 +185,7 @@use_bricks -+ Array of brick sizes to use in mosaic. Defaults to
c('4x2', '3x2', '2x2', '3x1', '2x1', '1x1')`.Array of brick sizes to use in mosaic. Defaults to
c('4x2', '2x2', '3x1', '2x1', '1x1')`. '1x1' will always be considered..re_level @@ -241,8 +241,7 @@build_bricks()Examples
-@@ -142,13 +142,13 @@# \donttest{ -#This is a brick ++ +#Build on top of each other by changing the Level value. +#This example builds a blue 2x2 brick on top of a red 2x2 +brick <- data.frame( + Level=c("A", "A", "B", "B"), + X1 = c(3, 3, 4, 4), #3 is red, 4 is blue + X2 = c(3, 3, 4, 4) +) + +brick %>% + bricks_from_table() %>% + build_bricks() + + rgl::clear3d() + +#Provide an additional piece_matrix argument to change the default brick shape. +pieces <- data.frame( + Level=c("A", "A", "B", "B"), + X1 = c("b", "b", "p", "p"), #b is brick (default), p is plate + X2 = c("b", "b", "p", "p") +) + +# \donttest{ +brick %>% + bricks_from_table(piece_matrix=pieces) %>% + build_bricks() + + rgl::clear3d() + # } + +#Provide a custom table of colors +custom_colors <- data.frame( +.value = c(3, 4), +Color = c("Bright orange", "Dark green") +) + +# \donttest{ +brick %>% + bricks_from_table(color_guide = custom_colors) %>% + build_bricks() + + rgl::clear3d() + # } + +#Limit the size of bricks used in the model with use_bricks +# \donttest{ +brick %>% + bricks_from_table(use_bricks = "2x1") %>% #Only use 2x1 bricks. + build_bricks() + + rgl::clear3d() + # }#This is a 4x2 brick. One level high, 2 x-values (columns), 4 y-values (rows). brick <- data.frame( Level="A", X1 = rep(3,4), #The number 3 is the brickrID for 'bright red' @@ -254,7 +253,58 @@ build_bricks() rgl::clear3d() -# }@@ -148,7 +149,8 @@-Build 3D brick model with rgl
+Build 3D brick model with 'rgl'
Source:R/build-bricks-rgl.Rbuild_bricks.Rd-Render the output of any of the
+bricks_from_*functions as a 3D model.Render the output of any of the
bricks_from_*functions as a 3D model. Opens an 'rgl' window.build_bricks( @@ -202,20 +202,29 @@ Set to 'TRUE' and rgl_lit='FALSE' for cartoon-looking bricks.bricks_from_table()Examples
-# \donttest{ -#This is a brick ++ +#Combine the option rgl_lit=FALSE & outline_bricks=TRUE +# This makes the rendering look like a drawing +brick_object %>% + build_bricks(outline_bricks = TRUE, rgl_lit = FALSE, + background_color = "#99e7ff") +rgl::clear3d()#This is a brick brick <- data.frame( Level="A", X1 = rep(3,4), #The number 3 is the brickrID for 'bright red' X2 = rep(3,4) ) -brick %>% - bricks_from_table() %>% +#Convert the dataframe to a list object that can be rendered +brick_object <- brick %>% + bricks_from_table() + +#Render it +brick_object %>% build_bricks() rgl::clear3d() -# }-Generates a plot of available brick colors.
+Generates a plot of available brick colors. These names must be used exactly when creating custom name lists. +There are 41 solid brick color names and 13 transparent colors. Transparent colors are not used in mosaics.
build_colors(.names_only = FALSE, include_transparent = TRUE)@@ -181,9 +183,7 @@Examples
#Generate plot of colors -# \donttest{ -build_colors()#>#># } - +build_colors(include_transparent = FALSE)#>#Print list of colors build_colors(TRUE)#> [1] "White" "Brick yellow" "Bright red" #> [4] "Bright blue" "Bright yellow" "Black" diff --git a/docs/reference/build_instructions-1.png b/docs/reference/build_instructions-1.png index ef990a5..dd94c29 100644 Binary files a/docs/reference/build_instructions-1.png and b/docs/reference/build_instructions-1.png differ diff --git a/docs/reference/build_instructions-2.png b/docs/reference/build_instructions-2.png new file mode 100644 index 0000000..5a691a5 Binary files /dev/null and b/docs/reference/build_instructions-2.png differ diff --git a/docs/reference/build_instructions.html b/docs/reference/build_instructions.html index 5c7220a..41e7398 100644 --- a/docs/reference/build_instructions.html +++ b/docs/reference/build_instructions.html @@ -6,7 +6,7 @@ -@@ -142,13 +142,13 @@Create instruction manuals — build_instructions • brickr +Create instruction manual for a 2D mosaic or 3D model — build_instructions • brickr @@ -44,8 +44,8 @@ - - + + @@ -79,7 +79,7 @@@@ -175,14 +175,23 @@-Create instruction manuals
+Create instruction manual for a 2D mosaic or 3D model
Source:R/build-instructions.Rbuild_instructions.Rd-Render faceted plot of instructions for 2D mosacis or 3D model objects.
+Render faceted plot of instructions for 2D mosacis or 3D model objects. For mosaics, can specify the number of steps.
build_instructions(brickr_obj, num_steps = 6)@@ -183,14 +183,26 @@ The current model level is clearly displayed, while the previous level is showsbuild_pieces()Examples
-# \donttest{ -# Create a random 24x24 'image'. -# Otherwise, use a jpeg or png - demo_image = array(scales::rescale(runif(24*24*3), c(0, 1)), dim=c(24, 24, 3)) +diff --git a/docs/reference/build_mosaic-1.png b/docs/reference/build_mosaic-1.png index 1784062..2e4b145 100644 Binary files a/docs/reference/build_mosaic-1.png and b/docs/reference/build_mosaic-1.png differ diff --git a/docs/reference/build_mosaic-2.png b/docs/reference/build_mosaic-2.png new file mode 100644 index 0000000..8b3dcbb Binary files /dev/null and b/docs/reference/build_mosaic-2.png differ diff --git a/docs/reference/build_mosaic.html b/docs/reference/build_mosaic.html index fea8cd6..37779b3 100644 --- a/docs/reference/build_mosaic.html +++ b/docs/reference/build_mosaic.html @@ -79,7 +79,7 @@# Import a jpeg or png + demo_file <- system.file("extdata", "demo_img.jpg", + package = "brickr", mustWork = TRUE) + demo_image <- jpeg::readJPEG(demo_file) -demo_image %>% - image_to_mosaic(img_size = 24) %>% - build_instructions()# } + #Create a mosaic oject + # \donttest{ + mosaic <- demo_image %>% + image_to_mosaic(img_size = 24) + # } + + #Rather than drawing the mosaic, use build_instructions() to draw instructions + # \donttest{ + mosaic %>% + build_instructions()# } + +#Change the number of steps for more detail +# \donttest{ + mosaic %>% + build_instructions(num_steps = 9)# }image_to_mosaic()Examples
-# \donttest{ -# Create a random 24x24 'image'. -# Otherwise, use a jpeg or png - demo_image = array(scales::rescale(runif(24*24*3), c(0, 1)), dim=c(24, 24, 3)) +@@ -142,7 +142,7 @@+# Import a jpeg or png + demo_file <- system.file("extdata", "demo_img.jpg", + package = "brickr", mustWork = TRUE) + demo_image <- jpeg::readJPEG(demo_file) +#Build a very small 12x12 mosaic. + # \donttest{ demo_image %>% - image_to_mosaic(img_size = 24) %>% - build_mosaic()# } + +#Build a mosaic in the default size of 48x48 studs with title +# \donttest{ +demo_image %>% + image_to_mosaic() %>% + build_mosaic("Demo mosaic")# }-@@ -173,15 +173,20 @@Display bricks required to build model or mosaic.
+Display bricks required to build model or mosaic
Source:R/piece-count.Rbuild_pieces.Rdbuild_pieces_table()Examples
-# \donttest{ -# Create a random 24x24 'image'. -# Otherwise, use a jpeg or png - demo_image = array(scales::rescale(runif(24*24*3), c(0, 1)), dim=c(24, 24, 3)) - -demo_image %>% - image_to_mosaic(img_size = 24) %>% - build_pieces()# } +@@ -142,7 +142,7 @@# Import a jpeg or png + demo_file <- system.file("extdata", "demo_img.jpg", + package = "brickr", mustWork = TRUE) + demo_image <- jpeg::readJPEG(demo_file) +#Create a mosaic oject + # \donttest{ + mosaic <- demo_image %>% + image_to_mosaic(img_size = 24) + # } + #Rather than drawing the mosaic, use build_pieces_table() to draw piece chart + # \donttest{ + mosaic %>% + build_pieces()# }diff --git a/docs/reference/scaled_to_colors.html b/docs/reference/scaled_to_colors.html index 82821be..bd86714 100644 --- a/docs/reference/scaled_to_colors.html +++ b/docs/reference/scaled_to_colors.html @@ -79,7 +79,7 @@-@@ -173,27 +173,33 @@Generate required bricks as a data frame.
+Generate required bricks as a data frame
Source:R/piece-count.Rbuild_pieces_table.Rdbuild_pieces()Examples
-# \donttest{ -# Create a random 24x24 'image'. -# Otherwise, use a jpeg or png - demo_image = array(scales::rescale(runif(24*24*3), c(0, 1)), dim=c(24, 24, 3)) +@@ -142,13 +143,14 @@# Import a jpeg or png + demo_file <- system.file("extdata", "demo_img.jpg", + package = "brickr", mustWork = TRUE) + demo_image <- jpeg::readJPEG(demo_file) +#Create a mosaic oject + # \donttest{ + mosaic <- demo_image %>% + image_to_mosaic(img_size = 24) + # } -demo_image %>% - image_to_mosaic(img_size = 24) %>% - build_pieces_table()#> # A tibble: 40 x 4 -#> Piece `LEGO Brick Color` `1 x 1` `2 x 1` -#> <chr> <chr> <dbl> <dbl> -#> 1 p Aqua 26 2 -#> 2 p Black 9 0 -#> 3 p Br. yellowish green 21 2 -#> 4 p Brick yellow 9 0 -#> 5 p Bright blue 22 1 -#> 6 p Bright bluish green 9 0 -#> 7 p Bright green 30 1 -#> 8 p Bright orange 10 0 -#> 9 p Bright purple 26 3 -#> 10 p Bright red 12 0 -#> # ... with 30 more rows# } + #Rather than drawing the mosaic, use build_pieces_table() to produce piece table + # \donttest{ + mosaic %>% + build_pieces_table()#> # A tibble: 24 x 8 +#> Piece `LEGO Brick Color` `1 x 1` `2 x 1` `2 x 2` `3 x 1` `4 x 1` `4 x 2` +#> <chr> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> +#> 1 p Aqua 12 2 1 2 0 1 +#> 2 p Br. yellowish green 3 0 0 0 1 0 +#> 3 p Brick yellow 14 4 2 3 3 0 +#> 4 p Bright green 0 2 1 0 0 0 +#> 5 p Bright orange 3 1 0 0 0 0 +#> 6 p Bright yellow 11 6 6 3 1 2 +#> 7 p Cool yellow 6 3 0 0 0 0 +#> 8 p Dark azur 1 1 0 0 0 0 +#> 9 p Dark orange 5 4 2 2 1 1 +#> 10 p Dark stone grey 2 1 0 0 1 0 +#> # ... with 14 more rows# }@@ -148,7 +148,7 @@-Consolidate 1x1 bricks into larger ones of the same color. Internal function.
+Consolidate 1x1 bricks into larger ones of the same color
Source:R/collect-bricks.Rcollect_bricks.Rd-Consolidate 1x1 bricks into larger ones of the same color. Internal function.
+Internal function for collecting single bricks into large ones. Used in both mosaics and 3D models. +Automatically generate missing piece_type or mid_level.
collect_bricks(image_list, use_bricks = NULL, default_piece_type = "b")@@ -158,7 +160,7 @@image_list -+ List output from legoize(). Contains an element
Img_lego.List output containing an element
Img_lego.use_bricks diff --git a/docs/reference/geom_brick_rect.html b/docs/reference/geom_brick_rect.html index 4324ab0..880d84b 100644 --- a/docs/reference/geom_brick_rect.html +++ b/docs/reference/geom_brick_rect.html @@ -79,7 +79,7 @@ diff --git a/docs/reference/image_to_mosaic-1.png b/docs/reference/image_to_mosaic-1.png index 92e6f9a..f44a2c3 100644 Binary files a/docs/reference/image_to_mosaic-1.png and b/docs/reference/image_to_mosaic-1.png differ diff --git a/docs/reference/image_to_mosaic-2.png b/docs/reference/image_to_mosaic-2.png index dcff5b4..e2edb17 100644 Binary files a/docs/reference/image_to_mosaic-2.png and b/docs/reference/image_to_mosaic-2.png differ diff --git a/docs/reference/image_to_mosaic-3.png b/docs/reference/image_to_mosaic-3.png new file mode 100644 index 0000000..69293c8 Binary files /dev/null and b/docs/reference/image_to_mosaic-3.png differ diff --git a/docs/reference/image_to_mosaic-4.png b/docs/reference/image_to_mosaic-4.png new file mode 100644 index 0000000..eedc6e7 Binary files /dev/null and b/docs/reference/image_to_mosaic-4.png differ diff --git a/docs/reference/image_to_mosaic-5.png b/docs/reference/image_to_mosaic-5.png new file mode 100644 index 0000000..0c971e9 Binary files /dev/null and b/docs/reference/image_to_mosaic-5.png differ diff --git a/docs/reference/image_to_mosaic.html b/docs/reference/image_to_mosaic.html index 90cd66a..1f2ae4c 100644 --- a/docs/reference/image_to_mosaic.html +++ b/docs/reference/image_to_mosaic.html @@ -79,7 +79,7 @@ @@ -183,9 +183,8 @@ See attached datalego_colorsas examples.method -+ 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
farver::compare_colour.The method to use for comparison. Options are 'euclidean', 'cie1976', 'cie94', 'cie2000', or 'cmc'. +See
compare_colour.color_palette @@ -223,18 +222,50 @@ Use "bw" for only grayscale bricks. Ignored if acolor_tableis supbuild_mosaic()Examples
-# \donttest{ -# Create a random 24x24 'image'. -# Otherwise, use a jpeg or png - demo_image = array(scales::rescale(runif(24*24*3), c(0, 1)), dim=c(24, 24, 3)) +diff --git a/docs/reference/image_to_scaled.html b/docs/reference/image_to_scaled.html index 6c4fb8d..185701b 100644 --- a/docs/reference/image_to_scaled.html +++ b/docs/reference/image_to_scaled.html @@ -6,7 +6,7 @@ -# Import a jpeg or png + demo_file <- system.file("extdata", "demo_img.jpg", + package = "brickr", mustWork = TRUE) + demo_image <- jpeg::readJPEG(demo_file) -demo_image %>% - image_to_mosaic(img_size = 24) %>% - build_mosaic()- #Only use the most common "universal" LEGO colors + #Create a 24x24 mosaic + # \donttest{ demo_image %>% - image_to_mosaic(img_size = 24, color_palette = "universal") %>% - build_mosaic()# } + + #Only use the two more common tiers of colors + # \donttest{ + demo_image %>% + image_to_mosaic(img_size = 24, + color_palette = c("universal", "generic")) %>% + build_mosaic()# } + + #Be more prescriptive with colors using 'color_table'. + # Here, we prevent all blues from being used + lego_colors_no_blue = lego_colors %>% + dplyr::filter(!grepl("[Bb]lue|[Aa]zur", Color)) + # \donttest{ + demo_image %>% + image_to_mosaic(img_size = 24, + color_table = lego_colors_no_blue) %>% + build_mosaic()# } + + #Color matching is done with the 'farver' package. There are different method. + # Change the method to euclidean (RGB distance matching) + # \donttest{ + demo_image %>% + image_to_mosaic(img_size = 24, + method = "euclidean") %>% + build_mosaic()# } + + #Change the default size of bricks to use. + # In this extreme example, use 4x6s for the background, 1x1 everywhere else + # \donttest{ + demo_image %>% + image_to_mosaic(img_size = 24, + use_bricks = c("4x6")) %>% + build_mosaic()# } +Scale an image raster array to a small number of pixels. — image_to_scaled • brickr +Scale an image raster array to a small number of pixels — image_to_scaled • brickr @@ -44,7 +44,7 @@ - + @@ -79,7 +79,7 @@ @@ -142,7 +142,7 @@@@ -190,25 +190,25 @@-diff --git a/docs/reference/index.html b/docs/reference/index.html index 4813eec..aec73fa 100644 --- a/docs/reference/index.html +++ b/docs/reference/index.html @@ -78,7 +78,7 @@Scale an image raster array to a small number of pixels.
+Scale an image raster array to a small number of pixels
Source:R/image-to-prep-mosaic.Rimage_to_scaled.Rd- + Convert an Excel 'brickr' template into a brickr 3D object
Convert an Excel 'brickr' template into a 3D object
- + Convert a 2D LEGO mosaic into a brickr 3D object
Convert a 2D LEGO mosaic into a 'brickr' 3D object
- + Convert a matrix table into a brickr 3D object
Convert a table into a 'brickr' 3D object
- + Build 3D brick model with rgl
Build 3D brick model with 'rgl'
@@ -228,19 +228,19 @@ - + Create instruction manuals
Create instruction manual for a 2D mosaic or 3D model
- + Display bricks required to build model or mosaic.
Display bricks required to build model or mosaic
diff --git a/docs/reference/lego_colors.html b/docs/reference/lego_colors.html index a3e4fdb..3f5ed22 100644 --- a/docs/reference/lego_colors.html +++ b/docs/reference/lego_colors.html @@ -45,7 +45,7 @@ - + @@ -79,7 +79,7 @@ - + Generate required bricks as a data frame.
Generate required bricks as a data frame
-A dataset containing the 54 colors available in brickr, along with metadata
+A dataset containing the 54 colors available in 'brickr', along with metadata
lego_colorsdiff --git a/docs/reference/pipe.html b/docs/reference/pipe.html index dda204e..8cc2d32 100644 --- a/docs/reference/pipe.html +++ b/docs/reference/pipe.html @@ -79,7 +79,7 @@