Bohemian Triangles

to generate a new and unique variation

Source Code

Every variart piece is open source, you can see exactly how it is drawn from the code.

var colors = ["#3A4C4E", "#F4BD63", "#EB6226", "#F1E1D2"];
var squareSize = 250;

for (var x = 0; x < 500; x += squareSize){
  for (var y = 0; y < 500; y += squareSize){
    var offset = getRandomInt(0, colors.length - 1);

    if(getRandomInt(0, 1) == 0){
      s.polygon([x, y, x, y + squareSize, x + squareSize, y])
        .attr({
        fill: colors[offset]
      })
    
      s.polygon([x + squareSize, y + squareSize, x + squareSize, y, x, y + squareSize])
        .attr({
        fill: colors[(offset + 1) % colors.length]
      })
    } else {
      s.polygon([x, y, x, y + squareSize, x + squareSize, y + squareSize])
        .attr({
        fill:  colors[offset]
      })

      s.polygon([x, y, x + squareSize, y, x + squareSize, y + squareSize])
        .attr({
        fill: colors[(offset + 1) % colors.length]
      })
    }    
  }
}