JavaScripture
Contribute via GitHub Feedback

ImageData : Object

Constructors

new ImageData(width : Number, height : Number) : ImageData

Creates an ImageData of the specified size filled with transparent black.

Example:

Run

Results:

 

new ImageData(data : Uint8ClampedArray, width : Number, height : Number) : ImageData

Creates an ImageData of the specified size with the specified data. data[0] is the Red component of the first pixel (top left), data[1] is the Green component of the first pixel, data[2] is the Blue component of the first pixel, data[3] is the Alpha component of the first pixel, data[4] is the Red component of the second pixel (one right of top left), etc.

Example:

Run

Results:

 

Instance Properties

data : Uint8ClampedArray  

The pixel color values. The data is stored in RGBA order so data[0] is pixel 0's red channel, data[1] is pixel 0's green channel, data[2] is pixel 0's blue channel, data[3] is pixel 0's alpha channel, data[4] is pixel 1's red channel, etc.

Example:

Run

Results:

 

height : Number  

The height of the buffer in pixels.

Example:

Run

Results:

 

width : Number  

The width of the buffer in pixels.

Example:

Run

Results: