Skip to content
Open
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
9 changes: 8 additions & 1 deletion mpl_typst/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,11 +241,18 @@ def normalize(coords) -> tuple[float, ...]:
else:
stroke.kwargs.update({'dash': bounds})

# Get clipping rectangle from graphics context
bbox = gc.get_clip_rectangle()
clip = None
if bbox:
p1, p2 = bbox.get_points()
clip = (p1[0], p1[1], p2[0], p2[1])

# Since Typst v0.13.0, path drawing API (aka curve) is more coherent to
# Matplotlib's Path object.
subpath: list[Call]
superpath: list[list[Call]] = []
for points, code in path.iter_segments(transform):
for points, code in path.iter_segments(transform, clip=clip):
points = normalize(points)
scalars = tuple([Scalar(p, 'in') for p in points])
match code:
Expand Down
Loading