Colour bars/Display: Difference between revisions
(upgraded to task) |
|||
Line 1: | Line 1: | ||
{{ |
{{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. |
||
Revision as of 19:33, 24 May 2011
You are encouraged to solve this task according to the task description, using any language you may know.
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.
Tcl
<lang tcl>package require Tcl 8.5 package require Tk 8.5
wm attributes . -fullscreen 1 pack [canvas .c] -fill both -expand 1 set colors {black red green blue magenta cyan yellow white}
for {set x 0} {$x < [winfo screenwidth c]} {incr x 8} {
.c create rectangle $x 0 [expr {$x+7}] [winfo screenheight c] \ -fill [lindex $colors 0] -outline {} set colors [list {*}[lrange $colors 1 end] [lindex $colors 0]]
}</lang>
ZX Spectrum Basic
<lang basic>10 REM The ZX Spectrum display is 32 columns wide, so we have 8 columns of 4 spaces 20 FOR r=0 TO 20: REM There are 21 rows 30 FOR c=0 TO 7: REM We use the native colour sequence here 40 PAPER c: REM set the background colour for the spaces to be printed 50 PRINT " ";: REM four spaces, the semicolon prevents newline 60 NEXT c 70 REM at this point the cursor has wrapped, so we don't need a newline 80 NEXT r</lang>