Skip to content

Instantly share code, notes, and snippets.

@emitanaka
Created April 19, 2019 12:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save emitanaka/6c654431a953e0ccde6fa0bdcc3ea608 to your computer and use it in GitHub Desktop.
Save emitanaka/6c654431a953e0ccde6fa0bdcc3ea608 to your computer and use it in GitHub Desktop.
IBS Logo Animation
library(gganimate)
library(tidyverse)
IBSlogo <- tribble(
~Row, ~Col, ~Fill, ~Text,
3, 1, "white", "I",
3, 2, "#7fb8ff", "",
3, 3, "#0170fe", "",
2, 1, "#0170fe", "",
2, 2, "white", "B",
2, 3, "#7fb8ff", "",
1, 1, "#7fb8ff", "",
1, 2, "#0170fe", "",
1, 3, "white", "S")
getIBSlogowFrame <- function(frame, shuffle=TRUE) {
if(shuffle) {
IBSlogo %>%
mutate(Fill=sample(Fill),
Frame=frame)
} else {
IBSlogo %>%
mutate(Frame=frame)
}
}
set.seed(1)
df <- map2(1:10, c(rep(TRUE, 7), rep(FALSE, 3)),
getIBSlogowFrame) %>%
plyr::ldply()
anim <- ggplot(df, aes(Col, Row)) +
geom_tile(aes(fill=I(Fill)), color="black",
width=0.98, height=0.98) +
geom_text(aes(label=Text), size=20,
family = "Times New Roman",
fontface="bold") +
theme_void() +
coord_equal() +
transition_states(Frame,
transition_length=1,
state_length=1)
animate(anim, width=300, height=300)
anim_save("IBSlogo.gif")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment