Created
February 9, 2021 22:14
-
-
Save djnavarro/a90265b0eed8dae9bad7052e7e3183d9 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
perlin_circle <- function( | |
cx = 0, cy = 0, n = 100, noise_max = 0.5, octaves = 2, r_min = 0.5, r_max = 1 | |
) { | |
tibble::tibble( | |
angle = seq(0, 2*pi, length.out = n), | |
xoff = scales::rescale(x = cos(angle), from = c(-1, 1), to = c(0, noise_max)), | |
yoff = scales::rescale(x = sin(angle), from = c(-1, 1), to = c(0, noise_max)), | |
r = scales::rescale( | |
x = ambient::fracture( | |
noise = ambient::gen_simplex, | |
fractal = ambient::fbm, | |
x = xoff, | |
y = yoff, | |
octaves = octaves | |
), | |
from = c(-0.5, 0.5), | |
to = c(r_min, r_max) | |
), | |
x = r * cos(angle) + cx, | |
y = r * sin(angle) + cy | |
) | |
} | |
pic <- ggplot2::ggplot( | |
data = perlin_circle(), | |
mapping = ggplot2::aes(x = x, y = y) | |
) + | |
ggplot2::geom_path() + | |
ggplot2::coord_equal() | |
plot(pic) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
credit for the core idea goes to @will-r-chase