Revert "Revert "Setup before starting fps measurement""
[platform/upstream/expedite.git] / src / bin / line_blend.c
1 #undef FNAME
2 #undef NAME
3 #undef ICON
4
5 /* metadata */
6 #define FNAME line_blend_start
7 #define NAME "Line Blend"
8 #define ICON "rect.png"
9
10 #ifndef PROTO
11 # ifndef UI
12 #  include "main.h"
13
14 /* standard var */
15 static int done = 0;
16 /* private data */
17 static Evas_Object *o_images[OBNUM];
18
19 /* setup */
20 static void _setup(void)
21 {
22    int i;
23    Evas_Object *o;
24    srnd();
25    for (i = 0; i < OBNUM; i++)
26      {
27         int r, g, b, a;
28
29         o = evas_object_line_add(evas);
30         o_images[i] = o;
31         a = (rnd()&0xff) / 2;
32         r = ((rnd()&0xff) * a) / 255;
33         g = ((rnd()&0xff) * a) / 255;
34         b = ((rnd()&0xff) * a) / 255;
35         efl_gfx_color_set(o, r, g, b, a);
36         evas_object_line_xy_set(o, ((win_w / 2) * (rnd()&0xff)) / 255, ((win_h / 2) * (rnd()&0xff)) / 255, ((win_w / 2) * (rnd()&0xff)) / 255 + (win_w / 2), ((win_h / 2) * (rnd()&0xff)) / 255 + (win_h / 2));
37         efl_gfx_entity_visible_set(o, EINA_TRUE);
38
39         
40      }
41    done = 0;
42 }
43
44 /* cleanup */
45 static void _cleanup(void)
46 {
47    int i;
48    for (i = 0; i < OBNUM; i++) efl_del(o_images[i]);
49 }
50
51 #define PI (double) 3.141592654
52
53 static void
54 _rotate_point(Evas_Coord *ox, Evas_Coord *oy, int r)
55 {
56    double d;
57    double x, y;
58    double angle;
59
60    x = *ox - (win_w / 2);
61    y = *oy - (win_h / 2);
62
63    d = sqrt(x * x + y * y);
64
65    angle = atan((double) y / (double) x);
66    if (x < 0) angle -= PI;
67
68    switch (r & 0x3)
69      {
70       case 0: angle += 1 * PI / 180; break;
71       case 1: angle += -1 * PI / 180; break;
72       case 2: angle += 7 * PI / 180; break;
73       case 3: angle += -1 * PI / 180; break;
74      }
75
76    *ox =  d * cos(angle) + (win_w / 2);
77    *oy =  d * sin(angle) + (win_h / 2);
78 }
79
80 /* loop - do things */
81 static void _loop(double t, int f)
82 {
83    int i;
84    Evas_Coord ox1, oy1, ox2, oy2;
85    Evas_Object *o;
86
87    for (i = 0; i < OBNUM; i++)
88      {
89         o = o_images[i];
90         evas_object_line_xy_get(o, &ox1, &oy1, &ox2, &oy2);
91              
92         _rotate_point(&ox1, &oy1, i);
93         _rotate_point(&ox2, &oy2, i);
94         evas_object_line_xy_set(o, ox1, oy1, ox2, oy2);
95      }
96    FPS_STD(NAME);
97 }
98
99 /* prepend special key handlers if interactive (before STD) */
100 static void _key(const char *key)
101 {
102    KEY_STD;
103 }
104
105
106
107
108
109
110
111
112
113
114
115
116 /* template stuff - ignore */
117 # endif
118 #endif
119
120 #ifdef UI
121 _ui_menu_item_add(ICON, NAME, FNAME);
122 #endif
123
124 #ifdef PROTO
125 void FNAME(void);
126 #endif
127
128 #ifndef PROTO
129 # ifndef UI
130 void FNAME(void)
131 {
132    _setup();
133    ui_func_set(_key, _loop);
134 }
135 # endif
136 #endif
137 #undef FNAME
138 #undef NAME
139 #undef ICON