delaunify

1.0.3 • Public • Published

delaunify

unstable

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)
    })
})

img

Usage

NPM

delaunify(img[, opts])

Triangulates the image. By default, it uses a random distribution of points.

Options:

  • min an [x,y] array for the minimum random value (default [0, 0])
  • max an [x,y] array for the maximum random value (default [imgWidth, imgHeight])
  • count the number of points to distribute (default 50)
  • fill a boolean, whether to apply a fill (default true)
  • stroke a boolean, whether to apply a stroke (default true)
  • points an array of [x,y] points to use instead of random; this will ignore the min, max and count options

License

MIT, see LICENSE.md for details.

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.3
    5
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.3
    5
  • 1.0.2
    0
  • 1.0.1
    0
  • 1.0.0
    0

Package Sidebar

Install

npm i delaunify

Weekly Downloads

5

Version

1.0.3

License

MIT

Last publish

Collaborators

  • hperigo
  • gabroell
  • josdelgaur
  • jam3dev
  • njam3
  • iranreyes
  • namniak
  • donghyukjang
  • alemesa
  • neoli
  • colin-j3
  • jmckinnell
  • n0wak
  • amelierosser
  • artemleznikov
  • jeffong
  • mattdesl