Last active
March 8, 2016 01:41
-
-
Save mmckegg/94cfe1480bdac34ea946 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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