Package Exports
- delaunify
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (delaunify) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
delaunify
Randomly delaunay-triangulates an image by distributing 2D points across the surface, and then triangulating it. The colours of each triangle is determined by the pixel color underneath the triangle's centroid.
A new canvas is returned with the same size as the image.
var load = require('img')
var domready = require('domready')
var uri = require('baboon-image-uri')
var delaunify = require('delaunify')
domready(function() {
//load image with baboon for testing
load(uri, function(err, img) {
if (err)
throw err
//delaunify the image into a canvas
var result = delaunify(img, { count: 350 })
document.body.appendChild(result)
})
})
Usage
delaunify(img[, opts])
Triangulates the image. By default, it uses a random distribution of points.
Options:
minan [x,y] array for the minimum random value (default[0, 0])maxan [x,y] array for the maximum random value (default[imgWidth, imgHeight])countthe number of points to distribute (default50)filla boolean, whether to apply a fill (defaulttrue)strokea boolean, whether to apply a stroke (defaulttrue)pointsan array of [x,y] points to use instead of random; this will ignore themin,maxandcountoptions
License
MIT, see LICENSE.md for details.
