/ p5 / re-code 18

var tiles = [7];
var windowSize = 780;
var tileSize = windowSize/15;

function setup(){
 createCanvas(windowSize,windowSize);
 createTiles();
 noLoop();

}

function draw(){
 background(255);
 imageMode(CENTER);
 for(var i = 0; i < width; i+=tileSize){
 for(var j = 0; j < height; j+=tileSize){
 var tile = floor(random(tiles.length));
 //boolean bw = (random(2) >= 1);
 var rotation = floor(random(4));
 push();
 translate(i,j);
 translate(tileSize/2, tileSize/2);
 rotate(PI*rotation/2);
 image(tiles[tile], 0, 0);
 pop();
 }
 }
}

function createTiles(){
 var i = 0;
 pg = createGraphics(tileSize, tileSize);
 pg.background(0);
 pg.noStroke();
 pg.fill(255);
 pg.ellipse(0, 0, tileSize*2, tileSize*2);
 tiles[i++] = pg;
 
 pg1 = createGraphics(tileSize, tileSize);
 pg1.background(255);
 pg1.noStroke();
 pg1.fill(0);
 pg1.ellipse(0, 0, tileSize*2, tileSize*2);
 tiles[i++] = pg1;
 
 pg2 = createGraphics(tileSize, tileSize);
 pg2.background(0);
 pg2.noStroke();
 pg2.fill(255);
 pg2.rect(0, 0, tileSize, tileSize/2);
 tiles[i++] = pg2;
 
 pg3 = createGraphics(tileSize, tileSize);
 pg3.background(255);
 pg3.noStroke();
 pg3.fill(0);
 pg3.rect(0, 0, tileSize, tileSize/2);
 tiles[i++] = pg3;
 
 pg4 = createGraphics(tileSize, tileSize);
 pg4.background(0);
 pg4.noStroke();
 pg4.fill(255);
 pg4.triangle(0, 0, tileSize, 0, 0, tileSize);
 tiles[i++] = pg4;
 
 pg5 = createGraphics(tileSize, tileSize);
 pg5.background(255);
 pg5.noStroke();
 pg5.fill(0);
 pg5.triangle(0, 0, tileSize, 0, 0, tileSize);
 tiles[i++] = pg5;
 
 //might happen less often than others...
 pg6 = createGraphics(tileSize, tileSize);
 pg6.background(0);
 tiles[i++] = pg6;
 //PGraphics pg2 = createGraphics(width/15, width/15, P2D);
}
Version Simplifiée

18b

var tiles = [2];
var windowSize = 400;
var tileSize = windowSize/5;

function setup(){
  createCanvas(windowSize,windowSize);
  createTiles();
  noLoop();
}

function draw(){
  background(255);
  imageMode(CENTER);
  for(var i = 0; i < width; i+=tileSize){
    for(var j = 0; j < height; j+=tileSize){ var tile = floor(random(tiles.length)); //boolean bw = (random(2) >= 1);
      var rotation = floor(random(4));
      push();
      translate(i,j);
      translate(tileSize/2, tileSize/2);
      rotate(PI*rotation/2);
      image(tiles[tile], 0, 0);
      pop();
    }
  }
}

function createTiles(){
  var i = 0;
  pg = createGraphics(tileSize, tileSize);
  pg.background(0);
  pg.noStroke();
  pg.fill(255);
  pg.ellipse(0, 0, tileSize*2, tileSize*2);
  tiles[i++] = pg;
  
  pg1 = createGraphics(tileSize, tileSize);
  pg1.background(255);
  pg1.noStroke();
  pg1.fill(0);
  pg1.ellipse(0, 0, tileSize*2, tileSize*2);
  tiles[i++] = pg1;
}