Tizen Native API  5.5
Vector Graphics Object

Vector Graphics Object is the scene graph for managing vector graphics objects. User can create shape objects as well as fill objects and give them to the Evas_Object_Vg for drawing on the screen as well as managing the lifecycle of the objects, enabling reuse of shape objects.

Since Evas_Object_Vg is an Evas_Object all operations applicable to an Evas_Object can be performed on it (clipping, mapping, etc).

To create complex vector graphics you can create a hierarchy of shape and fill objects and give the hierarchy to Evas_Object which will be responsible for drawing and showing on the screen.

As the shape object and fill object (linear and radial gradients) have retain mode API, you only have to create it once and set the properties and give it to Evas_Object_Vg.

Any change in the properties of a shape or fill object are automatically notified to Evas_Object_Vg triggering a redraw to reflect the changes.

To create a vector path, you can give a list of path commands to the shape object using efl_gfx_shape_path_set() API.

Below are the list of features currently supported by Vector object.

  • Drawing SVG Path. You can construct a path by using api in efl_gfx_utils.h
  • Gradient filling and stroking. You can fill or stroke the path using linear or radial gradient.
    See also:
    Evas_Vg_Gradient_Linear and Evas_Vg_Gradient_Radial
  • Transformation support for path and gradient fill. You can apply affine transforms to path objects.
    See also:
    Eina_Matrix.
    Note:
    Below are the list of interfaces and classes that can be used to draw vector graphics using vector objects.
  • Efl.Gfx.Shape
  • Evas.VG_Shape
  • Evas.VG_Node
  • Efl.Gfx.Gradient
  • Efl.Gfx.Gradient_Radial
  • Efl.Gfx.Gradient_Linear

Example:

 vector = evas_object_vg_add(canvas);
 root = evas_obj_vg_root_node_get(vector);
 shape = efl_add(EVAS_VG_SHAPE_CLASS, root);
 Efl_Gfx_Path_Command *path_cmd = NULL;
 double *points = NULL;
 efl_gfx_path_append_circle(&path_cmd, &points);
 *       evas_vg_node_origin_set(shape, 10, 10);
 *       efl_gfx_shape_stroke_width_set(shape, 1.0);
 *       evas_vg_node_color_set(shape, 128, 128, 128, 80);
 *       efl_gfx_shape_path_set(shape, path_cmd, points);
Since (EFL) :
1.14

Functions

Efl_Canvas_Vg_Node * evas_object_vg_root_node_get (const Efl_VG *obj)
 Get the root node of the evas_object_vg.
Evas_Objectevas_object_vg_add (Evas *e)
 Creates a new vector object on the given Evas e canvas.
Efl_VG * evas_vg_shape_add (Efl_VG *parent)
Efl_VG * evas_vg_container_add (Efl_VG *parent)
Eina_Bool evas_vg_node_visible_get (Eo *obj)
void evas_vg_node_visible_set (Eo *obj, Eina_Bool v)
void evas_vg_node_color_get (Eo *obj, int *r, int *g, int *b, int *a)
void evas_vg_node_color_set (Eo *obj, int r, int g, int b, int a)
void evas_vg_shape_stroke_color_get (Eo *obj, int *r, int *g, int *b, int *a)
void evas_vg_shape_stroke_color_set (Eo *obj, int r, int g, int b, int a)
double evas_vg_shape_stroke_width_get (Eo *obj)
void evas_vg_shape_stroke_width_set (Eo *obj, double w)
Efl_Gfx_Cap evas_vg_shape_stroke_cap_get (Eo *obj)
void evas_vg_shape_stroke_cap_set (Eo *obj, Efl_Gfx_Cap c)
Efl_Gfx_Join evas_vg_shape_stroke_join_get (Eo *obj)
void evas_vg_shape_stroke_join_set (Eo *obj, Efl_Gfx_Join j)
void evas_vg_shape_fill_set (Eo *obj, Efl_VG *f)
Efl_VG * evas_vg_shape_fill_get (const Eo *obj)
void evas_vg_shape_stroke_fill_set (Eo *obj, Efl_VG *f)
Efl_VG * evas_vg_shape_stroke_fill_get (const Eo *obj)
void evas_vg_gradient_stop_set (Eo *obj, const Efl_Gfx_Gradient_Stop *colors, unsigned int length)
void evas_vg_gradient_stop_get (Eo *obj, const Efl_Gfx_Gradient_Stop **colors, unsigned int *length)
void evas_vg_gradient_spread_set (Eo *obj, Efl_Gfx_Gradient_Spread s)
Efl_Gfx_Gradient_Spread evas_vg_gradient_spread_get (Eo *obj)
void evas_vg_gradient_linear_start_set (Eo *obj, double x, double y)
void evas_vg_gradient_linear_start_get (Eo *obj, double *x, double *y)
void evas_vg_gradient_linear_end_set (Eo *obj, double x, double y)
void evas_vg_gradient_linear_end_get (Eo *obj, double *x, double *y)
void evas_vg_gradient_radial_center_set (Eo *obj, double x, double y)
void evas_vg_gradient_radial_center_get (Eo *obj, double *x, double *y)
void evas_vg_gradient_radial_radius_set (Eo *obj, double r)
double evas_vg_gradient_radial_radius_get (Eo *obj)
void evas_vg_gradient_radial_focal_set (Eo *obj, double x, double y)
void evas_vg_gradient_radial_focal_get (Eo *obj, double *x, double *y)

Enumeration Type Documentation

Enumeration that defines how viewbox will be filled int the vg canvs's viewport. default Fill_Mode is none

Enumerator:
EVAS_OBJECT_VG_FILL_MODE_NONE 

Don't scale the viewbox. Placed it inside viewport taking align property into account

EVAS_OBJECT_VG_FILL_MODE_STRETCH 

Scale the viewbox so that it matches the canvas viewport. Aaspect ratio might be changed.

EVAS_OBJECT_VG_FILL_MODE_MEET 

Scale the viewbox so that it fits inside canvas viewport while maintaining the aspect ratio. At least one of the dimensions of the viewbox should be equal to the corresponding dimension of the viewport.

EVAS_OBJECT_VG_FILL_MODE_SLICE 

Scale the viewbox so that it covers the entire canvas viewport while maintaining the aspect ratio. At least one of the dimensions of the viewbox should be equal to the corresponding dimension of the viewport.


Function Documentation

Creates a new vector object on the given Evas e canvas.

The shape object hierarchy can be added to the evas_object_vg by accessing the root node of the vg canvas and adding the hierarchy as child to the root node.

Parameters:
[in]eThe given canvas.
Returns:
The created vector object handle.
See also:
evas_obj_vg_root_node_get()
Since (EFL) :
1.14
Since :
3.0
Efl_Canvas_Vg_Node* evas_object_vg_root_node_get ( const Efl_VG *  obj)

Get the root node of the evas_object_vg.

Parameters:
[in]objThe object.
Returns:
Root node of the VG canvas.
Since (EFL) :
1.14
Since :
3.0
Efl_VG* evas_vg_container_add ( Efl_VG *  parent)

Creates a new vector container object.

Parameters:
parentThe given vector container object.
Returns:
The created vector container object handle.
Since (EFL) :
1.14
Since :
3.0
void evas_vg_gradient_linear_end_get ( Eo *  obj,
double *  x,
double *  y 
)

Gets the end point of this linear gradient.

Parameters:
[out]xx co-ordinate of end point
[out]yy co-ordinate of end point
Since :
3.0
void evas_vg_gradient_linear_end_set ( Eo *  obj,
double  x,
double  y 
)

Sets the end point of this linear gradient.

Parameters:
[in]xx co-ordinate of end point
[in]yy co-ordinate of end point
Since :
3.0
void evas_vg_gradient_linear_start_get ( Eo *  obj,
double *  x,
double *  y 
)

Gets the start point of this linear gradient.

