Created
January 26, 2019 01:35
-
-
Save chichacha/efe42d6314895dd854ea3d11e66cdcd8 to your computer and use it in GitHub Desktop.
Going crazy with sprial
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(tidyverse) | |
spiral_draw <- function(a=1,b=1,c=2,d=1,e=1,n=365,sn=18){ | |
df <-spiral_df <- tibble( | |
t = seq(0,sn*pi, length.out=n+1) | |
) %>% | |
mutate(r = a + b*t^(1/c), | |
x = r * cos(t*d), | |
y = r * sin(t*e)) | |
df %>% | |
ggplot(aes(x=x,y=y)) + | |
geom_point(aes(color=t), alpha=0.5, size=1) + | |
geom_path(size=0.3, aes(color=t)) + | |
coord_fixed() + | |
theme_void() + | |
scale_color_viridis_c(guide="none", option="magma") | |
} | |
spiral_draw() | |
params <- tibble( | |
a = seq(0,2*pi,length.out=20), | |
b = 1, | |
c = 2, | |
d = 1, | |
e = 1, | |
n=1000, | |
sn=c(seq(100,500,length.out=10),seq(500,100,length.out=10)) | |
) | |
library(magick) | |
fig <-image_graph(width=800, height=600) | |
params %>% pmap(.,spiral_draw) | |
dev.off() | |
image_animate(fig, fps=5) %>% image_write("spiral_experiment.gif") |
Author
chichacha
commented
Jan 26, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment