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 RGBColor
  getter red, green, blue
 
  def initialize(@red = 0_u8, @green = 0_u8, @blue = 0_u8)
  end
 
  RED   = new(red: 255_u8)
  GREEN = new(green: 255_u8)
  BLUE  = new(blue: 255_u8)
  BLACK = new
  WHITE = new(255_u8, 255_u8, 255_u8)
end
 
class Pixmap
  getter width, height
  @data : Array(Array(RGBColor))
 
  def initialize(@width : Int32, @height : Int32)
    @data = Array.new(@width) { Array.new(@height, RGBColor::WHITE) }
  end
 
  def fill(color)
    @data.each &.fill(color)
  end
 
  def [](x, y)
    @data[x][y]
  end
 
  def []=(x, y, color)
    @data[x][y] = color
  end
end
 
bmap = Pixmap.new(5, 5)
pp bmap
 