[Bf-extensions-cvs] [a1aeff98] master: SVG: Fix wrong quadratic path when point is duplicate

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


Commit: a1aeff98908d47f5aba2457df444ac20a890f707
Author: Sergey Sharybin
Date:   Mon Oct 29 15:55:52 2018 +0100
Branches: master
https://developer.blender.org/rBAa1aeff98908d47f5aba2457df444ac20a890f707

SVG: Fix wrong quadratic path when point is duplicate

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

M	io_curve_svg/import_svg.py

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

diff --git a/io_curve_svg/import_svg.py b/io_curve_svg/import_svg.py
index 8cfd1178..4298470b 100644
--- a/io_curve_svg/import_svg.py
+++ b/io_curve_svg/import_svg.py
@@ -51,6 +51,11 @@ def srgb_to_linearrgb(c):
     else:
         return pow((c + 0.055) * (1.0 / 1.055), 2.4)
 
+def check_points_equal(point_a, point_b):
+    return (abs(point_a[0] - point_b[0]) < 1e-6 and 
+            abs(point_a[1] - point_b[1]) < 1e-6)
+
+
 def SVGParseFloat(s, i=0):
     """
     Parse first float value from string
@@ -644,7 +649,7 @@ class SVGPathParser:
             # filled.
 
             first = self._spline['points'][0]
-            if abs(first['x'] - x) < 1e-6 and abs(first['y'] - y) < 1e-6:
+            if check_points_equal((first['x'], first['y']), (x, y)):
                 if handle_left is not None:
                     first['handle_left'] = handle_left
                     first['handle_left_type'] = 'FREE'
@@ -801,14 +806,15 @@ class SVGPathParser:
 
             x, y = self._getCoordPair(code.islower(), self._point)
 
-            if self._spline is None:
-                self._appendPoint(self._point[0], self._point[1],
-                    handle_left_type='FREE', handle_left=self._point,
-                    handle_right_type='FREE', handle_right=self._point)
+            if not check_points_equal((x, y), self._point):
+                if self._spline is None:
+                    self._appendPoint(self._point[0], self._point[1],
+                        handle_left_type='FREE', handle_left=self._point,
+                        handle_right_type='FREE', handle_right=self._point)
 
-            self._appendPoint(x, y,
-                handle_left_type='FREE', handle_left=(x1, y1),
-                handle_right_type='FREE', handle_right=(x, y))
+                self._appendPoint(x, y,
+                    handle_left_type='FREE', handle_left=(x1, y1),
+                    handle_right_type='FREE', handle_right=(x, y))
 
             self._point = (x, y)
             self._handle = (x1, y1)



More information about the Bf-extensions-cvs mailing list