[Bf-extensions-cvs] [c2aef4a9] master: SVG: Fix wrong closed path with quadratic segments

Sergey Sharybin noreply at git.blender.org
Mon Oct 29 16:09:45 CET 2018


Commit: c2aef4a98f6cabef9a6d38a33035f02cf8233dd0
Author: Sergey Sharybin
Date:   Mon Oct 29 16:09:02 2018 +0100
Branches: master
https://developer.blender.org/rBAc2aef4a98f6cabef9a6d38a33035f02cf8233dd0

SVG: Fix wrong closed path with quadratic segments

Fixes T55601: SVG import wrong shape

===================================================================

M	io_curve_svg/import_svg.py

===================================================================

diff --git a/io_curve_svg/import_svg.py b/io_curve_svg/import_svg.py
index 4298470b..6b45d91d 100644
--- a/io_curve_svg/import_svg.py
+++ b/io_curve_svg/import_svg.py
@@ -666,6 +666,9 @@ class SVGPathParser:
             if last['handle_right_type'] == 'VECTOR' and handle_left_type == 'FREE':
                 last['handle_right'] = (last['x'], last['y'])
                 last['handle_right_type'] = 'FREE'
+            if last['handle_right_type'] == 'FREE' and handle_left_type == 'VECTOR':
+                handle_left = (x, y)
+                handle_left_type = 'FREE'
 
         point = {'x': x,
                  'y': y,
@@ -1230,6 +1233,19 @@ class SVGGeometryPATH(SVGGeometry):
 
         for spline in self._splines:
             act_spline = None
+
+            if spline['closed'] and len(spline['points']) >= 2:
+                first = spline['points'][0]
+                last = spline['points'][-1]
+                if (    first['handle_left_type'] == 'FREE' and
+                        last['handle_right_type'] == 'VECTOR'):
+                    last['handle_right_type'] = 'FREE'
+                    last['handle_right'] = (last['x'], last['y'])
+                if (    last['handle_right_type'] == 'FREE' and
+                        first['handle_left_type'] == 'VECTOR'):
+                    first['handle_left_type'] = 'FREE'
+                    first['handle_left'] = (first['x'], first['y'])
+
             for point in spline['points']:
                 co = self._transformCoord((point['x'], point['y']))



More information about the Bf-extensions-cvs mailing list