Implementation of the Marching Squares algorithm in javascript for Html5 Canvas