fix: enforce colorstop min 0 (#1743)

This commit is contained in:
ahebrank 2019-04-07 02:24:07 -04:00 committed by Niklas von Hertzen
parent c45ef099fe
commit 349bbf137a
1 changed files with 4 additions and 1 deletions

View File

@ -26,7 +26,10 @@ const addColorStops = (
const maxStop = Math.max.apply(null, gradient.colorStops.map(colorStop => colorStop.stop));
const f = 1 / Math.max(1, maxStop);
gradient.colorStops.forEach(colorStop => {
canvasGradient.addColorStop(f * colorStop.stop, colorStop.color.toString());
canvasGradient.addColorStop(
Math.floor(Math.max(0, f * colorStop.stop)),
colorStop.color.toString()
);
});
};