Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2017-09-19 10:52:34 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2018-01-01 18:21:14 +0300
commit8bd2c6d90d2de39de865abfa81084a0f394f0994 (patch)
tree075c87b0fdadb09b86ddfb8951eb9cba9a0b300c
parenta40d3ddf789d2dec9572ac6b5f6980ec067b8e53 (diff)
Fix T52822: Incorrect dimensions of imported svg files
Was caused by fix for T45460. Now both reports should be fixed properly.
-rw-r--r--io_curve_svg/import_svg.py18
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': [],