Last active
July 3, 2021 00:16
-
-
Save saiemgilani/402ac5b2003fa8c225f91ebff26c9070 to your computer and use it in GitHub Desktop.
How to make a hex sticker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(showtext) | |
library(hexSticker) | |
library(jpeg) | |
library(magick) | |
## Automatically use showtext to render text for future devices | |
showtext_auto() | |
font_add_google("Fjalla One") | |
font_add_google("Playfair Display") | |
font_add_google("Great Vibes") | |
font_add_google("Zilla Slab") | |
font_add_google("Orbitron") | |
font_add_google("Abril Fatface") | |
font_add_google("Barlow") | |
font_add_google("Bree Serif") | |
font_add_google("Bonbon") | |
font_add_google("Amiri") | |
font_add_google("Ropa Sans") | |
font_add_google("Cantata One") | |
font_add_google("Roboto Slab") | |
font_add_google("Cardo") | |
font_add_google("Poppins") | |
font_add_google("Montserrat") | |
font_add_google("EB Garamond") | |
font_add_google("Neuton") | |
font_add_google("Josefin Slab") | |
font_add_google("Unna") | |
m <- png::readPNG("data-raw/logo1.png") | |
img <- matrix(rgb(m[,,1],m[,,2],m[,,3]), nrow=dim(m)[1]) #0.2 is alpha | |
rast <- grid::rasterGrob(img, interpolate = T) | |
font <- "Fjalla One" | |
font1 <- "Roboto Slab" #"Playfair Display","Great Vibes" | |
filename0 <- paste0("data-raw/fontstyles/wehoop-tile-",font1,".png") | |
filename1 <- paste0("data-raw/fontstyles/wehoop-tile-",font1,"-1.png") | |
filename2 <- paste0("data-raw/fontstyles/wehoop-tile-",font1,"-2.png") | |
filename3 <- paste0("data-raw/fontstyles/wehoop-tile-",font1,"-3.png") | |
filename4 <- paste0("data-raw/fontstyles/wehoop-tile-",font1,"-4.png") | |
filename5 <- paste0("data-raw/fontstyles/wehoop-tile-",font1,"-5.png") | |
## use the ggplot2 example | |
sticker(rast, package="wehoop", | |
p_size = 28, p_x = 1, p_y = 1.45, | |
s_x = 1, s_y = 0.80, s_width = 1.0, s_height = 1.0, | |
h_fill = '#ecdddd', h_color = '#0815B2', | |
p_family = font1,filename=filename0) | |
## use the ggplot2 example | |
sticker(rast, package="wehoop", | |
p_size = 28, p_x = 1, p_y = 1.45, p_color = "#2C3E50", | |
s_x = 1, s_y = 0.80, s_width = 1.0, s_height = 1.0, | |
h_fill = '#ecdddd', h_color = '#2C3E50', | |
p_family = font1,filename=filename1) | |
sticker(rast, package="wehoop", | |
p_size = 20, p_x = 1, p_y = 1.45, p_color = "#0815B2", | |
s_x = 1, s_y = 0.80, s_width = 1.0, s_height = 1.0, | |
h_fill = '#ecdddd',h_color = '#0815B2', | |
p_family = font1,filename=filename2) | |
sticker(rast, package="wehoop", | |
p_size = 20, p_x = 1, p_y = 1.45, p_color = "#0815B2", | |
s_x = 1, s_y = 0.80, s_width = 1.0, s_height = 1.0, | |
h_fill = '#ecdddd',h_color = '#95A5A6', | |
p_family = font1,filename=filename3) | |
sticker(rast, package="wehoop", | |
p_size = 20, p_x = 1, p_y = 1.45, p_color = "black", | |
s_x = 1, s_y = 0.80, s_width = 1.0, s_height = 1.0, | |
h_fill = '#ecdddd',h_color = '#0815B2', | |
p_family = font1,filename=filename4) | |
sticker(rast, package="wehoop", | |
p_size = 20, p_x = 1, p_y = 1.45, p_color = "#0815B2", | |
s_x = 1, s_y = 0.80, s_width = 1.0, s_height = 1.0, | |
h_fill = '#ecdddd',h_color = '#efeef0', | |
p_family = font1,filename=filename5) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment