small fixes

This commit is contained in:
Mario Voigt 2024-04-02 02:53:04 +02:00
parent 32c5a9f8b3
commit 5cc30dfc73
2 changed files with 11 additions and 6 deletions

View File

@ -164,7 +164,7 @@ class ChainPaths(inkex.EffectExtension):
inkex.utils.debug("Warning: node {} has transform {}. Use 'Apply Transforms' extension before to handle this.".format(node.get('id'), node.get('transform')))
return
if so.debug: inkex.utils.debug("id={}, tag=".format(idnode.get('id'), node.tag))
if so.debug: inkex.utils.debug("id={}, tag=".format(node.get('id'), node.tag))
path_d = CubicSuperPath(Path(node.get('d')))
sub_idx = -1
for sub in path_d:

View File

@ -72,13 +72,13 @@ class DestructiveClip(inkex.EffectExtension):
elif cmd[0] == 'C':
# https://developer.mozilla.org/en/docs/Web/SVG/Tutorial/Paths
lineSegments.append([prev, [this[4], this[5]]])
errors.add("Curve node detected (svg type C), this node will be handled as a regular node")
errors.add("Curve node detected (svg type C), this node will be handled as a regular node. Try to flatten bezier curves before running this extension!")
else:
errors.add("Invalid node type detected: {}. This script only handle type M, L, Z".format(cmd[0]))
errors.add("Invalid node type detected: {}. This script only handles types M, L, Z".format(cmd[0]))
prev = this
return (lineSegments, errors)
def linesgmentsToSimplePath(self, lineSegments):
def lineSegmentsToSimplePath(self, lineSegments):
# reverses simplepathToLines - converts line segments to Move/Line-to's
path = []
end = None
@ -202,7 +202,12 @@ class DestructiveClip(inkex.EffectExtension):
self.error_messages.extend(['{}: {}'.format(id, err) for err in errors])
clippedSegments = self.clipLineSegments(segmentsToClip, clippingLineSegments)
if len(clippedSegments) != 0:
path = str(inkex.Path(self.linesgmentsToSimplePath(clippedSegments)))
segsOkay = True
for clippedSegment in clippedSegments:
if len(clippedSegment[0]) != 2: #must be 2, otherwise this errors in Path generation.
segsOkay = False
if segsOkay is True:
path = str(inkex.Path(self.lineSegmentsToSimplePath(clippedSegments)))
node.set('d', path)
else:
# don't put back an empty path(?) could perhaps put move, move?