class: center, middle, inverse, title-slide # Art + #rstats ### Sharla Gelfand ### Toronto Data Workshop --- class: middle, center # 👋 ## [@sharlagelfand](https://twitter.com/sharlagelfand) ## [bit.ly/artstats](https://bit.ly/artstats) --- class: center, middle, inverse # why aRt? --- background-image: url("brain.jpg") --- background-image: url("brain-no.jpg") --- class: center, middle ### You can do both ### Digital art is fast, iterative, surprising ### Less "I suck at this" beginner hurdles ### Less startup cost ### I ❤️ R --- class: inverse, middle, center # Pixel Art ### A form of digital art where images are edited at the pixel level. ### Think 8-bit video games aesthetics. --- class: middle .left-lil[ <img src="art/katie-segreti-ghost.jpg" width="667" style="display: block; margin: auto;" /> [Katie Segretti](https://twitter.com/katiesegreti) (via [@WeAreRLadies](https://twitter.com/WeAreRLadies/status/1291359584179957762)) ] .right-big[ <img src="art/coolbutuseless-arcade.png" width="1792" style="display: block; margin: auto;" /> [@coolbutuseless](https://coolbutuseless.github.io/2020/05/04/introducing-arcadefont-an-oldschool-arcade-vector-font-happy-star-wars-day/) ] --- .left-sixtyfive[ ```r library(ggplot2) library(dplyr) smile <- expand.grid(x = 1:8, y = 1:8) %>% filter(!(x %in% c(1, max(x)) & y %in% c(1, max(y)))) %>% filter(!(x %in% c(2, max(x) - 1) & y %in% c(1, max(y)))) %>% filter(!(x %in% c(1, max(x)) & y %in% c(2, max(y) - 1))) ggplot() + geom_tile( data = smile, aes(x = x, y = y), width = 1, height = 1, size = 1, fill = "yellow", colour = "black" ) + coord_equal() + theme_void() ``` ] -- .right-thirtyfive[ <img src="index_files/figure-html/smile-1-1.png" width="672" style="display: block; margin: auto;" /> ] --- .left-sixtyfive[ ```r library(ggplot2) library(dplyr) smile <- expand.grid(x = 1:8, y = 1:8) %>% filter(!(x %in% c(1, max(x)) & y %in% c(1, max(y)))) %>% filter(!(x %in% c(2, max(x) - 1) & y %in% c(1, max(y)))) %>% filter(!(x %in% c(1, max(x)) & y %in% c(2, max(y) - 1))) *eyes <- data.frame(x = c(3, 6), y = c(6, 6)) ggplot() + geom_tile( data = smile, aes(x = x, y = y), width = 1, height = 1, size = 1, fill = "yellow", colour = "black" ) + * geom_tile( * data = eyes, aes(x = x, y = y), width = 1, height = 1, * fill = "black", colour = "black" * ) + coord_equal() + theme_void() ``` ] .right-thirtyfive[ <img src="index_files/figure-html/smile-2-1.png" width="672" style="display: block; margin: auto;" /> ] --- .left-sixtyfive[ ```r library(ggplot2) library(dplyr) smile <- expand.grid(x = 1:8, y = 1:8) %>% filter(!(x %in% c(1, max(x)) & y %in% c(1, max(y)))) %>% filter(!(x %in% c(2, max(x) - 1) & y %in% c(1, max(y)))) %>% filter(!(x %in% c(1, max(x)) & y %in% c(2, max(y) - 1))) eyes <- data.frame(x = c(3, 6), y = c(6, 6)) *mouth <- data.frame(x = 3:6, y = c(3, 2, 2, 3)) ggplot() + geom_tile( data = smile, aes(x = x, y = y), width = 1, height = 1, size = 1, fill = "yellow", colour = "black" ) + geom_tile( data = eyes, aes(x = x, y = y), width = 1, height = 1, fill = "black", colour = "black" ) + * geom_tile( * data = mouth, aes(x = x, y = y), width = 1, height = 1, * fill = "black", colour = "black" * ) + coord_equal() + theme_void() ``` <img src="index_files/figure-html/smile-3-1.png" style="display: block; margin: auto;" /> ] .right-thirtyfive[ <img src="index_files/figure-html/smile-3-1.png" width="672" style="display: block; margin: auto;" /> ] --- class: center, inverse, middle # Rendering ### Recreating an image (realistic or not) from a 2D or 3D model, via a computer program. --- class: middle <img src="index_files/figure-html/unnamed-chunk-6-1.png" style="display: block; margin: auto;" /> [Sharla Gelfand](https://github.com/sharlagelfand/ggkeyboard) --- class: middle <img src="art/sarah-l-fossheim-switch.png" width="80%" style="display: block; margin: auto;" /> [Sarah L. Fossheim (CSS)](https://twitter.com/liatrisbian/status/1287475889089982469) --- class: middle .pull-left[ <img src="art/tyler-morgan-wall-elmat.png" width="922" style="display: block; margin: auto;" /> ] .pull-right[ <img src="art/tyler-morgan-wall-ggplot-glass.png" width="922" style="display: block; margin: auto;" /> ] [Tyler Morgan-Wall](https://www.tylermw.com/) --- .left-biggish[ ```r library(rayrender) generate_ground( material = diffuse(color = "#dd99ba") ) %>% render_scene() ``` ] -- .right-lillish[ <img src="index_files/figure-html/rayrender-1-1.png" width="672" style="display: block; margin: auto;" /> ## [`rayrender` package](https://www.rayrender.net/) ] --- .left-biggish[ ```r library(rayrender) generate_ground( material = diffuse(color = "#dd99ba") ) %>% * add_object(sphere( * material = diffuse(color = "#99badd") * )) %>% render_scene() ``` ] .right-lillish[ <img src="index_files/figure-html/rayrender-2-1.png" width="672" style="display: block; margin: auto;" /> ## [`rayrender` package](https://www.rayrender.net/) ] --- .left-biggish[ ```r library(rayrender) generate_ground( material = diffuse(color = "#dd99ba") ) %>% add_object(sphere( material = diffuse(color = "#99badd") )) %>% * add_object(sphere( * x = 2, radius = 0.5, * material = dielectric(color = "#badd99") * )) %>% render_scene( ) ``` ] .right-lillish[ <img src="index_files/figure-html/rayrender-3-1.png" width="672" style="display: block; margin: auto;" /> ## [`rayrender` package](https://www.rayrender.net/) ] --- .left-biggish[ ```r library(rayrender) generate_ground( material = diffuse(color = "#dd99ba") ) %>% add_object(sphere( material = diffuse(color = "#99badd") )) %>% add_object(sphere( x = 2, radius = 0.5, material = dielectric(color = "#badd99" )) %>% render_scene( * fov = 40 ) ``` ] .right-lillish[ <img src="index_files/figure-html/rayrender-4-1.png" width="672" style="display: block; margin: auto;" /> ## [`rayrender` package](https://www.rayrender.net/) ] --- .left-biggish[ ```r library(rayrender) generate_ground( material = diffuse(color = "#dd99ba") ) %>% add_object(sphere( material = diffuse(color = "#99badd") )) %>% add_object(sphere( x = 2, radius = 0.5, material = dielectric(color = "#badd99") )) %>% * add_object(cube( * x = -2, z = -1, width = 1, * material = metal(color = "#99ddba") * )) %>% render_scene( fov = 40 ) ``` ] .right-lillish[ <img src="index_files/figure-html/rayrender-5-1.png" width="672" style="display: block; margin: auto;" /> ## [`rayrender` package](https://www.rayrender.net/) ] --- .left-biggish[ ```r library(rayrender) generate_ground( material = diffuse(color = "#dd99ba") ) %>% add_object(sphere( material = diffuse(color = "#99badd") )) %>% add_object(sphere( x = 2, radius = 0.5, material = dielectric(color = "#badd99") )) %>% add_object(cube( x = -2, z = -1, width = 1, material = metal(color = "#99ddba") )) %>% * add_object(pig( * y = 1, z = 1, * scale = 0.4, angle = c(0, -60, 0) * )) %>% render_scene( fov = 40 ) ``` ] .right-lillish[ <img src="index_files/figure-html/rayrender-6-1.png" width="672" style="display: block; margin: auto;" /> ## [`rayrender` package](https://www.rayrender.net/) ] --- .left-biggish[ ```r library(rayrender) generate_ground( material = diffuse(color = "#dd99ba") ) %>% add_object(sphere( material = diffuse(color = "#99badd") )) %>% add_object(sphere( x = 2, radius = 0.5, material = dielectric(color = "#badd99") )) %>% add_object(cube( x = -2, z = -1, width = 1, material = metal(color = "#99ddba") )) %>% add_object(pig( y = 1, z = 1, scale = 0.4, angle = c(0, -60, 0) )) %>% render_scene( fov = 40, * lookfrom = c(-1, 4, 0) ) ``` ] .right-lillish[ <img src="index_files/figure-html/rayrender-7-1.png" width="672" style="display: block; margin: auto;" /> ## [`rayrender` package](https://www.rayrender.net/) ] --- class: inverse, middle, center # Generative art ### "Generative art is art programmed using a computer that intentionally introduces randomness as part of its creation process." ### - [Why Love Generative Art?](https://www.artnome.com/news/2018/8/8/why-love-generative-art) --- class: middle .pull-left[ <img src="art/danielle-navarro-lost.png" width="100%" style="display: block; margin: auto;" /> [Danielle Navarro](https://art.djnavarro.net) ] .pull-right[ <img src="art/danielle-navarro-pop-art.png" width="1333" style="display: block; margin: auto;" /> ] --- # Generative art The environment is constrained, but decisions are made randomly, rather than by the artist. .pull-left[ ```r library(ggplot2) library(ggforce) n <- 5 ggplot() + geom_circle(aes( x0 = rnorm(n), y0 = rnorm(n), r = runif(n) )) + theme_void() ``` ] .pull-right[ <img src="index_files/figure-html/circle-1-1.png" width="80%" style="display: block; margin: auto;" /> ] --- # Generative art Additional complexity doesn't mean additional time or effort. .pull-left[ ```r library(ggplot2) library(ggforce) *n <- 100 ggplot() + geom_circle(aes( x0 = rnorm(n), y0 = rnorm(n), r = runif(n) )) + theme_void() ``` ] .pull-right[ <img src="index_files/figure-html/circle-2-1.png" width="80%" style="display: block; margin: auto;" /> ] --- # [`generativeart`](https://github.com/cutterkom/generativeart) package .left-biggish[ ```r library(generativeart) formula <- list( x = quote(rnorm(5) * x_i - cos(y_i^2)), y = quote(rnorm(5) * y_i^2 + sin(x_i)) ) generate_img( formula = formula, polar = FALSE, nr_of_img = 1 ) ``` ] -- .right-lillish[ <img src="img/everything/2020-08-05-19-13_seed_8300.png" width="2400" style="display: block; margin: auto;" /> ] --- # [`generativeart`](https://github.com/cutterkom/generativeart) package .left-biggish[ ```r library(generativeart) formula <- list( x = quote(rnorm(5) * x_i - cos(y_i^2)), y = quote(rnorm(5) * y_i^2 + sin(x_i)) ) generate_img( formula = formula, * polar = TRUE, * nr_of_img = 2 ) ``` Seed: 2917 ] .right-lillish[ <img src="img/everything/2020-08-05-19-15_seed_2917.png" width="2400" style="display: block; margin: auto;" /> ] --- # [`generativeart`](https://github.com/cutterkom/generativeart) package .left-biggish[ ```r library(generativeart) formula <- list( x = quote(rnorm(5) * x_i - cos(y_i^2)), y = quote(rnorm(5) * y_i^2 + sin(x_i)) ) generate_img( formula = formula, * polar = TRUE, * nr_of_img = 2 ) ``` Seed: 3553 ] .right-lillish[ <img src="img/everything/2020-08-05-19-15_seed_3553.png" width="2400" style="display: block; margin: auto;" /> ] --- # [`generativeart`](https://github.com/cutterkom/generativeart) package .left-biggish[ ```r library(generativeart) formula <- list( * x = quote(runif(5) * x_i - cos(y_i^2)), y = quote(rnorm(5) * y_i^2 + sin(x_i)) ) generate_img( formula = formula, polar = TRUE, nr_of_img = 1, * color = "red" ) ``` ] .right-lillish[ <img src="img/everything/2020-08-05-19-24_seed_1351.png" width="2400" style="display: block; margin: auto;" /> ] --- # [`flametree` package](https://github.com/djnavarro/flametree/) .left-biggish[ ```r library(flametree) flametree_grow( seed = 1234, time = 1, split = 2 ) %>% flametree_plot() ``` ] .right-lillish[ <img src="index_files/figure-html/flametree-1-1.png" width="672" style="display: block; margin: auto;" /> ] --- # [`flametree` package](https://github.com/djnavarro/flametree/) .left-biggish[ ```r library(flametree) flametree_grow( seed = 1234, * time = 2, split = 2 ) %>% flametree_plot() ``` ] .right-lillish[ <img src="index_files/figure-html/flametree-2-1.png" width="672" style="display: block; margin: auto;" /> ] --- # [`flametree` package](https://github.com/djnavarro/flametree/) .left-biggish[ ```r library(flametree) flametree_grow( seed = 1234, time = 2, * split = 4 ) %>% flametree_plot() ``` ] .right-lillish[ <img src="index_files/figure-html/flametree-3-1.png" width="672" style="display: block; margin: auto;" /> ] --- # [`flametree` package](https://github.com/djnavarro/flametree/) .left-biggish[ ```r library(flametree) flametree_grow( seed = 1234, * time = 5, split = 4 ) %>% flametree_plot( * background = "pink", * palette = "ggthemes::Classic Red-Green Light" ) ``` ] .right-lillish[ <img src="index_files/figure-html/flametree-4-1.png" width="672" style="display: block; margin: auto;" /> ] --- .left-big[ <img src="art/thomas-lin-pedersen.png" width="100%" style="display: block; margin: auto;" /> ] .right-lil[ <center><h4><br><br><br><br> "For me, the sweet spot of generative art lies in creating a system that you know well enough to set it up for success, but is so complex that you still get surprised when you see the result." </h4> </center> ] [Thomas Lin Pedersen](https://www.data-imaginist.com/art) --- class: middle, center # And more! --- <img src="art/cedric-scherer-coffee.png" width="75%" style="display: block; margin: auto;" /> [Cédric Scherer](https://twitter.com/CedScherer/status/1281475431707877377) --- <img src="art/ryan-timpe-warhol.png" width="50%" style="display: block; margin: auto;" /> [Ryan Timpe](https://twitter.com/ryantimpe/status/1280241868123627521) --- <img src="art/allison-horst-rmarkdown.png" width="66%" style="display: block; margin: auto;" /> [Allison Horst](https://github.com/allisonhorst/stats-illustrations) --- <img src="art/allison-horst-dplyr.png" width="66%" style="display: block; margin: auto;" /> [Allison Horst](https://github.com/allisonhorst/stats-illustrations) --- .left-sixtyfive[ ## ty! [@sharlagelfand](https://twitter.com/sharlagelfand) [bit.ly/artstats](https://bit.ly/artstats) ## more links: [`rayshader`: Create Maps and Visualize Data in 2D and 3D](https://www.rayshader.com/) [`ambient`: A Generator of Multidimensional Noise](https://ambient.data-imaginist.com) [12 Months of aRt (Will Chase)](https://www.williamrchase.com/work/art/) [Fronkonstin (Antonio Sánchez Chinchón)](https://fronkonstin.com/) [Experiments in Generative Art with RStats (Sanjeev Kumar)](https://www.aamlai.com/2020/05/27/experiments-in-generative-art-with-rstats/) ] .right-thirtyfive[ <img src="is-this-art.png" width="1440" style="display: block; margin: auto;" /> ]