reorientGrads = (elem, m) => {
  const bb = utilsGetBBox(elem)
  for (let i = 0; i < 2; i++) {
    const type = i === 0 ? 'fill' : 'stroke'
    const attrVal = elem.getAttribute(type)
    if (attrVal && attrVal.startsWith('url(')) {
      const grad = getRefElem(attrVal)
      if (grad.tagName === 'linearGradient') {
        let x1 = grad.getAttribute('x1') || 0
        let y1 = grad.getAttribute('y1') || 0
        let x2 = grad.getAttribute('x2') || 1
        let y2 = grad.getAttribute('y2') || 0

        // Convert to USOU points
        x1 = (bb.width * x1) + bb.x
        y1 = (bb.height * y1) + bb.y
        x2 = (bb.width * x2) + bb.x
        y2 = (bb.height * y2) + bb.y

        // Transform those points
        const pt1 = transformPoint(x1, y1, m)
        const pt2 = transformPoint(x2, y2, m)

        // Convert back to BB points
        const gCoords = {
          x1: (pt1.x - bb.x) / bb.width,
          y1: (pt1.y - bb.y) / bb.height,
          x2: (pt2.x - bb.x) / bb.width,
          y2: (pt2.y - bb.y) / bb.height
        }

        const newgrad = grad.cloneNode(true)
        for (const [key, value] of Object.entries(gCoords)) {
          newgrad.setAttribute(key, value)
        }
        newgrad.id = svgCanvas.getNextId()
        findDefs().append(newgrad)
        elem.setAttribute(type, 'url(#' + newgrad.id + ')')
      }
    }
  }
}
@function module:path.reorientGrads
@param {Element} elem
@param {SVGMatrix} m
@returns {void}