Boolean Operations on Cairo Paths?
Asked Answered
L

2

7

Is there any way to build paths in Cairo by combining two paths together through Boolean operations such as Union, Difference, and Intersection? I'm working on a vector graphics application that uses Cairo to do its rendering and would like to give my users the ability to combine paths together in this manner, but I can't find a way to do it in Cairo.

Lawrenson answered 9/5, 2009 at 16:59 Comment(0)
M
2

I haven't found a way to do this with the cairo libraries. But it's a feature I've been looking for too. Would definitely be helpful when (for example) stroking the combination of two paths - compositing operators mentioned by ntd don't seem to be able to do this.

In the meantime, I'm trying to write scripts for inkscape, and letting inkscape do the unioning/differencing. Acceptable for the problem I'm working on but definitely not for yours. Have you had any luck, either with cairo or any other svg library? After a couple days of googling, it doesn't seem to be trivial :/

Mm answered 11/3, 2012 at 22:31 Comment(1)
ps - path intersect/combine/overlay is listed on the cairo site as a possible summer-of-code project cairographics.org/summerofcode/ideasMm
P
0

Combining paths with operators does not make any sense to me. What do you get from "line AND curve OR arc"?

Instead, you can apply compositing operators by using cairo_set_operator(): it will set how the current drawing operation (being it cairo_fill(), cairo_stroke() or whatever) should be mixed with the old content of the surface.

Pandarus answered 8/10, 2009 at 22:12 Comment(2)
An example of what I mean is the way Inkscape combines paths through boolean operations: usinginkscape.com/node/34. I suppose most of those effects could be achieved through a series of compositing operators, except that places where the two figures' paths intersect wouldn't necessarily have proper line joins.Lawrenson
I still don't understand the question: inkscape itself uses cairo since version 0.46: wiki.inkscape.org/wiki/index.php/Release_notes/…Pandarus

© 2022 - 2024 — McMap. All rights reserved.