#!/usr/bin/wish source color_model label .l -width 20 -height 10 pack .l bind .l [list OnMotion %x %y] bind .l [list .l configure -bg black] bind .l ShowOff focus .l set pi2 [expr atan2(1, 0) * 4] #================================================================= proc OnMotion { x y } { global pi2 set x [expr double($x)/[winfo width .l]*2 - 1] set y [expr 1 - double($y)/[winfo height .l]*2] set th [expr atan2($y, $x) / $pi2] if {$th < 0} { set th [expr $th + 1] } set r [expr sqrt($x*$x + $y*$y)] if {$r > 1} { set r 1 } .l configure -bg [HSBtoSTR $th $r 255] } proc ShowOff {} { set n 24 for {set i 0} {$i < $n} {incr i} { .l configure -bg [HSBtoSTR [expr double($i)/$n] 1 255] update idletasks after 50 } }