# hexSticker

####

#### Author: Brian M. Schilder

####

#### Most recent update: Aug-01-2021

You can make awesome hex stickers for your R packages using hexSticker.

# orthogene

Silhouettes from phylopic.

ggimage let’s you render images as data points.

ggpattern lets you fill objects with patterns or images.

    library(hexSticker)
    library(dplyr)
    library(ggplot2)
    library(ggimage)
    library(ggpattern)# remotes::install_github("coolbutuseless/ggpattern")
    library(ggplot2)

    pBase <- "http://phylopic.org/assets/images/submissions"
    image_info <- data.frame(
                    image = file.path(pBase,
                              c("c089caae-43ef-4e4e-bf26-973dd4cb65c5.512.png",# Human
                                "eedde61f-3402-4f7c-9350-49b74f5e1dba.512.png", # Macaque
                                "c8f71c27-71db-4b34-ac2d-e97fea8762cf.original.png", # Mouse
                                "6f4c653a-1da1-4e02-85ef-6344b2d8e02a.512.png", # Zebrafish
                                "ea8fa530-d856-4423-a81d-a74342cd1875.512.png", # Fly
                                "d6af4346-e56c-4f3d-84c7-fba921a293f1.512.png" # Worm
                              )
                              ),
                    species = c("Human", "Macaque", "Mouse",
                                "Zebrafish", "Fly","Worm"
                                ),
                    size=c(.5,1,1.1,
                           1.1,1.1,1)/5,
                    alpha=c(.8,.8,1,
                            .8,.8,1)
                    )
    image_info <- rbind(image_info, image_info[1,] %>% dplyr::mutate(size=0))

    ### From ggimage code
    polygon_df <- dplyr::tibble(
      angle = seq(0, 2*pi, length.out = 7) + pi/6,
      x     = cos(angle),
      y     = sin(angle)
    )
    polygon_df2 <- dplyr::tibble(
      angle = seq(0, 2*pi, length.out = 7) + pi/6,
      x     = cos(angle)*1.25,
      y     = sin(angle)*1.25
    )

    d <- cbind(polygon_df, image_info)

    hex_species <- ggplot(d, aes(x, y)) +
       ggpattern::geom_polygon_pattern(data = polygon_df2,
                                       pattern= 'image',
                                       aes(x=I(x/1), y=I(y/1)),
                                       pattern_type = 'expand',
        pattern_filename = here::here("inst/images/purple_blue.jpeg"),
        inherit.aes = FALSE) +
       geom_path(color="white", size = .8, alpha=.1) +
       geom_path(color="white", size=.5, alpha=.5) +
       geom_path(color="white", size=.1, alpha=1) +
       # geom_image(aes(image=image), size=.12, color="white", alpha=.1) +
       # geom_image(aes(image=image), size=.11, color="white", alpha=.2) +
       geom_image(aes(image=image, x=I(x/1), y=I(y/1), size=I(size), alpha=I(alpha)), color="white") +
       theme_void()

    s_width <- 1.6
    s <- sticker(hex_species,
              package="orthogene", p_size=20, p_y = 1,
              s_x=1, s_y=1, s_width=s_width, s_height=s_width*1.11111,
              h_color = "black", h_fill = "#330862",white_around_sticker = TRUE,
              filename=here::here("inst/hex/orthogene.png"), dpi = 400)

    print(s)

# Session Info

    utils::sessionInfo()

    ## R version 4.1.0 (2021-05-18)
    ## Platform: x86_64-pc-linux-gnu (64-bit)
    ## Running under: Ubuntu 20.04.2 LTS
    ##
    ## Matrix products: default
    ## BLAS/LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.8.so
    ##
    ## locale:
    ##  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C
    ##  [3] LC_TIME=en_US.UTF-8        LC_COLLATE=C
    ##  [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=C
    ##  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C
    ##  [9] LC_ADDRESS=C               LC_TELEPHONE=C
    ## [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
    ##
    ## attached base packages:
    ## [1] stats     graphics  grDevices utils     datasets  methods   base
    ##
    ## other attached packages:
    ## [1] orthogene_0.1.0
    ##
    ## loaded via a namespace (and not attached):
    ##  [1] fs_1.5.0                  usethis_2.0.1
    ##  [3] devtools_2.4.2            httr_1.4.2
    ##  [5] rprojroot_2.0.2           tools_4.1.0
    ##  [7] backports_1.2.1           bslib_0.2.5.1
    ##  [9] utf8_1.2.2                R6_2.5.0
    ## [11] DBI_1.1.1                 lazyeval_0.2.2
    ## [13] colorspace_2.0-2          withr_2.4.2
    ## [15] tidyselect_1.1.1          prettyunits_1.1.1
    ## [17] processx_3.5.2            curl_4.3.2
    ## [19] compiler_4.1.0            cli_3.0.1
    ## [21] xml2_1.3.2                desc_1.3.0
    ## [23] plotly_4.9.4.9000         sass_0.4.0
    ## [25] scales_1.1.1              callr_3.7.0
    ## [27] stringr_1.4.0             digest_0.6.27
    ## [29] foreign_0.8-81            rmarkdown_2.9
    ## [31] rio_0.5.27                pkgconfig_2.0.3
    ## [33] htmltools_0.5.1.1         sessioninfo_1.1.1
    ## [35] fastmap_1.1.0             htmlwidgets_1.5.3
    ## [37] rlang_0.4.11              readxl_1.3.1
    ## [39] rstudioapi_0.13           jquerylib_0.1.4
    ## [41] generics_0.1.0            jsonlite_1.7.2
    ## [43] dplyr_1.0.7               zip_2.2.0
    ## [45] car_3.0-11                homologene_1.4.68.19.3.27
    ## [47] magrittr_2.0.1            patchwork_1.1.1
    ## [49] Matrix_1.3-4              Rcpp_1.0.7
    ## [51] munsell_0.5.0             fansi_0.5.0
    ## [53] abind_1.4-5               lifecycle_1.0.0
    ## [55] stringi_1.7.3             yaml_2.2.1
    ## [57] carData_3.0-4             pkgbuild_1.2.0
    ## [59] grid_4.1.0                parallel_4.1.0
    ## [61] forcats_0.5.1             crayon_1.4.1
    ## [63] lattice_0.20-44           haven_2.4.1
    ## [65] hms_1.1.0                 knitr_1.33
    ## [67] ps_1.6.0                  pillar_1.6.1
    ## [69] ggpubr_0.4.0              ggsignif_0.6.2
    ## [71] pkgload_1.2.1             glue_1.4.2
    ## [73] gprofiler2_0.2.0          evaluate_0.14
    ## [75] data.table_1.14.0         remotes_2.4.0
    ## [77] vctrs_0.3.8               testthat_3.0.4
    ## [79] cellranger_1.1.0          gtable_0.3.0
    ## [81] purrr_0.3.4               tidyr_1.1.3
    ## [83] assertthat_0.2.1          cachem_1.0.5
    ## [85] ggplot2_3.3.5             xfun_0.24
    ## [87] openxlsx_4.2.4            broom_0.7.8
    ## [89] roxygen2_7.1.1            rstatix_0.7.0
    ## [91] viridisLite_0.4.0         tibble_3.1.3
    ## [93] memoise_2.0.0             ellipsis_0.3.2
    ## [95] here_1.0.1