Skip to content

Instantly share code, notes, and snippets.

@mmckegg
Last active March 8, 2016 01:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mmckegg/94cfe1480bdac34ea946 to your computer and use it in GitHub Desktop.
Save mmckegg/94cfe1480bdac34ea946 to your computer and use it in GitHub Desktop.
var bl = require('bl')
var controlFrame = new Buffer([0x00, 0x00, 0x00, 0x00])
module.exports = function (pixels, cb) {
var frame = bl()
// start frame
frame.append(controlFrame)
// body frames
var length = pixels.shape[0]
for (var i = 0; i < length; i++) {
frame.append(new Buffer([0xff,
pixels.get(i, 2), // blue
pixels.get(i, 1), // green
pixels.get(i, 0) // red
]))
}
// end frames
for (i = 0; i < length / 2; i++) {
frame.append(controlFrame)
}
return frame
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment