Colour pinstripe/Display: Difference between revisions
promoted to task |
→Tcl: Added implementation |
||
Line 1: | Line 1: | ||
{{task}} |
{{task|Test card}} |
||
The task is to create 1 pixel wide colour pinstripes across the width of the graphics display. A basic of colours should be using including black, white and each of the primary colours. The pinstripes should either use the system palette sequence or the sequence Black, Red, Green, Blue, Magenta, Cyan, Yellow, White. |
The task is to create 1 pixel wide colour pinstripes across the width of the graphics display. A basic of colours should be using including black, white and each of the primary colours. The pinstripes should either use the system palette sequence or the sequence Black, Red, Green, Blue, Magenta, Cyan, Yellow, White. |
||
Line 5: | Line 5: | ||
After filling the top quarter of the, we switch to a wider 2 pixel wide pinstripe pattern. Halfway down the display we switch to 3 pixel wide pinstripe and then finally to a 4 pixels wide pinstripe for the last quarter of the display. |
After filling the top quarter of the, we switch to a wider 2 pixel wide pinstripe pattern. Halfway down the display we switch to 3 pixel wide pinstripe and then finally to a 4 pixels wide pinstripe for the last quarter of the display. |
||
=={{header|Tcl}}== |
|||
⚫ | |||
{{libheader|Tk}} |
|||
<lang tcl>package require Tcl 8.5 |
|||
package require Tk 8.5 |
|||
wm attributes . -fullscreen 1 |
|||
pack [canvas .c -highlightthick 0] -fill both -expand 1 |
|||
set colors {black red green blue magenta cyan yellow white} |
|||
set dy [expr {[winfo screenheight .c]/4}] |
|||
[[Category:Test card]] |
|||
set y 0 |
|||
foreach dx {1 2 3 4} { |
|||
for {set x 0} {$x < [winfo screenwidth .c]} {incr x $dx} { |
|||
.c create rectangle $x $y [expr {$x+$dx}] [expr {$y+$dy}] \ |
|||
-fill [lindex $colors 0] -outline {} |
|||
set colors [list {*}[lrange $colors 1 end] [lindex $colors 0]] |
|||
} |
|||
incr y $dy |
|||
}</lang> |
|||
⚫ |
Revision as of 08:52, 6 June 2011
You are encouraged to solve this task according to the task description, using any language you may know.
The task is to create 1 pixel wide colour pinstripes across the width of the graphics display. A basic of colours should be using including black, white and each of the primary colours. The pinstripes should either use the system palette sequence or the sequence Black, Red, Green, Blue, Magenta, Cyan, Yellow, White.
After filling the top quarter of the, we switch to a wider 2 pixel wide pinstripe pattern. Halfway down the display we switch to 3 pixel wide pinstripe and then finally to a 4 pixels wide pinstripe for the last quarter of the display.
Tcl
<lang tcl>package require Tcl 8.5 package require Tk 8.5
wm attributes . -fullscreen 1 pack [canvas .c -highlightthick 0] -fill both -expand 1 set colors {black red green blue magenta cyan yellow white}
set dy [expr {[winfo screenheight .c]/4}] set y 0 foreach dx {1 2 3 4} {
for {set x 0} {$x < [winfo screenwidth .c]} {incr x $dx} {
.c create rectangle $x $y [expr {$x+$dx}] [expr {$y+$dy}] \
-fill [lindex $colors 0] -outline {}
set colors [list {*}[lrange $colors 1 end] [lindex $colors 0]]
} incr y $dy
}</lang>