import math,string

STEP=.25

class LightTree:
  def __init__(s,r):
    s.vals={}
    s.update(r)
  def update(s,rad):
    for ty in range(-rad,rad+1):
      for tx in range(-rad,rad+1):
        dist=math.sqrt(0.5+tx*tx+ty*ty)
        if dist<STEP: dist=STEP
        dx=tx/dist
        dy=ty/dist
        x=y=0.0
        path=[]
        d=0.0
        while d<dist:
          ix=int(round(x+dx*d))
          iy=int(round(y+dy*d))
          path.append( (ix,iy) )
          d=d+STEP
        print (tx,ty),dist
        if tx==4:
          print 'pos==',tx,ty
          print 'path==',path
          print 'zpath==',s.compress_path(path)
        s.vals[ (tx,ty) ]= ( dist,s.compress_path(path) )
  def compress_path(s,path):
    compressed=[]
    t=0
    for p in path:
      if len(compressed)==0 or p!=compressed[-1][0]:
        compressed.append( [ p, 0 ] )
      compressed[-1][-1] += 1
      t=t+1
    compressed=[t]+compressed
    return compressed
  def html(s):
    rv=[]
    rv.append("<html>")
    rv.append("<body>")
    l=[0,0,0,0]
    for x,y in s.vals.keys():
      l[0]=min(x,l[0])
      l[1]=min(y,l[1])
      l[2]=max(x,l[2])
      l[3]=max(y,l[3])
    rv.append('<table border="1">')
    for ty in range(l[1],l[3]+1):
      rv.append('  <tr>')
      for tx in range(l[0],l[2]+1):
        p=(tx,ty)
        v=s.vals[p][0]
        c=int(1.2*16/v)
        if c>15: c=15
        col='#%s'%( '0123456789abcdef'[c]*6 )
        rv.append('    <td bgcolor="%s">%s<br>%1.2f</td>'%(col,p,s.vals[p][0]))
        if p==(2,5):
          print "PATH==",s.vals[p]
      rv.append('  </tr>')
    rv.append('</table>')
    rv.append("</body>")
    rv.append("</html>")
    return rv


def main():
  tree=LightTree(6)
  print string.join(tree.html(),'\n')

if __name__=="__main__": main()
