Expedite initialize.
[framework/uifw/expedite.git] / src / bin / .svn / text-base / poly_blend.c.svn-base
1 #undef FNAME
2 #undef NAME
3 #undef ICON
4
5 /* metadata */
6 #define FNAME poly_blend_start
7 #define NAME "Polygon 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 static void
20 poly(Evas_Object *o, int type, Evas_Coord x, Evas_Coord y)
21 {
22    evas_object_polygon_points_clear(o);
23    switch (type % 4)
24      {
25       case 0: /* triangle */
26         evas_object_polygon_point_add(o, x + 50 , y + 0);
27         evas_object_polygon_point_add(o, x + 100, y + 100);
28         evas_object_polygon_point_add(o, x + 0  , y + 100);
29         break;
30       case 1: /* square */
31         evas_object_polygon_point_add(o, x + 0  , y + 0);
32         evas_object_polygon_point_add(o, x + 100, y + 0);
33         evas_object_polygon_point_add(o, x + 100, y + 100);
34         evas_object_polygon_point_add(o, x + 0  , y + 100);
35         break;
36       case 2: /* hex */
37         evas_object_polygon_point_add(o, x + 50 , y + 0);
38         evas_object_polygon_point_add(o, x + 100, y + 30);
39         evas_object_polygon_point_add(o, x + 100, y + 70);
40         evas_object_polygon_point_add(o, x + 50 , y + 100);
41         evas_object_polygon_point_add(o, x + 0  , y + 70);
42         evas_object_polygon_point_add(o, x + 0  , y + 30);
43         break;
44       case 3: /* star */
45         evas_object_polygon_point_add(o, x + 50 , y + 0);
46         evas_object_polygon_point_add(o, x + 60 , y + 40);
47         evas_object_polygon_point_add(o, x + 90 , y + 30);
48         evas_object_polygon_point_add(o, x + 70 , y + 60);
49         evas_object_polygon_point_add(o, x + 90 , y + 100);
50         evas_object_polygon_point_add(o, x + 50 , y + 70);
51         evas_object_polygon_point_add(o, x + 10 , y + 100);
52         evas_object_polygon_point_add(o, x + 30 , y + 60);
53         evas_object_polygon_point_add(o, x + 10 , y + 30);
54         evas_object_polygon_point_add(o, x + 40 , y + 40);
55         break;
56       default:
57         break;
58      }
59 }
60
61 /* setup */
62 static void _setup(void)
63 {
64    int i;
65    Evas_Object *o;
66    srnd();
67    for (i = 0; i < OBNUM; i++)
68      {
69         int r, g, b, a;
70
71         o = evas_object_polygon_add(evas);
72         o_images[i] = o;
73         a = (rnd()&0xff) / 2;
74         r = ((rnd()&0xff) * a) / 255;
75         g = ((rnd()&0xff) * a) / 255;
76         b = ((rnd()&0xff) * a) / 255;
77         evas_object_color_set(o, r, g, b, a);
78         poly(o, i, 0, 0);
79         evas_object_show(o);
80      }
81    done = 0;
82 }
83
84 /* cleanup */
85 static void _cleanup(void)
86 {
87    int i;
88    for (i = 0; i < OBNUM; i++) evas_object_del(o_images[i]);
89 }
90
91 /* loop - do things */
92 static void _loop(double t, int f)
93 {
94    int i;
95    Evas_Coord x, y, w, h;
96    Evas_Object *o;
97
98    for (i = 0; i < OBNUM; i++)
99      {
100         o = o_images[i];
101         evas_object_geometry_get(o, NULL, NULL, &w, &h);
102         x = (win_w / 2) - (w / 2);
103         x += sin((double)(f + (i * 13)) / (36.7 * SLOW)) * (win_w / 4);
104         y = (win_h / 2) - (h / 2);
105         y += cos((double)(f + (i * 28)) / (43.8 * SLOW)) * (win_h / 4);
106         evas_object_move(o, x, y);
107      }
108    FPS_STD(NAME);
109 }
110
111 /* prepend special key handlers if interactive (before STD) */
112 static void _key(char *key)
113 {
114    KEY_STD;
115 }
116
117
118
119
120
121
122
123
124
125
126
127
128 /* template stuff - ignore */
129 # endif
130 #endif
131
132 #ifdef UI
133 _ui_menu_item_add(ICON, NAME, FNAME);
134 #endif
135
136 #ifdef PROTO
137 void FNAME(void);
138 #endif
139
140 #ifndef PROTO
141 # ifndef UI
142 void FNAME(void)
143 {
144    ui_func_set(_key, _loop);
145    _setup();
146 }
147 # endif
148 #endif
149 #undef FNAME
150 #undef NAME
151 #undef ICON