Anonymous user
Bitmap/Bresenham's line algorithm: Difference between revisions
Bitmap/Bresenham's line algorithm (view source)
Revision as of 20:46, 19 September 2014
, 9 years ago→{{header|zkl}}: flip (0,0)
(Opps) |
(→{{header|zkl}}: flip (0,0)) |
||
Line 2,625:
ppm.write(File("foo.ppm","wb"));</lang>
<lang zkl>class PPM{ // (0,0) is
fcn init(width,height,rgb=0){
sz:=width*height;
Line 2,638:
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 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));
[h-1..0, -1].pump(out,'wrap(h){ data.
}
fcn circle(x0,y0,r,rgb){
|