   context.fill()
   return      
   
-drawCells = (cells, viewMatrix, tessellation, context) ->
-  cells.forItems  (chain, value) ->
-    #console.log "Drawing #{showNode chain}"
-    mtx = M.mul viewMatrix, nodeMatrixRepr(chain, tessellation.group)
-    #console.log "Matrix is #{JSON.stringify mtx}"
-    h = nodeHash(chain)
-    #console.log "node #{showNode chain}, hash = #{h}"
-    context.fillStyle = colors[ ((h % colors.length) + colors.length) % colors.length]
-    tessellation.makeCellShapePoincare( mtx, context )
-    context.fill()
-
 mooreNeighborhood = (n, m, appendRewrite)->(chain)->
   #reutrns Moore (vertex) neighborhood of the cell.
   # it contains N cells of von Neumann neighborhood


    if Number.isNaN(m) or m <= 0
      throw new Error "Parameter M is bad"
    if 1/n + 1/m >= 1
      throw new Error "Tessellation {#{n}; #{m}} is not hyperbolic."

    setGridImpl n, m

    doReset()
    
  catch e
    alert "Failed to set grid parameters: #{e}"

setGridImpl = (n, m)->
  tessellation = new Tessellation n,m
  console.log "Running knuth-bendix algorithm for #{n}, #{m}...."
  rewriteRuleset = knuthBendix vdRule tessellation.group.n, tessellation.group.m
  console.log "Finished"
  appendRewrite = makeAppendRewrite rewriteRuleset

  getNeighbors = mooreNeighborhood tessellation.group.n, tessellation.group.m, appendRewrite
  xytFromCell = xyt2cell tessellation.group, appendRewrite

  transitionFunc = parseTransitionFunction "B 3 S 2 3", tessellation.group.n, tessellation.group.m
  visibleCells = visibleNeighborhood tessellation, appendRewrite, minVisibleSize
###
#
###
moveView = (dx, dy) ->
  r2 = dx*dx+dy*dy
  dt = Math.sqrt(r2+1)
  k = (dt-1)/r2

  dx = x-cx
  dy = y-cy
  if dx*dx + dy*dy <= r*r*0.8*0.8
    dragHandler = new MouseToolPan x, y
  else
    dragHandler = new MouseToolRotate x, y

doCanvasMouseMove = (e) ->
  if dragHandler isnt null
