Updated 2014-06-22 16:34:05 by dkf

Richard Suchenwirth 2005-12-06 - Being asked how to create a GIF image, I hacked up this simple example that creates a photo image of a tricolore flag (three even-spaced vertical bands - like France, Italy, Belgium, Ireland and many more). The default is France. The procedure returns the image name - just save it in -format GIF if you want:
proc tricolore {w {colors {blue white red}}} {
    set im [image create photo]
    set fromx 0
    set dx [expr $w/3]
    set tox $dx
    set toy [expr $w*2/3]
    foreach color $colors {
        $im put $color -to $fromx 0 $tox $toy
        incr fromx $dx; incr tox $dx
    return $im

# Test:
pack [canvas .c -width 200 -height 200 -background grey]
.c create image 100 100 -image [tricolore 150]

# [tricolore 300] write foo.gif -format gif

See also edit