function changeOrigin(fObject, origin) {
  const { originX, originY } = origin;
  const { x: left, y: top } = fObject.getPointByOrigin(originX, originY);

  fObject.set({
    left,
    top,
    originX,
    originY,
  });

  fObject.setCoords();
}
Change object origin
@param {fabric.Object} fObject - fabric object
@param {Object} origin - origin of fabric object
  @param {string} originX - horizontal basis.
  @param {string} originY - vertical basis.