NazariyM
2/24/2018 - 4:36 PM

convert path to 0-1 range for clipPathUnits="objectBoundingBox"

let svgWidth = 1920;
let svgHeight = 1080;
let count = -1;
function replacer(match) {
  count++;
  if (count % 2) {
    return match / svgHeight;
  } else {
    return match / svgWidth;
  }
}
let svgPath = 'M846.94,470.89L725.63 0 494.05 0 372.74 470.89 236 0 0 0 239.32 681 506.37 681 609.84 277.9 713.32 681 980.36 681 1219.68 0 983.69 0 846.94 470.89z';
let nuPath = svgPath.replace(/(\d+(\.\d+)?)/g, replacer);
console.log(nuPath);