diff --git a/.Rbuildignore b/.Rbuildignore index ddcf9c2..8109830 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -1,5 +1,5 @@ ^LICENSE\.md$ -^LEGOMosaics\.Rproj$ +^brickr\.Rproj$ ^\.Rproj\.user$ admin_color_tools ^_pkgdown\.yml$ @@ -7,3 +7,6 @@ admin_color_tools ^pkgdown$ ^doc$ ^Meta$ +^\.travis\.yml$ +^README_files$ +^README\.Rmd$ diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..eba8c65 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,4 @@ +# R for travis: see documentation at https://docs.travis-ci.com/user/languages/r + +language: R +cache: packages diff --git a/DESCRIPTION b/DESCRIPTION index a88e2c1..fd94ee5 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: brickr Title: Tools to emulate the LEGO® System in R -Version: 0.1.0.9014 +Version: 0.1.0.9016 Authors@R: person(given = "Ryan", family = "Timpe", @@ -24,12 +24,17 @@ Imports: Suggests: rayshader, knitr, - rmarkdown + rmarkdown, + gridExtra, + png, + jpeg, + tibble Roxygen: list(markdown = TRUE) RoxygenNote: 6.1.1 URL: https://github.com/ryantimpe/brickr BugReports: https://github.com/ryantimpe/brickr/issues Collate: + 'brickr.R' 'bricks-from-mosaic.R' 'bricks-from-rayshader.R' 'bricks-from-tables.R' diff --git a/Images/goldengirls.JPG b/Images/goldengirls.JPG deleted file mode 100644 index 0a24780..0000000 Binary files a/Images/goldengirls.JPG and /dev/null differ diff --git a/Images/mf_unicorn.PNG b/Images/mf_unicorn.PNG deleted file mode 100644 index a18f04f..0000000 Binary files a/Images/mf_unicorn.PNG and /dev/null differ diff --git a/NAMESPACE b/NAMESPACE index b28e1ff..b2effb7 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -20,4 +20,8 @@ export(geom_brick_rect) export(image_to_mosaic) export(scale_fill_brick) export(theme_brick) +importFrom(grDevices,col2rgb) +importFrom(grDevices,rgb) importFrom(magrittr,"%>%") +importFrom(purrr,"%||%") +importFrom(stats,median) diff --git a/R/brickr.R b/R/brickr.R new file mode 100644 index 0000000..5d69b91 --- /dev/null +++ b/R/brickr.R @@ -0,0 +1,22 @@ +#' \code{brickr} package +#' +#' Google spreadsheets R API +#' +#' +#' @docType package +#' @name brickr +#' @importFrom purrr %||% +NULL + +## quiets concerns of R CMD check re: the .'s that appear in pipelines +if(getRversion() >= "2.15.1") { + utils::globalVariables(c(".", "aes", "alpha", "area_act", "area_tar", "B", "B_lego", + "brick_name", "Brick_size", "brick_type", "brickr_themes", "brickrID", + "channel", "col2rgb", "Color", "color_hex", "dist", "G", "G_lego", + "ggproto", "hex", "lego", "Lego_color", "LEGO_color", "lego_colors", + "Lego_name", "Level", "Lum", "n", "offset_x", "offset_y", "Palette", + "R", "R_lego", "shade", "shade_bw", "size1", "size2", "stud", + "studs", "theme", "Tr", "TYPE", "user_color", "x", "x_mid", "x_scaled", + "xg", "xmax", "xmin", "xx", "y", "y_mid", "y_scaled", "yg", "ymax", + "ymin", "yy", "z")) +} \ No newline at end of file diff --git a/R/build-instructions.R b/R/build-instructions.R index f836c6b..294db16 100644 --- a/R/build-instructions.R +++ b/R/build-instructions.R @@ -41,7 +41,7 @@ build_instructions <- function(brickr_obj, num_steps=6) { create_steps <- function(a, n_steps) { image %>% - dplyr::filter(between(Level, a-1, a)) %>% + dplyr::filter(dplyr::between(Level, a-1, a)) %>% dplyr::mutate(alpha = ifelse(Level == a, 1, 0.5)) %>% dplyr::mutate(Step = paste("Step", stringr::str_pad(a, 2, pad = "0"))) diff --git a/R/draw-key.R b/R/draw-key.R index fad96f4..d1dd3cf 100644 --- a/R/draw-key.R +++ b/R/draw-key.R @@ -1,3 +1,4 @@ +#' @importFrom grDevices col2rgb rgb #' @rdname brickr-ggproto #' @keywords internal draw_key_brick <- function(data, params, size) { diff --git a/R/geom-brick-col.R b/R/geom-brick-col.R index 5a5cdb1..245e5f2 100644 --- a/R/geom-brick-col.R +++ b/R/geom-brick-col.R @@ -25,6 +25,7 @@ #' scale_fill_brick() + #' coord_brick() + #' theme_brick() +#' @importFrom stats median #' @family Graphs #' @export diff --git a/R/image-to-prep-mosaic.R b/R/image-to-prep-mosaic.R index 51988ec..dcbaad4 100644 --- a/R/image-to-prep-mosaic.R +++ b/R/image-to-prep-mosaic.R @@ -80,8 +80,8 @@ image_to_scaled <- function(image, img_size = 48, brightness = 1, warhol = 1:3){ dplyr::mutate(color = rgb(R, G, B)) %>% dplyr::ungroup() %>% #Center the image - dplyr::filter(x <= median(x) + img_size2[1]/2, x > median(x) - img_size2[1]/2, - y <= median(y) + img_size2[2]/2, y > median(y) - img_size2[2]/2) %>% + dplyr::filter(x <= stats::median(x) + img_size2[1]/2, x > stats::median(x) - img_size2[1]/2, + y <= stats::median(y) + img_size2[2]/2, y > stats::median(y) - img_size2[2]/2) %>% #Flip y dplyr::mutate(y = (max(y) - y) + 1) diff --git a/R/theme-brick.R b/R/theme-brick.R index ced1dee..feafc6f 100644 --- a/R/theme-brick.R +++ b/R/theme-brick.R @@ -26,11 +26,11 @@ theme_brick <- function(brick_theme = "classic"){ theme_base + ggplot2::theme( - # plot.background = element_rect(fill = values$hex[1]), - panel.background = element_rect(fill = values$hex[1]), - panel.grid = element_blank(), - text = element_text(color = values$hex[2]), - legend.text = element_text(color = values$hex[2], size = 8) + # plot.background = ggplot2::element_rect(fill = values$hex[1]), + panel.background = ggplot2::element_rect(fill = values$hex[1]), + panel.grid = ggplot2::element_blank(), + text = ggplot2::element_text(color = values$hex[2]), + legend.text = ggplot2::element_text(color = values$hex[2], size = 8) ) } \ No newline at end of file diff --git a/README.Rmd b/README.Rmd index 377dfd8..24bb4b4 100644 --- a/README.Rmd +++ b/README.Rmd @@ -19,6 +19,7 @@ library(tidyverse) # brickr [![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://www.tidyverse.org/lifecycle/#experimental) + [![Travis build status](https://travis-ci.org/ryantimpe/brickr.svg?branch=master)](https://travis-ci.org/ryantimpe/brickr) ## Overview @@ -57,7 +58,10 @@ install.packages("rayshader") The mosaic functions renders an imported JPG or PNG file using LEGO colors and bricks. ```{r m1_set, fig.width = 3, fig.height=3, echo = TRUE, message = FALSE, warning = FALSE} -mosaic1 <- png::readPNG("Images/mf_unicorn.PNG") %>% +demo_img = tempfile() +download.file("http://ryantimpe.com/files/mf_unicorn.PNG", demo_img, mode="wb") + +mosaic1 <- png::readPNG(demo_img) %>% image_to_mosaic(img_size = 36) #Length of each side of mosaic in "bricks" #Plot 2D mosaic diff --git a/README.md b/README.md index ae71442..c6bb118 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,8 @@ The LEGO® System in R [![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://www.tidyverse.org/lifecycle/#experimental) +[![Travis build +status](https://travis-ci.org/ryantimpe/brickr.svg?branch=master)](https://travis-ci.org/ryantimpe/brickr) ## Overview diff --git a/README_files/figure-gfm/bricks_5-1.png b/README_files/figure-gfm/bricks_5-1.png index 9804b43..c721ddf 100644 Binary files a/README_files/figure-gfm/bricks_5-1.png and b/README_files/figure-gfm/bricks_5-1.png differ diff --git a/README_files/figure-gfm/bricks_6-1.png b/README_files/figure-gfm/bricks_6-1.png index 7bdd8f8..60e3580 100644 Binary files a/README_files/figure-gfm/bricks_6-1.png and b/README_files/figure-gfm/bricks_6-1.png differ diff --git a/README_files/figure-gfm/geom_brick-1.png b/README_files/figure-gfm/geom_brick-1.png index 61103ae..bf6e9a3 100644 Binary files a/README_files/figure-gfm/geom_brick-1.png and b/README_files/figure-gfm/geom_brick-1.png differ diff --git a/README_files/figure-gfm/geom_brick2-1.png b/README_files/figure-gfm/geom_brick2-1.png index 71c8df2..203248d 100644 Binary files a/README_files/figure-gfm/geom_brick2-1.png and b/README_files/figure-gfm/geom_brick2-1.png differ diff --git a/README_files/figure-gfm/m1_instructions-1.png b/README_files/figure-gfm/m1_instructions-1.png index 28ec7ff..a062b18 100644 Binary files a/README_files/figure-gfm/m1_instructions-1.png and b/README_files/figure-gfm/m1_instructions-1.png differ diff --git a/README_files/figure-gfm/m1_pieces-1.png b/README_files/figure-gfm/m1_pieces-1.png index cb5fd2f..6353f97 100644 Binary files a/README_files/figure-gfm/m1_pieces-1.png and b/README_files/figure-gfm/m1_pieces-1.png differ diff --git a/_pkgdown.yml b/_pkgdown.yml index 0cb5cda..e88139e 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -27,3 +27,19 @@ reference: - build_instructions - starts_with("build_pieces") - build_themes + +articles: +- title: Mosaics + desc: Creating mosaics from images. + contents: + - '`mosaics`' +- 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`' diff --git a/docs/LICENSE-text.html b/docs/LICENSE-text.html index 3ad2e03..871c765 100644 --- a/docs/LICENSE-text.html +++ b/docs/LICENSE-text.html @@ -70,7 +70,7 @@ brickr - 0.1.0.9014 + 0.1.0.9016 diff --git a/docs/LICENSE.html b/docs/LICENSE.html index dc895ad..444befa 100644 --- a/docs/LICENSE.html +++ b/docs/LICENSE.html @@ -70,7 +70,7 @@ brickr - 0.1.0.9014 + 0.1.0.9016 diff --git a/docs/articles/graphs.html b/docs/articles/graphs.html index 1a68f5e..924a31b 100644 --- a/docs/articles/graphs.html +++ b/docs/articles/graphs.html @@ -37,7 +37,7 @@ brickr - 0.1.0.9014 + 0.1.0.9016 diff --git a/docs/articles/graphs_files/figure-html/coord-1.png b/docs/articles/graphs_files/figure-html/coord-1.png index 64567e1..fcea2ee 100644 Binary files a/docs/articles/graphs_files/figure-html/coord-1.png and b/docs/articles/graphs_files/figure-html/coord-1.png differ diff --git a/docs/articles/graphs_files/figure-html/geom_brick-1.png b/docs/articles/graphs_files/figure-html/geom_brick-1.png index 194871a..9729fbf 100644 Binary files a/docs/articles/graphs_files/figure-html/geom_brick-1.png and b/docs/articles/graphs_files/figure-html/geom_brick-1.png differ diff --git a/docs/articles/graphs_files/figure-html/scales-1.png b/docs/articles/graphs_files/figure-html/scales-1.png index 245bd1a..f7d5fb0 100644 Binary files a/docs/articles/graphs_files/figure-html/scales-1.png and b/docs/articles/graphs_files/figure-html/scales-1.png differ diff --git a/docs/articles/graphs_files/figure-html/scales2-1.png b/docs/articles/graphs_files/figure-html/scales2-1.png index eb0ccb6..6dc8b88 100644 Binary files a/docs/articles/graphs_files/figure-html/scales2-1.png and b/docs/articles/graphs_files/figure-html/scales2-1.png differ diff --git a/docs/articles/index.html b/docs/articles/index.html index f57dc02..3673ba5 100644 --- a/docs/articles/index.html +++ b/docs/articles/index.html @@ -70,7 +70,7 @@ brickr - 0.1.0.9014 + 0.1.0.9016 @@ -137,15 +137,29 @@
-

