Perlin noise implementation (JavaScript, canvas)