Created
January 26, 2019 03:57
-
-
Save chichacha/32cad9d050cc66c9df83e553138528d3 to your computer and use it in GitHub Desktop.
Yarns and Circle
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) | |
df <- tibble( | |
t = seq(0,2*pi,length.out=1000), | |
x = cos(t), | |
y = sin(t) | |
) %>% mutate(idx = row_number(sample(t))) %>% | |
arrange(idx) | |
draw_yarn <- function(n=100){ | |
df %>% | |
ggplot(aes(x=x,y=y, color=t)) + | |
geom_point(size=0.1) + | |
geom_path(data= . %>% sample_n(size=n), size=0.5, alpha=0.75, lineend="round") + | |
theme_void() + | |
coord_fixed() + | |
scale_color_gradientn(guide="none", | |
colors=ggthemes::tableau_color_pal("Hue Circle")(19)) + | |
theme(panel.background=element_rect(fill="#000000")) + | |
geom_blank(aes(x=c(-2,2),y=c(-1.4,1.4), colour=NULL), data=data.frame()) | |
} | |
draw_yarn(500) | |
ggsave(file="yarn_500.png", width=20, height=16, type="cairo") | |
fig <-image_graph(width=800, height=600) | |
rep(500,10) %>% | |
map(.,draw_yarn) | |
dev.off() | |
image_animate(fig, fps=5) %>% image_write("circle_texturing_experiment_dark.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