get-center-pixel
v1.0.0
Published
Get the center pixel from an array of canvas pixel data
Downloads
5
Readme
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}
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