1 #!/usr/bin/env gsi-script
5 ; Copyright (c) 1997-2007 by Marc Feeley, All Rights Reserved.
7 ; Translation into Scheme of Figure 16.12 from Chapter 16 of John
8 ; Ousterhout's "Tcl and the Tk Toolkit".
10 (include "tcltk#.scm") ; import Tcl/Tk procedures and variables
14 (define (new-color value)
16 (define (get-number widget)
17 (string->number (tcl widget 'get)))
20 (number->string (+ (expt 2 24)
21 (* (expt 2 16) (get-number ".red"))
22 (* (expt 2 8) (get-number ".green"))
25 (string-set! color-code 0 #\#)
26 (tcl ".sample" 'configure background: color-code)))
52 (frame ".sample" height: "1.5c" width: "6c")
54 (pack ".red" ".green" ".blue" side: 'top)
56 (pack ".sample" side: 'bottom pady: "2m")
59 ; ==> Equivalent program in pure Tcl/Tk:
61 ; scale .red -label Red -from 0 -to 255 -length 10c \
62 ; -orient horizontal -command newColor
63 ; scale .green -label Green -from 0 -to 255 -length 10c \
64 ; -orient horizontal -command newColor
65 ; scale .blue -label Blue -from 0 -to 255 -length 10c \
66 ; -orient horizontal -command newColor
67 ; frame .sample -height 1.5c -width 6c
68 ; pack .red .green .blue -side top
69 ; pack .sample -side bottom -pady 2m
71 ; proc newColor value {
72 ; set color [format #%02x%02x%02x [.red get] [.green get] [.blue get]]
73 ; .sample configure -background $color