cutterkom / generativeart

Create Generative Art with R
GNU General Public License v3.0
916 stars 163 forks source link

request pdf export #2

Closed dvdrbls closed 5 years ago

dvdrbls commented 5 years ago

Thank you for this awesome library, the images are so beautiful, is there an option to create pdfs instead of png files?

Thanks again, David

cutterkom commented 5 years ago

hey, thank you!

Yes, ggsave() let's you export an image as a pdf as well. See: https://ggplot2.tidyverse.org/reference/ggsave.html

In order to work with generativeart, add thedevice-paramter to the generate_plot() function like this: ggplot2::ggsave(plot, filename = paste0(IMG_PATH, file_name), width = 6, height = 6, device = "pdf")

Does this help?

Best, Katharina

dvdrbls commented 5 years ago

Thank you, I am a beginner and barely able to understand the code most of the time, it gives me an error, can you help? Thanks

`library(generativeart) library(ggplot2)

set the paths

IMG_DIR <- "img/" IMG_SUBDIR <- "everything/" IMG_SUBDIR2 <- "handpicked/" IMG_PATH <- paste0(IMG_DIR, IMG_SUBDIR)

LOGFILE_DIR <- "logfile/" LOGFILE <- "logfile.csv" LOGFILE_PATH <- paste0(LOGFILE_DIR, LOGFILE)

create the directory structure

generativeart::setup_directories(IMG_DIR, IMG_SUBDIR, IMG_SUBDIR2, LOGFILE_DIR)

include a specific formula, for example:

my_formula <- list( x = quote(runif(1, -6, 1) x_i^4 - sin(y_i^1)), y = quote(runif(1, -1, 1) y_i^1 - cos(x_i^4)) )

call the main function to create five images with a polar coordinate system

generativeart::generate_img(formula = my_formula, nr_of_img = 1, polar = FALSE) ggplot2::ggsave(plot, my_formula = paste0(IMG_PATH, file_name), width = 6, height = 6, device = "pdf")`

cutterkom commented 5 years ago

Hey, I updated the package and you can now choose the filtetype in the main function. The default is png, but you can choose a pdf like this: generativeart::generate_img(formula = my_formula, nr_of_img = 1, polar = FALSE, filetype="pdf")

Update/Reinstall the package and then it works

dvdrbls commented 5 years ago

Thank you! This is so great