Skip to content

Commit

Permalink
Add logo
Browse files Browse the repository at this point in the history
  • Loading branch information
joelnitta committed Sep 29, 2022
1 parent 635eaec commit 1d4232c
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ docs
/doc/
/Meta/
.vscode
pkgdown
2 changes: 1 addition & 1 deletion README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ knitr::opts_chunk$set(
)
```

# canaper
# canaper <img src="man/figures/logo.png" align="right" alt="" width="120" />

<!-- badges: start -->
[![DOI](https://zenodo.org/badge/359280907.svg)](https://zenodo.org/badge/latestdoi/359280907)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<!-- README.md is generated from README.Rmd. Please edit that file -->
<!-- You'll still need to render `README.Rmd` regularly, to keep `README.md` up-to-date. `devtools::build_readme()` is handy for this. You could also use GitHub Actions to re-render `README.Rmd` every time you push. An example workflow can be found here: <https://github.com/r-lib/actions/tree/master/examples>. -->

# canaper
# canaper <img src="man/figures/logo.png" align="right" alt="" width="120" />

<!-- badges: start -->

Expand Down
77 changes: 77 additions & 0 deletions data-raw/logo.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# Script to generate logo
library(tidyverse)
library(canaper)
library(hexSticker)
library(magick)

# So we get the same background plot each time
set.seed(142)

# Make 20x20 grid simulating endemism
# this will be the sticker background
df <- expand.grid(x = 1:20, y = 1:20) %>%
as_tibble() %>%
mutate(
endem = sample(
x = names(cpr_endem_cols),
size = 20 * 20,
replace = TRUE,
# 30x more likely to get non-significant
prob = c(1, 1, 30, 1, 1)
)
) %>%
mutate(
endem = case_when(
# Make an empty space -2 and +2 around middle for printing package name
y > 8 & y < 12 ~ "not significant",
TRUE ~ endem
)
)

# Save this as background
ggplot(df, aes(x, y)) +
geom_tile(aes(fill = endem)) +
scale_fill_manual(values = mishler_endem_cols) +
theme_void() +
theme(
legend.position = "none"
)

ggsave("data-raw/logo_back.png")

# Generate sticker: background extends beyond hex
canaper_s <- sticker(
"data-raw/logo_back.png",
package = "canaper",
p_x = 1,
p_y = 1,
p_family = "mono",
p_size = 8,
p_color = "grey10",
s_x = 1,
s_y = 1,
s_width = 1.2,
s_height = 40,
dpi = 600,
asp = 1,
h_fill = mishler_endem_cols["not significant"],
h_color = "grey10",
h_size = 1.2,
url = "https://github.com/ropensci/canaper",
u_family = "sans",
u_size = 1.45,
u_y = 0.08,
u_x = 1,
# Make area around hex white
white_around_sticker = TRUE,
filename = "man/figures/logo.png"
)

# Convert area around hex to transparent
# https://github.com/GuangchuangYu/hexSticker/issues/39
image_read("man/figures/logo.png") %>%
image_fill(color = "transparent", refcolor = "white", fuzz = 20, point = "+1+1") %>% # nolint
image_fill(color = "transparent", refcolor = "white", fuzz = 20, point = "+1034+1") %>% # nolint
image_fill(color = "transparent", refcolor = "white", fuzz = 20, point = "+1+1198") %>% # nolint
image_fill(color = "transparent", refcolor = "white", fuzz = 20, point = "+1034+1198") %>% # nolint
image_write("man/figures/logo.png")
Binary file added man/figures/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 1d4232c

Please sign in to comment.