diff options
Diffstat (limited to 'libraries/ecore/src/examples/ecore_animator_example.c')
-rw-r--r-- | libraries/ecore/src/examples/ecore_animator_example.c | 116 |
1 files changed, 116 insertions, 0 deletions
diff --git a/libraries/ecore/src/examples/ecore_animator_example.c b/libraries/ecore/src/examples/ecore_animator_example.c new file mode 100644 index 0000000..6352f20 --- /dev/null +++ b/libraries/ecore/src/examples/ecore_animator_example.c | |||
@@ -0,0 +1,116 @@ | |||
1 | //Compile with: | ||
2 | //gcc -g -Wall `pkg-config --cflags --libs ecore-evas` -o ecore_animator_example ecore_animator_example.c | ||
3 | |||
4 | #include <Ecore.h> | ||
5 | #include <Ecore_Evas.h> | ||
6 | |||
7 | static Eina_Bool _advance_frame(void *data, double pos); | ||
8 | static Eina_Bool _advance_frame2(void *data, double pos); | ||
9 | static Eina_Bool _advance_frame3(void *data); | ||
10 | static Eina_Bool _start_second_anim(void *data); | ||
11 | static Eina_Bool _freeze_third_anim(void *data); | ||
12 | static Eina_Bool _thaw_third_anim(void *data); | ||
13 | |||
14 | int | ||
15 | main (int argc, char *argv[]) | ||
16 | { | ||
17 | Evas_Object *rect, *bg, *rect2; | ||
18 | Ecore_Evas *ee; | ||
19 | Evas *evas; | ||
20 | Ecore_Animator *anim; | ||
21 | |||
22 | ecore_evas_init(); | ||
23 | |||
24 | ee = ecore_evas_new(NULL, 0, 0, 300, 400, NULL); | ||
25 | ecore_evas_show(ee); | ||
26 | evas = ecore_evas_get(ee); | ||
27 | |||
28 | bg = evas_object_rectangle_add(evas); | ||
29 | evas_object_resize(bg, 300, 400); | ||
30 | evas_object_show(bg); | ||
31 | |||
32 | rect = evas_object_rectangle_add(evas); | ||
33 | evas_object_color_set(rect, 0, 0, 255, 255); | ||
34 | evas_object_resize(rect, 50, 50); | ||
35 | evas_object_show(rect); | ||
36 | |||
37 | rect2 = evas_object_rectangle_add(evas); | ||
38 | evas_object_color_set(rect2, 0, 55, 0, 255); | ||
39 | evas_object_resize(rect2, 50, 50); | ||
40 | evas_object_show(rect2); | ||
41 | |||
42 | ecore_animator_frametime_set(1./50); | ||
43 | ecore_animator_timeline_add(5, _advance_frame, rect); | ||
44 | |||
45 | anim = ecore_animator_add(_advance_frame3, rect2); | ||
46 | |||
47 | ecore_timer_add(10, _start_second_anim, rect); | ||
48 | ecore_timer_add(5, _freeze_third_anim, anim); | ||
49 | ecore_timer_add(10, _thaw_third_anim, anim); | ||
50 | ecore_main_loop_begin(); | ||
51 | |||
52 | evas_object_del(rect); | ||
53 | ecore_evas_free(ee); | ||
54 | ecore_animator_del(anim); | ||
55 | ecore_evas_shutdown(); | ||
56 | |||
57 | return 0; | ||
58 | } | ||
59 | |||
60 | static Eina_Bool | ||
61 | _advance_frame(void *data, double pos) | ||
62 | { | ||
63 | double frame = pos; | ||
64 | frame = ecore_animator_pos_map(pos, ECORE_POS_MAP_SPRING, 1.2, 15); | ||
65 | |||
66 | evas_object_resize(data, 50 * (1 + frame), 50 * (1 + frame)); | ||
67 | evas_object_move(data, 100 * frame, 100 * frame); | ||
68 | evas_object_color_set(data, 255 * frame, 0, 255 * (1 - frame), 255); | ||
69 | return EINA_TRUE; | ||
70 | } | ||
71 | |||
72 | static Eina_Bool | ||
73 | _start_second_anim(void *data) | ||
74 | { | ||
75 | ecore_animator_frametime_set(1./10); | ||
76 | ecore_animator_timeline_add(20, _advance_frame2, data); | ||
77 | return EINA_FALSE; | ||
78 | } | ||
79 | |||
80 | static Eina_Bool | ||
81 | _advance_frame2(void *data, double pos) | ||
82 | { | ||
83 | double frame = pos; | ||
84 | frame = ecore_animator_pos_map(pos, ECORE_POS_MAP_BOUNCE, 1.2, 50); | ||
85 | |||
86 | evas_object_resize(data, 100 - (50 * frame), 100 - (50 * frame)); | ||
87 | evas_object_move(data, 100 * (1 - frame), 100 * (1 - frame)); | ||
88 | evas_object_color_set(data, 255 * (1 - frame), 0, 255 * frame, 255); | ||
89 | return EINA_TRUE; | ||
90 | } | ||
91 | |||
92 | static Eina_Bool | ||
93 | _advance_frame3(void *data) | ||
94 | { | ||
95 | static int x = 0; | ||
96 | |||
97 | if(x >= 250) | ||
98 | x = 0; | ||
99 | evas_object_move(data, ++x, 350); | ||
100 | |||
101 | return EINA_TRUE; | ||
102 | } | ||
103 | |||
104 | static Eina_Bool | ||
105 | _freeze_third_anim(void *data) | ||
106 | { | ||
107 | ecore_animator_freeze(data); | ||
108 | return EINA_FALSE; | ||
109 | } | ||
110 | |||
111 | static Eina_Bool | ||
112 | _thaw_third_anim(void *data) | ||
113 | { | ||
114 | ecore_animator_thaw(data); | ||
115 | return EINA_FALSE; | ||
116 | } | ||