summaryrefslogtreecommitdiff
path: root/unsorted/evas/evas-vg-simple.c
diff options
context:
space:
mode:
authorCedric BAIL <cedric@osg.samsung.com>2015-07-02 21:51:54 +0200
committerCedric BAIL <cedric@osg.samsung.com>2015-08-21 16:40:31 +0200
commit0a3d6daf606f1675dea96b6f71dc36fee2e9cd9a (patch)
treebb95e46d7ff09a235ac99936e32e55db2c5b0d24 /unsorted/evas/evas-vg-simple.c
parent7103ddbfe71ec1b25dac79dae911fd43819eb98c (diff)
evas: improve simple VG example to interpolate a full VG tree.
Diffstat (limited to 'unsorted/evas/evas-vg-simple.c')
-rw-r--r--unsorted/evas/evas-vg-simple.c93
1 files changed, 82 insertions, 11 deletions
diff --git a/unsorted/evas/evas-vg-simple.c b/unsorted/evas/evas-vg-simple.c
index 854bde8..7332ce7 100644
--- a/unsorted/evas/evas-vg-simple.c
+++ b/unsorted/evas/evas-vg-simple.c
@@ -50,6 +50,12 @@ typedef struct _Point
50 int y; 50 int y;
51}Point; 51}Point;
52 52
53static Efl_VG *beginning = NULL;
54static Efl_VG *end = NULL;
55static Efl_VG *root = NULL;
56static double start_time = 0;
57static Ecore_Animator *anim = NULL;
58
53static 59static
54Bezier bezierFromPoints(Point p1, Point p2, 60Bezier bezierFromPoints(Point p1, Point p2,
55 Point p3, Point p4) 61 Point p3, Point p4)
@@ -440,18 +446,22 @@ vector_set(int x, int y, int w, int h)
440 eina_matrix3_identity(&matrix); 446 eina_matrix3_identity(&matrix);
441 eina_matrix3_rotate(&matrix, radian); 447 eina_matrix3_rotate(&matrix, radian);
442 448
443 Efl_VG *root = evas_object_vg_root_node_get(d.vg); 449 root = evas_object_vg_root_node_get(d.vg);
444 //eo_do(root, evas_vg_node_transformation_set(&matrix)); 450 //eo_do(root, evas_vg_node_transformation_set(&matrix));
445 451
446 Efl_VG *bg = eo_add(EFL_VG_SHAPE_CLASS, root); 452 Efl_VG *bg = eo_add(EFL_VG_SHAPE_CLASS, root,
453 efl_vg_name_set("bg"));
447 _rect_add(bg, 0, 0 , vg_w, vg_h); 454 _rect_add(bg, 0, 0 , vg_w, vg_h);
448 evas_vg_node_origin_set(bg, 0,0); 455 evas_vg_node_origin_set(bg, 0,0);
449 evas_vg_shape_stroke_width_set(bg, 1.0); 456 evas_vg_shape_stroke_width_set(bg, 1.0);
450 evas_vg_node_color_set(bg, 80, 80, 80, 80); 457 evas_vg_node_color_set(bg, 80, 80, 80, 80);
451 458
452 Efl_VG *shape = eo_add(EFL_VG_SHAPE_CLASS, root); 459 Efl_VG *shape = eo_add(EFL_VG_SHAPE_CLASS, root,
453 Efl_VG *rgradient = eo_add(EFL_VG_GRADIENT_RADIAL_CLASS, root); 460 efl_vg_name_set("shape"));
454 Efl_VG *lgradient = eo_add(EFL_VG_GRADIENT_LINEAR_CLASS, root); 461 Efl_VG *rgradient = eo_add(EFL_VG_GRADIENT_RADIAL_CLASS, root,
462 efl_vg_name_set("rgradient"));
463 Efl_VG *lgradient = eo_add(EFL_VG_GRADIENT_LINEAR_CLASS, root,
464 efl_vg_name_set("lgradient"));
455 465
456 _arcto(shape, 0, 0, 100, 100, 25, 330); 466 _arcto(shape, 0, 0, 100, 100, 25, 330);
457 467
@@ -492,7 +502,8 @@ vector_set(int x, int y, int w, int h)
492 evas_vg_node_color_set(shape, 0, 0, 255, 255); 502 evas_vg_node_color_set(shape, 0, 0, 255, 255);
493 evas_vg_shape_stroke_color_set(shape, 0, 0, 255, 128); 503 evas_vg_shape_stroke_color_set(shape, 0, 0, 255, 128);
494 504
495 Efl_VG *rect = eo_add(EFL_VG_SHAPE_CLASS, root); 505 Efl_VG *rect = eo_add(EFL_VG_SHAPE_CLASS, root,
506 efl_vg_name_set("rect"));
496 _rect_add(rect, 0, 0, 100, 100); 507 _rect_add(rect, 0, 0, 100, 100);
497 evas_vg_node_origin_set(rect, 100, 100); 508 evas_vg_node_origin_set(rect, 100, 100);
498 evas_vg_shape_fill_set(rect, lgradient); 509 evas_vg_shape_fill_set(rect, lgradient);
@@ -500,7 +511,8 @@ vector_set(int x, int y, int w, int h)
500 evas_vg_shape_stroke_join_set(rect, EFL_GFX_JOIN_ROUND); 511 evas_vg_shape_stroke_join_set(rect, EFL_GFX_JOIN_ROUND);
501 evas_vg_shape_stroke_color_set(rect, 255, 255, 255, 255); 512 evas_vg_shape_stroke_color_set(rect, 255, 255, 255, 255);
502 513
503 Efl_VG *rect1 = eo_add(EFL_VG_SHAPE_CLASS, root); 514 Efl_VG *rect1 = eo_add(EFL_VG_SHAPE_CLASS, root,
515 efl_vg_name_set("rect1"));
504 _rect_add(rect1, 0, 0, 70, 70); 516 _rect_add(rect1, 0, 0, 70, 70);
505 evas_vg_node_origin_set(rect1, 50, 70); 517 evas_vg_node_origin_set(rect1, 50, 70);
506 evas_vg_shape_stroke_scale_set(rect1, 2); 518 evas_vg_shape_stroke_scale_set(rect1, 2);
@@ -508,7 +520,8 @@ vector_set(int x, int y, int w, int h)
508 evas_vg_shape_stroke_join_set(rect1, EFL_GFX_JOIN_ROUND); 520 evas_vg_shape_stroke_join_set(rect1, EFL_GFX_JOIN_ROUND);
509 evas_vg_shape_stroke_color_set(rect1, 0, 100, 80, 100); 521 evas_vg_shape_stroke_color_set(rect1, 0, 100, 80, 100);
510 522
511 Efl_VG *circle = eo_add(EFL_VG_SHAPE_CLASS, root); 523 Efl_VG *circle = eo_add(EFL_VG_SHAPE_CLASS, root,
524 efl_vg_name_set("circle"));
512 _arcto(circle, 0, 0, 250, 100, 30, 300); 525 _arcto(circle, 0, 0, 250, 100, 30, 300);
513 evas_vg_shape_fill_set(circle, lgradient); 526 evas_vg_shape_fill_set(circle, lgradient);
514 //evas_vg_node_transformation_set(&matrix), 527 //evas_vg_node_transformation_set(&matrix),
@@ -516,24 +529,80 @@ vector_set(int x, int y, int w, int h)
516 evas_vg_node_color_set(circle, 50, 0, 0, 50); 529 evas_vg_node_color_set(circle, 50, 0, 0, 50);
517 530
518 // Foreground 531 // Foreground
519 Efl_VG *fg = eo_add(EFL_VG_SHAPE_CLASS, root); 532 Efl_VG *fg = eo_add(EFL_VG_SHAPE_CLASS, root,
533 efl_vg_name_set("fg"));
520 _rect_add(fg, 0, 0, vg_w, vg_h); 534 _rect_add(fg, 0, 0, vg_w, vg_h);
521 evas_vg_node_origin_set(fg, 0, 0); 535 evas_vg_node_origin_set(fg, 0, 0);
522 evas_vg_shape_stroke_width_set(fg, 5.0); 536 evas_vg_shape_stroke_width_set(fg, 5.0);
523 evas_vg_shape_stroke_join_set(fg, EFL_GFX_JOIN_ROUND); 537 evas_vg_shape_stroke_join_set(fg, EFL_GFX_JOIN_ROUND);
524 evas_vg_shape_stroke_color_set(fg, 70, 70, 0, 70); 538 evas_vg_shape_stroke_color_set(fg, 70, 70, 0, 70);
525 539
526 Efl_VG *tst = eo_add(EFL_VG_SHAPE_CLASS, root); 540 Efl_VG *tst = eo_add(EFL_VG_SHAPE_CLASS, root,
541 efl_vg_name_set("tst"));
527 evas_vg_shape_shape_append_rect(tst, 50, 25, 200, 200, 3, 5); 542 evas_vg_shape_shape_append_rect(tst, 50, 25, 200, 200, 3, 5);
528 evas_vg_node_color_set(tst, 0, 0, 200, 200); 543 evas_vg_node_color_set(tst, 0, 0, 200, 200);
529 evas_vg_shape_stroke_width_set(tst, 2); 544 evas_vg_shape_stroke_width_set(tst, 2);
530 evas_vg_shape_stroke_color_set(tst, 255, 0, 0, 255); 545 evas_vg_shape_stroke_color_set(tst, 255, 0, 0, 255);
531 546
532 Efl_VG *vc = eo_add(EFL_VG_SHAPE_CLASS, root); 547 Efl_VG *vc = eo_add(EFL_VG_SHAPE_CLASS, root,
548 efl_vg_name_set("vc"));
533 evas_vg_shape_shape_append_circle(vc, 100, 100, 23); 549 evas_vg_shape_shape_append_circle(vc, 100, 100, 23);
534 evas_vg_node_color_set(vc, 0, 200, 0, 255); 550 evas_vg_node_color_set(vc, 0, 200, 0, 255);
535 evas_vg_shape_stroke_width_set(vc, 4); 551 evas_vg_shape_stroke_width_set(vc, 4);
536 evas_vg_shape_stroke_color_set(vc, 255, 0, 0, 255); 552 evas_vg_shape_stroke_color_set(vc, 255, 0, 0, 255);
553
554 beginning = eo_add(EFL_VG_CONTAINER_CLASS, NULL,
555 efl_vg_dup(root));
556 end = eo_add(EFL_VG_CONTAINER_CLASS, NULL,
557 efl_vg_dup(root));
558
559 eo_do(end, circle = efl_vg_container_child_get("circle"));
560 eo_do(circle, efl_vg_transformation_set(&matrix));
561}
562
563static Eina_Bool
564_anim(void *data EINA_UNUSED)
565{
566 double pos, now;
567
568 now = ecore_loop_time_get();
569
570 if (now - start_time > 3)
571 {
572 Efl_VG *tmp = beginning;
573
574 beginning = end;
575 end = tmp;
576 start_time = now;
577 }
578
579 pos = ecore_animator_pos_map((now - start_time) / 3, ECORE_POS_MAP_SINUSOIDAL, 0, 0);
580
581 eo_do(root, efl_vg_interpolate(beginning, end, pos));
582
583 return EINA_TRUE;
584}
585
586static void
587_keydown(void *data EINA_UNUSED, Evas *evas EINA_UNUSED, Evas_Object *o EINA_UNUSED, void *einfo)
588{
589 Evas_Event_Key_Down *ev = einfo;
590
591 if (strcmp(ev->key, "a") == 0)
592 {
593 if (!anim)
594 {
595 anim = ecore_animator_add(_anim, NULL);
596 start_time = ecore_loop_time_get();
597 }
598 else
599 {
600 ecore_animator_del(anim);
601 anim = NULL;
602 }
603 /* eo_do(root, efl_vg_interpolate(beginning, end, 0.5)); */
604 }
605 fprintf(stderr, "key: [%s]\n", ev->key);
537} 606}
538 607
539int 608int
@@ -556,6 +625,8 @@ main(void)
556 625
557 d.bg = evas_object_rectangle_add(d.evas); 626 d.bg = evas_object_rectangle_add(d.evas);
558 evas_object_color_set(d.bg, 70, 70, 70, 255); /* white bg */ 627 evas_object_color_set(d.bg, 70, 70, 70, 255); /* white bg */
628 evas_object_focus_set(d.bg, 1);
629 evas_object_event_callback_add(d.bg, EVAS_CALLBACK_KEY_DOWN, _keydown, NULL);
559 evas_object_show(d.bg); 630 evas_object_show(d.bg);
560 631
561 _canvas_resize_cb(d.ee); 632 _canvas_resize_cb(d.ee);