proc extractColor {color} {
if {[scan $color "#%2x%2x%2x" red blue green] == 3} {
return [list $red $blue $green]
}
return {}
}
# puts [extractColor #1A3FAB]
proc packColor {red blue green} {
return [format "#%2x%2x%2x" $red $blue $green]
}
# puts [packColor 255 255 255]
proc calcColor {r g b brightPnc} {
return [list [expr round($r * ($brightPnc / 100.0) * 0.3) % 255] \
[expr round($g * ($brightPnc / 100.0) * 0.59) % 255] \
[expr round($b * ($brightPnc / 100.0) * 0.11) % 255]]
}
# puts [packColor {*}[calcColor {*}[extractColor "#66AC2E"] 30]]