summaryrefslogtreecommitdiffstats
path: root/library
diff options
context:
space:
mode:
authorfvogel <fvogelnew1@free.fr>2018-04-28 07:38:27 (GMT)
committerfvogel <fvogelnew1@free.fr>2018-04-28 07:38:27 (GMT)
commit68a7860a6edd28d88173b05e63c37949c94f91b7 (patch)
tree7ace9c06dd361e7895dc50124686ea37d883abb4 /library
parentbfb50ad11e3a58591619b861e38537e29980d8c0 (diff)
downloadtk-68a7860a6edd28d88173b05e63c37949c94f91b7.zip
tk-68a7860a6edd28d88173b05e63c37949c94f91b7.tar.gz
tk-68a7860a6edd28d88173b05e63c37949c94f91b7.tar.bz2
Fix [98c41cf3e7]: ::tk::Darken does not properly brighten colors
Diffstat (limited to 'library')
-rw-r--r--library/palette.tcl34
1 files changed, 17 insertions, 17 deletions
diff --git a/library/palette.tcl b/library/palette.tcl
index 9cecf5b..42c6a90 100644
--- a/library/palette.tcl
+++ b/library/palette.tcl
@@ -205,27 +205,27 @@ proc ::tk::RecolorTree {w colors} {
#
# Arguments:
# color - Name of starting color.
-# perecent - Integer telling how much to brighten or darken as a
+# percent - Integer telling how much to brighten or darken as a
# percent: 50 means darken by 50%, 110 means brighten
# by 10%.
proc ::tk::Darken {color percent} {
- foreach {red green blue} [winfo rgb . $color] {
- set red [expr {($red/256)*$percent/100}]
- set green [expr {($green/256)*$percent/100}]
- set blue [expr {($blue/256)*$percent/100}]
- break
- }
- if {$red > 255} {
- set red 255
- }
- if {$green > 255} {
- set green 255
- }
- if {$blue > 255} {
- set blue 255
- }
- return [format "#%02x%02x%02x" $red $green $blue]
+ if {$percent < 0} {
+ return #000000
+ } elseif {$percent > 200} {
+ return #ffffff
+ } elseif {$percent <= 100} {
+ lassign [winfo rgb . $color] r g b
+ set r [expr {($r/256)*$percent/100}]
+ set g [expr {($g/256)*$percent/100}]
+ set b [expr {($b/256)*$percent/100}]
+ } elseif {$percent > 100} {
+ lassign [winfo rgb . $color] r g b
+ set r [expr {255 - ((65535-$r)/256)*(200-$percent)/100}]
+ set g [expr {255 - ((65535-$g)/256)*(200-$percent)/100}]
+ set b [expr {255 - ((65535-$b)/256)*(200-$percent)/100}]
+ }
+ return [format #%02x%02x%02x $r $g $b]
}
# ::tk_bisque --