--- /dev/null
+/**
+ * gcc -o evas-vg-container evas-vg-container.c `pkg-config --libs --cflags ecore ecore-evas`
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#else
+#define PACKAGE_EXAMPLES_DIR "."
+#endif
+
+#define WIDTH 400
+#define HEIGHT 400
+
+#include <Ecore.h>
+#include <Ecore_Evas.h>
+
+#define COLORS_PREMULT
+
+struct content
+{
+ Ecore_Evas *ee;
+ Evas *ev;
+ Evas_Object *bg;
+ Evas_Object *vg;
+ Efl_VG *root;
+ Efl_VG *container[2];
+};
+static struct content cnt;
+
+static void
+_on_delete(Ecore_Evas *ee EINA_UNUSED)
+{
+ ecore_main_loop_quit();
+}
+
+static void
+_canvas_resize_cb(Ecore_Evas *ee)
+{
+ int w, h;
+
+ ecore_evas_geometry_get(ee, NULL, NULL, &w, &h);
+ evas_object_resize(cnt.bg, w, h);
+ evas_object_resize(cnt.vg, w, h);
+}
+
+static void
+_add_transformation(Efl_VG *shape, Eina_Matrix3 *m)
+{
+ Eina_Matrix3 new_m;
+ const Eina_Matrix3 *old_m;
+
+ old_m = evas_vg_node_transformation_get(shape);
+ if (old_m)
+ {
+ eina_matrix3_compose(m, old_m, &new_m);
+ evas_vg_node_transformation_set(shape, &new_m);
+ }
+ else
+ {
+ evas_vg_node_transformation_set(shape, m);
+ }
+}
+
+static void
+_change_opacity(Efl_VG *vg_obj)
+{
+ int r, g, b, a;
+ evas_vg_node_color_get(vg_obj, &r, &g, &b, &a);
+#ifdef COLORS_PREMULT
+ evas_color_argb_unpremul(a, &r, &g, &b);
+#endif // COLORS_PREMULT
+ a = (a + 50) & 0xff;
+ if (a > 240) a = 255;
+ if (a < 20) a = 0;
+#ifdef COLORS_PREMULT
+ evas_color_argb_premul(a, &r, &g, &b);
+#endif // COLORS_PREMULT
+ evas_vg_node_color_set(vg_obj, r, g, b, a);
+ printf("Object's alpha chnnel was set to %d, rgb:%d/%d/%d\n", a, r,g,b);
+}
+
+static void
+_on_keydown(void *data EINA_UNUSED,
+ Evas *evas EINA_UNUSED,
+ Evas_Object *o,
+ void *einfo)
+{
+ Evas_Event_Key_Down *ei = einfo;
+ Eina_Matrix3 m;
+
+ if ( *ei->key == 'q' )
+ {
+ _on_delete(cnt.ee);
+ return;
+ }
+ else if ( *ei->key == 'a' )
+ {
+ // doesn't work for container
+ _change_opacity(cnt.container[1]);
+ return;
+ }
+ else if (strcmp(ei->key, "t") == 0)
+ {
+ /* t - Translate the shapes +(10,10) */
+ eina_matrix3_identity(&m);
+ eina_matrix3_translate(&m, 10, 10);
+ }
+ else if (strcmp(ei->key, "T") == 0)
+ {
+ /* T - Translate the shapes -(10,10) */
+ eina_matrix3_identity(&m);
+ eina_matrix3_translate(&m, -10, -10);
+ }
+ else if (strcmp(ei->key, "r") == 0)
+ {
+ /* r - Rotate the shapes +10 degrees */
+ eina_matrix3_identity(&m);
+ eina_matrix3_rotate(&m, 10.0 * 2 * 3.141 / 360.0);
+ }
+ else if (strcmp(ei->key, "R") == 0)
+ {
+ /* R - Rotate the shapes -10 degrees */
+ eina_matrix3_identity(&m);
+ eina_matrix3_rotate(&m, -10.0 * 2 * 3.141 / 360.0);
+ }
+ else if (strcmp(ei->key, "s") == 0)
+ {
+ /* s - Scale the shapes +(.1, .1) */
+ eina_matrix3_identity(&m);
+ eina_matrix3_scale(&m, 1.1, 1.1);
+ }
+ else if (strcmp(ei->key, "S") == 0)
+ {
+ /* S - Scale the shapes -(.1, .1) */
+ eina_matrix3_identity(&m);
+ eina_matrix3_scale(&m, .9, .9);
+ }
+ else
+ return;
+
+ _add_transformation(cnt.container[0], &m);
+}
+
+static void
+_draw_shapes()
+{
+ // Container with red shapes
+ cnt.container[0] = evas_vg_container_add(cnt.root);
+
+ Efl_VG *shape = evas_vg_shape_add(cnt.container[0]);
+ evas_vg_shape_append_rect(shape, 100, 100, 100, 100, 0, 0);
+ evas_vg_node_color_set(shape, 255, 0, 0, 255);
+
+ shape = evas_vg_shape_add(cnt.container[0]);
+ evas_vg_shape_append_circle(shape, 200, 200, 50);
+ evas_vg_node_color_set(shape, 255, 0, 0, 255);
+
+ // Container with blue shapes
+ cnt.container[1] = evas_vg_container_add(cnt.root);
+
+ shape = evas_vg_shape_add(cnt.container[1]);
+ evas_vg_shape_append_rect(shape, 200, 200, 100, 100, 0, 0);
+ evas_vg_node_color_set(shape, 0, 0, 255, 255);
+
+ shape = evas_vg_shape_add(cnt.container[1]);
+ evas_vg_shape_append_circle(shape, 300, 300, 50);
+ evas_vg_node_color_set(shape, 0, 0, 255, 255);
+}
+
+static void
+_print_info()
+{
+ printf("Container 0 - Red shapes\n");
+ printf("Container 1 - Blue shapes\n");
+ printf("-------------------------\n");
+ printf("a - change opacity of container 1\n");
+ printf("t/T - Translate container 0 by +/- 10\n");
+ printf("r/R - Rotatate container 0 by +/- 10 degree\n");
+ printf("s/S - Scale container 0 by +/- 0.1\n");
+}
+
+static int
+_init_win()
+{
+ if (!ecore_evas_init()) return EXIT_FAILURE;
+
+ cnt.ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL);
+ if ( ! cnt.ee )
+ {
+ ecore_evas_shutdown();
+ return -1;
+ }
+
+ ecore_evas_callback_delete_request_set(cnt.ee, _on_delete);
+ ecore_evas_callback_resize_set(cnt.ee, _canvas_resize_cb);
+ ecore_evas_show(cnt.ee);
+
+ cnt.ev = ecore_evas_get(cnt.ee);
+ cnt.bg = evas_object_rectangle_add(cnt.ev);
+ evas_object_color_set(cnt.bg, 255, 255, 255, 255);
+ evas_object_focus_set(cnt.bg, EINA_TRUE);
+ evas_object_show(cnt.bg);
+
+ evas_object_event_callback_add(cnt.bg, EVAS_CALLBACK_KEY_DOWN, _on_keydown, NULL);
+
+ cnt.vg = evas_object_vg_add(cnt.ev);
+ evas_object_show(cnt.vg);
+
+ cnt.root = evas_vg_container_add(cnt.vg);
+ evas_object_vg_root_node_set(cnt.vg, cnt.root);
+
+ _canvas_resize_cb(cnt.ee);
+
+ return 0;
+}
+
+int
+main(void)
+{
+ int err = _init_win();
+ if (err != 0) return err;
+
+ _draw_shapes();
+ _print_info();
+
+ ecore_main_loop_begin();
+ ecore_evas_shutdown();
+
+ return 0;
+}