Colour bars/Display: Difference between revisions
Content added Content deleted
Line 1: | Line 1: | ||
{{task}} |
{{task}} |
||
The task is to display a series of vertical color bars across the width of the display. The color bars should either use the system palette, or the sequence of colors: Black, Red, Green, Blue, Magenta, Cyan, Yellow, White. |
The task is to display a series of vertical color bars across the width of the display. The color bars should either use the system palette, or the sequence of colors: Black, Red, Green, Blue, Magenta, Cyan, Yellow, White. |
||
=={{header|Icon}} and {{header|Unicon}}== |
|||
The procedure below is generalized to take a description of a ''test card'' and display it. |
|||
<lang Icon>link graphics,printf |
|||
procedure main() # generalized colour bars |
|||
DrawTestCard(Simple_TestCard()) |
|||
WDone() |
|||
end |
|||
procedure DrawTestCard(TC) |
|||
size := sprintf("size=%d,%d",TC.width,TC.height) |
|||
&window := TC.window := open(TC.id,"g","bg=black",size) | |
|||
stop("Unable to open window") |
|||
every R := TC.bands[r := 1 to *TC.bands -1] do |
|||
every C := R.bars[c := 1 to *R.bars - 1] do { |
|||
Fg(R.bars[c].colour) |
|||
FillRectangle( C.left, R.top, |
|||
R.bars[c+1].left-C.left, TC.bands[r+1].top-R.top ) |
|||
} |
|||
return TC |
|||
end |
|||
record testcard(window,id,width,height,bands) |
|||
record band(top,bars) |
|||
record bar(left,colour) |
|||
procedure Simple_TestCard() #: return structure simple testcard |
|||
return testcard(,"Simple Test Card",width := 800,height := 600, |
|||
[ band( 1, [ bar( 1, "black"), |
|||
bar(114, "red"), |
|||
bar(228, "green"), |
|||
bar(342, "blue"), |
|||
bar(456, "magenta"), |
|||
bar(570, "cyan"), |
|||
bar(684, "yellow"), |
|||
bar(width) ] ), |
|||
band(height) ]) |
|||
end</lang> |
|||
The following example is a wee tiny bit more interesting. |
|||
<lang Icon>procedure SMPTE_TestCard() #: return structure with 480i(ish) testcard |
|||
return testcard(,"SMPTE TV Test Card",width := 672,height := 504, |
|||
[ band( 1, [ bar( 1, "#c0c0c0"), |
|||
bar( 95, "#c0c000"), |
|||
bar(191, "#00c0c0"), |
|||
bar(288, "#00c000"), |
|||
bar(383, "#c000c0"), |
|||
bar(480, "#c00000"), |
|||
bar(575, "#0000c0"), |
|||
bar(width) ] ), |
|||
band(335, [ bar( 1, "#0000c0"), |
|||
bar( 95, "#131313"), |
|||
bar(191, "#c000c0"), |
|||
bar(288, "#131313"), |
|||
bar(383, "#00c0c0"), |
|||
bar(480, "#131313"), |
|||
bar(575, "#c0c0c0"), |
|||
bar(width) ] ), |
|||
band(378, [ bar( 1, "#00214c"), |
|||
bar(120, "#ffffff"), |
|||
bar(240, "#32006a"), |
|||
bar(360, "#131313"), |
|||
bar(480, "#090909"), |
|||
bar(512, "#131313"), |
|||
bar(544, "#1d1d1d"), |
|||
bar(576, "#131313"), |
|||
bar(width) ] ), |
|||
band(height) ]) |
|||
end</lang> |
|||
{{libheader|Icon Programming Library}} |
|||
[http://www.cs.arizona.edu/icon/library/src/procs/graphics.icn graphics.icn provides graphics] |
|||
[http://www.cs.arizona.edu/icon/library/src/procs/printf.icn printf.icn provides sprintf] |
|||
=={{header|J}}== |
=={{header|J}}== |