Only enlarge by half stroke width on either side

This commit is contained in:
Paul Kaplan
2017-10-05 13:30:01 -04:00
parent 3565c95f83
commit ab4046b852

View File

@@ -234,11 +234,11 @@ class SvgRenderer {
// Enlarge the bbox from the largest found stroke width
// This may have false-positives, but at least the bbox will always
// contain the full graphic including strokes.
const largestStrokeWidth = this._findLargestStrokeWidth(this._svgTag);
bbox.width += largestStrokeWidth * 2;
bbox.height += largestStrokeWidth * 2;
bbox.x -= largestStrokeWidth;
bbox.y -= largestStrokeWidth;
const halfStrokeWidth = this._findLargestStrokeWidth(this._svgTag) / 2;
bbox.width += halfStrokeWidth * 2;
bbox.height += halfStrokeWidth * 2;
bbox.x -= halfStrokeWidth;
bbox.y -= halfStrokeWidth;
// Set the correct measurements on the SVG tag, and save them.
this._svgTag.setAttribute('width', bbox.width);