Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement clipping region for groups #618

Open
hooyuser opened this issue May 31, 2024 · 5 comments
Open

Implement clipping region for groups #618

hooyuser opened this issue May 31, 2024 · 5 comments

Comments

@hooyuser
Copy link

Hi, I was wondering if there is a possibility to implement clipping regions for groups, similar to how it's handled in TikZ. In TikZ, we can define a clipping path within a scope to constrain the visible area of contained elements, as demonstrated below:

\begin{scope} 
    \clip (-2, 0) rectangle (2, 2);     
\end{scope}

Would it be possible to introduce a similar feature for groups in CeTZ, allowing users to define clipping regions that limit rendering to specified boundaries? This feature would be incredibly helpful for complex diagrams where elements outside a certain area need to be hidden.

@johannes-wolf
Copy link
Member

This is planned, but doing this for non-rectangular regions is not trivial.

@johannes-wolf
Copy link
Member

I guess you mean path-clipping (boolean operations on paths)?

@hooyuser
Copy link
Author

Thank you for your quick response!

Yes, I was referring to path-clipping similar to what is shown in the examples on this TikZ page. However, even just implementing clipping for rectangular regions will help a lot for my current needs.

Could you please elaborate on whether it's possible to set up a rectangular clipping region for groups with the current version of CeTZ? Any guidance or workarounds would also be greatly appreciated.

@johannes-wolf
Copy link
Member

With the current version of cetz it is possible but not implemented. You have to implement some form of path clipping. There is a closed PR #535 that implements this by using a wasm library.

@hooyuser
Copy link
Author

hooyuser commented Jun 4, 2024

Given the complexities of general clipping, I'm curious to learn how to implement rectangular clipping first. Could you provide some guidance or hints?

It’s a pity about the licensing issues that led to the closure of PR #535, especially considering the effort that must have gone into it. While I haven’t looked into this extensively, a preliminary search suggested that there may be some other suitable path-clipping libraries like Clipper2 or Graphite compatible with LGPL. I thought this might be worth mentioning for future considerations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants