Created
October 1, 2020 13:14
-
-
Save yutannihilation/485b5746ae18c02fa04a72d625039f07 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(string2path) | |
d <- string2path("ABCDE", "/usr/share/fonts/TTF/iosevka-extrabold.ttf") | |
colnames(d) <- c("x", "y", "group") | |
d$subgroup <- 1 | |
library(triangular) | |
library(ggplot2) | |
plot_frame <- function(i) { | |
x <- d %>% | |
group_by(group) %>% | |
mutate( | |
fixed = group %% 3 < 2 | row_number() == 1 | |
) %>% | |
ungroup() %>% | |
mutate( | |
x = if_else(fixed, x, x + i^0.3 * sin(i / 190) * sin((y - 4 + i / 22)) * (x - y)), | |
y = if_else(fixed, y, y + (i + x)^0.3 * sin(i / 147) * sin((x - 9 + i / 100))) + (y - 3.2)^2 * cos(i / 234) / 20, | |
) %>% | |
decompose() | |
ggplot(x) + | |
geom_polygon(aes(x, y, group = as.factor(idx))) + | |
theme_bw() + | |
coord_equal(xlim = c(-5, 25), ylim = c(-3, 10)) | |
} | |
gifski::save_gif( | |
for (i in 0:120) { | |
message(i) | |
print(plot_frame(i)) | |
}, | |
delay = 0.05 | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment