-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate-hexagon-sticker.R
More file actions
93 lines (82 loc) · 2.96 KB
/
create-hexagon-sticker.R
File metadata and controls
93 lines (82 loc) · 2.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# ===============================================
# Author: Javed Ali (www.javedali.net)
# ===============================================
# ===============================================
# Reqquired libraries
# ===============================================
# Install the hexSticker package
# install.packages("hexSticker")
# load the necessary packages
library(hexSticker) # hexSticker generator
library(magick) # Advanced image processing
library(sysfonts) # font selection
library(tidyverse)
# ===============================================
# Sticker function
# ===============================================
sticker(
subplot, # * image/ggplot object
s_x = 0.8, # * subplot x-position (left/right position)
s_y = 0.75, # * subplot y-position (up/down position)
s_width = 0.4, # * subplot width
s_height = 0.5, # * subplot height
package, # * package name to be displayed in hexSticker
p_x = 1, # * package name x-position
p_y = 1.4, # * package name y-position
p_color = "#FFFFFF", # * package name color
p_family = "Aller_Rg", #* package name font family
p_fontface = "plain", # * package name font face
p_size = 8, # * package name font size
h_size = 1.2, # * hexSticker size
h_fill = "#1881C2", # * hexSticker background color
h_color = "#87B13F", # * hexsticker border color
spotlight = FALSE, # * add spotlight effect to hexSticker
l_x = 1, # * spotlight effect x-position
l_y = 0.5, # * spotlight effect y-position
l_width = 3, # * spotlight effect width
l_height = 3, # * spotlight effect height
l_alpha = 0.4, # * spotlight effect level
url = "", # * url to add to the hexSticker
u_x = 1, # * url x-position
u_y = 0.08, # * url y-position
u_color = "black", # * url font color
u_family = "Aller_Rg", #* url font family
u_size = 1.5, # * url font size
u_angle = 30, # * url angle
white_around_sticker = FALSE, # * add white blocks around sticker
filename = paste0(package, ".png"), # * save hexSticker to file
asp = 1, # * adjust aspect ratio
dpi = 300 # * Dots Per Inch resolution
)
# ===============================================
# Create your sticker
# ===============================================
# Load the image to add on the sticker
graph_img <- image_read('line-graph.png')
# Load fonts for custom font styles
fonts_dataset <- font_files()
# font_add("Old English", "OLDENGL.TTF")
# Create sticker
sticker(
subplot = graph_img,
package = "MultiHazard",
s_width = 1.55,
s_height = 1.55,
s_x = 1,
s_y = 0.50,
p_size = 7,
h_fill = 'gold',
h_color = 'black', # hotpink
h_size = 1.4,
url = "",
u_size = 5,
u_color = 'violetred',
spotlight = F,
l_y = 1,
l_x = 1,
l_width = 3,
l_height = 3,
l_alpha = 0.3,
p_color = 'blue', #purple
p_family = "Old English",
) %>% print()