function copyByShape(selection) {
  const shape = selection.shape;
  const data = shape.data;
  const bx = shape.bounds.x; const by = shape.bounds.y;
  const bw = shape.bounds.w; const bh = shape.bounds.h;
  let pixels = [];
  for (let ii = 0; ii < data.length; ii += 4) {
    const idx = ii / 4;
    const xx = idx % bw;
    const yy = (idx / bw) | 0;
    const px = (yy * bw + xx) * 4;
    const alpha = data[px + 3];
    // ignore shape pixels that aren't used
    if (alpha <= 0) continue;
    const pixel = this.getAbsolutePixelAt(bx + xx, by + yy);
    if (pixel === null) continue;
    pixels.push({
      x: xx, y: yy, color: pixel
    });
  };
  this.clipboard.copy = {
    pixels: pixels,
    selection: selection
  };
}
Shape-based copying
@param {Object} selection