summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/examples/evas/efl-canvas-vg-simple.c652
-rw-r--r--src/examples/evas/meson.build1
2 files changed, 653 insertions, 0 deletions
diff --git a/src/examples/evas/efl-canvas-vg-simple.c b/src/examples/evas/efl-canvas-vg-simple.c
new file mode 100644
index 0000000000..36bdfcb6a8
--- /dev/null
+++ b/src/examples/evas/efl-canvas-vg-simple.c
@@ -0,0 +1,652 @@
1/**
2 * Example of Evas' vector graphics object and API.
3 *
4 * @verbatim
5 * gcc -o efl-canvas-vg-simple efl-canvas-vg-simple.c `pkg-config --libs --cflags evas ecore ecore-evas eina ector eo efl` -lm
6 * @endverbatim
7 */
8
9#ifdef HAVE_CONFIG_H
10#include "config.h"
11#else
12#define PACKAGE_EXAMPLES_DIR "."
13#endif
14
15#define WIDTH 600
16#define HEIGHT 800
17
18#include <Eo.h>
19#include <Efl.h>
20#include <Evas.h>
21#include <Ecore.h>
22#include <Ecore_Evas.h>
23#include <Eina.h>
24
25struct example_data
26{
27 Ecore_Evas *ee;
28 Evas *evas;
29 Efl_Canvas_Rectangle *bg;
30 Efl_VG *vg;
31 Eina_List *shape_list;
32
33};
34
35static struct example_data d;
36Ecore_Animator *animator;
37
38/* These data strings follows an SVG-like convention for describing the
39 * nodes of a path. 'M x,y' indicates a move-to operation that sets
40 * where to start drawing. 'L x,y' draws a straight line that ends at
41 * the given point. 'C x1,y1 x2,y2 x,y' defines a Bezier curve's two
42 * control points and the x,y coordinate where the curve ends. 'Z' marks
43 * the end of the path.
44 */
45static const char *batman = "M 256,213 C 245,181 206,187 234,262 147,181 169,71.2 233,18 220,56 235,81 283,88 285,78.7 286,69.3 288,60 289,61.3 290,62.7 291,64 291,64 297,63 300,63 303,63 309,64 309,64 310,62.7 311,61.3 312,60 314,69.3 315,78.7 317,88 365,82 380,56 367,18 431,71 453,181 366,262 394,187 356,181 344,213 328,185 309,184 300,284 291,184 272,185 256,213 Z";
46static const char *morph1[2] = {"M 0,0 L 0,0 L 100,0 L 100,0 L 100,100 L 100,100 L 0,100 L 0,100 L 0,0",
47 "M 0,0 L 50,-80 L 100,0 L 180,50 L 100,100 L 50,180 L 0,100 L -80,50 L 0,0"};
48
49static void _main_menu();
50static void _main_menu_key_handle(void *data EINA_UNUSED, const Efl_Event *ev);
51
52static const char *main_menu = \
53 "Main Menu:\n"
54 "\t1 - Basic Shape test\n"
55 "\t2 - Interpolation\n"
56 "\t3 - Gradient\n"
57 "\te - Exit\n"
58 "\th - Print help\n";
59
60static const char *basic_shape_menu = \
61 "Basic Shape Menu:\n"
62 "\tup - Increase Stroke Width by 0.5\n"
63 "\tdown - Decrease Stroke Width by 0.5\n"
64 "\tr - +10 degree rotation\n"
65 "\tR - -10 degree rotation\n"
66 "\ts - +(.1, .1) scale\n"
67 "\tS - -(.1, .1) scale\n"
68 "\tt - +(10,10) translation\n"
69 "\tT - +(10,10) translation\n"
70 "\td - Reset path data\n"
71 "\te - Exit\n"
72 "\tb - Back to Main Menu\n"
73 "\th - Print help\n";
74
75static const char *interpolation_menu = \
76 "Interpolation Menu:\n"
77 "\te - Exit\n"
78 "\tb - Back to Main Menu\n"
79 "\th - print help\n";
80
81static const char *gradient_menu = \
82 "Gradient Menu:\n"
83 "\te - Exit\n"
84 "\tb - Back to Main Menu\n"
85 "\th - print help\n";
86
87static void
88_on_delete(Ecore_Evas *ee EINA_UNUSED)
89{
90 if (animator) ecore_animator_del(animator);
91 ecore_main_loop_quit();
92}
93
94static void
95_canvas_resize_cb(Ecore_Evas *ee)
96{
97 int w, h;
98
99 ecore_evas_geometry_get(ee, NULL, NULL, &w, &h);
100
101 efl_gfx_entity_geometry_set(d.bg, EINA_RECT(0, 0, w, h));
102 efl_gfx_entity_geometry_set(d.vg, EINA_RECT(0, 0, w, h));
103}
104
105static void
106reset_test()
107{
108 if(d.vg) efl_del(d.vg);
109 d.shape_list = eina_list_free(d.shape_list);
110
111 d.vg = efl_add(EFL_CANVAS_VG_OBJECT_CLASS, d.evas,
112 efl_canvas_object_key_focus_set(efl_added, EINA_TRUE),
113 efl_gfx_entity_visible_set(efl_added, EINA_TRUE));
114
115 _canvas_resize_cb(d.ee);
116}
117
118// 2. Basic shape Test Case START
119
120/* Applies a matrix transformation to a shape. If there is already a
121 * matrix transformation applied, the new tranformation is matrix
122 * multiplied with the existing one so both transformations are used.
123 */
124static void
125_added_transformation(Efl_VG *shape, Eina_Matrix3 *m)
126{
127 Eina_Matrix3 new_m;
128 const Eina_Matrix3 *old_m;
129
130 old_m = efl_canvas_vg_node_transformation_get(shape);
131 if (old_m)
132 {
133 eina_matrix3_compose(m, old_m, &new_m);
134 efl_canvas_vg_node_transformation_set(shape, &new_m);
135 }
136 else
137 {
138 efl_canvas_vg_node_transformation_set(shape, m);
139 }
140}
141
142/*
143 * Applies various modifications to the canvas objects as directed by
144 * the user.
145 */
146static void
147_basic_shape_key_handle(void *data EINA_UNUSED, const Efl_Event *ev)
148{
149 Efl_VG *shape;
150 Eina_List *l;
151 Eina_Matrix3 m;
152 double stroke_w;
153
154 if (!strcmp(efl_input_key_sym_get(ev->info) , "h"))
155 {
156 /* h - Print help */
157 puts(basic_shape_menu);
158 }
159 else if (!strcmp(efl_input_key_sym_get(ev->info) , "e"))
160 {
161 /* e - Exit */
162 _on_delete(d.ee);
163 }
164
165 else if (!strcmp(efl_input_key_sym_get(ev->info) , "b"))
166 {
167 /* b - Back to Main Menu */
168 _main_menu();
169 }
170 else if (!strcmp(efl_input_key_sym_get(ev->info) , "Up"))
171 {
172 /* up - Increase Stroke Width by 0.5 */
173 EINA_LIST_FOREACH(d.shape_list, l, shape)
174 {
175 stroke_w = efl_gfx_shape_stroke_width_get(shape);
176 efl_gfx_shape_stroke_width_set(shape, stroke_w + 0.5);
177 efl_gfx_path_commit(shape);
178 }
179 }
180 else if (!strcmp(efl_input_key_sym_get(ev->info) , "Down"))
181 {
182 /* down - Decrease Stroke Width by 0.5 */
183 EINA_LIST_FOREACH(d.shape_list, l, shape)
184 {
185 stroke_w = efl_gfx_shape_stroke_width_get(shape);
186 if (stroke_w <= 0.5) stroke_w = 1;
187 efl_gfx_shape_stroke_width_set(shape, stroke_w - 0.5);
188 efl_gfx_path_commit(shape);
189 }
190 }
191 else if (!strcmp(efl_input_key_sym_get(ev->info) , "r"))
192 {
193 /* r - Rotate the shapes +10 degrees */
194 eina_matrix3_identity(&m);
195 eina_matrix3_rotate(&m, 10.0 * 2 * 3.141 / 360.0);
196 EINA_LIST_FOREACH(d.shape_list, l, shape)
197 {
198 _added_transformation(shape, &m);
199 }
200 }
201 else if (!strcmp(efl_input_key_sym_get(ev->info) , "R"))
202 {
203 /* R - Rotate the shapes -10 degrees */
204 eina_matrix3_identity(&m);
205 eina_matrix3_rotate(&m, -10.0 * 2 * 3.141 / 360.0);
206 EINA_LIST_FOREACH(d.shape_list, l, shape)
207 {
208 _added_transformation(shape, &m);
209 }
210 }
211 else if (!strcmp(efl_input_key_sym_get(ev->info) , "s"))
212 {
213 /* s - Scale the shapes +(.1, .1) */
214 eina_matrix3_identity(&m);
215 eina_matrix3_scale(&m, 1.1, 1.1);
216 EINA_LIST_FOREACH(d.shape_list, l, shape)
217 {
218 _added_transformation(shape, &m);
219 }
220 }
221 else if (!strcmp(efl_input_key_sym_get(ev->info) , "S"))
222 {
223 /* S - Scale the shapes -(.1, .1) */
224 eina_matrix3_identity(&m);
225 eina_matrix3_scale(&m, .9, .9);
226 EINA_LIST_FOREACH(d.shape_list, l, shape)
227 {
228 _added_transformation(shape, &m);
229 }
230 }
231 else if (!strcmp(efl_input_key_sym_get(ev->info) , "t"))
232 {
233 /* t - Translate the shapes +(10,10) */
234 eina_matrix3_identity(&m);
235 eina_matrix3_translate(&m, 10, 10);
236 EINA_LIST_FOREACH(d.shape_list, l, shape)
237 {
238 _added_transformation(shape, &m);
239 }
240 }
241 else if (!strcmp(efl_input_key_sym_get(ev->info) , "T"))
242 {
243 /* T - Translate the shapes +(10,10) */
244 eina_matrix3_identity(&m);
245 eina_matrix3_translate(&m, -10, -10);
246 EINA_LIST_FOREACH(d.shape_list, l, shape)
247 {
248 _added_transformation(shape, &m);
249 }
250 }
251 else if (!strcmp(efl_input_key_sym_get(ev->info) , "d"))
252 {
253 /* d - Reset path data */
254 EINA_LIST_FOREACH(d.shape_list, l, shape)
255 {
256 efl_gfx_path_reset(shape);
257 }
258 }
259}
260
261/* Create several different geometric objects - a line, rectangle,
262 * circle, and arc, each with distinct style and placement.
263 */
264static void
265_1_basic_shape_test()
266{
267 Efl_VG *container, *shape, *new_shape;
268
269 reset_test();
270 efl_event_callback_add(d.vg, EFL_EVENT_KEY_DOWN, _basic_shape_key_handle, NULL);
271 puts(basic_shape_menu);
272
273 container = efl_add(EFL_CANVAS_VG_CONTAINER_CLASS, d.vg);
274
275 // Line
276 shape = efl_add(EFL_CANVAS_VG_SHAPE_CLASS, container,
277 efl_gfx_path_append_move_to(efl_added, 0, 0), // Move strating point path
278 efl_gfx_path_append_line_to(efl_added, 100, 0), // Add line form move point
279 efl_gfx_shape_stroke_color_set(efl_added, 255, 0, 0, 255),
280 efl_gfx_shape_stroke_width_set(efl_added, 5),
281 efl_canvas_vg_node_origin_set(efl_added, 50, 50),
282 efl_gfx_shape_stroke_cap_set(efl_added, EFL_GFX_CAP_ROUND)); // Set stroke cap
283 d.shape_list = eina_list_append(d.shape_list, shape);
284
285 new_shape = efl_add(EFL_CANVAS_VG_SHAPE_CLASS, container,
286 efl_gfx_path_copy_from(efl_added, shape), // Path duplicate.
287 efl_gfx_shape_stroke_color_set(efl_added, 0, 100, 0, 100),
288 efl_gfx_path_append_line_to(efl_added, 100, 50),
289 efl_canvas_vg_node_origin_set(efl_added, 200, 50),
290 efl_gfx_shape_stroke_cap_set(efl_added, EFL_GFX_CAP_SQUARE));
291 d.shape_list = eina_list_append(d.shape_list, new_shape);
292
293 new_shape = efl_add(EFL_CANVAS_VG_SHAPE_CLASS, container,
294 efl_gfx_path_copy_from(efl_added, shape),
295 efl_gfx_shape_stroke_color_set(efl_added, 0, 0, 255, 255),
296 efl_gfx_path_append_line_to(efl_added, 50, 50),
297 efl_canvas_vg_node_origin_set(efl_added, 350, 50),
298 efl_gfx_shape_stroke_cap_set(efl_added, EFL_GFX_CAP_ROUND),
299 efl_gfx_shape_stroke_join_set(efl_added, EFL_GFX_JOIN_ROUND)); // Set stroke join
300 d.shape_list = eina_list_append(d.shape_list, new_shape);
301
302 // Rect
303 shape = efl_add(EFL_CANVAS_VG_SHAPE_CLASS, container,
304 efl_gfx_path_append_rect(efl_added, 0, 0, 100 , 100, 10, 10), // Draw Rectangle
305 efl_gfx_shape_stroke_color_set(efl_added, 255, 0, 0, 255),
306 efl_gfx_shape_stroke_width_set(efl_added, 5),
307 efl_canvas_vg_node_origin_set(efl_added, 50, 150));
308 d.shape_list = eina_list_append(d.shape_list, shape);
309
310 new_shape = efl_add(EFL_CANVAS_VG_SHAPE_CLASS, container,
311 efl_gfx_path_copy_from(efl_added, shape),
312 efl_gfx_shape_stroke_color_set(efl_added, 0, 0, 0, 0),
313 efl_gfx_color_set(efl_added, 0, 0, 100, 100), // Set fill color.
314 efl_canvas_vg_node_origin_set(efl_added, 200, 150));
315 d.shape_list = eina_list_append(d.shape_list, new_shape);
316
317 new_shape = efl_add(EFL_CANVAS_VG_SHAPE_CLASS, container,
318 efl_gfx_path_copy_from(efl_added, shape),
319 efl_gfx_shape_stroke_color_set(efl_added, 100, 0, 0, 100),
320 efl_gfx_color_set(efl_added, 0, 100, 100, 100),
321 efl_canvas_vg_node_origin_set(efl_added, 350, 150));
322 d.shape_list = eina_list_append(d.shape_list, new_shape);
323
324 // Circle
325 shape = efl_add(EFL_CANVAS_VG_SHAPE_CLASS, container,
326 efl_gfx_path_append_circle(efl_added, 50, 50, 50), //Draw Circle
327 efl_gfx_shape_stroke_color_set(efl_added, 255, 0, 0, 255),
328 efl_gfx_shape_stroke_width_set(efl_added, 5),
329 efl_canvas_vg_node_origin_set(efl_added, 50, 300));
330 d.shape_list = eina_list_append(d.shape_list, shape);
331
332 new_shape = efl_add(EFL_CANVAS_VG_SHAPE_CLASS, container,
333 efl_gfx_path_copy_from(efl_added, shape),
334 efl_gfx_shape_stroke_color_set(efl_added, 0, 0, 0, 0),
335 efl_gfx_color_set(efl_added, 0, 0, 255, 255),
336 efl_canvas_vg_node_origin_set(efl_added, 200, 300));
337 d.shape_list = eina_list_append(d.shape_list, new_shape);
338
339 new_shape = efl_add(EFL_CANVAS_VG_SHAPE_CLASS, container,
340 efl_gfx_path_copy_from(efl_added, shape),
341 efl_gfx_shape_stroke_color_set(efl_added, 150, 0, 0, 150),
342 efl_gfx_color_set(efl_added, 0, 0, 200, 200),
343 efl_canvas_vg_node_origin_set(efl_added, 350, 300));
344 d.shape_list = eina_list_append(d.shape_list, new_shape);
345
346 // Arc
347 shape = efl_add(EFL_CANVAS_VG_SHAPE_CLASS, container,
348 efl_gfx_path_append_arc(efl_added, 0, 0, 100, 100, 45, -200), // Draw Arc
349 efl_gfx_path_append_line_to(efl_added, 50, 50),
350 efl_gfx_shape_stroke_cap_set(efl_added, EFL_GFX_CAP_ROUND),
351 efl_gfx_shape_stroke_color_set(efl_added, 255, 0, 0, 255),
352 efl_gfx_shape_stroke_width_set(efl_added, 5),
353 efl_canvas_vg_node_origin_set(efl_added, 50, 450));
354 d.shape_list = eina_list_append(d.shape_list, shape);
355
356 new_shape = efl_add(EFL_CANVAS_VG_SHAPE_CLASS, container,
357 efl_gfx_path_append_arc(efl_added, 0, 0, 100, 100, 90, 200),
358 efl_gfx_shape_stroke_color_set(efl_added, 0, 0, 0, 0),
359 efl_gfx_color_set(efl_added, 0, 0, 200, 200),
360 efl_canvas_vg_node_origin_set(efl_added, 200, 450));
361 d.shape_list = eina_list_append(d.shape_list, new_shape);
362
363 new_shape = efl_add(EFL_CANVAS_VG_SHAPE_CLASS, container,
364 efl_gfx_path_append_arc(efl_added, 0, 0, 100, 100, 90, 200),
365 efl_gfx_path_append_line_to(efl_added, 50, 50),
366 efl_gfx_shape_stroke_color_set(efl_added, 0, 0, 0, 0),
367 efl_gfx_color_set(efl_added, 0, 0, 200, 200),
368 efl_canvas_vg_node_origin_set(efl_added, 350, 450));
369 d.shape_list = eina_list_append(d.shape_list, new_shape);
370
371 efl_canvas_vg_object_root_node_set(d.vg, container);
372}
373
374// 2. Basic shape Test Case END
375
376// 2. Interpolation Test Case START
377
378static void
379_interpolation_key_handle(void *data EINA_UNUSED, const Efl_Event *ev)
380{
381 if (!strcmp(efl_input_key_sym_get(ev->info) , "h"))
382 {
383 /* h - Print help */
384 puts(basic_shape_menu);
385 }
386 else if (!strcmp(efl_input_key_sym_get(ev->info) , "e"))
387 {
388 /* e - Exit */
389 _on_delete(d.ee);
390 }
391 else if (!strcmp(efl_input_key_sym_get(ev->info) , "b"))
392 {
393 /* b - Back to main menu */
394 _main_menu();
395 }
396}
397
398static int anim_index = 0;
399static Eina_Bool
400_interpolation_keyframe(void *data EINA_UNUSED, double pos)
401{
402 int next = (anim_index == 1) ? 0 : 1;
403
404 // Reset Base Object's path
405 efl_gfx_path_reset(eina_list_nth(d.shape_list, 2));
406 // Set Path that interpolated from 'from' Object and 'to' Object.
407 efl_gfx_path_interpolate(eina_list_nth(d.shape_list, 2),
408 eina_list_nth(d.shape_list, anim_index),
409 eina_list_nth(d.shape_list, next),
410 ecore_animator_pos_map(pos, ECORE_POS_MAP_SINUSOIDAL, 0.0, 0.0));
411
412 if (pos == 1.0)
413 {
414 anim_index = (anim_index == 1) ? 0 : 1;
415 animator = ecore_animator_timeline_add(1, _interpolation_keyframe, NULL);
416 }
417 return EINA_TRUE;
418}
419
420static void
421_2_interpolation_test()
422{
423 anim_index = 0;
424
425 Efl_VG *shape;
426
427 reset_test();
428
429 efl_event_callback_add(d.vg, EFL_EVENT_KEY_DOWN, _interpolation_key_handle, NULL);
430 animator = ecore_animator_timeline_add(1, _interpolation_keyframe, NULL);
431 puts(interpolation_menu);
432
433 //Interpolation 'from' and 'to' Object
434 shape = efl_add(EFL_CANVAS_VG_SHAPE_CLASS, d.vg,
435 efl_gfx_path_append_svg_path(efl_added, morph1[0]), // Set SVG path
436 efl_gfx_shape_stroke_color_set(efl_added, 255, 0, 0, 255),
437 efl_gfx_shape_stroke_width_set(efl_added, 5),
438 efl_canvas_vg_node_origin_set(efl_added, 100, 100)
439);
440 d.shape_list = eina_list_append(d.shape_list, shape);
441
442 shape = efl_add(EFL_CANVAS_VG_SHAPE_CLASS, d.vg,
443 efl_gfx_path_append_svg_path(efl_added, morph1[1]), // Set SVG path
444 efl_gfx_shape_stroke_color_set(efl_added, 0, 0, 255, 255),
445 efl_gfx_shape_stroke_width_set(efl_added, 10),
446 efl_canvas_vg_node_origin_set(efl_added, 150, 150));
447 d.shape_list = eina_list_append(d.shape_list, shape);
448
449 // Base Object
450 shape = efl_add(EFL_CANVAS_VG_SHAPE_CLASS, d.vg);
451 d.shape_list = eina_list_append(d.shape_list, shape);
452
453 efl_canvas_vg_object_root_node_set(d.vg, shape);
454}
455
456// 2. Interpolation Test Case END
457
458
459// 3. Gradient Test Case START
460
461static void
462_gradient_key_handle(void *data EINA_UNUSED, const Efl_Event *ev)
463{
464 if (!strcmp(efl_input_key_sym_get(ev->info) , "h"))
465 {
466 /* h - Print help */
467 puts(basic_shape_menu);
468 }
469 else if (!strcmp(efl_input_key_sym_get(ev->info) , "e"))
470 {
471 /* e - Exit */
472 _on_delete(d.ee);
473 }
474 else if (!strcmp(efl_input_key_sym_get(ev->info) , "b"))
475 {
476 /* b - Back to main menu */
477 _main_menu();
478 }
479}
480
481static void
482_3_gradient_test()
483{
484 Efl_VG *container, *shape;
485 Efl_Canvas_Vg_Gradient *grad_fill, *grad_stroke;
486
487 reset_test();
488 efl_event_callback_add(d.vg, EFL_EVENT_KEY_DOWN, _gradient_key_handle, NULL);
489 puts(gradient_menu);
490
491 container = efl_add(EFL_CANVAS_VG_CONTAINER_CLASS, d.vg);
492
493 // Rect Shape
494 shape = efl_add(EFL_CANVAS_VG_SHAPE_CLASS, container,
495 efl_gfx_path_append_rect(efl_added, 0, 0, 100 , 100, 10, 10),
496 efl_gfx_shape_stroke_color_set(efl_added, 255, 0, 0, 255),
497 efl_gfx_shape_stroke_width_set(efl_added, 5),
498 efl_canvas_vg_node_origin_set(efl_added, 50, 50));
499
500 //Make Linear gradient for fill
501 grad_stroke = efl_add(EFL_CANVAS_VG_GRADIENT_LINEAR_CLASS, container,
502 efl_gfx_gradient_linear_start_set(efl_added, 0, 0),
503 efl_gfx_gradient_linear_end_set(efl_added, 100, 100),
504 efl_gfx_entity_visible_set(efl_added, EINA_TRUE));
505 //Make Stops
506 float pa;
507 Efl_Gfx_Gradient_Stop stops[2];
508 stops[0].offset = 0;
509 pa = 100.0 / 255.0;
510 stops[0].r = (int)(255.0 * pa);
511 stops[0].g = 0;
512 stops[0].b = 0;
513 stops[0].a = 100;
514
515 stops[1].offset = 1;
516 pa = 200.0 / 255;
517 stops[1].r = 0;
518 stops[1].g = 0;
519 stops[1].b = (int)(255.0 * pa);
520 stops[1].a = 200.0;
521 efl_gfx_gradient_stop_set(grad_stroke, stops, 2);
522 //Set Gradient
523 efl_canvas_vg_shape_stroke_fill_set(shape, grad_stroke);
524
525 shape = efl_add(EFL_CANVAS_VG_SHAPE_CLASS, container,
526 efl_gfx_path_append_rect(efl_added, 0, 0, 100 , 100, 10, 10),
527 efl_gfx_shape_stroke_width_set(efl_added, 5),
528 efl_gfx_color_set(efl_added, 0, 0, 100, 100),
529 efl_canvas_vg_node_origin_set(efl_added, 50, 200));
530 //Make Radial Gradient for Stroke
531 grad_fill = efl_add(EFL_CANVAS_VG_GRADIENT_RADIAL_CLASS, container,
532 efl_gfx_gradient_radial_center_set(efl_added, 50, 50),
533 efl_gfx_gradient_radial_focal_set(efl_added, 10, 10),
534 efl_gfx_gradient_radial_radius_set(efl_added, 100),
535 efl_gfx_entity_visible_set(efl_added, EINA_TRUE));
536 //Make Stops
537 stops[0].offset = 0;
538 pa = 100.0 / 255.0;
539 stops[0].r = (int)(255.0 * pa);
540 stops[0].g = 0;
541 stops[0].b = 0;
542 stops[0].a = 100;
543
544 stops[1].offset = 1;
545 pa = 100.0 / 255;
546 stops[1].r = 0;
547 stops[1].g = (int)(255.0 * pa);
548 stops[1].b = 0;
549 stops[1].a = 100.0;
550 efl_gfx_gradient_stop_set(grad_fill, stops, 2);
551 //Set Gradient
552 efl_canvas_vg_shape_fill_set(shape, grad_fill);
553
554 efl_canvas_vg_object_root_node_set(d.vg, container);
555}
556// 3. Gradient Test Case END
557
558// Main Menu START
559static void
560_main_menu()
561{
562 Efl_VG *shape;
563 if (animator) ecore_animator_del(animator);
564 animator = NULL;
565 if(d.vg) efl_del(d.vg);
566 if(d.bg) efl_del(d.bg);
567 d.bg = efl_add(EFL_CANVAS_RECTANGLE_CLASS, d.evas,
568 efl_gfx_color_set(efl_added, 255, 255, 255, 255),
569 efl_gfx_entity_visible_set(efl_added, EINA_TRUE),
570 efl_canvas_object_key_focus_set(efl_added, EINA_TRUE),
571 efl_event_callback_add(efl_added, EFL_EVENT_KEY_DOWN, _main_menu_key_handle, NULL));
572
573 // Create the initial screen - Yellow color bat
574 // Make Efl.Canvas.Vg.Object object
575 d.vg = efl_add(EFL_CANVAS_VG_OBJECT_CLASS, d.evas,
576 efl_gfx_entity_visible_set(efl_added, EINA_TRUE));
577
578 // Make Efl.Canvas.Vg.Shape
579 shape = efl_add(EFL_CANVAS_VG_SHAPE_CLASS, d.vg,
580 efl_gfx_path_append_svg_path(efl_added, batman), // Set SVG path
581 efl_gfx_shape_stroke_color_set(efl_added, 255, 0, 0, 255), // Set Stroke color
582 efl_gfx_shape_stroke_width_set(efl_added, 5), // Set Stroke width
583 efl_gfx_color_set(efl_added, 255, 255, 0, 255), // Set Fill color
584 efl_canvas_vg_node_origin_set(efl_added, 25, 100)); // Set Position
585
586 // Set the root node of Efl.Canvas.Vg.Object
587 // The Efl.Canvas.Vg.Object searches and renders
588 // Efl.Canvas.Vg.Node(Shape, Container, etc...) from set root node.
589 efl_canvas_vg_object_root_node_set(d.vg, shape);
590
591 _canvas_resize_cb(d.ee);
592 puts(main_menu);
593}
594
595static void
596_main_menu_key_handle(void *data EINA_UNUSED, const Efl_Event *ev)
597{
598
599 if (!strcmp(efl_input_key_sym_get(ev->info) , "h"))
600 {
601 /* h - Help menu */
602 puts(main_menu);
603 }
604 else if (!strcmp(efl_input_key_sym_get(ev->info) , "e"))
605 {
606 /* e - Exit */
607 _on_delete(d.ee);
608 }
609 else if (!strcmp(efl_input_key_sym_get(ev->info) , "1"))
610 {
611 /* 1 - Basic Shape test */
612 _1_basic_shape_test();
613 }
614 else if (!strcmp(efl_input_key_sym_get(ev->info) , "2"))
615 {
616 /* 2 - Interpolation */
617 _2_interpolation_test();
618 }
619 else if (!strcmp(efl_input_key_sym_get(ev->info) , "3"))
620 {
621 /* 3 - Gradient */
622 _3_gradient_test();
623 }
624}
625// Main Menu END
626
627int
628main(void)
629{
630 if (!ecore_evas_init())
631 return EXIT_FAILURE;
632
633 d.ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL);
634 if (!d.ee)
635 goto error;
636
637 ecore_evas_callback_delete_request_set(d.ee, _on_delete);
638 ecore_evas_callback_resize_set(d.ee, _canvas_resize_cb);
639 ecore_evas_show(d.ee);
640
641 d.evas = ecore_evas_get(d.ee);
642
643 _main_menu();
644
645 ecore_main_loop_begin();
646 ecore_evas_shutdown();
647 return 0;
648
649error:
650 ecore_evas_shutdown();
651 return -1;
652}
diff --git a/src/examples/evas/meson.build b/src/examples/evas/meson.build
index 93539e73b3..279e8830c9 100644
--- a/src/examples/evas/meson.build
+++ b/src/examples/evas/meson.build
@@ -51,6 +51,7 @@ examples = [
51 'evas-vg-simple', 51 'evas-vg-simple',
52 'evas-vg-json', 52 'evas-vg-json',
53 'efl-canvas-animation', 53 'efl-canvas-animation',
54 'efl-canvas-vg-simple',
54] 55]
55 56
56foreach example : examples 57foreach example : examples