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,38 @@
/*REXX program demonstrates how to process/display a simple RGB raster graphics image.*/
red = 'ff 00 00'x /*a method to define a red value. */
blue = '00 00 ff'x /*" " " " " blue " */
@. = /*define entire @. array to nulls. */
outFN = 'image' /*the filename of the output image PPM */
sWidth = 500; sHeight= 500 /*the screen width and height in pixels*/
call RGBfill red /*set the entire image to red. */
x= 10; y= 40 /*set pixel's coördinates. */
call RGBset x, y, blue /*set a pixel (at 10,40) to blue. */
color = RGBget(x, y) /*get the color of a pixel. */
hexV = c2x(color) /*get hex value of pixel's color. */
binV = x2b(hexV) /* " binary " " " " */
bin3V = left(binV, 8) substr(binV, 9, 8) right(binV, 8)
hex3V = left(hexV, 2) substr(hexV, 3, 2) right(hexV, 2)
xy= '(' || x","y')' /*create a handy─dandy literal for SAY.*/
say xy ' pixel in binary: ' binV /*show the binary value of 20,50 */
say xy ' pixel in binary: ' bin3V /*show again, but with spaces. */
say /*show a blank between binary and hex. */
say xy ' pixel in hex: ' hexV /*show again, but in hexadecimal. */
say xy ' pixel in hex: ' hex3V /*show again, but with spaces. */
call PPMwrite outFN, sWidth, sHeight /*create a PPM (output) file of image. */ /* ◄■■■■■■■■ not part of this task.*/
say /*show a blank. */
say 'The file ' outFN".PPM was created." /*inform user that a file was created. */
exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
RGBfill: @.=arg(1); return /*fill image with a color.*/
RGBget: parse arg px,py; return @.px.py /*get a pixel's color. */
RGBset: parse arg px,py,p$; @.px.py=p$; return /*set " " " */
/*──────────────────────────────────────────────────────────────────────────────────────*/
PPMwrite: parse arg oFN, width, height /*obtain output filename, width, height*/
oFID= oFN'.PPM'; $='9'x; #=255 /*fileID; separator; max color value.*/
call charout oFID, , 1 /*set the position of the file's output*/
call charout oFID,'P6'width || $ || height || $ || # || $ /*write hdr info.*/
do j=1 for width
do k=1 for height; call charout oFID, @.j.k
end /*k*/ /* ↑ write the PPM file, ··· */
end /*j*/ /* └───────── ··· one pixel at a time.*/
call charout oFID; return /*close the output file just to be safe*/

View file

@ -0,0 +1,111 @@
/* REXX ***************************************************************
* Draw a picture from pixels
* 16.06.2014 Walter Pachl
**********************************************************************/
oid='pic.bmp'; 'erase' oid
blue ='FF0000'x;
green='00FF00'x;
red ='0000FF'x;
white='ffffff'x;
black='000000'x;
w=600 /* width */
h=300 /* height */
w3=w*3
bfType ='BM'
bfSize ='46000000'x
bfReserved ='00000000'x
bfOffBits ='36000000'x
biSize ='28000000'x
biWidth =lend(w)
biHeight =lend(h)
biPlanes ='0100'x
biBitCount ='1800'x
biCompression ='00000000'x
biSizeImage ='10000000'x
biXPelsPerMeter='00000000'x
biYPelsPerMeter='00000000'x
biClrUsed ='00000000'x
biClrImportant ='00000000'x
s=bfType||,
bfSize||,
bfReserved||,
bfOffBits||,
biSize||,
biWidth||,
biHeight||,
biPlanes||,
biBitCount||,
biCompression||,
biSizeImage||,
biXPelsPerMeter||,
biYPelsPerMeter||,
biClrUsed||,
biClrImportant
pic=copies(red,w*h) /* fill the rectangle with color red */
Call rect 100,100,180,180,green /* draw a green rectangle */
Call rect 100,100,160,160,blue /* and a blue rectangle within that */
Call dot 120,120,white /* one pixel is hardly visible */
Do x=98 To 102 /* draw a square of 25 pixels */
Do y=98 To 102
Call dot x,y,white
End
End
Call charout oid,s||pic /* write the picture to file */
dmy=col(97,98)
dmy=col(98,98)
Exit
lend: Procedure
/**********************************************************************
* compute the representation of a number (little endian)
**********************************************************************/
Parse Arg n
res=reverse(d2c(n,4))
rev=reverse(res)
say 'lend:' arg(1) '->' c2x(res) '=>' c2d(rev)
Return res
rect: Procedure Expose pic w h w3
/**********************************************************************
* Fill a rectangle with center at x,y and width/height = wr/hr
**********************************************************************/
Parse Arg x,y,wr,hr,color
Say x y wr hr c2x(color)
i=w3*(y-1)+3*(x-1)+1 /* Pixel position of center */
ia=max(w3*(y-1)+1,i-3*(wr%2)) /* position of left border */
ib=min(i+3*wr%2,w3*y) /* position of right border */
lc=ib-ia /* length of horizontal line */
If lc>=0 Then Do
os=copies(color,lc%3) /* the horizontal line */
Do hi=-hr%2 to hr%2 /* loop from lower to upper border*/
i=trunc(ia+w3*hi) /* position of line's left border */
If i>1 Then Do
pic=overlay(os,pic,i) /* put the line into the picture */
j=i%w3
End
End
End
Return
dot: Procedure Expose pic w h w3
/**********************************************************************
* Put a dot at position x/y into the picture
**********************************************************************/
Parse Arg x,y,color
i=w3*(y-1)+3*(x-1)
pic=overlay(color,pic,i+1)
Return
col: Procedure Expose pic w h w3
/**********************************************************************
* get the color at position x/y
**********************************************************************/
Parse Arg x,y,color
i=w3*(y-1)+3*(x-1)
say 'color at pixel' x'/'y'='c2x(substr(pic,i+1,3))
Return c2x(substr(pic,i+1,3))