• Stars
    star
    855
  • Rank 53,320 (Top 2 %)
  • Language
    R
  • License
    GNU General Publi...
  • Created about 6 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Create Generative Art with R

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.

More Repositories

1

destatiscleanr

Imports and cleans data from official German statistical offices to jump-start the data analysis
R
48
star
2

storyteller

A WordPress theme for multimedia storytelling
PHP
18
star
3

remove-na-lgbtiq-queer-knowledge-graph

A knowledge graph on queer history
R
12
star
4

r-shiny-realtime-streaming-data

This is a template for streaming real time data into an R-Shiny webapp. It includes working examples for ggplot, plotly and scatterD3.
R
9
star
5

generativeart-crochet-patterns

This code combines Crochets patterns from @aschinchon with the R-package generativeart.
R
9
star
6

generativeart-circle-lines

R
6
star
7

germanpolls

Scrape German polling data from Wahlrecht.de.
R
5
star
8

convert-csv-to-ics-in-R

Convert a csv-file to an ics-file in R that can be imported in many calendars using webDAV
R
5
star
9

parlamentsspiegel-scraper

A scraper for Parlamentsspiegel, a collection of the federal German parliamentary documentation.
Python
5
star
10

scraper-us-gun-violence-archive

Scraper for US mass shootings
R
3
star
11

destatiscleanr-app

Imports and cleans data from official German statistical offices to jump-start the data analysis. Web version of the R package destatiscleanr
R
3
star
12

gutenberg-corpus

Scrapy Spider for Projekt Gutenberg
Python
2
star
13

country-boundaries-worldwide

Data that answers the question: How long is the border a country shares with its neighbor country?
2
star
14

url-sharing-wordpress-plugin

The URL Sharing Plugin adds a text field with the post URL at the end of your posts โ€“ a qz.com like sharing approach.
JavaScript
2
star
15

kabrutils

Misc personal utility functions
R
1
star
16

datablog

HTML
1
star
17

ansible-playbooks

Some playbooks, mostly R
1
star
18

cutterkom

1
star
19

Deutschlandkarte-Lokalblogger

A map of German blogs with Dยง
1
star
20

tutorials

A collection of tutorials
1
star
21

karte-kommunalwahlen

Karten Kommunalwahlen Hogn.de
1
star
22

r-snippets

R
1
star
23

regensburg-geojson

1
star
24

wikidata-lgbtiq-queries

A collection of SPAQRL queries on LGBTIQ* topics in Wikidata
1
star
25

Geocoding-Karte-Kommunwahlen

1
star
26

2017-btwergebnisse

R
1
star
27

Bootstrap-WordPress-Starter-Kit

A WordPress-Theme based on Bootstrap to get started with rapid protoyping or theme development.
CSS
1
star