Make a horizonally-flipped copy of a buffer or image.
@param {external:canvas|external:image} buffer The original image
@return {external:canvas} The flipped buffer
function flipBufferHorizontally(buffer) {
  return makeBuffer(buffer.width, buffer.height, function(context) {
    context.scale(-1, 1);
    context.drawImage(buffer, -buffer.width, 0);
  });
}