
package require Tk
proc yinyang {w x0 y0 diameter {col1 black} {col2 white}} {
set xm [expr {$x0 + $diameter/2.}]
set ym [expr {$y0 + $diameter/2.}]
set x1 [expr {$x0 + $diameter}]
set y1 [expr {$y0 + $diameter}]
set y2 [expr {$ym - $diameter/4.}]
set y3 [expr {$ym + $diameter/4.}]
$w create arc $x0 $y0 $x1 $y1 -start 0 -extent 180 -fill $col1
$w create arc $x0 $y0 $x1 $y1 -start 180 -extent 180 -fill $col2
$w create arc $x0 $y2 $xm $y3 -start 0 -extent 180 -fill $col2 -outline $col2
$w create arc $xm $y2 $x1 $y3 -start 180 -extent 180 -fill $col1 -outline $col1
}
#-- Test and demo:
pack [canvas .c]
yinyang .c 20 20 100 red blueNot to nitpick.. but I'm going to nitpick:There should be a red circle in the middle of the blue and a blue circle in the middle of the red.. symbolizing that nothing is pure. Also the orientation of the slices is usually vertical not horizontal, see e.g.: http://en.wikipedia.org/wiki/Yin_yang


