function clearSelection(selection) {
  const shape = selection.shape;
  const bounds = shape.bounds;
  const data = shape.data;
  const x = selection.x; const y = selection.y;
  const w = selection.w; const h = selection.h;
  const layer = this.getCurrentLayer();
  layer.createBatchAt(x, y);
  batch.isEraser = true;
  const bw = bounds.w; const bh = bounds.h;
  batch.resizeRectangular(
    x, y,
    w - 1, h - 1
  );
  let count = 0;
  for (let ii = 0; ii < data.length; ii += 4) {
    const idx = (ii / 4) | 0;
    const xx = (idx % bw) | 0;
    const yy = (idx / bw) | 0;
    const px = (yy * bw + xx) * 4;
    if (data[px + 3] <= 0) continue;
    const pixel = this.getAbsolutePixelAt(x + xx, y + yy);
    // only erase if we have sth to erase
    if (pixel === null) continue;
    batch.erasePixelFast(x + xx, y + yy, pixel);
    count++;
  };
  // nothing to change
  if (count <= 0) {
    batch.kill();
    return;
  }
  batch.refreshTexture(false);
  this.enqueue(CommandKind.CLEAR, batch);
  return;
}
Shape-based clearing
@param {Object} selection
@return {Void}