code: function (tile, x, y) {
          var tileWidth = this.layer.tileSize.w,
              tileHeight = this.layer.tileSize.h,
              data = this.image,
              bytes = this.bytes,
              w = this.size.w,
              x0 = Math.max(0, x), // intersection of tile and shapshot (viewport)
              y0 = Math.max(0, y),
              x1 = Math.min(w, x + tileWidth) - 1,
              y1 = Math.min(this.size.h, y + tileHeight) - 1;
  
          if (x0 > x1 || y0 > y1) return; // tile isn't visible
  
          var canvas = document.createElement("canvas"); // create canvas for tile
          canvas.width = tileWidth;
          canvas.height = tileHeight;
  
          var ctx = canvas.getContext("2d"); // copy to canvas context tile image
          ctx.drawImage(tile, 0, 0);
  
          var imgData = ctx.getImageData(0, 0, tileWidth, tileHeight),
              tileData = imgData.data,
              i = (y0 * w + x0) * bytes,
              len = (x1 - x0 + 1) * bytes,
              w1 = tileWidth * bytes,
              k1 = ((y0 - y) * tileWidth + x0 - x) * bytes,
              k2 = ((y1 - y) * tileWidth + x0 - x + 1) * bytes;
  
          w *= bytes;
          // copy only the visible data of image to snapshot
          for (var k = k1; k < k2; k += w1) { // walk through rows (Y)
              data.set(tileData.subarray(k, k + len), i); // copy row
              i += w;
          }
      }
docs: private