qrohlf / trianglify

Algorithmically generated triangle art
http://qrohlf.com/trianglify/
GNU General Public License v3.0
10.08k stars 669 forks source link

colours more random? #133

Closed ser closed 4 years ago

ser commented 4 years ago

When I generate ten tranglify images to fill some details in my website I noticed that colours of them are often very similar to each other. I mean base colour of course. I'm using default 'random' values. How to make it more vary?

// magic triangles
function addTriangleTo(target) {
  var dimensions = target.getClientRects()[0];
  var pattern = trianglify({
    cellSize: 15,
    width: dimensions.width,
    height: dimensions.height
  }).toCanvas();
  triangle = pattern.toDataURL("image/png");
  target.style['background-image'] = 'url(' + triangle + ')';
  target.style['opacity'] = '0.5';
}
for (var i = 1; i < 11; i++) {
  imgid = 't'+i.toString()
  addTriangleTo(document.getElementById(imgid));
}
qrohlf commented 4 years ago

The default palette is a full set of the colorbrewer scales, which includes several similar sets of colors. If you’d like to customize the palette that is used for the ‘random’ option, you can pass in your own via the palette config parameter. See the README for more info on the data format that the palette config parameter expects.