--- /dev/null
+/**
+ * gcc -o evas-vg-clipping evas-vg-clipping.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>
+
+struct content
+{
+ Ecore_Evas *ee;
+ Evas *ev;
+ Evas_Object *bg;
+ Evas_Object *vg;
+ Efl_VG *shapes[2];
+};
+static struct content cnt;
+static uint8_t shapeid = 1;
+
+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
+_on_keydown(void *data EINA_UNUSED, Evas *evas EINA_UNUSED, Evas_Object *o, void *einfo)
+{
+ Evas_Event_Key_Down *ei = einfo;
+ if (*ei->key == 'q')
+ {
+ _on_delete(cnt.ee);
+ }
+
+ if (*ei->key == 'a')
+ {
+ int r, g, b, a;
+ evas_vg_node_color_get(cnt.shapes[shapeid], &r, &g, &b, &a);
+
+ evas_color_argb_unpremul(a, &r, &g, &b);
+
+ a = (a + 50) & 0xff;
+ if (a > 240) a = 255;
+ if (a < 20) a = 0;
+
+ printf("Object #%d alpha chnnel was set to %d, rgb:%d/%d/%d\n", shapeid, a, r, g, b);
+
+ evas_color_argb_premul(a, &r, &g, &b);
+
+ evas_vg_node_color_set(cnt.shapes[shapeid], r, g, b, a);
+ }
+
+ if (*ei->key == 's')
+ {
+ shapeid = (shapeid + 1) % 2;
+ printf("Active object switched to #%d\n", shapeid);
+ }
+
+ if (strcmp(ei->key, "Left") == 0)
+ {
+ double x, y;
+ evas_vg_node_origin_get(cnt.shapes[shapeid], &x, &y);
+ x -= 100;
+ if (x < -100) x = -100;
+ evas_vg_node_origin_set(cnt.shapes[shapeid], x, y);
+ printf("Active object #%d moved left\n", shapeid);
+ }
+ else if (strcmp(ei->key, "Right") == 0)
+ {
+ double x, y;
+ evas_vg_node_origin_get(cnt.shapes[shapeid], &x, &y);
+ x += 100;
+ if (x > 100) x = 100;
+ evas_vg_node_origin_set(cnt.shapes[shapeid], x, y);
+ printf("Active object #%d moved left\n", shapeid);
+ }
+}
+
+int main(void)
+{
+ Efl_VG *container = NULL;
+
+ 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);
+
+ _canvas_resize_cb(cnt.ee);
+
+ container = evas_vg_container_add(cnt.vg);
+
+ Efl_VG *back = evas_vg_shape_add(container);
+ evas_vg_shape_append_rect(back, 150, 150, 100, 100, 0, 0);
+ evas_vg_node_color_set(back, 0x00, 0xba, 0xcc, 255);
+ cnt.shapes[0] = back;
+
+ Efl_VG *front = evas_vg_shape_add(container);
+ evas_vg_shape_append_rect(front, 100, 100, 200, 200, 0, 0);
+ evas_vg_node_color_set(front, 0xfa, 0xa0, 0xcc, 255);
+ cnt.shapes[1] = front;
+
+ printf("Evas clipping test example\n");
+ printf("'a' to change alpha value\n");
+ printf("'s' to switch active object\n");
+ printf("left/right to move object\n");
+ printf("'q' to quit\n");
+
+ evas_object_vg_root_node_set(cnt.vg, container);
+ ecore_main_loop_begin();
+ ecore_evas_shutdown();
+
+ return 0;
+}