Skip to content
Snippets Groups Projects
Commit 747c0a37 authored by Sergey Sharybin's avatar Sergey Sharybin
Browse files

Merge branch 'master' into blender2.8

parents 85e6619a c2aef4a9
No related branches found
No related tags found
No related merge requests found
...@@ -47,9 +47,13 @@ SVGEmptyStyles = {'useFill': None, ...@@ -47,9 +47,13 @@ SVGEmptyStyles = {'useFill': None,
def srgb_to_linearrgb(c): def srgb_to_linearrgb(c):
if c < 0.04045: 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: 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): def SVGParseFloat(s, i=0):
...@@ -645,7 +649,7 @@ class SVGPathParser: ...@@ -645,7 +649,7 @@ class SVGPathParser:
# filled. # filled.
first = self._spline['points'][0] 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: if handle_left is not None:
first['handle_left'] = handle_left first['handle_left'] = handle_left
first['handle_left_type'] = 'FREE' first['handle_left_type'] = 'FREE'
...@@ -662,6 +666,9 @@ class SVGPathParser: ...@@ -662,6 +666,9 @@ class SVGPathParser:
if last['handle_right_type'] == 'VECTOR' and handle_left_type == 'FREE': if last['handle_right_type'] == 'VECTOR' and handle_left_type == 'FREE':
last['handle_right'] = (last['x'], last['y']) last['handle_right'] = (last['x'], last['y'])
last['handle_right_type'] = 'FREE' 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, point = {'x': x,
'y': y, 'y': y,
...@@ -796,20 +803,21 @@ class SVGPathParser: ...@@ -796,20 +803,21 @@ class SVGPathParser:
else: else:
if self._handle is not None: if self._handle is not None:
x1, y1 = SVGFlipHandle(self._point[0], self._point[1], x1, y1 = SVGFlipHandle(self._point[0], self._point[1],
self._handle[0], self._handle[1]) self._handle[0], self._handle[1])
else: else:
x1, y1 = self._point x1, y1 = self._point
x, y = self._getCoordPair(code.islower(), self._point) x, y = self._getCoordPair(code.islower(), self._point)
if self._spline is None: if not check_points_equal((x, y), self._point):
self._appendPoint(self._point[0], self._point[1], if self._spline is None:
handle_left_type='FREE', handle_left=self._point, self._appendPoint(self._point[0], self._point[1],
handle_right_type='FREE', handle_right=self._point) handle_left_type='FREE', handle_left=self._point,
handle_right_type='FREE', handle_right=self._point)
self._appendPoint(x, y, self._appendPoint(x, y,
handle_left_type='FREE', handle_left=(x1, y1), handle_left_type='FREE', handle_left=(x1, y1),
handle_right_type='FREE', handle_right=(x, y)) handle_right_type='FREE', handle_right=(x, y))
self._point = (x, y) self._point = (x, y)
self._handle = (x1, y1) self._handle = (x1, y1)
...@@ -961,7 +969,7 @@ class SVGPathParser: ...@@ -961,7 +969,7 @@ class SVGPathParser:
raise Exception('Unknown path command: {0}' . format(code)) raise Exception('Unknown path command: {0}' . format(code))
if cmd in {'Z', 'z'}: if cmd in {'Z', 'z'}:
closed =True closed = True
else: else:
closed = False closed = False
...@@ -1225,6 +1233,19 @@ class SVGGeometryPATH(SVGGeometry): ...@@ -1225,6 +1233,19 @@ class SVGGeometryPATH(SVGGeometry):
for spline in self._splines: for spline in self._splines:
act_spline = None 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']: for point in spline['points']:
co = self._transformCoord((point['x'], point['y'])) co = self._transformCoord((point['x'], point['y']))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment