-
Notifications
You must be signed in to change notification settings - Fork 95
/
Copy pathmarkup.R
56 lines (48 loc) · 2.09 KB
/
markup.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
library(tidyverse)
library(svgparser)
library(magick)
library(colorspace)
library(magick)
# Load `header` list with needed data
header <- readRDS("R/portraits/med/header.rds")
colors <- header$colors
swatchplot(colors)
text_color <- colors[5]
# Take original graphic from `render_highquality` and
# add annotations.
img <- image_read(header$outfile)
annot <- glue("This map shows population density within 25 km of the ",
"Mediterranean Sea. Population estimates are bucketed ",
"into 400 meter hexagons.") |>
str_wrap(47)
cat(annot)
img |>
image_crop(geometry = "9500x5000+0+100", gravity = "center") |>
image_annotate(text = "POPULATION DENSITY ALONG THE", gravity = "north",
location = "+2500+400", font = "El Messiri",
color = text_color,
size = 150) |>
image_annotate(text = "Mediterranean Coast", gravity = "north",
location = "+2500+600", font = "El Messiri",
color = text_color,
size = 350, weight = 700) |>
image_annotate(text = annot, gravity = "southwest",
location = "+200+200", font = "El Messiri",
color = alpha(text_color, .75),
size = 125) |>
image_annotate(text = "Kontur Population Data (June 30, 2022 Release)", gravity = "southeast",
location = "+200+100", font = "El Messiri",
color = alpha(text_color, .5),
size = 75, weight = 700) |>
image_annotate(text = "Graphic by Spencer Schien (@MrPecners)", gravity = "southeast",
location = "+200+200", font = "El Messiri",
color = alpha(text_color, .5),
size = 75, weight = 700) |>
# image_composite(image_modulate(f_image, saturation = 100) |>
# image_scale("50%x"),
# gravity = "south",
# offset = "+0+200") |>
image_write("images/med/titled_med_pop.png")
image_read("images/med/titled_med_pop.png") |>
image_scale(geometry = "48%x") |>
image_write("tracked_graphics/titled_med_pop_small.png")