 
   constructor: (piece) ->
     @piece = piece
-    @hex_draw = @piece.puzzle.hex_draw
+    @puzzle = @piece.puzzle
+    @hex_box = @puzzle.hex_box
+    @hex_draw = @puzzle.hex_draw
     @img = document.createElement('canvas')
     @img.id = "piece-mask"
     @piece_mask_context = @img.getContext('2d')
 
 
-  draw_pattern: () ->
-    @img.width = @piece.box.width
-    @img.height = @piece.box.height
+  draw_piece_pattern: () -> # TODO Fix this and the HexBox refactor is complete.
+    @img.width = @hex_box.width
+    @img.height = @hex_box.height
     @hexes = @piece.hexes
     @hex_draw.set_context("piece_mask")
     xx = 6
+    xx = 0
     if @piece.box.high_hex_adjust == true then hx_adjust = -9 else hx_adjust = 0
     for hx in @hexes
       aa = hx[0] - @piece.box.anchor_hex[0] + 1


    @events = new EventHandler(this)

    @pattern = new PuzzlePattern(this)
    @mask = new MissingPiecesMask(this)
    @piece = new PuzzlePiece(this)

    @pattern.draw_pattern()
    @piece.construct_piece("c")
    @piece.draw_piece(0,0)

#    @piece.draw_piece_ab(@piece.box.anchor_hex[0],@piece.box.anchor_hex[1])

    @hex_box.set_hex_box("c")

#    @hex_draw.draw_all_hexes()


  constructor: (puzzle_app) ->

    @puzzle = puzzle_app
    @puzzle_pattern = @puzzle.puzzle_pattern
    @grid = @puzzle_pattern.grid
    @hex_draw = @puzzle.hex_draw
    @missing = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p"]

