Learn R Programming

brickr (version 0.3.5)

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

Description

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

Usage

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

Run this code
# NOT RUN {
# 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
 
# }
# NOT RUN {
 mosaic <- demo_image %>% 
    image_to_mosaic(24)
    
# }
# NOT RUN {
 
 #Pass the mosaic object to bricks_from_mosaic() to convert to 3D specifications
 
# }
# NOT RUN {
 mosaic %>% 
   bricks_from_mosaic() %>% 
   build_bricks()
   
   rgl::clear3d()
   
# }
# NOT RUN {
   
 #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
 
# }
# NOT RUN {
 mosaic %>% 
   bricks_from_mosaic(mosaic_height = 3, highest_el = "dark") %>% 
   build_bricks()
 
  rgl::clear3d()
  
# }

Run the code above in your browser using DataLab