All vignettes

-

+

Mosaics

+

Creating mosaics from images.

+ + +
+
+

3D Models

+

Creating 3D LEGO models.

+
+
+

Charts

+

ggplot2 brickr extension

+ +
diff --git a/docs/articles/models-from-other.html b/docs/articles/models-from-other.html index 84be229..851575b 100644 --- a/docs/articles/models-from-other.html +++ b/docs/articles/models-from-other.html @@ -37,7 +37,7 @@ brickr - 0.1.0.9014 + 0.1.0.9016 @@ -124,10 +124,13 @@
  • highest_el specifies if ‘light’ or ‘dark’ color bricks should be the tallest in the model. The default is ‘light’.
  • -
    mosaic <- png::readPNG("../Images/mf_unicorn.PNG") %>% 
    -  image_to_mosaic()
    +
    demo_img = tempfile() 
    +download.file("http://ryantimpe.com/files/mf_unicorn.PNG", demo_img, mode="wb")
     
    -mosaic %>% build_mosaic()
    +mosaic <- png::readPNG(demo_img) %>% + image_to_mosaic() + +mosaic %>% build_mosaic()

    
     mosaic %>% 
    diff --git a/docs/articles/models-from-program.html b/docs/articles/models-from-program.html
    index 5748623..ed4b181 100644
    --- a/docs/articles/models-from-program.html
    +++ b/docs/articles/models-from-program.html
    @@ -37,7 +37,7 @@
           
           
             brickr
    -        0.1.0.9014
    +        0.1.0.9016
           
         
    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 e532969..b3f2626 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 8595347..619ee67 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 c8a62be..81214a6 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 6628d6f..d4cd46e 100644 --- a/docs/articles/models-from-tables.html +++ b/docs/articles/models-from-tables.html @@ -37,7 +37,7 @@ brickr - 0.1.0.9014 + 0.1.0.9016 diff --git a/docs/articles/mosaics.html b/docs/articles/mosaics.html index 32d95ba..a0a66b1 100644 --- a/docs/articles/mosaics.html +++ b/docs/articles/mosaics.html @@ -37,7 +37,7 @@ brickr - 0.1.0.9014 + 0.1.0.9016 @@ -114,13 +114,16 @@ Getting started

    You can generate a brickr mosaic object from an image using brickr::image_to_mosaic(). Pass this object to build_mosaic() to construct a visualization of the mosaic.

    -
    mosaic <- png::readPNG("../Images/mf_unicorn.PNG") %>% 
    -  image_to_mosaic()
    +
    demo_img = tempfile() 
    +download.file("http://ryantimpe.com/files/mf_unicorn.PNG", demo_img, mode="wb")
     
    -mosaic %>% build_mosaic()
    +mosaic <- png::readPNG(demo_img) %>% + image_to_mosaic() + +mosaic %>% build_mosaic()

    The default is to create a mosaic with 48 knobs (brick studs) on each side. Change this using the img_size input. A single value will create a square mosaic, while an array of two values represent the width and length.

    -
    png::readPNG("../Images/mf_unicorn.PNG") %>% 
    +
    png::readPNG(demo_img) %>% 
       image_to_mosaic(img_size = 32) %>% 
       build_mosaic()

    @@ -147,11 +150,11 @@
  • ‘special’ colors are typically reserved for certain products and it’s likely that bricks might not be actively produced in these colors.
  • Use the color_palette input in the image_to_mosaic() function to limit the bricks used to any combination of these three categories.

    -
    p1 <- png::readPNG("../Images/mf_unicorn.PNG") %>% 
    +
    p1 <- png::readPNG(demo_img) %>% 
       image_to_mosaic(32, color_palette = c('universal', 'generic')) %>% 
       build_mosaic(title = "universal & generic")
     
    -p2 <- png::readPNG("../Images/mf_unicorn.PNG") %>% 
    +p2 <- png::readPNG(demo_img) %>% 
       image_to_mosaic(32, color_palette = c('universal')) %>% 
       build_mosaic(title = "universal")
     
    @@ -162,7 +165,7 @@
     

    Grayscale

    For grayscale or black and white mosaics, use color_palette = 'bw'. This creates the mosaic by measuring the brightness of each pixel in the image and mapping it one of the four shades of gray. Use the contrast input to adjust the relative brightness of the pixels.

    -
    png::readPNG("../Images/mf_unicorn.PNG") %>% 
    +
    png::readPNG(demo_img) %>% 
       image_to_mosaic(32, color_palette = 'bw', contrast = 1.1)%>% 
       build_mosaic()

    @@ -175,7 +178,7 @@ lego_colors_wo_blue <- lego_colors %>% dplyr::filter(!grepl("blue|azur", tolower(Color))) -png::readPNG("../Images/mf_unicorn.PNG") %>% +png::readPNG(demo_img) %>% image_to_mosaic(32, color_table = lego_colors_wo_blue)%>% build_mosaic(title = "Mosaic without blue or azur")

    @@ -187,7 +190,7 @@

    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") %>% 
    -  purrr::map(~png::readPNG("../Images/mf_unicorn.PNG") %>% 
    +  purrr::map(~png::readPNG(demo_img) %>% 
       image_to_mosaic(24, method =.x) %>% 
       build_mosaic(title = .x )) -> mosaics_by_method
     
    @@ -198,12 +201,15 @@
     

    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.

    -
    c(FALSE, TRUE) %>% 
    -  purrr::map(~jpeg::readJPEG("../Images/goldengirls.JPG") %>% 
    -  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))
    +
    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))

    @@ -216,7 +222,7 @@

    3D Mosaics

    With rayshader installed, 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("../Images/mf_unicorn.PNG") %>% 
    +
    png::readPNG(demo_img) %>% 
       image_to_mosaic(32) %>% 
       bricks_from_mosaic(highest_el = "dark") %>% 
       build_bricks(brick_type = "plate")
    diff --git a/docs/authors.html b/docs/authors.html
    index 441a9d4..328357e 100644
    --- a/docs/authors.html
    +++ b/docs/authors.html
    @@ -70,7 +70,7 @@
           
           
             brickr
    -        0.1.0.9014
    +        0.1.0.9016
           
         
    diff --git a/docs/index.html b/docs/index.html index 6874801..6138b18 100644 --- a/docs/index.html +++ b/docs/index.html @@ -39,7 +39,7 @@ brickr - 0.1.0.9014 + 0.1.0.9016
    @@ -150,11 +150,14 @@

    Mosaics

    The mosaic functions renders an imported JPG or PNG file using LEGO colors and bricks.

    -
    mosaic1 <- png::readPNG("Images/mf_unicorn.PNG") %>% 
    -  image_to_mosaic(img_size = 36) #Length of each side of mosaic in "bricks"
    +
    demo_img = tempfile() 
    +download.file("http://ryantimpe.com/files/mf_unicorn.PNG", demo_img, mode="wb")
     
    -#Plot 2D mosaic
    -mosaic1 %>% build_mosaic()
    +mosaic1 <- png::readPNG(demo_img) %>% + image_to_mosaic(img_size = 36) #Length of each side of mosaic in "bricks" + +#Plot 2D mosaic +mosaic1 %>% build_mosaic()

    In general, any {brickr} function that begins with build_ generates a graphical output from a {brickr} list object from other functions.

    @@ -353,6 +356,7 @@

    Dev status

    • Lifecycle: experimental
    • +
    • Travis build status
    diff --git a/docs/index_files/figure-html/geom_brick2-1.png b/docs/index_files/figure-html/geom_brick2-1.png index 39ab8c5..f75dbb7 100644 Binary files a/docs/index_files/figure-html/geom_brick2-1.png and b/docs/index_files/figure-html/geom_brick2-1.png differ diff --git a/docs/news/index.html b/docs/news/index.html index 561133f..a8ec8aa 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -70,7 +70,7 @@ brickr - 0.1.0.9014 + 0.1.0.9016
    diff --git a/docs/reference/brickr-ggproto.html b/docs/reference/brickr-ggproto.html index 8e5780a..7dc0187 100644 --- a/docs/reference/brickr-ggproto.html +++ b/docs/reference/brickr-ggproto.html @@ -72,7 +72,7 @@ brickr - 0.1.0.9014 + 0.1.0.9016
    diff --git a/docs/reference/brickr.html b/docs/reference/brickr.html new file mode 100644 index 0000000..befbea6 --- /dev/null +++ b/docs/reference/brickr.html @@ -0,0 +1,175 @@ + + + + + + + + +<code>brickr</code> package — brickr • brickr + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + +
    + +
    +
    + + +
    + +

    Google spreadsheets R API

    + +
    + + + +
    + +
    + +
    + + +
    +

    Site built with pkgdown 1.3.0.

    +
    +
    +
    + + + + + + diff --git a/docs/reference/bricks_from_coords.html b/docs/reference/bricks_from_coords.html index 5e5bf10..b9f061d 100644 --- a/docs/reference/bricks_from_coords.html +++ b/docs/reference/bricks_from_coords.html @@ -72,7 +72,7 @@ brickr - 0.1.0.9014 + 0.1.0.9016
    diff --git a/docs/reference/bricks_from_excel.html b/docs/reference/bricks_from_excel.html index 093a0a4..8bc6116 100644 --- a/docs/reference/bricks_from_excel.html +++ b/docs/reference/bricks_from_excel.html @@ -72,7 +72,7 @@ brickr - 0.1.0.9014 + 0.1.0.9016 diff --git a/docs/reference/bricks_from_mosaic.html b/docs/reference/bricks_from_mosaic.html index 4206621..9eee597 100644 --- a/docs/reference/bricks_from_mosaic.html +++ b/docs/reference/bricks_from_mosaic.html @@ -72,7 +72,7 @@ brickr - 0.1.0.9014 + 0.1.0.9016 diff --git a/docs/reference/bricks_from_rayshader.html b/docs/reference/bricks_from_rayshader.html index b0e9227..4c34af5 100644 --- a/docs/reference/bricks_from_rayshader.html +++ b/docs/reference/bricks_from_rayshader.html @@ -72,7 +72,7 @@ brickr - 0.1.0.9014 + 0.1.0.9016 diff --git a/docs/reference/bricks_from_table.html b/docs/reference/bricks_from_table.html index 1fc1107..b301247 100644 --- a/docs/reference/bricks_from_table.html +++ b/docs/reference/bricks_from_table.html @@ -72,7 +72,7 @@ brickr - 0.1.0.9014 + 0.1.0.9016 diff --git a/docs/reference/build_bricks.html b/docs/reference/build_bricks.html index 45ab5e6..fd73ad2 100644 --- a/docs/reference/build_bricks.html +++ b/docs/reference/build_bricks.html @@ -72,7 +72,7 @@ brickr - 0.1.0.9014 + 0.1.0.9016 diff --git a/docs/reference/build_colors.html b/docs/reference/build_colors.html index 6b733cb..924f8ec 100644 --- a/docs/reference/build_colors.html +++ b/docs/reference/build_colors.html @@ -72,7 +72,7 @@ brickr - 0.1.0.9014 + 0.1.0.9016 diff --git a/docs/reference/build_instructions.html b/docs/reference/build_instructions.html index 1eb9d0f..2bf8107 100644 --- a/docs/reference/build_instructions.html +++ b/docs/reference/build_instructions.html @@ -72,7 +72,7 @@ brickr - 0.1.0.9014 + 0.1.0.9016 diff --git a/docs/reference/build_mosaic.html b/docs/reference/build_mosaic.html index 7cec99f..472af81 100644 --- a/docs/reference/build_mosaic.html +++ b/docs/reference/build_mosaic.html @@ -72,7 +72,7 @@ brickr - 0.1.0.9014 + 0.1.0.9016 diff --git a/docs/reference/build_pieces.html b/docs/reference/build_pieces.html index 56bf580..c625851 100644 --- a/docs/reference/build_pieces.html +++ b/docs/reference/build_pieces.html @@ -72,7 +72,7 @@ brickr - 0.1.0.9014 + 0.1.0.9016 diff --git a/docs/reference/build_pieces_table.html b/docs/reference/build_pieces_table.html index 69dfbd9..5a164c2 100644 --- a/docs/reference/build_pieces_table.html +++ b/docs/reference/build_pieces_table.html @@ -72,7 +72,7 @@ brickr - 0.1.0.9014 + 0.1.0.9016 diff --git a/docs/reference/build_themes.html b/docs/reference/build_themes.html index 73c620a..ef8d392 100644 --- a/docs/reference/build_themes.html +++ b/docs/reference/build_themes.html @@ -72,7 +72,7 @@ brickr - 0.1.0.9014 + 0.1.0.9016 diff --git a/docs/reference/collect_bricks.html b/docs/reference/collect_bricks.html index fe7fd1b..69ec101 100644 --- a/docs/reference/collect_bricks.html +++ b/docs/reference/collect_bricks.html @@ -72,7 +72,7 @@ brickr - 0.1.0.9014 + 0.1.0.9016 diff --git a/docs/reference/coord-brick.html b/docs/reference/coord-brick.html index b6e477c..ad5f17f 100644 --- a/docs/reference/coord-brick.html +++ b/docs/reference/coord-brick.html @@ -73,7 +73,7 @@ Use coord_brick_flip() for horizontal bars." /> brickr - 0.1.0.9014 + 0.1.0.9016 diff --git a/docs/reference/geom_brick_col.html b/docs/reference/geom_brick_col.html index 9a87df0..dc4325d 100644 --- a/docs/reference/geom_brick_col.html +++ b/docs/reference/geom_brick_col.html @@ -73,7 +73,7 @@ Bar height is determined by values in the data using the y aesthetic. With the e brickr - 0.1.0.9014 + 0.1.0.9016 diff --git a/docs/reference/geom_brick_rect.html b/docs/reference/geom_brick_rect.html index b9d7ff7..483fce0 100644 --- a/docs/reference/geom_brick_rect.html +++ b/docs/reference/geom_brick_rect.html @@ -72,7 +72,7 @@ brickr - 0.1.0.9014 + 0.1.0.9016 diff --git a/docs/reference/image_to_mosaic.html b/docs/reference/image_to_mosaic.html index bcbba41..ec87745 100644 --- a/docs/reference/image_to_mosaic.html +++ b/docs/reference/image_to_mosaic.html @@ -72,7 +72,7 @@ brickr - 0.1.0.9014 + 0.1.0.9016 diff --git a/docs/reference/image_to_scaled.html b/docs/reference/image_to_scaled.html index a5fc787..c40d1f8 100644 --- a/docs/reference/image_to_scaled.html +++ b/docs/reference/image_to_scaled.html @@ -72,7 +72,7 @@ brickr - 0.1.0.9014 + 0.1.0.9016 diff --git a/docs/reference/index.html b/docs/reference/index.html index 6e964bf..142cb6a 100644 --- a/docs/reference/index.html +++ b/docs/reference/index.html @@ -70,7 +70,7 @@ brickr - 0.1.0.9014 + 0.1.0.9016 diff --git a/docs/reference/layer_from_bricks.html b/docs/reference/layer_from_bricks.html index 422a313..8fdd8a2 100644 --- a/docs/reference/layer_from_bricks.html +++ b/docs/reference/layer_from_bricks.html @@ -72,7 +72,7 @@ brickr - 0.1.0.9014 + 0.1.0.9016 diff --git a/docs/reference/pipe.html b/docs/reference/pipe.html index ef3e7ff..0364493 100644 --- a/docs/reference/pipe.html +++ b/docs/reference/pipe.html @@ -72,7 +72,7 @@ brickr - 0.1.0.9014 + 0.1.0.9016 diff --git a/docs/reference/scale_fill_brick.html b/docs/reference/scale_fill_brick.html index fb895b2..75a9981 100644 --- a/docs/reference/scale_fill_brick.html +++ b/docs/reference/scale_fill_brick.html @@ -72,7 +72,7 @@ brickr - 0.1.0.9014 + 0.1.0.9016 diff --git a/docs/reference/scaled_to_colors.html b/docs/reference/scaled_to_colors.html index fa2ae10..15de5c9 100644 --- a/docs/reference/scaled_to_colors.html +++ b/docs/reference/scaled_to_colors.html @@ -72,7 +72,7 @@ brickr - 0.1.0.9014 + 0.1.0.9016 diff --git a/docs/reference/theme_brick.html b/docs/reference/theme_brick.html index 0b0c285..d5fb799 100644 --- a/docs/reference/theme_brick.html +++ b/docs/reference/theme_brick.html @@ -72,7 +72,7 @@ brickr - 0.1.0.9014 + 0.1.0.9016 diff --git a/docs/sitemap.xml b/docs/sitemap.xml index d0fb054..52d3e4d 100644 --- a/docs/sitemap.xml +++ b/docs/sitemap.xml @@ -6,6 +6,9 @@ http://brickr.org/reference/brickr-ggproto.html + + http://brickr.org/reference/brickr.html + http://brickr.org/reference/bricks_from_coords.html diff --git a/man/brickr.Rd b/man/brickr.Rd new file mode 100644 index 0000000..b9839a3 --- /dev/null +++ b/man/brickr.Rd @@ -0,0 +1,10 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/brickr.R +\docType{package} +\name{brickr} +\alias{brickr} +\alias{brickr-package} +\title{\code{brickr} package} +\description{ +Google spreadsheets R API +} diff --git a/vignettes/models-from-other.Rmd b/vignettes/models-from-other.Rmd index cbc2480..ad710ae 100644 --- a/vignettes/models-from-other.Rmd +++ b/vignettes/models-from-other.Rmd @@ -30,7 +30,10 @@ Begin with a brickr mosaic from an image. Rather than graphically rendering the * `highest_el` specifies if 'light' or 'dark' color bricks should be the tallest in the model. The default is 'light'. ```{r bricks_6, echo=TRUE, warning=FALSE, message=FALSE, fig.width=4, fig.height=4} -mosaic <- png::readPNG("../Images/mf_unicorn.PNG") %>% +demo_img = tempfile() +download.file("http://ryantimpe.com/files/mf_unicorn.PNG", demo_img, mode="wb") + +mosaic <- png::readPNG(demo_img) %>% image_to_mosaic() mosaic %>% build_mosaic() diff --git a/vignettes/mosaics.Rmd b/vignettes/mosaics.Rmd index 203273f..1bc6dd8 100644 --- a/vignettes/mosaics.Rmd +++ b/vignettes/mosaics.Rmd @@ -25,7 +25,10 @@ You can generate a brickr mosaic object from an image using `brickr::image_to_mo ![](../Images/mf_unicorn.PNG){ width='250px' } ```{r g1} -mosaic <- png::readPNG("../Images/mf_unicorn.PNG") %>% +demo_img = tempfile() +download.file("http://ryantimpe.com/files/mf_unicorn.PNG", demo_img, mode="wb") + +mosaic <- png::readPNG(demo_img) %>% image_to_mosaic() mosaic %>% build_mosaic() @@ -34,7 +37,7 @@ mosaic %>% build_mosaic() The default is to create a mosaic with 48 knobs (brick studs) on each side. Change this using the `img_size` input. A single value will create a square mosaic, while an array of two values represent the width and length. ```{r g2} -png::readPNG("../Images/mf_unicorn.PNG") %>% +png::readPNG(demo_img) %>% image_to_mosaic(img_size = 32) %>% build_mosaic() ``` @@ -61,11 +64,11 @@ Each of the 41 colors belongs to one of three categories: Use the `color_palette` input in the `image_to_mosaic()` function to limit the bricks used to any combination of these three categories. ```{r c_palettes, fig.width=6, fig.height=4} -p1 <- png::readPNG("../Images/mf_unicorn.PNG") %>% +p1 <- png::readPNG(demo_img) %>% image_to_mosaic(32, color_palette = c('universal', 'generic')) %>% build_mosaic(title = "universal & generic") -p2 <- png::readPNG("../Images/mf_unicorn.PNG") %>% +p2 <- png::readPNG(demo_img) %>% image_to_mosaic(32, color_palette = c('universal')) %>% build_mosaic(title = "universal") @@ -78,7 +81,7 @@ gridExtra::grid.arrange(p1, p2, layout_matrix = matrix(c(1,2), ncol=2)) For grayscale or black and white mosaics, use `color_palette = 'bw'`. This creates the mosaic by measuring the brightness of each pixel in the image and mapping it one of the four shades of gray. Use the contrast input to adjust the relative brightness of the pixels. ```{r c_bw} -png::readPNG("../Images/mf_unicorn.PNG") %>% +png::readPNG(demo_img) %>% image_to_mosaic(32, color_palette = 'bw', contrast = 1.1)%>% build_mosaic() ``` @@ -92,7 +95,7 @@ With the `color_table` input, it is possible to restrict the colors in the mosai lego_colors_wo_blue <- lego_colors %>% dplyr::filter(!grepl("blue|azur", tolower(Color))) -png::readPNG("../Images/mf_unicorn.PNG") %>% +png::readPNG(demo_img) %>% image_to_mosaic(32, color_table = lego_colors_wo_blue)%>% build_mosaic(title = "Mosaic without blue or azur") ``` @@ -105,7 +108,7 @@ The default algorithm is 'cie94', though the other farver options are available ```{r c_methods, fig.height=5, fig.width=5} c("cie94", "cie2000", "euclidean", "brickr_classic") %>% - purrr::map(~png::readPNG("../Images/mf_unicorn.PNG") %>% + purrr::map(~png::readPNG(demo_img) %>% image_to_mosaic(24, method =.x) %>% build_mosaic(title = .x )) -> mosaics_by_method @@ -118,8 +121,11 @@ gridExtra::grid.arrange(grobs = mosaics_by_method, layout_matrix =rbind(c(1,2),c When rendering a mosaic from a photographic with many shades of similar colors, using [dithering](https://en.wikipedia.org/wiki/Floyd%E2%80%93Steinberg_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. ```{r c_dither, fig.width=6, fig.height=4} +gg_img = tempfile() +download.file("http://ryantimpe.com/files/goldengirls.JPG", gg_img, mode="wb") + c(FALSE, TRUE) %>% - purrr::map(~jpeg::readJPEG("../Images/goldengirls.JPG") %>% + purrr::map(~jpeg::readJPEG(gg_img) %>% image_to_mosaic(dithering = .x) %>% build_mosaic(title = paste("dithering =", .x))) -> mosaics_by_dither @@ -135,7 +141,7 @@ The input `brightness` can be used to scale up or down the RGB values of the ima With [rayshader](https://www.rayshader.com/) installed, 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. ```{r c_threed} -png::readPNG("../Images/mf_unicorn.PNG") %>% +png::readPNG(demo_img) %>% image_to_mosaic(32) %>% bricks_from_mosaic(highest_el = "dark") %>% build_bricks(brick_type = "plate")