Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
19
Task/Bitmap/Zkl/bitmap-1.zkl
Normal file
19
Task/Bitmap/Zkl/bitmap-1.zkl
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
class PPM{ // (0,0) is logically bottom left
|
||||
fcn init(width,height){
|
||||
sz:=width*height*3;
|
||||
var [const]
|
||||
data=sz.pump(Data(sz),0), // initialize to Black (RGB=000)
|
||||
w=width, h=height;
|
||||
}
|
||||
fcn fill(rgb){
|
||||
sz:=data.len()/3;
|
||||
data.clear(); sz.pump(data,T(Void,rgb.toBigEndian(3)));
|
||||
}
|
||||
fcn __sGet(x,y) { data.toBigEndian(3*y*w + 3*x,3); } //ppm[x,y]
|
||||
fcn __sSet(rbg,x,y){ data[3*y*w + 3*x,3]=rbg.toBigEndian(3); } //ppm[x,y]=rgb
|
||||
fcn write(out){ // write bottom to top to move (0,0) from bottom 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.seek(3*h*w); data.read(3*w) });
|
||||
out.close();
|
||||
}
|
||||
}
|
||||
5
Task/Bitmap/Zkl/bitmap-2.zkl
Normal file
5
Task/Bitmap/Zkl/bitmap-2.zkl
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
ppm:=PPM(256,256);
|
||||
ppm.fill(0x00FF88);
|
||||
foreach x in ([50..200]){ ppm[x,50]=0xff|00|00; } // horizontal red line
|
||||
|
||||
ppm.write(File("foo.ppm","wb"));
|
||||
Loading…
Add table
Add a link
Reference in a new issue