Canvas

Canvas Tutorials

Canvas Methods and Properties

HTML canvas createImageData() Method

HTML canvas createImageData() Method

 

 

The createImageData() method is used to create a new, blank ImageData object. Its pixel values are transparent black by default.
Every pixel in the ImageData object has four pieces of information. These are:-

  1. R - The color red (from 0-255)
  2. G - The color green (from 0-255)
  3. B - The color blue (from 0-255)
  4. A - The alpha channel (from 0-255; 0 is transparent and 255 is fully visible)

So, transparent black indicates: (0,0,0,0).

 

Syntax:-

 

Its syntax is:- var imageData = context.createImageData(width, height); OR var imageData = context.createImageData(imageData);

 

Further Explanation:-

 

Parameter Description
width The width of the new ImageData object, in pixels
height The height of the new ImageData object, in pixels
imageData anotherImageData object

Code Explanation

All Tutorials related to Canvas Methods and Properties

All Sections related to Canvas