function copyBySelection(selection) {
  const x = selection.x; const y = selection.y;
  const w = selection.w; const h = selection.h;
  let pixels = [];
  for (let ii = 0; ii < w * h; ++ii) {
    const xx = ii % w;
    const yy = (ii / w) | 0;
    const pixel = this.getAbsolutePixelAt(x + xx, y + yy);
    if (pixel === null) continue;
    pixels.push({
      x: xx, y: yy, color: pixel
    });
  };
  this.clipboard.copy = {
    pixels: pixels,
    selection: selection
  };
}
Rectangle-based copying
@param {Object} selection