Index: uspace/lib/gfx/include/gfx/coord.h
===================================================================
--- uspace/lib/gfx/include/gfx/coord.h	(revision f93e4e3ae22ee5f272a9195be2946896615a6219)
+++ uspace/lib/gfx/include/gfx/coord.h	(revision db3c6795e784ae1634ae0880b340ff7c83f110ef)
@@ -52,4 +52,5 @@
 extern void gfx_rect_envelope(gfx_rect_t *, gfx_rect_t *, gfx_rect_t *);
 extern void gfx_rect_clip(gfx_rect_t *, gfx_rect_t *, gfx_rect_t *);
+extern void gfx_rect_ctr_on_rect(gfx_rect_t *, gfx_rect_t *, gfx_rect_t *);
 extern void gfx_rect_points_sort(gfx_rect_t *, gfx_rect_t *);
 extern void gfx_rect_dims(gfx_rect_t *, gfx_coord2_t *);
Index: uspace/lib/gfx/src/coord.c
===================================================================
--- uspace/lib/gfx/src/coord.c	(revision f93e4e3ae22ee5f272a9195be2946896615a6219)
+++ uspace/lib/gfx/src/coord.c	(revision db3c6795e784ae1634ae0880b340ff7c83f110ef)
@@ -238,4 +238,28 @@
 }
 
+/** Center rectangle on rectangle.
+ *
+ * Translate rectangle @a a so that its center coincides with the
+ * center of rectangle @a b, saving the result in @a dest.
+ *
+ * @param a Rectnagle to translate
+ * @param b Rectangle on which to center
+ * @param dest Place to store resulting rectangle
+ */
+void gfx_rect_ctr_on_rect(gfx_rect_t *a, gfx_rect_t *b, gfx_rect_t *dest)
+{
+	gfx_coord2_t adim;
+	gfx_coord2_t bdim;
+
+	gfx_rect_dims(a, &adim);
+	gfx_rect_dims(b, &bdim);
+
+	dest->p0.x = b->p0.x + bdim.x / 2 - adim.x / 2;
+	dest->p0.y = b->p0.y + bdim.y / 2 - adim.y / 2;
+
+	dest->p1.x = dest->p0.x + adim.x;
+	dest->p1.y = dest->p0.y + adim.y;
+}
+
 /** Sort points of a rectangle.
  *
Index: uspace/lib/gfx/test/coord.c
===================================================================
--- uspace/lib/gfx/test/coord.c	(revision f93e4e3ae22ee5f272a9195be2946896615a6219)
+++ uspace/lib/gfx/test/coord.c	(revision db3c6795e784ae1634ae0880b340ff7c83f110ef)
@@ -597,4 +597,43 @@
 }
 
+/** Center rectangle on rectangle */
+PCUT_TEST(rect_ctr_on_rect)
+{
+	gfx_rect_t a;
+	gfx_rect_t b;
+	gfx_rect_t dest;
+
+	/* Dimensions: 20 x 20 */
+	b.p0.x = 10;
+	b.p0.y = 20;
+	b.p1.x = 30;
+	b.p1.y = 40;
+
+	/* Dimensions: 20 x 20 */
+	a.p0.x = 100;
+	a.p0.y = 200;
+	a.p1.x = 120;
+	a.p1.y = 220;
+
+	/* Centering rectangle of same size should give us the same rectangle */
+	gfx_rect_ctr_on_rect(&a, &b, &dest);
+	PCUT_ASSERT_INT_EQUALS(b.p0.x, dest.p0.x);
+	PCUT_ASSERT_INT_EQUALS(b.p0.y, dest.p0.y);
+	PCUT_ASSERT_INT_EQUALS(b.p1.x, dest.p1.x);
+	PCUT_ASSERT_INT_EQUALS(b.p1.y, dest.p1.y);
+
+	/* Dimensions: 10 x 10 */
+	a.p0.x = 100;
+	a.p0.y = 200;
+	a.p1.x = 110;
+	a.p1.y = 210;
+
+	gfx_rect_ctr_on_rect(&a, &b, &dest);
+	PCUT_ASSERT_INT_EQUALS(15, dest.p0.x);
+	PCUT_ASSERT_INT_EQUALS(25, dest.p0.y);
+	PCUT_ASSERT_INT_EQUALS(25, dest.p1.x);
+	PCUT_ASSERT_INT_EQUALS(35, dest.p1.y);
+}
+
 /** Sort span points that are already sorted should produde indentical points */
 PCUT_TEST(rect_points_sort_sorted)
