Blue Effigy

to generate a new and unique variation

Source Code

Every variart piece is a small program. This is the one that drew what you're looking at.

var saturation = [24, 34, 42, 49, 57, 63, 67];
var lightness = [81, 68, 57, 46, 37, 28, 20];
var tilt = intVariable('Tilt', -25, 25);
var depth = intVariable('Facets', 20, 80) / 100;
var hue = intVariable('Hue', 0, 359);
var colors = [];
for (var c = 0; c < lightness.length; c++) {
  var h = ((hue + c * 3) % 360) / 60;
  var l = lightness[c] / 100;
  var chroma = (1 - Math.abs(2 * l - 1)) * saturation[c] / 100;
  var x = chroma * (1 - Math.abs(h % 2 - 1));
  var rgb = [[chroma, x, 0], [x, chroma, 0], [0, chroma, x], [0, x, chroma], [x, 0, chroma], [chroma, 0, x]][Math.floor(h)];
  var hex = '#';
  for (var channel = 0; channel < 3; channel++) {
    hex += ('0' + Math.round((rgb[channel] + l - chroma / 2) * 255).toString(16)).slice(-2);
  }
  colors.push(hex);
}
var shoulder = getRandomInt(-15, 20);
var crown = getRandomInt(-9, 9);
var waist = getRandomInt(-22, 22);
var headWidth = getRandomArbitary(0.78, 1.18);
var headHeight = getRandomArbitary(0.84, 1.04);
var bodyWidth = getRandomArbitary(0.85, 1.03);
var reverse = getRandomInt(0, 1);
s.rect(0, 0, width, height).attr({fill: '#eee5d2'});

var points = [
  [211 + tilt, 64 + crown], [325 + tilt, 80 + crown],
  [321 + tilt, 118 + crown], [208 + tilt, 179],
  [187, 225], [301, 244], [295, 278],
  [66, 302 + shoulder], [386, 276 + shoulder],
  [429, 399], [434, 436], [57, 436],
  [160 + waist, 373], [253 + waist, 326], [369, 436],
  [135, 436], [204, 436]
];
var faces = [
  [0, 1, 2, 0], [0, 2, 3, 3], [0, 3, 4, 1],
  [2, 5, 3, 4], [3, 5, 4, 6],
  [4, 5, 13, 3], [5, 6, 13, 5],
  [4, 13, 12, 2], [4, 12, 7, 1],
  [5, 8, 6, 1], [6, 8, 14, 2], [6, 14, 13, 1],
  [8, 9, 14, 0], [9, 10, 14, 5],
  [7, 12, 15, 5], [7, 15, 11, 3],
  [12, 13, 16, 1], [13, 14, 16, 0], [12, 16, 15, 4]
];
// Interior joints move without breaking the shared edges of the planes.
points[3][0] += getRandomInt(-16, 16) * depth;
points[3][1] += getRandomInt(-25, 25) * depth;
points[12][0] += getRandomInt(-24, 24) * depth;
points[13][1] += getRandomInt(-30, 30) * depth;
for (var p = 0; p < points.length; p++) {
  if (p < 4) {
    points[p][0] = 265 + tilt + (points[p][0] - 265 - tilt) * headWidth;
    points[p][1] = 235 + (points[p][1] - 235) * headHeight;
  } else {
    points[p][0] = 250 + (points[p][0] - 250) * bodyWidth;
  }
  if (reverse) points[p][0] = width - points[p][0];
}
function plane(vertices, shade) {
  var color = colors[Math.max(0, Math.min(6, shade))];
  s.polygon(vertices).attr({fill: color, stroke: color, strokeWidth: 0.5});
}
for (var i = 0; i < faces.length; i++) {
  var face = faces[i];
  var vertices = [];
  for (var j = 0; j < 3; j++) {
    vertices.push(points[face[j]][0], points[face[j]][1]);
  }
  var shade = face[3] + getRandomInt(-1, 1);
  if (i > 4 && getRandomArbitary(0, 1) < depth * 0.65) {
    var cx = (vertices[0] + vertices[2] + vertices[4]) / 3;
    var cy = (vertices[1] + vertices[3] + vertices[5]) / 3;
    for (var k = 0; k < 3; k++) {
      var next = (k + 1) % 3;
      plane([vertices[k * 2], vertices[k * 2 + 1], vertices[next * 2], vertices[next * 2 + 1], cx, cy], shade + k - 1);
    }
  } else {
    plane(vertices, shade);
  }
}