Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,14 @@
-- demo\rosetta\Bitmap_write_ppm.exw
constant dimx = 512, dimy = 512
constant fn = open("first.ppm","wb") -- b - binary mode
sequence color
printf(fn, "P6\n%d %d\n255\n", {dimx,dimy})
for y=0 to dimy-1 do
for x=0 to dimx-1 do
color = {remainder(x,256), -- red
remainder(y,256), -- green
remainder(x*y,256)} -- blue
puts(fn,color)
end for
end for
close(fn)

View file

@ -0,0 +1,15 @@
global procedure write_ppm(string filename, sequence image)
integer fn = open(filename,"wb"),
dimx = length(image),
dimy = length(image[1])
printf(fn, "P6\n%d %d\n255\n", {dimx,dimy})
for y=1 to dimy do
for x=1 to dimx do
integer pixel = image[x][y] -- red,green,blue
sequence r_g_b = sq_and_bits(pixel,{#FF0000,#FF00,#FF})
r_g_b = sq_floor_div(r_g_b,{#010000,#0100,#01})
puts(fn,r_g_b)
end for
end for
close(fn)
end procedure