setting vertex colors
first, run this code only on primitive objects until you understand what it does.
this is for setting vertex colors of a vertex color map
getting vertex colors
getting vertex colors is similar but in reverse, remember that 1 vertex can be shared by several polygons and each polygon can set a different color for that vertex/index. Notice how the plane divided into 4 below has one central vertex which is shared by 4 surrounding polygons, each polygon has a different color for that vertex.
Material from vertex color map
this requires setting viewport shading from solid to texture.