Skip to content

Commit

Permalink
Reuse existing inkex objects for existing guides
Browse files Browse the repository at this point in the history
This modification fixes #122.
  • Loading branch information
spakin committed Dec 30, 2023
1 parent 3f15215 commit b28139c
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions simpinkscr/simple_inkscape_scripting.py
Original file line number Diff line number Diff line change
Expand Up @@ -1733,14 +1733,17 @@ def get_inkex_object(self):
class SimpleGuide(SVGOutputMixin):
'Represent an Inkscape guide.'

def __init__(self, pos, angle, color=None, label=None):
def __init__(self, pos, angle, color=None, label=None, _inkex_object=None):
'Create a guide at a given position and angle.'
# pos is stored in user coordinates, and angle is clockwise.
# In contrast, inkex expects pos to be relative to a
# lower-left origin and angle to be counter-clockwise.
global _simple_top
self._inkscape_obj = inkex.elements.Guide()
self._move_to_wrapper(pos, angle)
if _inkex_object is None:
self._inkscape_obj = inkex.elements.Guide()
self._move_to_wrapper(pos, angle)
else:
self._inkscape_obj = _inkex_object
self.color = color
self.label = label

Expand Down Expand Up @@ -1834,7 +1837,7 @@ def _from_inkex_object(self, iobj):
angle = -angle

# Return a Simple Inkscape Scripting SimpleGuide.
return SimpleGuide(pos, angle)
return SimpleGuide(pos, angle, _inkex_object=iobj)


class SimpleCanvas:
Expand Down

0 comments on commit b28139c

Please sign in to comment.