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.


INCLUDE "H6:REALMATH.ACT"
INCLUDE "D2:CIRCLE.ACT" ;from the Action! Tool Kit
 
PROC YinYang(INT x BYTE y BYTE r)
  INT i,a,b,rr,r2,rr2,r5,rr5,y1,y2
  REAL tmp1,tmp2
 
  Circle(x,y,r,1)
 
  rr=r*r
  r2=r/2 rr2=rr/4
  Color=1
  FOR i=0 TO r
  DO
    a=rr-i*i
    IntToReal(a,tmp1)
    Sqrt(tmp1,tmp2)
    a=RealToInt(tmp2)
 
    b=rr2-(i-r2)*(i-r2)
    IntToReal(b,tmp1)
    Sqrt(tmp1,tmp2)
    b=RealToInt(tmp2)
 
    Plot(x+b,y-i) DrawTo(x+a,y-i)
    Plot(x-b,y+i) DrawTo(x+a,y+i)
  OD
 
  r5=r/5
  rr5=rr/25
  y1=y-r2 y2=y+r2
  FOR i=0 TO r5
  DO
    a=rr5-i*i
    IntToReal(a,tmp1)
    Sqrt(tmp1,tmp2)
    a=RealToInt(tmp2)
 
    Color=1
    Plot(x-a,y1-i) DrawTo(x+a,y1-i)
    Plot(x-a,y1+i) DrawTo(x+a,y1+i)
 
    Color=0
    Plot(x-a,y2-i) DrawTo(x+a,y2-i)
    Plot(x-a,y2+i) DrawTo(x+a,y2+i)
  OD
RETURN
 
PROC Main()
  BYTE CH=$02FC,COLOR1=$02C5,COLOR2=$02C6
 
  Graphics(8+16)
  MathInit()
  COLOR1=$00
  COLOR2=$0F
 
  YinYang(180,120,60)
  YinYang(100,40,30)
 
  DO UNTIL CH#$FF OD
  CH=$FF
RETURN