Created
May 20, 2018 04:05
-
-
Save eliocamp/4d7115ef341e71f1aa2684ca7b5bf178 to your computer and use it in GitHub Desktop.
This file contains 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(ggplot2) | |
url <- "https://ih0.redbubble.net/image.512523322.6908/flat,800x800,075,f.jpg" | |
file <- tempfile() | |
download.file(url, file) | |
im <- jpeg::readJPEG(file) | |
im <- apply(im, c(1, 2), sum) | |
im <- im/3 | |
ys <- nrow(im) | |
xs <- ncol(im) | |
dimnames(im) <- list(y = seq_len(nrow(im)), x = seq_len(ncol(im))) | |
im <- reshape2::melt(im) | |
s <- 10 | |
per <- 6 | |
a <- s/5 | |
fill <- "#D0DCF2" | |
im <- subset(im, y %in% seq(1, ys, by = s - 1)) | |
ggplot(im, aes(x)) + | |
geom_ribbon(aes(ymin = -y + a*cos(x/max(x)*2*pi*per) - value*s/2, | |
ymax = -y + a*cos(x/max(x)*2*pi*per) + value*s/2, | |
group = y), fill = fill) + | |
scale_x_continuous(expand = c(0, 0)) + | |
scale_y_continuous(expand = c(0, 0)) + | |
coord_equal() + | |
theme_void() + | |
theme(plot.background = element_rect(fill = "black")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment