[whatwg] new ImageData(w, h) proposal

Ian Hickson ian at hixie.ch
Fri May 11 15:11:40 PDT 2007


On Mon, 5 Mar 2007, Mathieu HENRI wrote:
> 
> The ImageData [1] object used in Canvas should be instantiable like 
> HTMLImageElement are using the Image constructor [2,3].

You can already do that:

   var imagedata = {
     height: 1,
     width: 1,
     data: [0,0,0,0]
   };


> * Specify the ImageData constructor should go in 3.14.7.1.10. Pixel
> manipulation [4]:
> 
>     ImageData(in unsigned long w, in unsigned long h)
> 
>     Constructs an ImageData object. The new object's width and height
> attributes must be set to respectively w and h. The new object's data is
> set to transparent black, that is w*h*4 integers set to 0.

   var imagedata = {
     height: h,
     width: w,
     data: [i for (i in function (n) { for (let i = 0; i < n; i += 1) yield 0 }(w*h*4)) ]
   };

-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'



More information about the whatwg mailing list