In case it's useful, I put together a helper function that'll normalize all the values inside a path so that they're between 0 and 1:
function normalizePath(path) {
path = gsap.utils.toArray(path);
if (!path[0].hasAttribute("d")) {
path = gsap.utils.toArray(path[0].children);
}
if (path.length > 1) {
path.forEach(normalizePath);
return path;
}
let _svgPathExp = /[achlmqstvz]|(-?\d*\.?\d*(?:e[\-+]?\d+)?)[0-9]/ig,
_scientific = /[\+\-]?\d*\.?\d+e[\+\-]?\d+/ig,
d = path[0].getAttribute("d"),
a = d.replace(_scientific, m => { let n = +m; return (n < 0.0001 && n > -0.0001) ? 0 : n; }).match(_svgPathExp),
nums = a.filter(n => !isNaN(n)).map(n => +n),
normalize = gsap.utils.normalize(Math.min(...nums), Math.max(...nums)),
finals = a.map(val => isNaN(val) ? val : normalize(+val)),
s = "",
prevWasCommand;
finals.forEach((value, i) => {
let isCommand = isNaN(value)
s += (isCommand && i ? " " : prevWasCommand || !i ? "" : ",") + value;
prevWasCommand = isCommand;
});
path[0].setAttribute("d", s);
return path;
}
Usage:
normalizePath("#mask")
So that'll make a path like this:
<path d="M3903,6453.410182017132 L300,1.542786465904 L-10000,1481.542786465904 L-10000,6453.410182017132 Z"></path>
Into this:
<path d="M0.8449920014268762,1 L0.6260100420554431,0.6078705068325081 L0,0.6978214643317369 L0,1 Z"></path>
I hope that helps somebody.