# colorBox.tcl (wiki version) # Version 0.2 # inspired by the book 'Effektiv Tcl/Tk programmieren'. Used their code to begin the project. # Mark Harrison, DSC Communications Corp. # Michael McLennan, Bell Labs Innovations for Lucent Technologies # based on informationen from http://de.wikipedia.org/wiki/HSV-Farbraum # Names: # HE = Holger Ewert # EH = Eric Hassold # RS = Richard Suchenwirth # Histo: # Version 0.0 started at 22.02.2006 # Version 0.1 started at 14.03.2006 # HE: removed array ::he::dialog::colors and procedure ::he::dialog::colorname2color # RS shows me a way to avoid them. # Version 0.2 started at 17.03.2006 # HE: Bugfix (found by EH): checkAndSetInitialcolor used fixed colorname. Fixed. # Put all expr expression inside of {} # Function: # A color chooser (a replacement for tk_chooseColor) namespace eval ::he::dialog { variable colordialog array set colordialog " c00 #000019 c01 #000033 c02 #00004c c03 #000066 c04 #00007f c05 #000099 c06 #0000b2 c07 #0000cc c08 #0000e5 c09 #0000ff c10 #001900 c11 #003300 c12 #004c00 c13 #006600 c14 #007f00 c15 #009900 c16 #00b200 c17 #00cc00 c18 #00e500 c19 #00ff00 c20 #190000 c21 #330000 c22 #4c0000 c23 #660000 c24 #7f0000 c25 #990000 c26 #b20000 c27 #cc0000 c28 #e50000 c29 #ff0000 c30 #191919 c31 #333333 c32 #4c4c4c c33 #666666 c34 #7f7f7f c35 #999999 c36 #b2b2b2 c37 #cccccc c38 #e5e5e5 c39 #ffffff " package require msgcat namespace import ::msgcat::mc } # de.msg namespace eval ::he::dialog { msgcat::mcmset de " {Color} {Farbe} {Bad option %1\$s:} {Falscher Parameter: %1\$s:} {Must be -initialcolor, -parent, or -title .} {Erlaubt: -initialcolor, -parent, oder -title .} {Bad window path name %1\$s} {Fenster %1\$s existiert nicht.} {Ok} {OK} {Cancel} {Abbrechen} {Add color} {Farbe hinzufügen} {Red} {Rot} {Green} {Grün} {Blue} {Blau} {Hue} {Farbt.} {Sat.} {Sätt.} {Bright.} {Hell.} " } # en.msg namespace eval ::he::dialog { msgcat::mcmset en " {Color} {Color} {Bad option %1\$s:} {Bad option %1\$s:} {Must be -initialcolor, -parent, or -title.} {Must be -initialcolor, -parent, or -title.} {Bad window path name %1\$s} {Bad window path name %1\$s} {Ok} {Ok} {Cancel} {Cancel} {Add color} {Add color} {Red} {Red} {Green} {Green} {Blue} {Blue} {Hue} {Hue} {Sat.} {Sat.} {Bright.} {Bright.} " } proc ::he::dialog::windowFit {top} { if {$::tcl_platform(os) eq {Windows CE}} { if {[info exists ::etcl::etcl]} { bind $top <ConfigureRequest> {::etcl::autofit %W} bind $top <Expose> {::etcl::autofit %W} ::etcl::autofit $top } else { wm geometry $top 240x[expr {320 - 51}]+0+0 } } else { wm geometry $top 240x[expr {320 - 51}]+[expr {[winfo pointerx .] - 120}]+[expr {[winfo pointery .] - 135}] } return } proc ::he::dialog::colordialog {args} { variable colordialog set colordialog(-initialcolor) #408080 set colordialog(-parent) {.} set colordialog(-title) [mc "Color"] # First we check the parameter foreach {para value} $args { switch -exact -- $para { -initialcolor { colordialog_checkAndSetInitialcolor $value } -parent { if {![winfo exists $value]} { error [mc "Bad window path name %1\$s" $value] } set colordialog(-parent) $value } -title { set colordialog(-title) $value } default { error "[mc "Bad option %1\$s." $value] [mc "Must be -initialcolor, -parent, or -title ."]" } } } scan $colordialog(-initialcolor) "#%2x%2x%2x" colordialog(red) colordialog(green) colordialog(blue) colordialog_set_hsb # create the windowname for the dialogbox if {$colordialog(-parent) eq {.}} { set colordialog(w) ._colordialog } else { set colordialog(w) [set colordialog(-parent)]._colordialog } set w $colordialog(w) if {[winfo exists $w]} { colordialog_destroy } colordialog_create set colordialog(selected) {} vwait ::he::dialog::colordialog(selected) return $colordialog(selected) } proc ::he::dialog::colordialog_create {} { variable dir variable colordialog set w $colordialog(w) toplevel $w -class colordialog wm protocol $w WM_DELETE_WINDOW ::he::dialog::colordialog_cancel wm minsize $w 216 65 ;#220 wm maxsize $w 240 [expr {320 - 52}] wm title $w $colordialog(-title) frame $w.e ;# frame with the entries frame $w.c ;# frame with HSB-chooser frame $w.c.s ;# frame with the user defined colors frame $w.b ;# frame with buttons # frame with HSB-chooser canvas $w.c.dial frame $w.c.sample -width 10 -height 101 grid $w.c.dial -row 0 -column 0 grid $w.c.sample -row 0 -column 1 grid $w.c.s -row 1 -column 0 -columnspan 2 grid rowconfigure $w.c 0 -weight 0 grid rowconfigure $w.c 1 -weight 1 grid columnconfigure $w.c 0 -weight 1 grid columnconfigure $w.c 1 -weight 0 # frame with the entries label $w.e.lr -text "[mc "Red"]:" label $w.e.lg -text "[mc "Green"]:" label $w.e.lb -text "[mc "Blue"]:" label $w.e.lh -text "[mc "Hue"]:" label $w.e.ls -text "[mc "Sat."]:" label $w.e.lv -text "[mc "Bright."]:" entry $w.e.er -width 5 -validate all -vcmd {::he::dialog::colordialog_vcmdRGB %P %V red} entry $w.e.eg -width 5 -validate all -vcmd {::he::dialog::colordialog_vcmdRGB %P %V green} entry $w.e.eb -width 5 -validate all -vcmd {::he::dialog::colordialog_vcmdRGB %P %V blue} entry $w.e.eh -width 5 -validate all -vcmd {::he::dialog::colordialog_vcmdH %P %V} entry $w.e.es -width 5 -validate all -vcmd {::he::dialog::colordialog_vcmdS %P %V} entry $w.e.ev -width 5 -validate all -vcmd {::he::dialog::colordialog_vcmdB %P %V} .e.ev -width 5 -validate all -vcmd {::he::dialog::colordialog_vcmdB %P %V} grid configure $w.e.lr -column 0 -row 0 grid configure $w.e.lg -column 2 -row 0 grid configure $w.e.lb -column 4 -row 0 grid configure $w.e.lh -column 0 -row 1 grid configure $w.e.ls -column 2 -row 1 grid configure $w.e.lv -column 4 -row 1 grid configure $w.e.er -column 1 -row 0 grid configure $w.e.eg -column 3 -row 0 grid configure $w.e.eb -column 5 -row 0 grid configure $w.e.eh -column 1 -row 1 grid configure $w.e.es -column 3 -row 1 grid configure $w.e.ev -column 5 -row 1 $w.c.dial create image 5 5 -anchor nw -image $colordialog(img_hs) -tags hsmap $w.c.dial create image 190 5 -anchor nw -image $colordialog(img_v) -tags bmap $w.c.dial create oval 0 0 5 5 -fill black -tags hsval -width 3 -fill {} $w.c.dial create line 189 5 201 5 -fill black -tags bval -width 3 $w.c.dial configure -width 201 -height 107 $w.c.dial bind hsmap <1> "::he::dialog::colordialog_set_hs %x %y" $w.c.dial bind hsmap <B1-Motion> "::he::dialog::colordialog_set_hs %x %y" $w.c.dial bind bmap <1> "::he::dialog::colordialog_set_b %y" $w.c.dial bind bmap <B1-Motion> "::he::dialog::colordialog_set_b %y" # frame with the user defined colors for {set n 0} {$n <= 3} {incr n} { for {set m 0} {$m <= 9} {incr m} { radiobutton $w.c.s.c$n$m \ -indicatoron 0 \ -bg $colordialog(c$n$m) \ -selectcolor $colordialog(c$n$m) \ -value c$n$m \ -variable ::he::dialog::colordialog(c) \ -width 2 \ -command "::he::dialog::colordialog_sel $w.c.s.c$n$m" grid configure $w.c.s.c$n$m -row $n -column $m } } } # frame with buttons button $w.b.ok -text [mc "Ok"] -command ::he::dialog::colordialog_ok button $w.b.cancel -text [mc "Cancel"] -command ::he::dialog::colordialog_cancel button $w.b.add -text [mc "Add color"] -command ::he::dialog::colordialog_add pack $w.b.ok $w.b.cancel -side left pack $w.b.add -side right # Frames darstellen grid configure $w.e -row 0 -sticky nsew grid configure $w.c -row 1 -sticky ew grid configure $w.b -row 2 -sticky nsew grid rowconfigure $w {0 2} -weight 0 grid rowconfigure $w 1 -weight 1 colordialog_refresh windowFit $w grab set $w return } proc ::he::dialog::colordialog_checkAndSetInitialcolor {value} { variable colordialog foreach {r g b} [winfo rgb . $value] break set colordialog(-initialcolor) [format "#%02x%02x%02x" [expr {$r/256}] [expr {$g/256}] [expr {$b/256}]] return } proc ::he::dialog::colordialog_refresh {} { variable colordialog set w $colordialog(w) set h $colordialog(hue) set s $colordialog(saturation) if {$h eq {}} { set h 180 } set x0 [expr {($h / 2) + 5}] set y0 [expr {(100 - $s) + 5}] $w.c.dial coords hsval [expr {$x0-4}] [expr {$y0-4}] [expr {$x0+4}] [expr {$y0+4}] set b $colordialog(brightness) set y1 [expr {(100 - $b) + 5}] $w.c.dial coords bval 189 $y1 201 $y1 $w.c.sample configure -background [colordialog_hsb2rgb1 $colordialog(hue) $colordialog(saturation) $colordialog(brightness)] foreach {win index} [list $w.e.er red $w.e.eg green $w.e.eb blue $w.e.eh hue $w.e.es saturation $w.e.ev brightness] { $win configure -validate none $win delete 0 end $win insert end $colordialog($index) $win configure -validate all } return } proc ::he::dialog::colordialog_vcmdRGB {value type name2} { variable colordialog set state 0 switch -exact -- $type { key { if {($value >= 0 && $value <= 255) || ($value eq {})} { set state 1 } } focusout { if {($value >= 0 && $value <= 255)} { set colordialog($name2) $value set state 1 } if {$value ne {}} { puts "A2 $value $type $name2";update colordialog_set_hsb } colordialog_refresh } } return $state } proc ::he::dialog::colordialog_vcmdH {value type} { variable colordialog set state 0 switch -exact -- $type { key { if {($value >= 0 && $value <= 359) || ($value eq {})} { set state 1 } } focusout { if {$value >= 0 && $value <= 359} { set colordialog(hue) $value set state 1 colordialog_set_rgb } elseif {$value eq {}} { set colordialog(hue) $value set colordialog(saturation) 0 set state 1 colordialog_set_rgb } colordialog_refresh } } return $state } proc ::he::dialog::colordialog_vcmdS {value type} { variable colordialog set state 0 switch -exact -- $type { key { if {($value >= 0 && $value <= 100) || ($value eq {})} { set state 1 } } focusout { if {($value >= 0 && $value <= 100)} { set colordialog(saturation) $value set state 1 } if {$value ne {}} { if {$colordialog(hue) eq {}} { set colordialog(hue) 0 } colordialog_set_rgb } colordialog_refresh } } return $state } proc ::he::dialog::colordialog_vcmdB {value type} { variable colordialog set state 0 switch -exact -- $type { key { if {($value >= 0 && $value <= 100) || ($value eq {})} { set state 1 } } focusout { if {($value >= 0 && $value <= 100)} { set colordialog(hue) $value set state 1 } if {$value ne {}} { colordialog_set_rgb } colordialog_refresh } } return $state } proc ::he::dialog::colordialog_destroy {} { variable colordialog grab release $colordialog(w) destroy $colordialog(w) return } # command of ok button proc ::he::dialog::colordialog_ok {} { variable colordialog set colordialog(selected) [format "#%02x%02x%02x" $colordialog(red) $colordialog(green) $colordialog(blue)] colordialog_destroy return } # command of cancel button proc ::he::dialog::colordialog_cancel {} { variable colordialog set colordialog(selected) {} colordialog_destroy return } # add user defined color proc ::he::dialog::colordialog_add {} { variable colordialog if {$colordialog(c) eq {}} { tk_messageBox -icon error -type ok -message "No color button selcted!" return } set w $colordialog(w) set color [$w.c.sample cget -background] set colordialog($colordialog(c)) $color $w.c.s.$colordialog(c) configure -bg $color -selectcolor $color return } # choose user defined color proc ::he::dialog::colordialog_sel {win} { variable colordialog set color [$win cget -background] scan $color "#%2x%2x%2x" colordialog(red) colordialog(green) colordialog(blue) colordialog_set_hsb colordialog_refresh return } # calculate Brightness from y-coordinate proc ::he::dialog::colordialog_set_b {y} { variable colordialog if {$y < 5} { set y 5 } elseif {$y > 105} { set y 105 } set colordialog(brightness) [expr {100 - ($y - 5)}] colordialog_set_rgb colordialog_refresh return } # calculate hue and saturation from x- and y-coordinate proc ::he::dialog::colordialog_set_hs {x y} { variable colordialog if {$y < 5} { set y 5 } elseif {$y > 105} { set y 105 } if {$x < 5} { set x 5 } elseif {$x > 184} { set x 184 } set colordialog(hue) [expr {($x - 5) * 2}] set colordialog(saturation) [expr {100 - ($y - 5)}] colordialog_set_rgb colordialog_refresh return } proc ::he::dialog::colordialog_set_rgb {} { variable colordialog set rgb [colordialog_hsb2rgb $colordialog(hue) $colordialog(saturation) $colordialog(brightness)] set colordialog(red) [lindex $rgb 0] set colordialog(green) [lindex $rgb 1] set colordialog(blue) [lindex $rgb 2] return } proc ::he::dialog::colordialog_set_hsb {} { variable colordialog set hsb [colordialog_rgb2hsb $colordialog(red) $colordialog(green) $colordialog(blue)] set colordialog(hue) [lindex $hsb 0] set colordialog(saturation) [lindex $hsb 1] set colordialog(brightness) [lindex $hsb 2] return } proc ::he::dialog::colordialog_hsb2rgb {h s v} { set s [expr {$s / 100.0}] set v [expr {$v / 100.0}] if {$s == 0} { set v [expr {round(255*$v)}] set r $v set g $v set b $v } else { set hi [expr {fmod(floor($h / 60.0), 6)}] set f [expr {$h / 60.0 - $hi}] set p [expr {round(255 * $v * (1.0 - $s))}] set q [expr {round(255 * $v * (1.0 - $s * $f))}] set t [expr {round(255 * $v * (1.0 - $s * (1.0 - $f)))}] set v [expr {round(255 * $v)}] switch [expr {int($hi)}] { 0 {set r $v; set g $t; set b $p} 1 {set r $q; set g $v; set b $p} 2 {set r $p; set g $v; set b $t} 3 {set r $p; set g $q; set b $v} 4 {set r $t; set g $p; set b $v} 5 {set r $v; set g $p; set b $q} } } return [list $r $g $b] } proc ::he::dialog::colordialog_hsb2rgb1 {h s v} { variable colordialog set rgb [colordialog_hsb2rgb $h $s $v] return [format "#%02x%02x%02x" [lindex $rgb 0] [lindex $rgb 1] [lindex $rgb 2]] } proc ::he::dialog::colordialog_rgb2hsb {r g b} { variable colordialog if {$r == 0 && $g == 0 && $b == 0} { set h 0 set s 0 set v 0 } else { set r [expr {$r / 255.0}] set g [expr {$g / 255.0}] set b [expr {$b / 255.0}] set l [list $r $g $b] set max [lindex [lsort -real $l] end] set min [lindex [lsort -real $l] 0] set maxColor [lindex [lindex [lsort -index 0 -real [list [list $r r] [list $g g] [list $b b]]] end] 1] set maxColor [lindex [lindex [lsort -index 0 -real [list [list $r r] [list $g g] [list $b b]]] end] 1] set s [expr {int(($max - $min) / $max * 100)}] set v [expr {int($max * 100)}] if {$s == 0} { set h {} } else { switch -exact -- $maxColor { r { set h [expr {int((0.0 + ($g - $b) / ($max - $min)) * 60)}] } g { set h [expr {int((2.0 + ($b - $r) / ($max - $min)) * 60)}] } b { set h [expr {int((4.0 + ($r - $g) / ($max - $min)) * 60)}] } } if {$h < 0} { set h [expr {$h + 360}] } } } return [list $h $s $v] } set ::he::dialog::colordialog(img_hs) [image create photo -data { R0lGODlhtQBlAPcAAAAAAIAAAACAAICAAAAAgIAAgACAgICAgMDAwP8AAAD/ AP//AAAA//8A/wD//////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAA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sqPNbGlXm9m+PTa2hXvs5HKb2d1WrrfFHW5yg9vczJbu sdNt3WNzt93Mdrd33z1vedc73veGd76P/Wr0xprPmqawcPBpfWuCK9fTom4u r928aF/3OtioRvWqzzvxYrv42da+OLU1nnGOTzvb1wb5uM8t8m+XnOQnLze6 9W3vleOb3i5n+cuZrdh9F9vftu1zwAG9c07b2ucHz/WnSb3whv8azt2FOIrx TPFW85vZT4d61KU+dapX3epXx3rWtb51rnc96zRHNrTBjnGPl13a2j57yLe9 dm2PPOUodzu41z13lat75euGed5bPvOVgx3sXgd84AU/eMIX3vB+33jYpT32 xKf92WhXu+PJ3Xa1g5vyKF+33E3Obs7jve719rzMa05vsMe79Hw3fOpVv3rW t57qAQEAOw== }] set ::he::dialog::colordialog(img_v) [image create photo -data { R0lGODlhCgBlAPcAAP////z8/Pr6+vf39/X19fLy8vDw8O3t7evr6+jo6Obm 5uPj4+Dg4N7e3tvb29nZ2dbW1tTU1NHR0c/Pz8zMzMnJycfHx8TExMLCwr+/ v729vbq6uri4uLW1tbOzs7CwsK2traurq6ioqKampqOjo6GhoZ6enpycnJmZ mZaWlpSUlJGRkY+Pj4yMjIqKioeHh4WFhYKCgoCAgH19fXp6enh4eHV1dXNz c3BwcG5ubmtra2lpaWZmZmNjY2FhYV5eXlxcXFlZWVdXV1RUVFJSUk9PT01N TUpKSkdHR0VFRUJCQkBAQD09PTs7Ozg4ODY2NjMzMzAwMC4uLisrKykpKSYm JiQkJCEhIR8fHxwcHBoaGhcXFxQUFBISEg8PDw0NDQoKCggICAUFBQMDAwAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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AA7 }]
RS: "There is no way"? Look at this:-)
% winfo rgb . yellowgreen 39578 52685 12850 % foreach {r g b} [winfo rgb . yellowgreen] break % format #%02x%02x%02x [expr {$r/256}] [expr {$g/256}] [expr {$b/256}] #9acd32HE Thank you! Have this command completely forget. Changed it above. Know the file size is more pocketPC like :-)
EH Let's make the file size even smaller, but also display a truecolor Hue-Saturation palette instead of the dithered GIF one, and last but not least, allow the dialog to be resizable. This code replace the inlined images by dynamic ones, generated on the fly. Let's add a binding to <Configure> to have the dialog regenerate the images, and now this dialog will also display fine on true-VGA (640x480) PDA. HE Very good idea. I have tried an own solution in the very beginning. I tested your solution but got the same result. Calculating an truecolor palette creates two problems (at least on my pocketPCs):
- I test it on two packetPC. The first try on an pda with windows mobile 2003 se: the truecolor Hue-Saturation palette looks ugly. The second try on windows mobile 5.0 looks great. I think it depends on the quality of the display. To use the code on both pocketPCs I need to use the gifs :-(
- The startup time grows unacceptable for me on both pocketPC (+15 - +20 seconds). This is also a reason to use the gifs :-(
$w.c.dial bind hsmap <1> "::he::dialog::colordialog_set_hs %x %y" $w.c.dial bind hsmap <B1-Motion> "::he::dialog::colordialog_set_hs %x %y" $w.c.dial bind bmap <1> "::he::dialog::colordialog_set_b %y" $w.c.dial bind bmap <B1-Motion> "::he::dialog::colordialog_set_b %y"By the way. We need not only a binding to <Configure> to make the dialog resizable. colordialog_set_hs and colordialog_set_b are based on the geometry of the pictures. Changing this geometry needs changing this procs.EH Some other comments:
- I suggest to add {} around your expr, especially in hsb2rgb/rgb2hsb procedures. This make a huge difference in performance (and since the dynamic image generator use them for each pixel...). HE I changed it in the code above. Testing the procedures shows great performance. But on my acer n50 it doesn't look faster :-(
- In checkAndSetInitialColor, you left the "yellowgreen" value given by Richard as an example. It should be $value instead. Actually, the whole procedure is useless, since winfo rgb parse all valid color formats, so it should be: HE Fixed it in the code above and deleted it below.
- Not specific to this dialog, but more generally to eTcl on PocketPC: ::etcl::autofit should be bind to <Expose> event too (together with <ConfigureRequest>). This is because if SIP state change when eTcl doesn't have the focus, it won't notice it. Not that important, but better. (I really have to release some documentation soon. Shame on me!). HEThanks for the hint. Added it (Added it in Alternative dialogs for pocketPC/etcl too).
# Generate a vertical gradient proc ::he::dialog::vgradient {width height} { set c0 0xff set c1 0x00 set img [image create photo -width $width -height $height] if {$width<=0 || $height<=0} { return $img } for {set y 0} {$y<$height} {incr y} { if {$height<=1} { set gs $c0 } else { set gs [expr {$c0+(($c1-$c0)*$y)/($height-1)}] } set color [format "#%02x%02x%02x" $gs $gs $gs] $img put [list [list $color]] -to 0 $y $width [expr {$y+1}] } return $img } # Generate Hue-Saturation map proc ::he::dialog::hsmap {reqwidth reqheight {img ""}} { if {![string compare "" $img]} { set img [image create photo -width $reqwidth -height $reqheight] } else { $img configure -width $reqwidth -height $reqheight $img blank } if {$reqwidth<=0 || $reqheight<=0} { return $img } # Max brightness # set v 100.0 set v 255 # make code run $rx*$ry times faster. rx=ry=3 still produces a nice # map with no visible artefact, while taking lest than 0.2s on # an ipaq 4150 to generate a 180x100 image if {$::tcl_platform(os) eq {Windows CE}} { set rx 3 set ry 3 } else { set rx 1 set ry 1 } set width [expr {$reqwidth/$rx}] set height [expr {$reqheight/$ry}] set fmax [expr {$width/6}] set pixels [list] for {set y 0} {$y<$height} {incr y} { if {$height<=1} { set s 255 } else { set s [expr {(255*($height-1-$y))/($height-1)}] if {$s<=0} { set s 0 } } if {$s<=0} { # White for {set x 0} {$x<$width} {incr x} { lappend pixels 0xff 0xff 0xff } } else { set x 0 set p [expr {255-$s}] foreach h {0 1 2 3 4 5} { set f 0 set xmax [expr {(($h+1)*$width)/6}] while {$x<$xmax} { set q [expr {255-($s*$f)/$fmax}] set t [expr {255-($s*($fmax-$f))/$fmax}] if {$h==0} { lappend pixels $v $t $p } elseif {$h==1} { lappend pixels $q $v $p } elseif {$h==2} { lappend pixels $p $v $t } elseif {$h==3} { lappend pixels $p $q $v } elseif {$h==4} { lappend pixels $t $p $v } else { lappend pixels $v $p $q } incr x incr f } } } } set header "P6\n\# PPM data\n${width} ${height}\n255\n" append tkdata [binary format {a*c*} $header $pixels] if {$rx!=1 || $ry!=1} { set tmp [image create photo] $tmp put $tkdata -to 0 0 $width $height -format PPM $img copy $tmp -zoom $rx $ry -compositingrule set image delete $tmp } else { $img put $tkdata -to 0 0 $width $height -format PPM } return $img } set ::he::dialog::colordialog(img_hs) [::he::dialog::hsmap 181 100] set ::he::dialog::colordialog(img_v) [::he::dialog::vgradient 10 101]
2006-05-12 HE Some startup and file size improvements: Changing multiple 'set colordialog() ...' to one 'array set' and the multiple 'msgcat::mcset' to one 'msgcat::mcmset' for every locale.