forked from enlightenment/efl
svg: added support for parsing and showing of polyline data.
Reviewers: cedric, jpeg Reviewed By: jpeg Subscribers: cedric, jpeg Differential Revision: https://phab.enlightenment.org/D4064
This commit is contained in:
parent
22f97be785
commit
3ab15990d3
|
@ -978,6 +978,16 @@ _create_polygon_node(Svg_Node *parent, const char *buf, unsigned buflen)
|
|||
return node;
|
||||
}
|
||||
|
||||
static Svg_Node *
|
||||
_create_polyline_node(Svg_Node *parent, const char *buf, unsigned buflen)
|
||||
{
|
||||
Svg_Node *node = _create_node(parent, SVG_NODE_POLYLINE);
|
||||
|
||||
eina_simple_xml_attributes_parse(buf, buflen,
|
||||
_attr_parse_polygon_node, node);
|
||||
return node;
|
||||
}
|
||||
|
||||
#define RECT_DEF(Name, Field) \
|
||||
{ #Name, sizeof (#Name), offsetof(Svg_Rect_Node, Field)}
|
||||
|
||||
|
@ -1055,7 +1065,8 @@ static const struct {
|
|||
TAG_DEF(ellipse),
|
||||
TAG_DEF(path),
|
||||
TAG_DEF(polygon),
|
||||
TAG_DEF(rect)
|
||||
TAG_DEF(rect),
|
||||
TAG_DEF(polyline),
|
||||
};
|
||||
|
||||
static const struct {
|
||||
|
|
|
@ -387,6 +387,7 @@ struct
|
|||
{ SVG_NODE_CIRCLE, "circle" },
|
||||
{ SVG_NODE_ELLIPSE, "ellipse" },
|
||||
{ SVG_NODE_POLYGON, "polygon" },
|
||||
{ SVG_NODE_POLYLINE, "polygon" },
|
||||
{ SVG_NODE_RECT, "rect" },
|
||||
{ SVG_NODE_PATH, "path" },
|
||||
{ SVG_NODE_UNKNOWN, NULL }
|
||||
|
|
|
@ -2437,11 +2437,25 @@ _apply_vg_property(Svg_Node *node, Efl_VG *vg)
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_add_polyline(Efl_VG *vg, double *array, int size, Eina_Bool polygon)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (size < 2) return;
|
||||
|
||||
evas_vg_shape_shape_append_move_to(vg, array[0], array[1]);
|
||||
for (i=2; i < size; i+=2)
|
||||
evas_vg_shape_shape_append_line_to(vg, array[i], array[i+1]);
|
||||
|
||||
if (polygon)
|
||||
evas_vg_shape_shape_append_close(vg);
|
||||
}
|
||||
|
||||
static void
|
||||
_create_vg_node(Svg_Node *node, Efl_VG *parent)
|
||||
{
|
||||
Efl_VG *vg = NULL;
|
||||
int i;
|
||||
Svg_Node *child;
|
||||
Eina_List *l;
|
||||
|
||||
|
@ -2464,12 +2478,10 @@ _create_vg_node(Svg_Node *node, Efl_VG *parent)
|
|||
break;
|
||||
case SVG_NODE_POLYGON:
|
||||
vg = evas_vg_shape_add(parent);
|
||||
for (i=0; i < node->node.polygon.points_count; i+=2)
|
||||
{
|
||||
if (!i)
|
||||
evas_vg_shape_shape_append_move_to(vg, node->node.polygon.points[i], node->node.polygon.points[i+1]);
|
||||
evas_vg_shape_shape_append_line_to(vg, node->node.polygon.points[i], node->node.polygon.points[i+1]);
|
||||
}
|
||||
_add_polyline(vg, node->node.polygon.points, node->node.polygon.points_count, EINA_TRUE);
|
||||
break;
|
||||
case SVG_NODE_POLYLINE:
|
||||
_add_polyline(vg, node->node.polygon.points, node->node.polygon.points_count, EINA_FALSE);
|
||||
break;
|
||||
case SVG_NODE_ELLIPSE:
|
||||
vg = evas_vg_shape_add(parent);
|
||||
|
|
Loading…
Reference in New Issue