Update of /cvsroot/pure-data/pd/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14825
Modified Files: Tag: devel_0_39 desire.tk Log Message: adds some small codes to get complementary color for displaying the color names over the changing bg color
Index: desire.tk =================================================================== RCS file: /cvsroot/pure-data/pd/src/Attic/desire.tk,v retrieving revision 1.1.2.193 retrieving revision 1.1.2.194 diff -C2 -d -r1.1.2.193 -r1.1.2.194 *** desire.tk 26 Apr 2006 14:52:41 -0000 1.1.2.193 --- desire.tk 26 Apr 2006 15:32:04 -0000 1.1.2.194 *************** *** 3329,3334 **** global _ preset_colors set _($self:$name) $c .$self.$name configure \ ! -background [format #%6.6x $_($self:$name)] # somehow this hilites one more pixel outside of what it should be #-highlightbackground [format #%6.6x $_($self:$name)] --- 3329,3335 ---- global _ preset_colors set _($self:$name) $c + set fg_color [complement [format #%6.6x $c]] .$self.$name configure \ ! -background [format #%6.6x $_($self:$name)] -foreground $fg_color # somehow this hilites one more pixel outside of what it should be #-highlightbackground [format #%6.6x $_($self:$name)] *************** *** 3399,3403 **** #set c [expr $c & 0xFCFCFC] set c 0xFCFCFC ! button $f.color -text $look($name) -font {Courier 8} -width 10 -pady 2 \ -command [list iemgui_choose_col $w $name.color $look($name)] \ -relief sunken -background $look($name) \ --- 3400,3405 ---- #set c [expr $c & 0xFCFCFC] set c 0xFCFCFC ! set text_color [complement $look($name)] ! button $f.color -text $look($name) -font {Courier 8} -width 10 -pady 2 -fg $text_color \ -command [list iemgui_choose_col $w $name.color $look($name)] \ -relief sunken -background $look($name) \ *************** *** 3472,3483 **** }
- proc color_popup2 {frame init_color} { - set color [tk_chooseColor -initialcolor $init_color -title "Choose color"] - puts "color :: $color" - $frame.color_chooser configure -bg $color -activebackground $color - - }
############ .pdrc editor
proc dropmenu_set {frame name} { --- 3474,3512 ---- }
############ .pdrc editor + #Turns #rgb into 3 elem list of decimal vals. + proc rgb2dec c { + set c [string tolower $c] + if {[regexp -nocase {^#([0-9a-f])([0-9a-f])([0-9a-f])$} $c x r g b]} { + # double'ing the value make #9fc == #99ffcc + scan "$r$r $g$g $b$b" "%x %x %x" r g b + } else { + if {![regexp {^#([0-9a-f]+)$} $c junk hex] || \ + [set len [string length $hex]]>12 || $len%3 != 0} { + if {[catch {winfo rgb . $c} rgb]} { + return -code error "bad color value "$c"" + } else { + return $rgb + } + } + set len [expr {$len/3}] + scan $hex "%${len}x%${len}x%${len}x" r g b + } + return [list $r $g $b] + } + #Returns a complementary color + proc complement {orig {grays 1}} { + foreach {r g b} [rgb2dec $orig] {break} + set R [expr {(~$r)%256}] + set G [expr {(~$g)%256}] + set B [expr {(~$b)%256}] + if {$grays && abs($R-$r) < 32 && abs($G-$g) < 32 && abs($B-$b) < 32} { + set R [expr {($r+128)%256}] + set G [expr {($g+128)%256}] + set B [expr {($b+128)%256}] + } + return [format "#%02x%02x%02x" $R $G $B] + }
proc dropmenu_set {frame name} {