get-center-pixel

1.0.0 • Public • Published

get-center-pixel

given an array of pixel data not unlike that returned by canvasContext.getImageData().data and a width and a height, returns the data for the center pixel as {r: 0-255, g: 0-255, b: 0-255, a: 0-255}

NPM js-standard-style Build Status

EXAMPLE

  /// ... canvas/context setup code up here ... \\\\\\
  var width = canvas.width
  var height = canvas.height
  var pixels = ctx.getImageData(0, 0, width, height).data
  var getCenterPixel = require('get-center-pixel')
  getCenterPixel(pixels, widht, height)
  // => {r: 100, g: 212, b: 53, a: 183}
  // now do something with that pixel

Dependencies (2)

Dev Dependencies (2)

Package Sidebar

Install

npm i get-center-pixel

Weekly Downloads

0

Version

1.0.0

License

MIT

Last publish

Collaborators

  • coleww