Grayscale image: Difference between revisions

m
→‎{{header|REXX}}: changed some comments and whitespace.
m (→‎{{header|REXX}}: changed spacing in the REXX section header.)
m (→‎{{header|REXX}}: changed some comments and whitespace.)
Line 1,466:
Note:   REXX uses characters instead of binary for storing numbers, so there is no rounding   (using characters to
<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; store numbers is almost the same as using decimal floating point).
<lang rexx>/*REXX program converts a RGB (red─green─blue) image tointo a grayscale /greyscale image. */
blue= '00 00 ff'x /*define the blue color (hexadecimal).*/
@.= blue /*set the entire image to blue color.*/
Line 1,477:
g=substr(@.col.row, 2, 1) ; g=c2d(g) /* " " " green " " */
b= right(@.col.row, 1) ; b=c2d(b) /* " " " blue " " */
@.col.row_= d2c( (.2126*r + .7152*g + .0722*b) % 1) /*convert RGB number ───► grayscale. */
end /*@.col.row*/ =copies(_, 3) /*redefine [↑]old RGB D2C convert ───► decimal ───>grayscale. char*/
end /*row*/ /* [↑] D2C convert decimal ───► char*/
end /*col*/ /* [↑] x%1 is the same as TRUNC(x) */
/*stick a fork in it, we're all done. */</lang>
Line 1,495 ⟶ 1,496:
 
/*Both Z & Y are normally not viewable*/
/*on most terminals (appear as blanks).*/</lang><br><br>
 
=={{header|Ruby}}==