$ include "seed7_05.s7i"; include "draw.s7i"; include "color.s7i"; const proc: writePPM (in string: fileName, in PRIMITIVE_WINDOW: aWindow) is func local var file: ppmFile is STD_NULL; var integer: x is 0; var integer: y is 0; var color: pixColor is black; begin ppmFile := open(fileName, "w"); if ppmFile <> STD_NULL then writeln(ppmFile, "P6"); writeln(ppmFile, width(aWindow) <& " " <& height(aWindow)); writeln(ppmFile, "255"); for y range 0 to pred(height(aWindow)) do for x range 0 to pred(width(aWindow)) do pixColor := getPixelColor(aWindow, x, y); write(ppmFile, str(chr(pixColor.redLight)) <& chr(pixColor.greenLight) <& chr(pixColor.blueLight)); end for; end for; close(ppmFile); end if; end func;