Skip to content

Commit

Permalink
Fix AnnotationFilter sticker for hexStickers 0.1.0
Browse files Browse the repository at this point in the history
- Adapt the R script to create the AnnotationFilter sticker to the new
  hexStickers package (issue #23).
  • Loading branch information
jorainer committed Mar 21, 2017
1 parent 4618248 commit 84532f4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
Binary file modified AnnotationFilter/AnnotationFilter.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 9 additions & 12 deletions AnnotationFilter/AnnotationFilter_hexSticker.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,22 @@ col_bg <- col_bg_3
col_border <- col_border_3
col_text <- "#ffffff" ## white
col_ped <- "#ffffff"
## col_ped <- "#000000"
n_steps <- 30
## Upper rectangle
## Transparence rectangle
y_min <- 0.75
y_max <- 0.9
x_min <- 0.2
x_max <- 1.4
y_max <- 1.04
x_min <- 0.1
x_max <- 1.9
alpha_max <- 0.7
## alpha_max <- 0.5

img <- readPNG("./drawing_2.png")
## Invert and add alpha channel.
img_a <- matrix(rgb(1 - img[,,1], 1 - img[,,2], 1 - img[,,3], img[,,4] * 0.8),
nrow = dim(img)[1])
g_img <- rasterGrob(img_a, width = 0.65, x = 0.48, interpolate = TRUE)
g_img <- rasterGrob(img_a, width = 1, x = 0.5, interpolate = TRUE)

## Rectangle with color shade to transparency
ys <- seq(y_min, y_max, length.out = n_steps + 1)
## alpha_steps <- seq(from = 0, to = alpha_max, length.out = n_steps)
alpha_steps <- c(seq(from = 0, to = alpha_max, length.out = n_steps / 3),
rep(alpha_max, n_steps / 3),
seq(from = alpha_max, to = 0, length.out = n_steps / 3))
Expand All @@ -43,15 +40,15 @@ trans_rect <- geom_rect(data = trans_df, fill = col_bg,
alpha = alpha))

gg <- ggplot() +
geom_rect(aes(xmin = 0, xmax = 1.5, ymin = 0, ymax = 1.5), fill = NA) +
geom_rect(aes(xmin = 0, xmax = x_max, ymin = 0, ymax = 1.5), fill = NA) +
annotation_custom(g_img, xmin = -0.02, ymin = -0.15) +
trans_rect +
theme_void() + guides(alpha = FALSE) +
scale_alpha_continuous(range = c(0, alpha_max))
## print(gg)
print(gg)

sticker(gg, package="AnnotationFilter", p_size = 5.5, p_y = 1.25, s_x = 0.9,
s_y = 1.1, s_width = 0.9, s_height = 1.4, p_color = col_text,
sticker(gg, package="AnnotationFilter", p_size = 5.5, p_y = 1.25, s_x = 0.89,
s_y = 1.08, s_width = 1.04, s_height = 1.7, p_color = col_text,
h_fill = col_bg, h_color = col_border, filename="AnnotationFilter.png",
p_family = "Aller_Lt")

Expand Down

0 comments on commit 84532f4

Please sign in to comment.