Bitmap/Bresenham's line algorithm: Difference between revisions

→‎{{header|zkl}}: added readPPMFile
(→‎{{header|zkl}}: added readPPMFile)
Line 2,922:
out.write("P6\n#rosettacode PPM\n%d %d\n255\n".fmt(w,h));
[h-1..0, -1].pump(out,'wrap(h){ data.seek(3*h*w); data.read(3*w) });
}
fcn readPPMFile(fileName){
image:=File(f:=fileName,"rb").read(); f.close();
image.readln(2);
w,h:=image.readln().split().apply("toInt");
 
image.del(0,image.find("\n255\n") + 5); // del PPM header
ppm:=PPM(w,h);
ppm.data.clear(); // gonna write file image data
// image is stored upside down
[h-1..0, -1].pump(ppm.data,'wrap(h){ image.seek(3*h*w); image.read(3*w) });
ppm
}
fcn circle(x0,y0,r,rgb){
Anonymous user