-
Notifications
You must be signed in to change notification settings - Fork 1
/
chore.R
74 lines (67 loc) · 1.84 KB
/
chore.R
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
library(rmarkdown)
#' Generate `pagemap` hex sticker
#'
#' @param run default is set to \code{FALSE}, do not re-generate sticker
render_sticker <- function(run = FALSE) {
if (run) {
library(hexSticker)
library(showtext)
library(ggplot2)
font_add_google("Rubik")
icon_data <- data.frame(
x1 = c(1, 6, 1, 1, 5, 5, 5, 5, 5),
x2 = c(8, 8, 5.5, 4.5, 8, 8, 8, 8, 8),
y1 = c(9, 6, 6, 1, 5, 4, 3, 2, 1),
y2 = c(10, 8.5, 8.5, 5.5, 5.5, 4.5, 3.5, 2.5, 1.5),
t = c('1', '2', '1', '2', '3', '3', '3', '3', '3')
)
p <- ggplot() +
scale_x_continuous(name = "x") +
scale_y_continuous(name = "y") +
geom_rect(
data = icon_data,
mapping = aes(
xmin = x1,
xmax = x2,
ymin = y1,
ymax = y2,
fill = t
),
alpha = 0.5,
show.legend = FALSE
) +
scale_fill_manual(values = c("#999999", "#666666", "#333333")) +
theme_void() +
theme_transparent()
sticker(
p,
package = "pagemap",
p_size = 9,
p_y = 1.3,
p_color = rgb(0, 0, 0, 0.8),
p_family = "Rubik",
h_size = 1.5,
h_fill = rgb(0, 0, 0, 0.1),
h_color = rgb(0, 0, 0, 0.5),
s_x = 1,
s_y = 0.9,
s_width = 1.3,
s_height = 1,
filename = "./vignettes/pagemap.png"
)
message("Re-generate hex sticker.")
} else {
message("Pass step of re-generate hex sticker.")
}
}
# ==== Generate hex sticker ====
render_sticker(run = FALSE)
# ==== Render index.html ====
render(input = "./vignettes/pagemap.Rmd",
output_file = "../docs/index.html")
# ==== Render README.md ====
render(
input = "./vignettes/pagemap.Rmd",
output_file = "../README.md",
output_format = md_document("gfm", pandoc_args = "--wrap=preserve")
)