Version 2 of counterclock

Updated 2005-05-19 21:28:42

if 0 {Richard Suchenwirth 2005-05-19 - Mathematicians are well aware of the importance of counterclockwise orientation. For the rest of us, who wonder how it looks like, here's a counterclock, strongly based on a little A-D clock :)

http://mini.net/files/counterclock.gif }

 proc main {} {
    pack [canvas .c -width 100 -height 100]
    for {set i 1} {$i<13} {incr i} {
        set a [expr {(180+$i*30)/180.*acos(-1)}]
        set x [expr {50 + 43 * sin($a)}]
        set y [expr {50 + 43 * cos($a)}]
        .c create text $x $y -text $i
    }
    every 1000 {drawhands .c 50 50}
 }
 proc drawhands {w xm ym} {
     $w delete hands
     set secSinceMidnight [expr {[clock seconds] - [clock scan 00:00:00]}]
     foreach divisor {60 3600 43200} length {40 35 30} width {1 2 3} {
         set angle [expr {$secSinceMidnight * -2 *acos(-1) / $divisor}]
         set x [expr {$xm + $length * sin($angle)}]
         set y [expr {$ym - $length * cos($angle)}]
         $w create line $xm $ym $x $y -width $width -tags hands
     }
 }
 proc every {ms body} {eval $body; after $ms [info level 0]}

 main

Category Toys - Arts and crafts of Tcl-Tk programming