Bitmap/Bresenham's line algorithm: Difference between revisions
Content added Content deleted
(Opps) |
(→{{header|zkl}}: flip (0,0)) |
||
Line 2,625: | Line 2,625: | ||
ppm.write(File("foo.ppm","wb"));</lang> |
ppm.write(File("foo.ppm","wb"));</lang> |
||
<lang zkl>class PPM{ // (0,0) is |
<lang zkl>class PPM{ // (0,0) is logically bottom left |
||
fcn init(width,height,rgb=0){ |
fcn init(width,height,rgb=0){ |
||
sz:=width*height; |
sz:=width*height; |
||
Line 2,638: | Line 2,638: | ||
fcn __sGet(x,y) { data.toBigEndian(3*y*w + 3*x,3); } //ppm[x,y] |
fcn __sGet(x,y) { data.toBigEndian(3*y*w + 3*x,3); } //ppm[x,y] |
||
fcn __sSet(rbg,x,y){ data[3*y*w + x*3,3]=rbg.toBigEndian(3); } //ppm[x,y]=rgb |
fcn __sSet(rbg,x,y){ data[3*y*w + x*3,3]=rbg.toBigEndian(3); } //ppm[x,y]=rgb |
||
fcn write(out){ |
fcn write(out){ // write bottom to top to move (0,0) from top left to bottom left |
||
out.write("P6\n#rosettacode PPM\n%d %d\n255\n".fmt(w,h)); |
out.write("P6\n#rosettacode PPM\n%d %d\n255\n".fmt(w,h)); |
||
out. |
[h-1..0, -1].pump(out,'wrap(h){ data.seek(3*h*w); data.read(3*w) }); |
||
} |
} |
||
fcn circle(x0,y0,r,rgb){ |
fcn circle(x0,y0,r,rgb){ |