Create an empty PixelArray with V8 / node.js

I would like to make an empty PixelArray to compare with node-canvas output from JavaScript.

For instance:

var cleanData = new PixelArray ( 20 ); 

Is it possible? Am I in the wrong version of Node.js? (0.8.3)

+4
source share
1 answer

Powered by Uint8ClampedArray .

 var cleanData = new Uint8ClampedArray( width * height * 4 ); 

Some background:

http://www.khronos.org/registry/typedarray/specs/latest/#7.1 Uint8ClampedArray is defined to replace CanvasPixelArray. It behaves the same way with other typed array representations, except that setters and the constructor use the [WEBIDL] clip instead of modular arithmetic when converting the values ​​of incoming numbers.

+2
source

Source: https://habr.com/ru/post/1447863/


All Articles