Show a basic storage type to handle a simple RGB raster graphics image,
and some primitive associated functions.

If possible provide a function to allocate an uninitialised image,
given its width and height, and provide 3 additional functions:

   one to fill an image with a plain RGB color,
   one to set a given pixel with a color,
   one to get the color of a pixel.


(If there are specificities about the storage or the allocation, explain those.)

These functions are used as a base for the articles in the category raster graphics operations, 
and a basic output function to check the results
is available in the article write ppm file.




class PPM{	// (0,0) is logically bottom left
   fcn init(width,height){
      sz:=width*height*3;
      var [const] 
         data=sz.pump(Data(sz),0),  // initialize to Black (RGB=000)
	 w=width, h=height;
   }
   fcn fill(rgb){
      sz:=data.len()/3;
      data.clear(); sz.pump(data,T(Void,rgb.toBigEndian(3)));
   }
   fcn __sGet(x,y)    { data.toBigEndian(3*y*w + 3*x,3);        } //ppm[x,y]
   fcn __sSet(rbg,x,y){	data[3*y*w + 3*x,3]=rbg.toBigEndian(3); } //ppm[x,y]=rgb
   fcn write(out){   // write bottom to top to move (0,0) from bottom left to bottom left
      out.write("P6\n#rosettacode PPM\n%d %d\n255\n".fmt(w,h));
      [h-1..0, -1].pump(out,'wrap(h){ data.seek(3*h*w); data.read(3*w) });
      out.close();
   }
}