You might want to tell which method of rendering to the screen you are using as methods of getting the RGB of a pixel might very depending on the render surface. Depending on what library you are taking advantage of there might be a command like readpixel or getRGB, or there might not be any commands and you will have to write something up yourself, like when using an arraybuffer or a piece of memory to store the screen in.