Created
February 8, 2016 22:16
-
-
Save mikolalysenko/9c732f07628863b529f1 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 ndarray = require('ndarray') | |
//Context is a canvas 2d context | |
var imageData = context.createImageData(WIDTH, HEIGHT) | |
//Wrap pixels in an ndarray with shape [width x height x 4 (rgba)] | |
var ndpixels = ndarray(imageData.data, [WIDTH, HEIGHT, 4], [4, 4 * WIDTH, 1], 0) | |
//Now you can edit pixels as an ndarray! | |
// ... | |
//When done, you blit back using the original image | |
context.putImageData(imageData) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment