Skip to content

Instantly share code, notes, and snippets.

@saurabhdhiman
Created October 23, 2021 04:08
Show Gist options
  • Save saurabhdhiman/b65a60046cf8e7edd40fd3de97d8f3fd to your computer and use it in GitHub Desktop.
Save saurabhdhiman/b65a60046cf8e7edd40fd3de97d8f3fd to your computer and use it in GitHub Desktop.
library(tidyverse)
library(paletteer)
gradient_attempt <- data.frame(level = seq(1,300,by=1),
size = seq(30,0.1, by =-0.1))
prmtns <- data.frame(x = seq(0,60,by=30),
y = seq(0,60,by=30))%>%
expand(x, y)
final = crossing(prmtns, gradient_attempt)
colorx = paletteer_c(`"pals::ocean.ice"`,40)
lets_do_it= function(size_limit, index)
{
ggx <- final %>%
filter(size >size_limit)%>%
ggplot(aes(fill=-size)) +
geom_tile(aes(x=x, y=y, width = size, height = size))+
scale_fill_gradientn(colors=colorx) +
coord_fixed()+
# coord_polar()+
theme_void()+
theme(legend.position="none")+
scale_x_continuous(expand = c(0, 0))+
scale_y_continuous(expand = c(0, 0))
# ggx
ggsave(paste0("thursday_",index,".png"), dpi = 320, height = 10, width = 10)
}
#static
lets_do_it(15,100)
#animation
ix =1
its = seq(30,1, by =-1)
for (x in as.list(its)){
lets_do_it(x,ix)
ix = ix+1
}
# ffmpeg -r 3 -i thursday_%d.png -crf 25 thursday_3fps.mp4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment