Greyscale bars/Display: Difference between revisions

m ({{omit from|GUISS}})
Line 76:
return app.exec( ) ;
}</lang>
 
=={{header|Icon}} and {{header|Unicon}}==
This procedure uses code from the [[Colour_bars/Display|Colour bars/Display task]], specifically the: ''DrawTestCard'' procedure and ''testcard'', ''band'', and ''bar''
records.
 
<lang Icon>link graphics,printf,numbers
procedure main()
DrawTestCard(GreyScale_TestCard())
WDone()
end
 
procedure greyscale(l,h,s) #: generate s greys over range l:h
every i := round(l to h+1 by ((h-l)/(s-1.))) do
suspend sprintf("%d,%d,%d",i,i,i) # return rgb black-grey-white
end
 
procedure GreyScale_TestCard() #: return greyscale testcard
TC := testcard(,"GreyScale Test Card",
width := 800, height := 600,
list(numbands := 4) )
maxv := 2^16-1 # largest colour value
every (iv := [], i := 1 to numbands) do { # for each band
every put(v := [], greyscale(0,maxv,2^(2+i))) # compute greyscale
put(iv, if i%2 = 0 then v else reverse(v)) # switch directions
}
 
every r := height/numbands * ((i := 1 to numbands)-1) + 1 do {
TC.bands[i] := band(r,[])
every c := width/(*iv[i]) * ((j := 1 to *iv[i])-1) + 1 do
put(TC.bands[i].bars, bar( c, iv[i,j]))
put((TC.bands[i]).bars, bar(width)) # right sentinal
}
put(TC.bands,band(height)) # bottom sentinal
return TC
end</lang>
 
{{libheader|Icon Programming Library}}
[http://www.cs.arizona.edu/icon/library/src/procs/graphics.icn graphics.icn supports graphics]
[http://www.cs.arizona.edu/icon/library/src/procs/printf.icn printf.icn provides sprintf, etc.]
[http://www.cs.arizona.edu/icon/library/src/procs/numbers.icn numbers.icn provides round]
 
=={{header|J}}==
Anonymous user