t = eina_bezier_t_at(right, len);
_eina_bezier_split_left(right, t, left);
}
+
+EAPI void
+eina_bezier_bounds_get(const Eina_Bezier *b, double *x, double *y, double *w, double *h)
+{
+ double xmin = b->start.x;
+ double xmax = b->start.x;
+ double ymin = b->start.y;
+ double ymax = b->start.y;
+
+ if (b->ctrl_start.x < xmin)
+ xmin = b->ctrl_start.x;
+ else if (b->ctrl_start.x > xmax)
+ xmax = b->ctrl_start.x;
+ if (b->ctrl_end.x < xmin)
+ xmin = b->ctrl_end.x;
+ else if (b->ctrl_end.x > xmax)
+ xmax = b->ctrl_end.x;
+ if (b->end.x < xmin)
+ xmin = b->end.x;
+ else if (b->end.x > xmax)
+ xmax = b->end.x;
+
+ if (b->ctrl_start.y < ymin)
+ ymin = b->ctrl_start.y;
+ else if (b->ctrl_start.y > ymax)
+ ymax = b->ctrl_start.y;
+ if (b->ctrl_end.y < ymin)
+ ymin = b->ctrl_end.y;
+ else if (b->ctrl_end.y > ymax)
+ ymax = b->ctrl_end.y;
+ if (b->end.y < ymin)
+ ymin = b->end.y;
+ else if (b->end.y > ymax)
+ ymax = b->end.y;
+
+ if (x) *x = xmin;
+ if (y) *y = ymin;
+ if (w) *w = xmax - xmin;
+ if (h) *h = ymax - ymin;
+}
*/
EAPI void eina_bezier_split_at_length(const Eina_Bezier *b, double len, Eina_Bezier *left, Eina_Bezier *right) EINA_ARG_NONNULL(1);
+/**
+ * @brief get the bound of the the bezier.
+ *
+ * @param b The floating point bezier.
+ * @param x x coordinate of bounding box.
+ * @param y y coordinate of bounding box.
+ * @param w width of bounding box.
+ * @param h height of bounding box.
+ *
+ * @p b. No check is done on @p b.
+ * @since 1.16
+ */
+EAPI void eina_bezier_bounds_get(const Eina_Bezier *b, double *x, double *y, double *w, double *h) EINA_ARG_NONNULL(1);
+
#endif // EINA_BEZIER_H
}
END_TEST
+START_TEST(eina_bezier_test_bounds_get)
+{
+ Eina_Bezier b;
+ double x, y, w, h;
+
+ eina_init();
+ eina_bezier_values_set(&b,
+ 0, 0,
+ 100, 0,
+ 0, 100,
+ 100, 100);
+
+ eina_bezier_bounds_get(&b, &x, &y, &w, &h);
+
+ fail_if(x !=0 || y!=0 || w !=100 || h !=100 );
+
+ eina_shutdown();
+}
+END_TEST
+
void
eina_test_bezier(TCase *tc)
{
tcase_add_test(tc, eina_bezier_test_t_at);
tcase_add_test(tc, eina_bezier_test_point_at);
tcase_add_test(tc, eina_bezier_test_split_at_length);
+ tcase_add_test(tc, eina_bezier_test_bounds_get);
}