Created
May 3, 2020 03:13
-
-
Save djnavarro/12515175d2a32b4a4842aadfbeb11e71 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(flametree) # https://github.com/djnavarro/flametree | |
library(scopes) # https://github.com/djnavarro/scopes | |
library(ggforce) | |
library(ggplot2) | |
library(dplyr) | |
library(ambient) | |
# settings | |
pixels <- 1000 | |
fname <- "~/Desktop/scopetree.png" | |
gen <- 10 | |
# create the scopes data for the background | |
background <- scope_grid( | |
grain = pixels, | |
border = scope_circle(x = .7, y = .4, r = .2), | |
outer = scope_texture(value = "distance2"), | |
inner = scope_texture( | |
frequency = 20, octaves = 10, value = "distance2" | |
) | |
) | |
# create the flametree data for the foreground | |
foreground <- flametree_grow(time = gen) %>% | |
mutate( | |
x = normalise(coord_x), | |
y = normalise(coord_y) | |
) | |
# draw both together on the plot | |
picture <- ggplot() + | |
geom_raster( | |
data = background, | |
mapping = aes(x, y, fill = color), | |
inherit.aes = FALSE, | |
show.legend = FALSE | |
) + | |
geom_bezier2( | |
data = foreground, | |
mapping = aes(x, y, group = id_path), | |
show.legend = FALSE, | |
lineend = "round", | |
color = "black", | |
size = 1.5 | |
) + | |
geom_point( | |
data = foreground %>% filter(id_time > gen & id_step == 2), | |
mapping = aes(x, y, colour = seg_col), | |
size = 8, | |
alpha = .5, | |
show.legend = FALSE | |
) + | |
scale_x_continuous(expand = c(0,0)) + | |
scale_y_continuous(expand = c(0,0)) + | |
scale_fill_identity() + | |
scale_color_viridis_c(option = "magma") + | |
theme_void() + | |
coord_fixed() | |
# save it as an image | |
ggsave( | |
filename = fname, | |
plot = picture, | |
width = pixels/300, | |
height = pixels/300, | |
dpi = 300 | |
) | |
Author
djnavarro
commented
May 3, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment