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.




RGB ::= (R: int(0), G: int(0), B: int(0));
 
newBitmap: int * int -> RGB(2);
newBitmap(width, height)[y, x] :=
	 (R: 0, G: 0, B: 0)
	 foreach y within 1 ... height, 
	 		 x within 1 ... width;
 
fill: RGB(2) * RGB -> RGB(2);
fill(bitmap(2), color)[y, x] :=
	color
	foreach y within 1 ... size(bitmap),
			x within 1 ... size(bitmap[y]);
 
setColorAt: RGB(2) * int * int * RGB -> RGB(2);
setColorAt(bitmap(2), x, y, color)[Y, X] :=
		color when Y = y and X = x
	else
		bitmap[Y, X];
 
getColorAt: RGB(2) * int * int -> RGB;	
getColorAt(bitmap(2), x, y) := bitmap[y, x]; 
 
lightGreen := (R: 51, G: 255, B: 51);
lightRed := (R: 255, G: 51, B: 51);
 
main(args(2)) :=
	let
		width := 1920;
		height := 1200;
 
		cleanImage := newBitmap(width, height);
 
		filledGreen := fill(cleanImage, lightGreen);
 
		redCenter := setColorAt(filledGreen, width / 2, height / 2, lightRed);
	in
		getColorAt(redCenter, width / 2, height / 2);