Unimaginable Images

Quin Kennedy


Based on: Unimaginable Images by Vera Molnar, 1978

Category: direct


Description:

This sketch is running in the browser.






/* 
Part of the ReCode Project (http://recodeproject.com)
Based on "Unimaginable Images" by Vera Molnar
Originally published in "Computer Graphics and Art" vol3 no2, 1978
Copyright (c) 2012 Quin Kennedy - OSI/MIT license (http://recodeproject/license).
*/

//(from the "196 Trapeziums Series")

static final int numTiles = 14;
static final float gutterRelativeSize = .5;
static final int windowSize = 400;
//we need space for each tile, 
//space for each gutter above each tile, 
//and space for the final gutter (below of the bottom row)
static final int tileSize = floor(windowSize/(numTiles*(1+gutterRelativeSize)+gutterRelativeSize));
static final int gutterSize = floor(tileSize*gutterRelativeSize);

void setup(){
  int actualWinSize = (tileSize+gutterSize)*numTiles+gutterSize;
  size(actualWinSize, actualWinSize);
  noLoop();
}

void draw(){
  background(255);
  stroke(0);
  //strokeWeight(2);
  strokeJoin(ROUND);
  noFill();
  //for each grid cell...
  for(int i = 0, gi = gutterSize; i < numTiles; i++, gi += gutterSize+tileSize){
    for(int j = 0, gj = gutterSize; j < numTiles; j++, gj += gutterSize+tileSize){
      drawTrapezium(gi+tileSize/2, gj+tileSize/2);
    }
  }
}

void drawTrapezium(float xCenter, float yCenter){
  float topScale = random(-2, 2);
  float bottomScale = random(-2, 2);
  float halfTile = tileSize/2.;
  quad(xCenter - tileSize/2 + random(-tileSize, tileSize), yCenter - halfTile,
        xCenter + tileSize/2 + random(-tileSize, tileSize), yCenter - halfTile,
        xCenter + tileSize/2 + random(-tileSize, tileSize), yCenter + halfTile,
        xCenter - tileSize/2 + random(-tileSize, tileSize), yCenter + halfTile);
}