set PI 3.14159265358979323846
set twoPI 6.2831853071795864769
set halfPI 1.57079632679489661923

proc maximum {a b} {
    return [expr $a>$b?$a:$b]
}

proc minimum {a b} {
    return [expr $a<$b?$a:$b]
}

proc boolean {string} {
    # ignore case
    set n [string tolower $string]
    return [expr {($n!=0)||($n=="true")||($n=="on")||($n=="yes")}]
}

proc objectWidgetName {class id {parentWidget .}} {
    # build a unique widget name with class name and object id and append it to parent widget name (handle main widget special case)
    return [expr ("$parentWidget"=="."?".":"${parentWidget}.")]$class$id
}

proc llast {l} {
    return [lindex $l [expr [llength $l]-1]]
}

proc showWholeCanvas {canvas} {
    set extent [$canvas bbox all]
    set left [expr [lindex $extent 0]-1]
    set top [expr [lindex $extent 1]-1]
    set right [expr [lindex $extent 2]+1]
    set bottom [expr [lindex $extent 3]+1]
    $canvas configure -scrollregion [list $left $top $right $bottom] -width [expr $right-$left] -height [expr $bottom-$top]
}
