geometry: Adds a clutter_geometry_intersects API

This adds a public function named clutter_geometry_intersects which
determines if two geometries intersect or not returning TRUE if so else
FALSE.
This commit is contained in:
Robert Bragg 2010-09-07 17:00:49 +01:00
parent 8a2e164354
commit ff4c24f0a4
3 changed files with 32 additions and 3 deletions

View File

@ -8724,6 +8724,32 @@ clutter_geometry_union (const ClutterGeometry *geometry_a,
result->height = y_2 - y_1; result->height = y_2 - y_1;
} }
/**
* clutter_geometry_intersects:
* @geometry0: The first geometry to test
* @geometry1: The second geometry to test
*
* Determines if @geometry0 and geometry1 intersect returning %TRUE if
* they do else %FALSE.
*
* Return value: %TRUE of @geometry0 and geometry1 intersect else
* %FALSE.
*
* Since: 1.4
*/
gboolean
clutter_geometry_intersects (const ClutterGeometry *geometry0,
const ClutterGeometry *geometry1)
{
if (geometry1->x >= (geometry0->x + (gint)geometry0->width) ||
geometry1->y >= (geometry0->y + (gint)geometry0->height) ||
(geometry1->x + (gint)geometry1->width) <= geometry0->x ||
(geometry1->y + (gint)geometry1->height) <= geometry0->y)
return FALSE;
else
return TRUE;
}
/* /*
* ClutterVertices * ClutterVertices
*/ */

View File

@ -191,6 +191,8 @@ GType clutter_geometry_get_type (void) G_GNUC_CONST;
void clutter_geometry_union (const ClutterGeometry *geometry_a, void clutter_geometry_union (const ClutterGeometry *geometry_a,
const ClutterGeometry *geometry_b, const ClutterGeometry *geometry_b,
ClutterGeometry *result); ClutterGeometry *result);
gboolean clutter_geometry_intersects (const ClutterGeometry *geometry0,
const ClutterGeometry *geometry1);
/** /**
* ClutterKnot: * ClutterKnot:

View File

@ -465,6 +465,7 @@ clutter_vertex_equal
<SUBSECTION> <SUBSECTION>
ClutterGeometry ClutterGeometry
clutter_geometry_union clutter_geometry_union
clutter_geometry_intersects
<SUBSECTION Standard> <SUBSECTION Standard>
CLUTTER_TYPE_GEOMETRY CLUTTER_TYPE_GEOMETRY