bricks_from_mosaic: Convert a 2D LEGO mosaic into a 'brickr' 3D object

Description Usage Arguments Value See Also Examples

View source: R/bricks-from-mosaic.R

Description

Stacks LEGO plates to create a 3D version of the 2D brick mosaics. Height of bricks determined by brightness of color.

Usage

1
bricks_from_mosaic(mosaic_list, mosaic_height = 6, highest_el = "light")

Arguments

mosaic_list

List output from image_to_bricks(). Contains an element Img_lego.

mosaic_height

Number of layers in the 3D image.

highest_el

Brick height is determined by brightness of color. Use highest_el = 'dark' for darkest bricks to have mosaic_height.

Value

A list with elements Img_lego to pass to build_bricks.

See Also

Other 3D Models: bricks_from_coords(), bricks_from_excel(), bricks_from_table(), build_bricks()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# Import a jpeg or png
 demo_file <- system.file("extdata", "demo_img.jpg", 
                          package = "brickr", mustWork = TRUE)
 demo_image <- jpeg::readJPEG(demo_file)
 
 #Begin with a 24x24 mosaic object
 
 mosaic <- demo_image %>% 
    image_to_mosaic(24)
    
 
 #Pass the mosaic object to bricks_from_mosaic() to convert to 3D specifications
 
 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
 
 mosaic %>% 
   bricks_from_mosaic(mosaic_height = 3, highest_el = "dark") %>% 
   build_bricks()
 
  rgl::clear3d()
  

brickr documentation built on Aug. 3, 2020, 1:07 a.m.