Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 17 additions & 13 deletions inkscape/objects_to_spine.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,19 +303,23 @@ def delete_invisible_children(node: BaseElement):

# @staticmethod
def get_bounding_box(self, node: BaseElement) -> tuple[float, float, float, float] | None:
transform = None
parent = node.getparent()
if parent is not None:
transform = parent.composed_transform()
bounding_box = node.bounding_box(transform)

if bounding_box is None:
return None

x = round(self.svg.uutounit(bounding_box.x.minimum))
y = round(self.svg.uutounit(bounding_box.y.minimum))
width = round(self.svg.uutounit(bounding_box.width))
height = round(self.svg.uutounit(bounding_box.height))
node_id = node.get_id()

def q(arg: str) -> float:
# Ask Inkscape for the bbox of this id in page coordinates (px)
out = inkscape(
self.options.input_file,
**{
"query-id": node_id,
arg: None,
}
)
return float(str(out).strip())

x = q("query-x")
y = q("query-y")
width = q("query-width")
height = q("query-height")
return x, y, width, height

@staticmethod
Expand Down