Parameters:
[out]xx co-ordinate of start point
[out]yy co-ordinate of start point
Since :
3.0
void evas_vg_gradient_linear_start_set ( Eo *  obj,
double  x,
double  y 
)

Sets the start point of this linear gradient.

Parameters:
[in]xx co-ordinate of start point
[in]yy co-ordinate of start point
Since :
3.0
void evas_vg_gradient_radial_center_get ( Eo *  obj,
double *  x,
double *  y 
)

Gets the center of this radial gradient.

Parameters:
[out]xx co-ordinate of center point
[out]yy co-ordinate of center point
Since :
3.0
void evas_vg_gradient_radial_center_set ( Eo *  obj,
double  x,
double  y 
)

Sets the center of this radial gradient.

Parameters:
[in]xx co-ordinate of center point
[in]yy co-ordinate of center point
Since :
3.0
void evas_vg_gradient_radial_focal_get ( Eo *  obj,
double *  x,
double *  y 
)

Gets the focal point of this radial gradient.

Parameters:
[out]xx co-ordinate of focal point
[out]yy co-ordinate of focal point
Since :
3.0
void evas_vg_gradient_radial_focal_set ( Eo *  obj,
double  x,
double  y 
)

Sets the focal point of this radial gradient.

Parameters:
[in]xx co-ordinate of focal point
[in]yy co-ordinate of focal point
Since :
3.0
double evas_vg_gradient_radial_radius_get ( Eo *  obj)

Gets the center radius of this radial gradient.

Since :
3.0
void evas_vg_gradient_radial_radius_set ( Eo *  obj,
double  r 
)

Sets the center radius of this radial gradient.

Parameters:
[in]rcenter radius
Since :
3.0
Efl_Gfx_Gradient_Spread evas_vg_gradient_spread_get ( Eo *  obj)

Returns the spread method use by this gradient. The default is EFL_GFX_GRADIENT_SPREAD_PAD.

Since (EFL) :
1.14
Since :
3.0
void evas_vg_gradient_spread_set ( Eo *  obj,
Efl_Gfx_Gradient_Spread  s 
)

Specifies the spread method that should be used for this gradient.

Since (EFL) :
1.14
Parameters:
[in]sspread type to be used
Since :
3.0
void evas_vg_gradient_stop_get ( Eo *  obj,
const Efl_Gfx_Gradient_Stop **  colors,
unsigned int *  length 
)

get the list of color stops.

Since (EFL) :
1.14
Parameters:
[out]colorscolor stops list
[out]lengthlength of the list
Since :
3.0
void evas_vg_gradient_stop_set ( Eo *  obj,
const Efl_Gfx_Gradient_Stop *  colors,
unsigned int  length 
)

Set the list of color stops for the gradient

Since (EFL) :
1.14
Parameters:
[in]colorscolor stops list
[in]lengthlength of the list
Since :
3.0
void evas_vg_node_color_get ( Eo *  obj,
int *  r,
int *  g,
int *  b,
int *  a 
)

Retrieves the general/main color of the given Efl_Vg object.

Retrieves the “main” color's RGB component (and alpha channel) values, which range from 0 to 255. For the alpha channel, which defines the object's transparency level, 0 means totally transparent, while 255 means opaque. These color values are premultiplied by the alpha value.

Note:
Use NULL pointers on the components you're not interested in: they'll be ignored by the function.
Parameters:
[out]rThe red component of the given color.
[out]gThe green component of the given color.
[out]bThe blue component of the given color.
[out]aThe alpha component of the given color.
Since :
3.0
void evas_vg_node_color_set ( Eo *  obj,
int  r,
int  g,
int  b,
int  a 
)

Sets the general/main color of the given Efl_Vg object to the given one.

See also:
evas_vg_node_color_get() (for an example)
Note:
These color values are expected to be premultiplied by a.
Parameters:
[in]objThe object.
[in]rThe red component of the given color.
[in]gThe green component of the given color.
[in]bThe blue component of the given color.
[in]aThe alpha component of the given color.
Since :
3.0

Retrieves whether or not the given Efl_Vg object is visible.

Since :
3.0
void evas_vg_node_visible_set ( Eo *  obj,
Eina_Bool  v 
)

Makes the given Efl_Vg object visible or invisible.

Parameters:
[in]vEINA_TRUE if to make the object visible, EINA_FALSE otherwise
Since :
3.0
Efl_VG* evas_vg_shape_add ( Efl_VG *  parent)

Creates a new vector shape object.

Parameters:
parentThe given vector container object.
Returns:
The created vector shape object handle.
Since (EFL) :
1.14
Since :
3.0
Efl_VG* evas_vg_shape_fill_get ( const Eo *  obj)

returns the object that is set for the fill property

Parameters:
objThe object whose fill property is inspected.
Returns:
The object that is set as fill property.
Since :
3.0
void evas_vg_shape_fill_set ( Eo *  obj,
Efl_VG *  f 
)

set a vg object as the fill property

Parameters:
objThe object whose fill property gets modified.
fThe object content will be used for filling.
Since :
3.0
Efl_Gfx_Cap evas_vg_shape_stroke_cap_get ( Eo *  obj)

Gets the cap style used for stroking path.

Since (EFL) :
1.14
Since :
3.0
void evas_vg_shape_stroke_cap_set ( Eo *  obj,
Efl_Gfx_Cap  c 
)

Sets the cap style to be used for stroking the path. The cap will be used for capping the end point of a open subpath.

See also:
Efl_Gfx_Cap
Since (EFL) :
1.14
Parameters:
[in]ccap style to use , default is EFL_GFX_CAP_BUTT
Since :
3.0
void evas_vg_shape_stroke_color_get ( Eo *  obj,
int *  r,
int *  g,
int *  b,
int *  a 
)

Gets the color used for stroking the path.

Since (EFL) :
1.14
Parameters:
[out]rThe red component of the given color.
[out]gThe green component of the given color.
[out]bThe blue component of the given color.
[out]aThe alpha component of the given color.
Since :
3.0
void evas_vg_shape_stroke_color_set ( Eo *  obj,
int  r,
int  g,
int  b,
int  a 
)

Sets the color to be used for stroking the path.

Since (EFL) :
1.14
Parameters:
[in]rThe red component of the given color.
[in]gThe green component of the given color.
[in]bThe blue component of the given color.
[in]aThe alpha component of the given color.
Since :
3.0
Efl_VG* evas_vg_shape_stroke_fill_get ( const Eo *  obj)

returns the object that is set for the stroke fill property

Parameters:
objThe object whose stroke fill property is inspected.
Returns:
The object that is set as stroke fill property.
Since :
3.0
void evas_vg_shape_stroke_fill_set ( Eo *  obj,
Efl_VG *  f 
)

set a vg object as the stroke fill property

Parameters:
objThe object whose stroke fill property gets modified.
fThe object content will be used for stroke filling.
Since :
3.0
Efl_Gfx_Join evas_vg_shape_stroke_join_get ( Eo *  obj)

Gets the join style used for stroking path.

Since (EFL) :
1.14
Since :
3.0
void evas_vg_shape_stroke_join_set ( Eo *  obj,
Efl_Gfx_Join  j 
)

Sets the join style to be used for stroking the path. The join style will be used for joining the two line segment while stroking the path.

See also:
Efl_Gfx_Join
Since (EFL) :
1.14
Parameters:
[in]jjoin style to use , default is EFL_GFX_JOIN_MITER
Since :
3.0
double evas_vg_shape_stroke_width_get ( Eo *  obj)

Gets the stroke width to be used for stroking the path.

Since (EFL) :
1.14
Since :
3.0
void evas_vg_shape_stroke_width_set ( Eo *  obj,
double  w 
)

Sets the stroke width to be used for stroking the path.

Since (EFL) :
1.14
Parameters:
[in]wstroke width to be used
Since :
3.0