 
     @grid = new PuzzleGridModel
     @puzzle_view = new PuzzleView
+    @hx = new HexBuilder
+
     @piece = new PuzzlePiece(this)
 
 


  constructor: () ->

    alert("PuzzleView constructor")
    @canvas = document.getElementById("puzzle-widget")
    @context = @canvas.getContext("2d")

    @img = document.getElementById("frame")
    @context.drawImage(@img,100,30)


#   #   #   #   #   #


class HexBuilder

  constructor: () ->
    @canvas = document.getElementById("puzzle-widget")
    @context = @canvas.getContext("2d")
    @colors = ["#cc5050","#5050cc","#50cccc","#50cc50","#cccc50","#cc50cc"]

    @fillhex(1,1,1)
    @fillhex(1,2,0)
    @fillhex(2,1,3)
    @fillhex(2,2,4)
    @fillhex(3,1,5)
    @fillhex(3,2,0)


  fillhex: (a,b,c_no) ->
    x = 106+a*14
    y = 35+b*20
    y = y+9 if (a%2 == 0)
    @context.fillStyle = @colors[c_no]
    @context.beginPath()
    @context.moveTo(x,y)
    @context.lineTo(x+9,y)
    @context.lineTo(x+14,y+9)
    @context.lineTo(x+9,y+19)
    @context.lineTo(x,y+19)
    @context.lineTo(x-5,y+9)
    @context.lineTo(x,y)
    @context.fill()
    @context.closePath()
