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>2018-10-29 18:09:54 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2018-10-29 18:09:54 +0300
commit747c0a3731f10972eb373a119171d75a35b95b7c (patch)
treee6b22a8ce594e7bf1c200c282bffdd613ccd5ffb /io_curve_svg
parent85e6619a02f53f690ebfd269fbbfb6e98a20174a (diff)
parentc2aef4a98f6cabef9a6d38a33035f02cf8233dd0 (diff)
Merge branch 'master' into blender2.8
Diffstat (limited to 'io_curve_svg')
-rw-r--r--io_curve_svg/import_svg.py45
1 files changed, 33 insertions, 12 deletions
diff --git a/io_curve_svg/import_svg.py b/io_curve_svg/import_svg.py
index 1a8c2f65..c7302711 100644
--- a/io_curve_svg/import_svg.py
+++ b/io_curve_svg/import_svg.py
@@ -47,9 +47,13 @@ SVGEmptyStyles = {'useFill': None,
def srgb_to_linearrgb(c):
if c < 0.04045:
- return 0.0 if c < 0.0 else c * (1.0 / 12.92);
+ return 0.0 if c < 0.0 else c * (1.0 / 12.92)
else:
- return pow((c + 0.055) * (1.0 / 1.055), 2.4);
+ 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):
@@ -645,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'
@@ -662,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,
@@ -796,20 +803,21 @@ class SVGPathParser:
else:
if self._handle is not None:
x1, y1 = SVGFlipHandle(self._point[0], self._point[1],
- self._handle[0], self._handle[1])
+ self._handle[0], self._handle[1])
else:
x1, y1 = self._point
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)
@@ -961,7 +969,7 @@ class SVGPathParser:
raise Exception('Unknown path command: {0}' . format(code))
if cmd in {'Z', 'z'}:
- closed =True
+ closed = True
else:
closed = False
@@ -1225,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']))