Skip to content

Commit

Permalink
fix: enforce colorstop min 0 (#1743)
Browse files Browse the repository at this point in the history
  • Loading branch information
ahebrank authored and niklasvh committed Apr 7, 2019
1 parent c45ef09 commit 349bbf1
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/renderer/CanvasRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
);
});
};

Expand Down

0 comments on commit 349bbf1

Please sign in to comment.