function calculate_colors()
{
var temp_pixel;
filehandle = file_open_write ("address.txt");
var format;
var h = 0;
var w = 0;
over_canvas.visible = off;
wait(2);
bmap_for_screen(tempy, 1, 0);
wait(1);
format = bmap_lock(tempy, 0);
while(h < bmap_height(tempy))
{
while(w < bmap_width(tempy))
{
temp_pixel = pixel_to_vec(temp, NULL, format, pixel_for_bmap(tempy, w, h));
colorpercents[6] += (temp_pixel.green == 75);
colorpercents[(temp_pixel.red == 255) + ((temp_pixel.green == 255) * 2) + ((temp_pixel.blue == 255) * 4)] += 1;
//Order of colors in array colorpercents is: Other, Red, Green, Yellow, Blue, Purple, Orange, White
w += 1;
wait(1);
}
w = 0;
h += 1;
wait(1);
}
over_canvas.visible = on;
file_var_write(filehandle, colorpercents[0]); //these next few commands write the results of the color scan into an outside document so I can analyze them
file_var_write(filehandle, colorpercents[1]);
file_var_write(filehandle, colorpercents[2]);
file_var_write(filehandle, colorpercents[3]);
file_var_write(filehandle, colorpercents[4]);
file_var_write(filehandle, colorpercents[5]);
file_var_write(filehandle, colorpercents[6]);
file_var_write(filehandle, colorpercents[7]);
file_var_write(filehandle, temp_pixel.red); //these three lines write the red, green, and blue values of the last pixel scanned into the same document
file_var_write(filehandle, temp_pixel.green);
file_var_write(filehandle, temp_pixel.blue);
over_canvas.bmap = tempy;
bmap_unlock(tempy);
file_close(filehandle);
}