evas vector: Added ellipse API 65/249365/3
authorMichal Szczecinski <m.szczecinsk@partner.samsung.com>
Thu, 10 Dec 2020 13:24:05 +0000 (14:24 +0100)
committerHermet Park <chuneon.park@samsung.com>
Fri, 11 Dec 2020 08:36:10 +0000 (08:36 +0000)
In thorVG circle API provides two radius parameters so arc should not be
used to draw ellipses. To simplify code in vg_common lib ellipse API was
created.

Change-Id: I28cc59c9f7c3fa82b1ae3823cd712dce6090bdbc

src/lib/evas/Evas_Legacy.h
src/lib/evas/canvas/efl_canvas_vg_shape.c
src/static_libs/vg_common/vg_common_svg.c

index fe936e8..93d9737 100755 (executable)
@@ -4460,6 +4460,20 @@ EAPI void evas_vg_shape_append_close(Evas_Vg_Shape *obj);
 EAPI void evas_vg_shape_append_circle(Evas_Vg_Shape *obj, double x, double y, double radius);
 
 /**
+ * @brief Append a ellipse with given center and x-radius, y-radius
+ *
+ * @param[in] obj The object.
+ * @param[in] cx The x co-ordinate of the center of the ellipse.
+ * @param[in] cy The y co-ordinate of the center of the ellipse.
+ * @param[in] rx The horizontal radius of the ellipse
+ * @param[in] ry The vertical radius of the ellipse
+ * @param[in] radius The radius of the circle.
+ *
+ * @since 1.25
+ */
+EAPI void evas_vg_shape_append_ellipse(Evas_Vg_Shape *obj, double cx, double cy, double rx, double ry);
+
+/**
  * @brief Append the given rectangle with rounded corner to the path.
  *
  * The xr and yr arguments specify the radii of the ellipses defining the
index b555ecc..df433a7 100644 (file)
@@ -1470,6 +1470,23 @@ evas_vg_shape_append_circle(Evas_Vg_Shape *obj, double x, double y, double radiu
 }
 
 EAPI void
+evas_vg_shape_append_ellipse(Evas_Vg_Shape *obj, double cx, double cy, double rx, double ry)
+{
+#ifdef HAVE_THORVG
+   Efl_Canvas_Vg_Shape_Data *sd = NULL;
+
+   if (!obj) return;
+   sd = _get_shape_data(obj);
+   if (!sd || !sd->shape) return;
+   tvg_shape_append_circle(sd->shape, cx, cy, rx, ry);
+   _assign_current_point(sd, NULL, cx, cy - ry);
+#else
+   efl_gfx_path_append_arc(obj, cx - rx, cy - ry, 2 * rx, 2 * ry, 0, 360);
+#endif
+   efl_canvas_vg_node_change(obj);
+}
+
+EAPI void
 evas_vg_shape_append_rect(Evas_Vg_Shape *obj, double x, double y, double w, double h, double rx, double ry)
 {
 #ifdef HAVE_THORVG
index e5328ea..5dd4830 100644 (file)
@@ -928,9 +928,8 @@ vg_common_create_vg_node_helper(Svg_Node *node, Efl_VG *parent, Vg_File_Data *vg
            break;
         case SVG_NODE_ELLIPSE:
            vg = efl_add(EFL_CANVAS_VG_SHAPE_CLASS, parent);
-           evas_vg_shape_append_arc(vg, node->node.ellipse.cx - node->node.ellipse.rx,
-                                   node->node.ellipse.cy - node->node.ellipse.ry,
-                                   2*node->node.ellipse.rx, 2*node->node.ellipse.ry, 0, 360);
+           evas_vg_shape_append_ellipse(vg, node->node.ellipse.cx, node->node.ellipse.cy,
+               node->node.ellipse.rx, node->node.ellipse.ry);
            evas_vg_shape_append_close(vg);
            break;
         case SVG_NODE_CIRCLE: