     k = 2.0 / canvas.height
     moveView dx*k , dy*k
     
-  mouseUp: (e)->
-    console.log "up"
-    
-class RotatingDragger
+class MouseToolRotate extends MouseTool
   constructor: (x, y) ->
     @xc = canvas.width * 0.5
     @yc = canvas.width * 0.5
-    
     @angle0 = @angle x, y 
     
   angle: (x,y) -> Math.atan2( x-@xc, y-@yc)

E("btn-set-rule").addEventListener "click", doSetRule
E("btn-set-grid").addEventListener "click", doSetGrid

test_drawOrder2NMeighbors = ->
  coordsWithPaths = []
  
  #Initial cell
  cell = null
  
  for nei in getNeighbors cell
    for nei2 in getNeighbors nei
      if cells.get nei2
        console.log "already present! #{showNode nei2}"
      else
        cells.put nei2, 1
        cellCenter = M.mulv nodeMatrixRepr(nei2, tessellation.group), [0,0,1]
        found = false
        for [z, paths], i in coordsWithPaths
          if M.approxEqv z, cellCenter
            console.log "Path #{showNode nei2} already has equals:"
            for p, j in paths
              console.log "  #{j+1}) #{showNode p}"
              #throw new Error "Stop"
            paths.push nei2
            found = true
            break
        if not found
          console.log "First occurence of #{showNode nei2}"
          coordsWithPaths.push [cellCenter, [nei2]]
            

  console.log "Population is #{cells.count}"    
  console.log JSON.stringify rewriteRuleset
    
  #cells.put null, 1
  #cells.put newNode('a', 1, newNode('b',1,null)), 1
  #cells.put newNode('a', 1, newNode('b',1,newNode('a', 2, newNode('b',1,null)))), 1
                          

  context.save()
  s = Math.min( canvas.width, canvas.height ) / 2
  context.scale s, s
  context.translate 1, 1

  drawCells cells, tfm, tessellation, context
  context.restore()

#test_drawOrder2NMeighbors()

  redraw()

doStep = ->
  cells = evaluateWithNeighbors cells, getNeighbors, transitionFunc.evaluate.bind(transitionFunc)
  redraw()

#Flag to avoid requestAnimationFrame congestion. It really helps a lot!
frameRequested = false
redraw = ->
  s = Math.min( canvas.width, canvas.height ) / 2

  if not frameRequested
    frameRequested = true
    window.requestAnimationFrame ->
      frameRequested = false
      context.clearRect 0, 0, canvas.width, canvas.height
      context.save()
      context.scale s, s
      context.translate 1, 1
      drawVisibleCells visibleCells, cells, tfm, tessellation, context
      context.restore()

updatePopulation = ->
  #console.log "Redraw. Population is #{cells.count}"
  E("population").innerHTML = ""+cells.count

toggleCellAt = (x,y) ->
  s = Math.min( canvas.width, canvas.height ) * 0.5
