#undef FNAME #undef NAME #undef ICON /* metadata */ #define FNAME poly_blend_start #define NAME "Polygon Blend" #define ICON "rect.png" #ifndef PROTO # ifndef UI # include "main.h" /* standard var */ static int done = 0; /* private data */ static Evas_Object *o_images[OBNUM]; static void poly(Evas_Object *o, int type, Evas_Coord x, Evas_Coord y) { if (o) eo_do(o, evas_obj_polygon_points_clear()); switch (type % 4) { case 0: /* triangle */ if (o) eo_do(o, evas_obj_polygon_point_add(x + 50 , y + 0), evas_obj_polygon_point_add(x + 100, y + 100), evas_obj_polygon_point_add(x + 0 , y + 100)); break; case 1: /* square */ if (o) eo_do(o, evas_obj_polygon_point_add(x + 0 , y + 0), evas_obj_polygon_point_add(x + 100, y + 0), evas_obj_polygon_point_add(x + 100, y + 100), evas_obj_polygon_point_add(x + 0 , y + 100)); break; case 2: /* hex */ if (o) eo_do(o, evas_obj_polygon_point_add(x + 50 , y + 0), evas_obj_polygon_point_add(x + 100, y + 30), evas_obj_polygon_point_add(x + 100, y + 70), evas_obj_polygon_point_add(x + 50 , y + 100), evas_obj_polygon_point_add(x + 0 , y + 70), evas_obj_polygon_point_add(x + 0 , y + 30)); break; case 3: /* star */ if (o) eo_do(o, evas_obj_polygon_point_add(x + 50 , y + 0), evas_obj_polygon_point_add(x + 60 , y + 40), evas_obj_polygon_point_add(x + 90 , y + 30), evas_obj_polygon_point_add(x + 70 , y + 60), evas_obj_polygon_point_add(x + 90 , y + 100), evas_obj_polygon_point_add(x + 50 , y + 70), evas_obj_polygon_point_add(x + 10 , y + 100), evas_obj_polygon_point_add(x + 30 , y + 60), evas_obj_polygon_point_add(x + 10 , y + 30), evas_obj_polygon_point_add(x + 40 , y + 40)); break; default: break; } } /* setup */ static void _setup(void) { int i; Evas_Object *o; srnd(); for (i = 0; i < OBNUM; i++) { int r, g, b, a; o = eo_add(EVAS_POLYGON_CLASS, G_evas); o_images[i] = o; a = (rnd()&0xff) / 2; r = ((rnd()&0xff) * a) / 255; g = ((rnd()&0xff) * a) / 255; b = ((rnd()&0xff) * a) / 255; if (o) eo_do(o, evas_obj_color_set(r, g, b, a), evas_obj_visibility_set(EINA_TRUE)); poly(o, i, 0, 0); } done = 0; } /* cleanup */ static void _cleanup(void) { int i; for (i = 0; i < OBNUM; i++) eo_del(o_images[i]); } /* loop - do things */ static void _loop(double t, int f) { int i; Evas_Coord x, y, w, h; Evas_Object *o; for (i = 0; i < OBNUM; i++) { o = o_images[i]; if (o) eo_do(o, evas_obj_size_get(&w, &h)); x = (win_w / 2) - (w / 2); x += sin((double)(f + (i * 13)) / (36.7 * SLOW)) * (win_w / 4); y = (win_h / 2) - (h / 2); y += cos((double)(f + (i * 28)) / (43.8 * SLOW)) * (win_h / 4); if (o) eo_do(o, evas_obj_position_set(x, y)); } FPS_STD(NAME); } /* prepend special key handlers if interactive (before STD) */ static void _key(char *key) { KEY_STD; } /* template stuff - ignore */ # endif #endif #ifdef UI _ui_menu_item_add(ICON, NAME, FNAME); #endif #ifdef PROTO void FNAME(void); #endif #ifndef PROTO # ifndef UI void FNAME(void) { ui_func_set(_key, _loop); _setup(); } # endif #endif #undef FNAME #undef NAME #undef ICON