How to resolve the algorithm Pinstripe/Display step by step in the Tcl programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Pinstripe/Display step by step in the Tcl programming language

Table of Contents

Problem Statement

The task is to demonstrate the creation of a series of vertical pinstripes across the entire width of the display.

c.f. Colour_pinstripe/Display

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Pinstripe/Display step by step in the Tcl programming language

Source code in the tcl programming language

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 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
}


  

You may also check:How to resolve the algorithm Loops/Infinite step by step in the BCPL programming language
You may also check:How to resolve the algorithm Sequence of non-squares step by step in the Racket programming language
You may also check:How to resolve the algorithm Flow-control structures step by step in the Julia programming language
You may also check:How to resolve the algorithm Fairshare between two and more step by step in the XPL0 programming language
You may also check:How to resolve the algorithm User input/Text step by step in the Déjà Vu programming language