mardi 13 octobre 2020

Reproducing "Computer composition with lines" in R

Folks,

I am trying to reproduce a famous computer art work, "Computer Composition with Lines", by A. Michael Noll, in R using ggplot.

Here is the original: https://collections.vam.ac.uk/item/O1193787/computer-composition-with-lines-photograph-noll-a-michael/

I made it to the point where I can create a circle of randomly black or white pixels, but I have a hard time in creating patterns similar to the ones used by Noll.

I can easily create a matrix of ones and zeroes, then cut away the parts that are out of a circle. But the pattern (I tried uniform, beta, normal...) is definitely too similar to white noise, while there is a structure in the randomness of the original work.

library(tidyverse)

# this generates the matrix
genData <- function(N) {

  # a N*N matrix of ones and zero according to a rounded beta draw
  df <- tibble(x = rep(seq(1,N), N),
         y = rep(seq(1,N), each = N),
         z = round(rbeta(N*N, 2, 1)))

  # centering on zero and cutting away all points outside of a circle
  df %>% 
    mutate(x = x-(N/2 + 1), y = y-(N/2 + 1)) %>% 
    filter(x^2 + y^2 < (N/2)^2)
}

#this plots the data
plotData <- function(df, color = "black"){
  df %>% 
    ggplot(aes(x,y, fill = as.factor(z)))+
    geom_tile()+
    scale_fill_manual(values = c(color, "white"))+
    coord_equal()+
    theme_void()+
    theme(legend.position = "none")
}

#executing
genData(100) %>% 
  plotData()

Which results in:

enter image description here

I suppose the question boils down to which random process can I use here? I did not find any lead online.




Aucun commentaire:

Enregistrer un commentaire