inst/template/dev-hex.R

# Create the hex sticker for this package

# Library
library(hexSticker)
library(magrittr)

# Define logo location
logo_location <- system.file("<LOCATION OF LOGO>",
                             package = "{{{tjutils::dev_pkg_name(envir = envir)}}}")
assertthat::assert_that(logo_location != "")
hex_location  <- "inst/figures/{{{tjutils::dev_pkg_name(envir = envir)}}}_hex.png"

# Render sticker
sticker(
    subplot  = logo_location %>%
        png::readPNG() %>%
        grid::rasterGrob(interpolate = TRUE),
    package  = "{{{tjutils::dev_pkg_name(envir = envir)}}}",
    filename = hex_location,
    p_size   = 20,
    s_width  = 10,
    s_height = 0.9,
    s_x      = 1,
    p_color  = "#000000",
    h_color  = "#000000",
    h_fill   = "#FFFFFF"
)

# Use the logo
usethis::use_logo(hex_location)
tjpalanca/tjutils documentation built on Jan. 20, 2021, 2:01 p.m.