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

API question: negative space / cutouts #596

Closed
dannymcgee opened this issue Jun 4, 2024 · 4 comments
Closed

API question: negative space / cutouts #596

dannymcgee opened this issue Jun 4, 2024 · 4 comments

Comments

@dannymcgee
Copy link

Hey there! I have a bit of experience with Skia, and I'm trying to apply some of the techniques I've learned there to Vello, but I can't quite figure out how to handle negative space. For example, in Skia I can use SkPath::reverseAddPath to "subtract" a path from an existing one, which has the same effect as drawing the second path with SkPathFillType::kInverseWinding: the second shape effectively cuts a hole out of the original. But I haven't been able to find anything similar yet with Vello. I tried using BezPath::reverse_subpaths + extend, but that didn't seem to have the intended result. Is this not implemented yet, or am I just missing it?

@raphlinus
Copy link
Contributor

We don't have that feature. Are you using this path as a clip or a fill? In the latter case, you need a bounding box somewhere (though I suppose it could ultimately be the viewport).

Just reversing subpaths won't do it, but you can get some of the effect by adding an enclosing rectangle of the opposite winding. That won't be the same for self-intersecting paths though.

I'd be open to adding some kind of feature for this, most likely a negative clip. Among other things, it's needed to support more of Skia's imaging model.

@dannymcgee
Copy link
Author

We don't have that feature. Are you using this path as a clip or a fill? In the latter case, you need a bounding box somewhere (though I suppose it could ultimately be the viewport).

Thanks for the quick response! Either way would work I suppose, but currently I'm just using fills.

The specific use case I ran into is that I'm trying to render a checkbox as a filled rounded rect with a checkmark-shaped hole in the middle, with the intention being that you could place it on an arbitrary background without having to manually color-match the checkmark like I'm doing currently. (An SVG would probably be the saner way to do this, but I do like having parametric control of the rounded rect at least.)

Vello UI experiment

@dominikh
Copy link

dominikh commented Jun 4, 2024

Does this overlap with linebender/kurbo#277?

@dannymcgee
Copy link
Author

Does this overlap with linebender/kurbo#277?

Yes! I actually missed that issue when I was searching, thanks for the link.

I'll go ahead and close this since my original question has been answered and the feature is being tracked elsewhere.

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

3 participants