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.




functor
export
   New
   Get
   Set
   Transform
define
   fun {New Width Height Init}
      C = {Array.new 1 Height unit}
   in
      for Row in 1..Height do
	 C.Row := {Array.new 1 Width Init}
      end
 
      array2d(width:Width
	      height:Height
	      contents:C)
   end
 
   fun {Get array2d(contents:C ...) X Y}
      C.Y.X
   end
 
   proc {Set array2d(contents:C ...) X Y Val}
      C.Y.X := Val
   end
 
   proc {Transform array2d(contents:C width:W height:H ...) Fun}
      for Y in 1..H do
	 for X in 1..W do
	    C.Y.X := {Fun C.Y.X}
	 end
      end
   end
 
   %% omitted: Clone, Map, Fold, ForAll
end