Add API for boolean operations on paths
The new APIs here are: gsk_path_union gsk_path_intersection gsk_path_difference gsk_path_symmetric_difference gsk_path_simplify
This commit is contained in:
@@ -1291,3 +1291,96 @@ gsk_path_offset (GskPath *self,
|
||||
|
||||
return gsk_path_builder_free_to_path (builder);
|
||||
}
|
||||
|
||||
/**
|
||||
* gsk_path_simplify:
|
||||
* @self: a `GskPath`
|
||||
* @fill_rule: a `GskFillRule`
|
||||
*
|
||||
* Create a new path that describes the same area as @self,
|
||||
* without overlapping contours.
|
||||
*
|
||||
* Returns: a new `GskPath`
|
||||
*/
|
||||
GskPath *
|
||||
gsk_path_simplify (GskPath *self,
|
||||
GskFillRule fill_rule)
|
||||
{
|
||||
return gsk_path_op (GSK_PATH_OP_SIMPLIFY, fill_rule, self, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* gsk_path_union:
|
||||
* @first: a `GskPath`
|
||||
* @second: a `GskPath`
|
||||
* @fill_rule: a `GskFillRule`
|
||||
*
|
||||
* Create a new path that describes the union of the areas
|
||||
* of the given paths.
|
||||
*
|
||||
* Returns: a new `GskPath`
|
||||
*/
|
||||
GskPath *
|
||||
gsk_path_union (GskPath *first,
|
||||
GskPath *second,
|
||||
GskFillRule fill_rule)
|
||||
{
|
||||
return gsk_path_op (GSK_PATH_OP_UNION, fill_rule, first, second);
|
||||
}
|
||||
|
||||
/**
|
||||
* gsk_path_intersection:
|
||||
* @first: a `GskPath`
|
||||
* @second: a `GskPath`
|
||||
* @fill_rule: a `GskFillRule`
|
||||
*
|
||||
* Create a new path that describes the intersection of the areas
|
||||
* of the given paths.
|
||||
*
|
||||
* Returns: a new `GskPath`
|
||||
*/
|
||||
GskPath *
|
||||
gsk_path_intersection (GskPath *first,
|
||||
GskPath *second,
|
||||
GskFillRule fill_rule)
|
||||
{
|
||||
return gsk_path_op (GSK_PATH_OP_INTERSECTION, fill_rule, first, second);
|
||||
}
|
||||
|
||||
/**
|
||||
* gsk_path_difference:
|
||||
* @first: a `GskPath`
|
||||
* @second: a `GskPath`
|
||||
* @fill_rule: a `GskFillRule`
|
||||
*
|
||||
* Create a new path that describes the difference of the areas
|
||||
* of the given paths.
|
||||
*
|
||||
* Returns: a new `GskPath`
|
||||
*/
|
||||
GskPath *
|
||||
gsk_path_difference (GskPath *first,
|
||||
GskPath *second,
|
||||
GskFillRule fill_rule)
|
||||
{
|
||||
return gsk_path_op (GSK_PATH_OP_DIFFERENCE, fill_rule, first, second);
|
||||
}
|
||||
|
||||
/**
|
||||
* gsk_path_symmetric_difference:
|
||||
* @first: a `GskPath`
|
||||
* @second: a `GskPath`
|
||||
* @fill_rule: a `GskFillRule`
|
||||
*
|
||||
* Create a new path that describes the symmetric difference
|
||||
* of the areas of the given paths.
|
||||
*
|
||||
* Returns: a new `GskPath`
|
||||
*/
|
||||
GskPath *
|
||||
gsk_path_symmetric_difference (GskPath *first,
|
||||
GskPath *second,
|
||||
GskFillRule fill_rule)
|
||||
{
|
||||
return gsk_path_op (GSK_PATH_OP_XOR, fill_rule, first, second);
|
||||
}
|
||||
|
||||
@@ -120,6 +120,30 @@ GskPath * gsk_path_offset (GskPath
|
||||
float distance,
|
||||
GskStroke *stroke);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GskPath * gsk_path_union (GskPath *first,
|
||||
GskPath *second,
|
||||
GskFillRule fill_rule);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GskPath * gsk_path_intersection (GskPath *first,
|
||||
GskPath *second,
|
||||
GskFillRule fill_rule);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GskPath * gsk_path_difference (GskPath *first,
|
||||
GskPath *second,
|
||||
GskFillRule fill_rule);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GskPath * gsk_path_symmetric_difference (GskPath *first,
|
||||
GskPath *second,
|
||||
GskFillRule fill_rule);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GskPath * gsk_path_simplify (GskPath *self,
|
||||
GskFillRule fill_rule);
|
||||
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GskPath, gsk_path_unref)
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
Reference in New Issue
Block a user