tkpath - clock

Here is a sample conversion of the analog clock An analog clock in Tk by wdb to show the effects of tkpath's anti-aliasing https://web.archive.org/web/20070208072732/tclbuzz.com/imgmisc/side-by-side-clocks.gif

Modified code, sorry you'll have to go fetch the binary from sourceforge and note the required files (only 2). See tkpath

APE 04-01-2020 : update example

package require Tk

# DEMO CONVERSION OF excellent analog clock by
# Wolf-Dieter Busch, "wdb" on the tcl wiki
# -Roy Terry 22Dec06


eval destroy [winfo child .]

set TKPATH 1
if {$TKPATH && $tcl_platform(platform) eq "windows"} {
    # NEED TO FIXUP PACKAGE CODE
    package require tkpath
    set ::tkpath::antialias 1

    set WIDTH strokewidth
    set FILL  stroke
    set LITEM pline

    tkp::canvas .uhr -width 200 -height 200 -highlightthickness 0

} else {
    set WIDTH width
    set FILL  fill
    set LITEM line

    canvas .uhr -width 200 -height 200 -highlightthickness 0

}

wm geometry .  +[expr {[winfo screenwidth .]-[winfo reqwidth .]}]+0

pack .uhr
bind .uhr <Double-Button-1> {
    if {[expr {![wm overrideredirect .]}]} {
        wm overrideredirect . yes
        # .uhr configure -background SystemBackground
    } else {
        wm overrideredirect . no
        # .uhr configure -background SystemButtonFace
    }
}

set PI [expr {asin(1)*2}]
set sekundenzeigerlaenge 85
set minutenzeigerlaenge  75
set stundenzeigerlaenge  60

proc drawClock {} {
    global PI
    global sekundenzeigerlaenge
    global minutenzeigerlaenge
    global stundenzeigerlaenge
    set aussenradius 95.0
    set innenradius  83.0
    # Ziffernblatt
    .uhr create oval 5 5 195 195 -fill white -outline ""
    # Zeiger
    .uhr create $::LITEM 100 100     [expr {100+$stundenzeigerlaenge}] 100 -tag stundenschatten
    .uhr create $::LITEM 100 100 100 [expr {100-$minutenzeigerlaenge}]     -tag minutenschatten
    .uhr create $::LITEM 100 100 100 [expr {100+$sekundenzeigerlaenge}]    -tag sekundenschatten
    .uhr create $::LITEM 100 100     [expr {100+$stundenzeigerlaenge}] 100 -tag {stundenzeiger zeiger}
    .uhr create $::LITEM 100 100 100 [expr {100-$minutenzeigerlaenge}]     -tag {minutenzeiger zeiger}
    .uhr create $::LITEM 100 100 100 [expr {100+$sekundenzeigerlaenge}]    -tag {sekundenzeiger zeiger}
    .uhr itemconfigure stundenzeiger    -$::WIDTH 8
    .uhr itemconfigure minutenzeiger    -$::WIDTH 4
    .uhr itemconfigure sekundenzeiger   -$::WIDTH 2 -$::FILL red
    .uhr itemconfigure stundenschatten  -$::WIDTH 8 -$::FILL gray
    .uhr itemconfigure minutenschatten  -$::WIDTH 4 -$::FILL gray
    .uhr itemconfigure sekundenschatten -$::WIDTH 2 -$::FILL gray
    # NO changes to wdb's code below this point
    # Ziffern
    for {set i 0} {$i < 60} {incr i} {
        set r0 [expr {$innenradius + 5}]
        set r1 [expr {$innenradius +10}]
        set x0 [expr {sin($PI/30*(30-$i))*$r0+100}]
        set y0 [expr {cos($PI/30*(30-$i))*$r0+100}]
        set x1 [expr {sin($PI/30*(30-$i))*$r1+100}]
        set y1 [expr {cos($PI/30*(30-$i))*$r1+100}]
        if {[expr {$i%5}]} {
        }
    }
    for {set i 0} {$i < 12} {incr i} {
        set x [expr {sin($PI/6*(6-$i))*$innenradius+100}]
        set y [expr {cos($PI/6*(6-$i))*$innenradius+100}]
        .uhr create text $x $y \
                -text [expr {$i ? $i : 12}] \
                -font {Helvetica 13 bold} \
                -fill #666666 \
                -tag ziffer
    }
    wm resizable . no no
}

proc stundenZeigerAuf {std} {
    global PI
    global stundenzeigerlaenge
    set x0 100
    set y0 100
    set dx [expr {sin ($PI/6*(6-$std))*$stundenzeigerlaenge}]
    set dy [expr {cos ($PI/6*(6-$std))*$stundenzeigerlaenge}]
    set x1 [expr {$x0 + $dx}]
    set y1 [expr {$y0 + $dy}]
    .uhr coords stundenzeiger $x0 $y0 $x1 $y1
    set schattenabstand 3
    set x0s [expr {$x0 + $schattenabstand}]
    set y0s [expr {$y0 + $schattenabstand}]
    set x1s [expr {$x1 + $schattenabstand}]
    set y1s [expr {$y1 + $schattenabstand}]
    .uhr coords stundenschatten $x0s $y0s $x1s $y1s
}

proc minutenZeigerAuf {min} {
    global PI
    global minutenzeigerlaenge
    set x0 100
    set y0 100
    set dx [expr {sin ($PI/30*(30-$min))*$minutenzeigerlaenge}]
    set dy [expr {cos ($PI/30*(30-$min))*$minutenzeigerlaenge}]
    set x1 [expr {$x0 + $dx}]
    set y1 [expr {$y0 + $dy}]
    .uhr coords minutenzeiger $x0 $y0 $x1 $y1
    set schattenabstand 4
    set x0s [expr {$x0 + $schattenabstand}]
    set y0s [expr {$y0 + $schattenabstand}]
    set x1s [expr {$x1 + $schattenabstand}]
    set y1s [expr {$y1 + $schattenabstand}]
    .uhr coords minutenschatten $x0s $y0s $x1s $y1s
}

proc sekundenZeigerAuf {sec} {
    global PI
    global sekundenzeigerlaenge
    set x0 100
    set y0 100
    set dx [expr {sin ($PI/30*(30-$sec))*$sekundenzeigerlaenge}]
    set dy [expr {cos ($PI/30*(30-$sec))*$sekundenzeigerlaenge}]
    set x1 [expr {$x0 + $dx}]
    set y1 [expr {$y0 + $dy}]
    .uhr coords sekundenzeiger $x0 $y0 $x1 $y1
    set schattenabstand 5
    set x0s [expr {$x0 + $schattenabstand}]
    set y0s [expr {$y0 + $schattenabstand}]
    set x1s [expr {$x1 + $schattenabstand}]
    set y1s [expr {$y1 + $schattenabstand}]
    .uhr coords sekundenschatten $x0s $y0s $x1s $y1s
}

proc showTime {} {
    after cancel showTime
    after 1000 showTime
    set secs [clock seconds]
    set l [clock format $secs -format {%H %M %S} ]
    wm title . [join $l :]
    set std [lindex $l 0]
    set min [lindex $l 1]
    set sec [lindex $l 2]
    regsub ^0 $std "" std
    regsub ^0 $min "" min
    regsub ^0 $sec "" sec
    set min [expr {$min + 1.0 * $sec/60}]
    set std [expr {$std + 1.0 * $min/60}]
    stundenZeigerAuf $std
    minutenZeigerAuf $min
    sekundenZeigerAuf $sec
}

drawClock
showTime