Draw a sphere: Difference between revisions
Content deleted Content added
m →{{header|REXX}}: added whitespace and changed comments. |
m →{{header|REXX}}: used a better idiomatic form for concatenation, added whitespace. |
||
Line 4,182: | Line 4,182: | ||
if 8=='f8'x then shading= ".:!*oe&#%@" /* EBCDIC dithering chars. */ |
if 8=='f8'x then shading= ".:!*oe&#%@" /* EBCDIC dithering chars. */ |
||
else shading= "·:!°oe@░▒▓" /* ASCII " " */ |
else shading= "·:!°oe@░▒▓" /* ASCII " " */ |
||
parse value norm(lightSource) with s1 s2 |
parse value norm(lightSource) with s1 s2 s3 /*normalize light source. */ |
||
shadeLen= length(shading) - 1; rr= r**2; |
shadeLen= length(shading) - 1; rr= r**2; r2= r+r /*handy─dandy variables. */ |
||
do i=floor(-r ) to ceil(r ); x= i + .5; xx= x**2; $= |
do i=floor(-r ) to ceil(r ); x= i + .5; xx= x**2; $= |
||
Line 4,193: | Line 4,193: | ||
if b<=0 then brite= shadeLen |
if b<=0 then brite= shadeLen |
||
else brite= max(0, (1-b) * shadeLen) % 1 |
else brite= max(0, (1-b) * shadeLen) % 1 |
||
$= |
$= $ || substr(shading, brite + 1, 1) |
||
end /* [↑] build display line.*/ |
end /* [↑] build display line.*/ |
||
else $= $' ' /*append a blank to line. */ |
else $= $' ' /*append a blank to line. */ |