Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: ggpattern
Type: Package
Title: 'ggplot2' Pattern Geoms
Version: 1.3.2-3
Version: 1.3.2-4
Authors@R: c(person("Mike", "FC", role = "aut"),
person("Trevor L.", "Davis", role = c("aut", "cre"),
email = "trevor.l.davis@gmail.com",
Expand Down
1 change: 0 additions & 1 deletion README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,6 @@ See the vignette on developing patterns: [`vignette("developing-patterns", packa
#### Other examples

* [Animating Patterns with `{gganimate}`](https://trevorldavis.com/R/ggpattern/dev/articles/gganimate.html): `vignette("gganimate", package = "ggpattern")`
* [Creating the Logo in R](https://trevorldavis.com/R/ggpattern/dev/articles/create-logo.html): `vignette("create-logo", package = "ggpattern")`

# Limitations

Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,6 @@ See the vignette on developing patterns: [`vignette("developing-patterns", packa
#### Other examples

* [Animating Patterns with `{gganimate}`](https://trevorldavis.com/R/ggpattern/dev/articles/gganimate.html): `vignette("gganimate", package = "ggpattern")`
* [Creating the Logo in R](https://trevorldavis.com/R/ggpattern/dev/articles/create-logo.html): `vignette("create-logo", package = "ggpattern")`

# Limitations

Expand Down
66 changes: 66 additions & 0 deletions data-raw/logo.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
library("grid")
library("ggplot2")
library("ggpattern")
library("piecepackr")

draw_logo <- function(bleed = FALSE, cut = FALSE) {
angle <- seq(0, 2 * pi, length.out = 7) + pi / 6
polygon_df <- data.frame(
angle = angle,
x = cos(angle),
y = sin(angle)
)
p <- ggplot(polygon_df) +
geom_polygon_pattern(
aes(x = x, y = y),
fill = "white",
colour = "black",
pattern_spacing = 0.15,
pattern_density = 0.4,
pattern_fill = "lightblue",
pattern_colour = "#002366",
pattern_angle = 45
) +
labs(title = "ggpattern") +
coord_equal() +
theme_bw(25) +
theme(axis.title = element_blank())

plot_grob <- ggplotGrob(p)

w <- 4.5
grid.newpage()
pushViewport(viewport(width = unit(w, "inches"), height = unit(w, "inches")))
hex <- pp_shape("convex6")

# Draw hex background
grid.draw(hex$shape(gp = gpar(fill = "white", col = "black", lwd = 4)))

# Draw ggplot grob clipped to the hex shape via a mask
hex_mask <- as.mask(hex$shape(gp = gpar(fill = "white", col = NA)))
pushViewport(viewport(mask = hex_mask))
pushViewport(viewport(x = 0.45, height = unit(0.8 * w, "inches")))
grid.draw(plot_grob)
popViewport()
popViewport()

# Redraw hex border on top to clean up edges
grid.draw(hex$shape(gp = gpar(fill = NA, col = "black", lwd = 4)))

if (isTRUE(bleed) && isTRUE(cut)) {
pushViewport(viewport(width = unit(5 / 6, "npc"), height = unit(5 / 6, "npc")))
grid.draw(hex$shape(gp = gpar(fill = "transparent", col = "orange")))
popViewport()
}

popViewport()
}

w <- 4.5
svg("man/figures/logo.svg", width = w, height = w, bg = "transparent")
draw_logo()
dev.off()

png("man/figures/logo.png", width = w, height = w, units = "in", res = 72, bg = "transparent")
draw_logo()
dev.off()
Binary file modified 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.
67 changes: 0 additions & 67 deletions vignettes/create-logo.Rmd

This file was deleted.

Loading