Greyscale bars/Display: Difference between revisions

(→‎Tcl: Added implementation)
Line 7:
 
Halfway down the display, we start with black, and produce 32 bars, ending in white, and for the last quarter, we start with white and step through 62 shades of grey, before finally arriving at black in the bottom right hand corner, producing a total of 64 bars for the bottom quarter.
 
=={{header|J}}==
'''Solution:'''
<lang j> size=.2{.".wd'qm' NB. requires J6 or less
rows=. (2^3+i.4),._1^i.4
bars=. ((64%{.)#[:(<:@|%~i.)*/)"1 rows
togreyscale=. (256#. [:<.255 255 255&*)"0
'rgb' viewmat (4<.@%~{:size)# (64<.@%~{.size)#"1 togreyscale bars</lang>
 
Note that this solution is not posted directly to the screen but to a viewmat window, which may not be centered.
 
=={{header|PureBasic}}==
Anonymous user