summaryrefslogtreecommitdiff
path: root/src/bin/line_blend.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/bin/line_blend.c')
-rw-r--r--src/bin/line_blend.c143
1 files changed, 143 insertions, 0 deletions
diff --git a/src/bin/line_blend.c b/src/bin/line_blend.c
new file mode 100644
index 0000000..dedc471
--- /dev/null
+++ b/src/bin/line_blend.c
@@ -0,0 +1,143 @@
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 */
15static int done = 0;
16/* private data */
17static Evas_Object *o_images[OBNUM];
18
19/* setup */
20static 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 = eo_add(EVAS_OBJ_LINE_CLASS, 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 eo_do(o,
36 evas_obj_color_set(r, g, b, a),
37 evas_obj_line_xy_set(((win_w / 2) * (rnd()&0xff)) / 255,
38 ((win_h / 2) * (rnd()&0xff)) / 255,
39 ((win_w / 2) * (rnd()&0xff)) / 255 + (win_w / 2),
40 ((win_h / 2) * (rnd()&0xff)) / 255 + (win_h / 2)),
41 evas_obj_visibility_set(EINA_TRUE));
42
43
44 }
45 done = 0;
46}
47
48/* cleanup */
49static void _cleanup(void)
50{
51 int i;
52 for (i = 0; i < OBNUM; i++) eo_del(o_images[i]);
53}
54
55#define PI (double) 3.141592654
56
57static void
58_rotate_point(Evas_Coord *ox, Evas_Coord *oy, int r)
59{
60 double d;
61 double x, y;
62 double angle;
63
64 x = *ox - (win_w / 2);
65 y = *oy - (win_h / 2);
66
67 d = sqrt(x * x + y * y);
68
69 angle = atan((double) y / (double) x);
70 if (x < 0) angle -= PI;
71
72 switch (r & 0x3)
73 {
74 case 0: angle += 1 * PI / 180; break;
75 case 1: angle += -1 * PI / 180; break;
76 case 2: angle += 7 * PI / 180; break;
77 case 3: angle += -1 * PI / 180; break;
78 }
79
80 *ox = d * cos(angle) + (win_w / 2);
81 *oy = d * sin(angle) + (win_h / 2);
82}
83
84/* loop - do things */
85static void _loop(double t, int f)
86{
87 int i;
88 Evas_Coord ox1, oy1, ox2, oy2;
89 Evas_Object *o;
90
91 for (i = 0; i < OBNUM; i++)
92 {
93 o = o_images[i];
94 eo_do(o, evas_obj_line_xy_get(&ox1, &oy1, &ox2, &oy2));
95
96 _rotate_point(&ox1, &oy1, i);
97 _rotate_point(&ox2, &oy2, i);
98 eo_do(o, evas_obj_line_xy_set(ox1, oy1, ox2, oy2));
99 }
100 FPS_STD(NAME);
101}
102
103/* prepend special key handlers if interactive (before STD) */
104static void _key(char *key)
105{
106 KEY_STD;
107}
108
109
110
111
112
113
114
115
116
117
118
119
120/* template stuff - ignore */
121# endif
122#endif
123
124#ifdef UI
125_ui_menu_item_add(ICON, NAME, FNAME);
126#endif
127
128#ifdef PROTO
129void FNAME(void);
130#endif
131
132#ifndef PROTO
133# ifndef UI
134void FNAME(void)
135{
136 ui_func_set(_key, _loop);
137 _setup();
138}
139# endif
140#endif
141#undef FNAME
142#undef NAME
143#undef ICON