3 ms·
Also - CSS tricks don't work if you're writing command line tools or backend code in JS.
by dkopi 10y ago
Also - CSS tricks don't work if you're writing command line tools or backend code in JS.
- onion2k 10y agoThat is true, but grafi.js relies on a browser's canvas API to convert an image to a Uint8ClampedArray of colour values, so it won't work on a command line or backend either. As a way to learn about convolution filters it seems fairly good though.
- dkopi 10y agoGood point. https://www.npmjs.com/package/get-pixels https://www.npmjs.com/package/get-pixels can help parse an image to pixels, but it returns a different format than the canvas API's Uint8ClampedArray.
- megalodon 10y agoI haven't tested but I think you can convert ndarray to Uint8ClampedArray by doing new Uint8ClampedArray(ndarray.data);
- zbjornson 10y agoNode-canvas provides a compliant Canvas implementation: https://github.com/Automattic/node-canvas https://github.com/Automattic/node-canvas
- alfanick 10y agothat is wrong way to do this - write efficient code (simple operations on an array) instead of using huge canvas library to make a library you don't need to use usable