node package manager
Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »



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


  /// ... 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