An example algorithm
add a point to the queue (x0,y0)
remember the color of the starting point
until the queue is empty
  {
  take a point (x,y) from the queue
  if A[y][x] = color of starting point then
    {
    A[y][x] = 2;
    add a point to the queue (x-1,y)
    add a point to the queue (x+1,y)
    add a point to the queue (x,y-1)
    add a point to the queue (x,y+1)
    }
  }