The problem is that you are assuming that l takes an absolute coordinate, but actually it takes a relative one. When you write:
M 50 0 l 50 600
You think that this means writing a line from (50.0) to (50, 600), but actually it means starting at (50, 0), moving (50, 600). Consequently, a beveled mesh.
You just need to write vpaths as follows (replacing x and y after l with 0 ):
var vpath = "M " + x + " 0 l 0 " + this.height + " z";
and
var hpath = "M 0 " + y + " l " + this.width + " 0 z";
source share