diff options
Diffstat (limited to 'io_curve_svg/import_svg.py')
-rw-r--r-- | io_curve_svg/import_svg.py | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/io_curve_svg/import_svg.py b/io_curve_svg/import_svg.py index 91cff022..0dfc70a4 100644 --- a/io_curve_svg/import_svg.py +++ b/io_curve_svg/import_svg.py @@ -202,6 +202,7 @@ def SVGMatrixFromNode(node, context): return Matrix() rect = context['rect'] + has_user_coordinate = (len(context['rects']) > 1) m = Matrix() x = SVGParseCoord(node.getAttribute('x') or '0', rect[0]) @@ -210,7 +211,7 @@ def SVGMatrixFromNode(node, context): h = SVGParseCoord(node.getAttribute('height') or str(rect[1]), rect[1]) m = Matrix.Translation(Vector((x, y, 0.0))) - if len(context['rects']) > 1: + if has_user_coordinate: if rect[0] != 0 and rect[1] != 0: m = m * Matrix.Scale(w / rect[0], 4, Vector((1.0, 0.0, 0.0))) m = m * Matrix.Scale(h / rect[1], 4, Vector((0.0, 1.0, 0.0))) @@ -225,9 +226,14 @@ def SVGMatrixFromNode(node, context): if vw == 0 or vh == 0: return m - sx = w / vw - sy = h / vh - scale = min(sx, sy) + if has_user_coordinate or (w != 0 and h != 0): + sx = w / vw + sy = h / vh + scale = min(sx, sy) + else: + scale = 1.0 + w = vw + h = vh tx = (w - vw * scale) / 2 ty = (h - vh * scale) / 2 @@ -1784,7 +1790,6 @@ class SVGGeometrySVG(SVGGeometryContainer): """ rect = SVGRectFromNode(self._node, self._context) - self._pushRect(rect) matrix = self.getNodeMatrix() @@ -1796,6 +1801,7 @@ class SVGGeometrySVG(SVGGeometryContainer): matrix = matrix * Matrix.Translation([0.0, -document_height , 0.0]) self._pushMatrix(matrix) + self._pushRect(rect) super()._doCreateGeom(False) @@ -1829,7 +1835,7 @@ class SVGLoader(SVGGeometryContainer): m = m * Matrix.Scale(1.0 / 90.0 * 0.3048 / 12.0, 4, Vector((1.0, 0.0, 0.0))) m = m * Matrix.Scale(-1.0 / 90.0 * 0.3048 / 12.0, 4, Vector((0.0, 1.0, 0.0))) - rect = (1, 1) + rect = (0, 0) self._context = {'defines': {}, 'transform': [], |