diff --git a/src/style/Color.js b/src/style/Color.js index 4fcb8a9e..98072939 100644 --- a/src/style/Color.js +++ b/src/style/Color.js @@ -863,12 +863,14 @@ var Color = Base.extend(new function() { destination.x, destination.y); } for (var i = 0, l = stops.length; i < l; i++) { - var stop = stops[i]; + var stop = stops[i], + offset = stop._offset; // Use the defined offset, and fall back to automatic linear // calculation. // NOTE: that if _offset is 0 for the first entry, the fall-back // will be so too. - canvasGradient.addColorStop(stop._offset || i / (l - 1), + canvasGradient.addColorStop( + offset == null ? i / (l - 1) : offset, stop._color.toCanvasStyle()); } return this._canvasStyle = canvasGradient; diff --git a/src/svg/SvgExport.js b/src/svg/SvgExport.js index 394f194f..fefc7653 100644 --- a/src/svg/SvgExport.js +++ b/src/svg/SvgExport.js @@ -232,9 +232,10 @@ new function() { for (var i = 0, l = stops.length; i < l; i++) { var stop = stops[i], stopColor = stop._color, - alpha = stopColor.getAlpha(); + alpha = stopColor.getAlpha(), + offset = stop._offset; attrs = { - offset: stop._offset || i / (l - 1) + offset: offset == null ? i / (l - 1) : offset }; if (stopColor) attrs['stop-color'] = stopColor.toCSS(true);