 
 
   clear_margins: () ->
+    tp = @top_margin
+    rt = @right_margin
     bt = @bottom_margin
-    rt = @right_margin
+    lf = @left_margin
     @context = @get_drawing_context("canvas")
+    @context.clearRect(tp[0],tp[1],tp[2],tp[3])
+    @context.clearRect(rt[0],rt[1],rt[2],rt[3])
     @context.clearRect(bt[0],bt[1],bt[2],bt[3])
-    @context.clearRect(rt[0],rt[1],rt[2],rt[3]) # TODO need to add top margin
+    @context.clearRect(lf[0],lf[1],lf[2],lf[3])
 
 
   get_drawing_context: (mode) ->


  dot: (x,y) ->
    hex = @puzzle.events.piece_drag.get_piece_hex_position(x,y)
#    hex = @grid_model.get_hex(x,y)
    if hex[0] > 0 and hex[0] < 25 and hex[1] > 0 and hex[1] < 11
      color = @get_dot_color(hex)
      @put_dot(x,y,color)

    @dot(x,y)


  hex_quick_mark: () ->
    for aa in [1..24]
      for bb in [1..10]
        if not (aa%2 == 1 and bb == 10)
          corner = @puzzle.hex_box.get_box_xy_ab(aa,bb)
          ctr_x = corner[0]+9
          ctr_y = corner[1]+10
          @circle_hex(ctr_x,ctr_y)


  adjusted_hex_quick_mark: () ->
    dxy = @puzzle.events.piece_drag.get_piece_offset()
    for aa in [-7..24]
      for bb in [1..10]
        if aa == 1 && bb == 1 then origin = true else origin = false
        if not (aa%2 == 1 and bb == 10)
          corner = @puzzle.hex_box.get_box_xy_ab(aa,bb)
          ctr_x = corner[0]+9+dxy[0]
          ctr_y = corner[1]+10+dxy[1]
          hx11 = [corner[0]-9,corner[1]-10] if aa == 1 && bb == 1
          @circle_hex(ctr_x,ctr_y,origin)


  circle_hex: (x,y,origin) ->
    canvas = document.getElementById("puzzle-widget")
    context = canvas.getContext('2d')
    context.strokeStyle = "black"
    context.fillStyle = "blue"
    context.beginPath()
    context.arc(x,y,8.2,0,6.28)
    context.stroke()
    context.fill() if origin == true
    context.closePath()


  mark_hex_centerpoints: () ->
    for aa in [1..24]
      for bb in [1..10]
        if not (aa%2 == 1 and bb == 10)
          corner = @puzzle.hex_box.get_box_xy_ab(aa,bb)
          @put_dot(corner[0],corner[1],"#666666")
          ctr_x = corner[0]+9
          ctr_y = corner[1]+10
