#!/usr/local/bin/wish -f # xcmstest -- Simple program for exploring color spaces. # Copyright (c) 1995 by James F. Carter. May be distributed, modified and # sold without royalty so long as this copyright notice is kept in the source. # There is no warranty on this program and the author accepts no liability # for its use. # Written for tcl/tk 7.3/3.6pl1 (should work with any 3.x and with 7.4/4.0). # Requires X11R5 or X11R6 library in tk, and similar server. # Widget layout: # Panel in which color is displayed # Minimum Scale Maximum Multiplier (for component 0) # Minimum Scale Maximum Multiplier (for component 1) # Minimum Scale Maximum Multiplier (for component 2) # Colorsystem Color-readout Err Quit # Type the colorsystem name (rgbi, CIELuv, etc., but program doesn't do rgb) # in the Colorsystem entry (and press return). Put the minimum and maximum # scale values in their respective entries (and press return to get the scale # widget configured) -- e.g. 0 to 100 for rgbi and many others. Put a # multiplier in its entry widget; the scale value is multiplied by this, e.g # .01 for rgbi and similar components. Slide the scales and see what, if # anything, you get. If the color is invalid (e.g. L not in 0 to 1 or # 0 to 100), "Err" lights up in red. Press the Quit button to quit. # Remember to load the device color characterization data using xcmsdb -- # if you have it (see xcmsetup, same place you got xcmstest) and if certain # xlib bugs, that this program was written to explore, have been fixed. # Review of TK entry widget: Click in it to focus. BackSpace erases backward. # ^U clears the existing entry. ^V inserts the selection. Smear with the # mouse to select the content. # The main panel. option add *background gray . configure -background gray frame .panel -width 300 -height 300 pack propagate .panel 0 pack .panel # Color component scales and entries; see above for layout. foreach c {0 1 2} { frame .fr$c pack .fr$c -fill x -expand 1 -padx 4 set min$c 0 entry .fr$c.min -width 5 -textvariable min$c -relief sunken bind .fr$c.min "config $c" scale .fr$c.scl -orient horizontal -showvalue 1 -from 0 -to 100 \ -command "setcolor $c" set col$c 0 set max$c 100 entry .fr$c.max -width 5 -textvariable max$c -relief sunken bind .fr$c.max "config $c" set mpy$c .01 entry .fr$c.mpy -width 5 -textvariable mpy$c -relief sunken bind .fr$c.mpy "update" pack .fr$c.min -in .fr$c -side left pack .fr$c.mpy .fr$c.max -in .fr$c -side right pack .fr$c.scl -in .fr$c -side left -fill both -expand 1 } # Bottom row; see above for layout. frame .btm pack .btm -in . -side top -fill x -expand 1 -padx 4 set system CIExyz entry .btm.sys -width 7 -textvariable system -relief sunken bind .btm.sys update pack .btm.sys -in .btm -side left label .btm.err -width 3 -foreground red button .btm.quit -text Quit -command exit pack .btm.quit .btm.err -in .btm -side right label .btm.color pack .btm.color -in .btm -side left -fill x -expand 1 -padx 4 # Configure a scale with a new upper and lower limit. proc config {c} { global min$c max$c .fr$c.scl configure -from [set min$c] -to [set max$c] } # Scale action command; change a color variable and update the color. proc setcolor {c val} { global col$c set col$c $val update } # Update the color (chromatically in .panel and textually in .btm.color) # using the values in global variables col$c and the multipliers. proc update {} { global system foreach c {0 1 2} { global col$c mpy$c lappend cl [expr {[set col$c]*[set mpy$c]}] } set color $system:[join $cl /] .btm.color configure -text $color if {[catch ".panel configure -background $color"]} { set err ERR } else { set err {} } .btm.err configure -text $err } update ;#Start off with black.