Colour pinstripe/Display

From Rosetta Code
Revision as of 08:52, 6 June 2011 by rosettacode>Dkf (→‎Tcl: Added implementation)
Task
Colour pinstripe/Display
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

Library: 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}] 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>