One well-known symbol of the philosophy of duality known as yin and yang is the taijitu.



Task

   Create a function that, given a parameter representing size, generates such a symbol scaled to the requested size.
   Generate and display the symbol for two different (small) sizes.


link graphics
 
procedure main() 
YinYang(100)
YinYang(40,"blue","yellow","white")
WDone()  # quit on Q/q
end
 
procedure YinYang(R,lhs,rhs,bg)   # draw YinYang with radius of R pixels and ...
/lhs := "white"                   # left hand side 
/rhs := "black"                   # right hand side
/bg  := "grey"                    # background
 
wsize  := 2*(C := R + (margin := R/5))
 
W := WOpen("size="||wsize||","||wsize,"bg="||bg) | stop("Unable to open Window")
WAttrib(W,"fg="||lhs) & FillCircle(W,C,C,R,+dtor(90),dtor(180))        # main halves
WAttrib(W,"fg="||rhs) & FillCircle(W,C,C,R,-dtor(90),dtor(180))     
WAttrib(W,"fg="||lhs) & FillCircle(W,C,C+R/2,R/2,-dtor(90),dtor(180))  # sub halves
WAttrib(W,"fg="||rhs) & FillCircle(W,C,C-R/2,R/2,dtor(90),dtor(180))
WAttrib(W,"fg="||lhs) & FillCircle(W,C,C-R/2,R/8)                      # dots
WAttrib(W,"fg="||rhs) & FillCircle(W,C,C+R/2,R/8)
end