Trianglify

Trianglify

Trianglify generates colorful triangle meshes that can be used as SVG images and CSS backgrounds.

This is inspired by btmills/geopattern thanks to Quinn Rohlf for this.

Get it: npm install --save trianglify

Sample usage:

1
2
3
var Trianglify = require('trianglify');
var pattern = Trianglify({width: 200, height: 200});
document.body.appendChild(pattern.canvas());

There are few wonderful options color_function being one of them.

Color function that uses the HSL color format to generate a rainbow pattern:

1
2
3
4
5
var colorFunc = function(x, y) {
    return 'hsl('+Math.floor(Math.abs(x*y)*360)+',80%,60%)';
};

var pattern = Trianglify({color_function: colorFunc})

GIF FTW!

Trianglify

Suggest a module

Comments