Code Monkey home page Code Monkey logo

generativeart's Introduction

generativeart

Announcement

This package collects more and more stars here on Github and is widely used for NFTs. Just browse on NFT platforms - it won't take you long to discover patterns be that might be decandents of this repository.

I would like to clarify: I am not a fan of Blockchain, NFT and Web3.

Why? Read this text: "The Third Web" by @tante.


Create Generative Art with R.

More on Instagram

Description

One overly simple but useful definition is that generative art is art programmed using a computer that intentionally introduces randomness as part of its creation process. -- Why Love Generative Art? - Artnome

The R package generativeart let's you create images based on many thousand points. The position of every single point is calculated by a formula, which has random parameters. Because of the random numbers, every image looks different.

In order to make an image reproducible, generative art implements a log file that saves the file_name, the seed and the formula.

Install

You can install the package with the devtools package directly from Github:

devtools::install_github("cutterkom/generativeart")

generativeart uses the packages ggplot2, magrittr, purrr and dplyr.

Usage

The package works with a specific directory structure that fits my needs best. The first step is to create it with setup_directories(). All images are saved by default in img/everything/. I use img/handpicked/ to choose the best ones. In logfile/ you will find a csv file that saves the file_name, the seed and the used formula.

library(generativeart)

# 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, -1, 1) * x_i^2 - sin(y_i^2)),
  y = quote(runif(1, -1, 1) * y_i^3 - cos(x_i^2))
)

# call the main function to create five images with a polar coordinate system
generativeart::generate_img(formula = my_formula, nr_of_img = 5, polar = TRUE, filetype = "png", color = "black", background_color = "white")
  • You can create as many images as you want by setting nr_of_img.
  • For every image a seed is drawn from a number between 1 and 10000.
  • This seed determines the random numbers in the formula.
  • You can choose between cartesian and polar coordinate systems by setting polar = TRUE or polar = FALSE
  • You can choose the colors with color = 'black' and background_color = 'hotpink'
  • You can save the output image in various formats. Default is png, the alternatives are defined by the device options of ggplot::ggsave().
  • the formula is a list()

Examples

It is a good idea to use the sine and cosine in the formula, since it guarantees nice shapes, especially when combined with a polar coordinate system. One simple example:

my_formula <- list(
  x = quote(runif(1, -1, 1) * x_i^2 - sin(y_i^2)),
  y = quote(runif(1, -1, 1) * y_i^3 - cos(x_i^2))
)

generativeart::generate_img(formula = my_formula, nr_of_img = 5, polar = TRUE, color = "black", background_color = "white")

Two possible images:

seed = 1821, polar = TRUE:

seed = 5451, polar = FALSE:

The corresponding log file looks like that:

file_name seed formula_x formula_y
2018-11-16-17-13_seed_1821.png 1821 runif(1, -1, 1) * x_i^2 - sin(y_i^2) runif(1, -1, 1) * y_i^3 - cos(x_i^2)
2018-11-16-17-12_seed_5451.png 5451 runif(1, -1, 1) * x_i^2 - sin(y_i^2) runif(1, -1, 1) * y_i^3 - cos(x_i^2)

Inspiration

The basic concept is heavily inspired by Fronkonstin's great blog.

generativeart's People

Contributors

cutterkom avatar martinmspedersen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

generativeart's Issues

background color?

I've tried several tricks and can't seem to change background color. Suggestions?

Release

Hi, I'm trying to get this package onto conda forge. Can a release on Github be made to facilitate that?

I'm not install

Hi

I can't install the repositorie. I have installed the packages ggplot2, magrittr, purrr and dplyr. Then execute devtools::install_github("cutterkom/generativeart") and the next error is printed by terminal.

Installing package into ‘C:/Users/.../Documents/R/win-library/3.6’
(as ‘lib’ is unspecified)

  • installing source package 'generativeart' ...
    ** using staged installation
    ** R
    ** byte-compile and prepare package for lazy loading
    Error: (convertido del aviso) package 'magrittr' was built under R version 3.6.3
    Ejecución interrumpida
    ERROR: lazy loading failed for package 'generativeart'
  • removing 'C:/Users/FRIKIS/Documents/R/win-library/3.6/generativeart'
    Error: Failed to install 'generativeart' from GitHub:
    (converted from warning) installation of package

Thanks for your response

Generate_img call always fails with "Error in read.table"

Hello

I'm trying to run the example as documented in the "Usage" section in the readme. However there's an issue that I haven't been able to solve. Whenever I try to run the generativeart::generate_img(), I get the following error:

Error in read.table(file = file, header = header, sep = sep, quote = quote,  : 
  no lines available in input

I'm guessing when generate_img is called, then at some point in the belly of the beast generativeart::generate_data(my_formula) is called, which would populate the table which will be read later on, but looks like in my case this did not happen. Any ideas what might be causing this?

I've double checked all the preconditions (all required packages installed, directory setup done, typos triple checked).
Screenshot 2022-01-13 at 14 45 11

Licence for generated images

Dear all,

We are using the generativeart code to design the cover of an academic open access journal.
We found the licence for the code. But what about the images themselves? Can they be published with the same licence or, rather, a corresponding CC licence?

Best,
Frédéric Clavert

request pdf export

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

gganimate object taking too much time to render

I am trying to render an animation from the plot.

generativeart::generate_data(my_formula) is giving me around 400,000 entries. The large gganimate object that is created is 12.5 MB in size. Does is take a lot of time to render?

I have no idea since I am using gganimate for the first time.

image not appearing

image

once the main function is called the error displayed about a coordinate system is shown then proceeds to corrupt the CSV file and leave nothing in the img directory

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.