Skip to content

Instantly share code, notes, and snippets.

@rosalieb
Forked from alistaire47/squircle.R
Created January 16, 2023 17:58
Show Gist options
  • Save rosalieb/30a13962e615f42c962ff2891a1db182 to your computer and use it in GitHub Desktop.
Save rosalieb/30a13962e615f42c962ff2891a1db182 to your computer and use it in GitHub Desktop.
squircles
library(tidyverse)
library(gganimate)
animate(
crossing(
p = seq(0.1, 5, by = 0.1),
theta = seq(0, 2*pi, length.out = 101)
) %>%
mutate(r = 1 / (abs(cos(theta))^p + abs(sin(theta))^p)^(1/p)) %>%
ggplot(aes(theta, r, fill = p)) +
geom_area(show.legend = FALSE) +
scale_fill_viridis_c(option = 'A') +
coord_polar() +
theme_void() +
transition_time(p),
rewind = TRUE,
nframes = 300,
fps = 100/3,
device = "svglite",
renderer = magick_renderer(),
width = 5, height = 5
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment