1.1.0 • Published 6 years ago

draw-noise v1.1.0

Weekly downloads
9
License
MIT
Repository
github
Last release
6 years ago

draw-noise

Draw the output of a noise function on node-canvas and save it as a PNG!

Noise image

Installation

$ yarn add draw-noise

# Or, if you're old-school...

$ npm install --save draw-noise

Usage

const drawNoise = require('draw-noise')
const { Simplex2 } = require('tumult')
const path = require('path')

const simplex = new Simplex2('seed')
const filename = path.join(__dirname, './myimage.png')

drawNoise((x, y) => simplex.gen(x / 32, y / 32), {
  width: 400
  height: 400
  filename
})

API

drawNoise(noiseFn, options)

  • noiseFn: A two-dimensional noise function, or an array of two-dimensional noise functions, with a range of -1, 1 Required
  • options:
    • width: The width of the image, in pixels. Defaults to 100px
    • height: The height of the image, in pixels. Defaults to 100px
    • filename: The filename of the image. Can be an absolute or relative path. Defaults to ./noise.png