Fix code closing paths to look at each section separately
This commit is contained in:
parent
d1299ae2c9
commit
3513cf88a8
|
@ -494,11 +494,17 @@ Creation date: {date}
|
||||||
for j, path in enumerate(part.pathes):
|
for j, path in enumerate(part.pathes):
|
||||||
p = []
|
p = []
|
||||||
x, y = 0, 0
|
x, y = 0, 0
|
||||||
|
start = None
|
||||||
|
last = None
|
||||||
path.faster_edges()
|
path.faster_edges()
|
||||||
for c in path.path:
|
for c in path.path:
|
||||||
x0, y0 = x, y
|
x0, y0 = x, y
|
||||||
C, x, y = c[0:3]
|
C, x, y = c[0:3]
|
||||||
if C == "M":
|
if C == "M":
|
||||||
|
if start and points_equal(start[1], start[2],
|
||||||
|
last[1], last[2]):
|
||||||
|
p.append("Z")
|
||||||
|
start = c
|
||||||
p.append(f"M {x:.3f} {y:.3f}")
|
p.append(f"M {x:.3f} {y:.3f}")
|
||||||
elif C == "L":
|
elif C == "L":
|
||||||
if abs(x - x0) < EPS:
|
if abs(x - x0) < EPS:
|
||||||
|
@ -531,6 +537,12 @@ Creation date: {date}
|
||||||
t.set("alignment-baseline", 'hanging')
|
t.set("alignment-baseline", 'hanging')
|
||||||
else:
|
else:
|
||||||
print("Unknown", c)
|
print("Unknown", c)
|
||||||
|
|
||||||
|
last = c
|
||||||
|
|
||||||
|
if start and start is not last and \
|
||||||
|
points_equal(start[1], start[2], last[1], last[2]):
|
||||||
|
p.append("Z")
|
||||||
color = (
|
color = (
|
||||||
random_svg_color()
|
random_svg_color()
|
||||||
if RANDOMIZE_COLORS
|
if RANDOMIZE_COLORS
|
||||||
|
@ -539,11 +551,6 @@ Creation date: {date}
|
||||||
if p and p[-1][0] == "M":
|
if p and p[-1][0] == "M":
|
||||||
p.pop()
|
p.pop()
|
||||||
if p: # might be empty if only contains text
|
if p: # might be empty if only contains text
|
||||||
if points_equal(path.path[0][1],
|
|
||||||
path.path[0][2],
|
|
||||||
path.path[-1][1],
|
|
||||||
path.path[-1][2]):
|
|
||||||
p.append("Z")
|
|
||||||
t = ET.SubElement(g, "path", d=" ".join(p), stroke=color)
|
t = ET.SubElement(g, "path", d=" ".join(p), stroke=color)
|
||||||
t.set("stroke-width", f'{path.params["lw"]:.2f}')
|
t.set("stroke-width", f'{path.params["lw"]:.2f}')
|
||||||
t.tail = "\n "
|
t.tail = "\n "
|
||||||
|
|
Loading…
Reference in New Issue