gifBalls

runs on: Base 64 encode/decode

KPV 2003-05-12 added a blue gif ball (by taking the red ball and doing a RGB->BGR palette color swap); made to work with tcllib base64 package (with workaround for an 8.4.2 bug); and added binary translation for Windows.


 package require base64

 ## ******************************************************** 
 ##
 ## Name: gifBalls
 ##
 ## Description:
 ## Creates .gif files of red, yellow, blue and green balls.
 ##
 ## Parameters:
 ## where - the directory to drop the balls in.
 ## Usage:
 ##   gifBalls [ file join $::env(HOME) public_html gifs ]
 ## Comments:
 ##   Base 64 encoded for freshness.

 proc gifBalls { { where "" } } {

     set red {R0lGODlhFAAPAPMPAAAAADgFD00CEGoDGHMTJ21ZXZISK6USL7
              MoRJ1aZ9IzUvRUdNVAXscbPv9ylKqcniH5BAEAAAAALAAAAAAU
              AA8AAARwEMgpX7qPavrQ+YdBZNv0HIDCKE04kNvZMEvNeIMAU8
              mhLI7gQuEqlAwHWtCxYLgIMeRvOTwQBoHS4ICg2RCGXHZDQCIU
              aPBVMNYkBgZkSCQ2lgSDAWGfZwd2HAJ4fX6AGg9sggGLhiUPBZ
              CNJZMaEQA7}

     set yellow {R0lGODlhFAAPAPMPAAAAADExBD09Kk5OAmtrDFNTKmxsWIm
                 JFLCwM5mZJaCgUsXFONPTUvb2ceXlWKennCH5BAEAAAAALA
                 AAAAAUAA8AAARqEMgpX1Lq0U3t+QdBaNz0HAmyIEk4kNyZL
                 I7DMC3xlsqBOI0gA+EylAgpoJCoK8QIPkbQxhwEjqjFbZgQ
                 WY/QFILlClw5hoEI5LUaSwO1SBc3wzaPgCC+NwfuMX5+AoA
                 lAA8GBQaFho0UEQA7}

     set green {R0lGODlhFAAPAPQAAAAAAAA4BwBNCgBqEgBzE0ZtTACSEwCl
                FgqzJj+dTADHIQ/SKRzVOyv0RUf/bH+qgwAAAAAAAAAAAAAA
                AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
                ACH5BAEAABAALAAAAAAUAA8AAAV2ICSO4pOcD6mSD3K8h0Gk
                6/gc0MIsSjzQq5uC0SgyXAMBkJQ4LBqOaGPhK9QMB2LU0WD4
                CEHsczs9EAaB2uCAIBoRhmR6RcAiFnj4WTBXJQYGWDEyclY1
                AgMDBIuJfAFLLAKIjY6QKg98kgGbljUPBaCdNaMqIQA7}
     
     set blue {R0lGODlhFAAPALMAAAAAAA8FOBACTRgDaicTc11ZbSsSki8Sp
               UQos2danVIz0nRU9F5A1T4bx5Ry/56cqiH5BAEAAAAALAAAAA
               AUAA8AAwRwEMgpX7qPavrQ+YdBZNv0HIDCKE04kNvZMEvNeIM
               AU8mhLI7gQuEqlAwHWtCxYLgIMeRvOTwQBoHS4ICg2RCGXHZD
               QCIUaPBVMNYkBgZkSCQ2lgSDAWGfZwd2HAJ4fX6AGg9sggGLh
               iUPBZCNJZMaEQA7}

     foreach color { red yellow green blue } {
        set fn  [ file join $where ball_${color}.gif ]
        set fid [ open $fn w ]
        fconfigure $fid -translation binary
        regsub -all {\s} [ set $color ] {} data
        puts -nonewline $fid [ ::base64::decode $data]
        close $fid
     }
 }
 ## ********************************************************

 # Test:
 gifBalls "."

gold added inline pix gifBalls pix png