Checking if path is simple and closed using cairo

主宰稳场 提交于 2019-12-07 23:55:29

but I'm not sure how this would be possible, since I want to allow both polygons and curved based shapes, like a circle.

Do you know about cairo_copy_path_flat? It gets a flattened copy of the current path, meaning that all curves are approximated with lines.

So, you would somehow get a cairo context (cairo_t in C), create your shape there (with line_to, curve_to, arc etc). Then you do not call fill or stroke, but instead cairo_copy_path_flat.

The resulting path is a series of move_to, line_to and close_path commands which you could then (somehow...) check for intersecting. Checking two straight lines for intersection is relatively straight forward, so you could e.g. just check each line for intersection with every other line.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!