Last active
April 29, 2019 23:09
-
-
Save tylermorganwall/847b5e2075f13d20ae5e33d98cb3daae 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(rayshader) | |
jpeg::readJPEG("meme_background.jpg") -> memebackground | |
par(mar = c(0,0,0,0)) | |
plot(c(0, 1), c(0, 1), ann = F, bty = 'n', type = 'n', xaxt = 'n', yaxt = 'n') | |
png(filename = "meme_text.png",width = dim(memebackground)[1],height=dim(memebackground)[2]) | |
plot.new() | |
text(x = 0.5, y = 0.5, paste("WHEN YOU\nDISCOVER\n\n\nR CAN\nMAKE MEMES"), | |
cex = 11, col = "black",font=2) | |
dev.off() | |
png::readPNG("meme_text.png") -> memetext | |
fff2 = fff[,,1] | |
fff2[!is.na(fff2)] = 1 | |
text1 = memetext[,,1:3] | |
textmap = text1[,,1] | |
textmap[!(textmap < 0.2)] = NA | |
textmap[!is.na(textmap)] = 50 | |
plot_3d(rayshader:::flipud(aperm(memebackground,c(2,1,3))), | |
rayshader:::fliplr(fff2),zscale=1,soliddepth = -100,shadow = TRUE, | |
shadowdepth = -200, | |
solidcolor = "black", windowsize = c(800,800),theta=90,background = "#ec63ff", shadowcolor = "#3f0847") | |
plot_3d(rayshader:::flipud(1-aperm(text1,c(2,1,3))), | |
rayshader:::fliplr(textmap),zscale=1,soliddepth = 1,shadow = FALSE, | |
shadowdepth = -10, | |
solidcolor = "black",windowsize = c(800,800),theta=90,background = "#ec63ff") | |
thetavec = 90+30 * sin(0:359/180*pi) | |
i=1 | |
for(i in 1:360) { | |
render_camera(fov=0,zoom=0.7,theta=thetavec[i],phi=60) | |
render_snapshot(glue::glue("3dmeme{i}")) | |
} | |
av::av_encode_video(glue::glue("3dmeme{1:360}.png"),framerate = 60, output = "meme.mp4") | |
system("rm 3dmeme*.png") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Awesome, thanks for sharing! I'm very new to this package; where did the
fff
object exactly come from in this code snippet?