109 lines
2.2 KiB
C++
109 lines
2.2 KiB
C++
|
|
#ifdef HAVE_CONFIG_H
|
|
# include <config.h>
|
|
#endif
|
|
|
|
#include "Eo.h"
|
|
#include "Evas.h"
|
|
|
|
#include "Eo.hh"
|
|
#include "Eina.hh"
|
|
#include "Evas.hh"
|
|
|
|
#include "main.h"
|
|
|
|
#define EXPEDITE_CXX_TEST_IMPL
|
|
#include "line_blend_capi.h"
|
|
|
|
/* standard var */
|
|
static int done = 0;
|
|
/* private data */
|
|
static efl::eina::list<evas::line> lines;
|
|
|
|
/* setup */
|
|
static void _setup(void)
|
|
{
|
|
evas::canvas canvas(::eo_ref(G_evas));
|
|
srnd();
|
|
for (int i = 0; i < OBNUM; i++)
|
|
{
|
|
evas::line o(efl::eo::parent = canvas);
|
|
lines.push_back(o);
|
|
int a = (rnd()&0xff) / 2;
|
|
int r = ((rnd()&0xff) * a) / 255;
|
|
int g = ((rnd()&0xff) * a) / 255;
|
|
int b = ((rnd()&0xff) * a) / 255;
|
|
o.color_set(r, g, b, a);
|
|
o.xy_set(((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));
|
|
o.visibility_set(true);
|
|
}
|
|
done = 0;
|
|
}
|
|
|
|
/* cleanup */
|
|
static void _cleanup()
|
|
{
|
|
lines.clear();
|
|
}
|
|
|
|
#define PI (double) 3.141592654
|
|
|
|
static void
|
|
_rotate_point(Evas_Coord *ox, Evas_Coord *oy, int r)
|
|
{
|
|
double d;
|
|
double x, y;
|
|
double angle;
|
|
|
|
x = *ox - (win_w / 2);
|
|
y = *oy - (win_h / 2);
|
|
|
|
d = sqrt(x * x + y * y);
|
|
|
|
angle = atan((double) y / (double) x);
|
|
if (x < 0) angle -= PI;
|
|
|
|
switch (r & 0x3)
|
|
{
|
|
case 0: angle += 1 * PI / 180; break;
|
|
case 1: angle += -1 * PI / 180; break;
|
|
case 2: angle += 7 * PI / 180; break;
|
|
case 3: angle += -1 * PI / 180; break;
|
|
}
|
|
|
|
*ox = d * cos(angle) + (win_w / 2);
|
|
*oy = d * sin(angle) + (win_h / 2);
|
|
}
|
|
|
|
/* loop - do things */
|
|
static void _loop(double t, int f)
|
|
{
|
|
Evas_Coord ox1, oy1, ox2, oy2;
|
|
Evas_Object *o;
|
|
int i = 0;
|
|
for (evas::image& img : images)
|
|
{
|
|
img.xy_get(&ox1, &oy1, &ox2, &oy2);
|
|
_rotate_point(&ox1, &oy1, i);
|
|
_rotate_point(&ox2, &oy2, i);
|
|
img.xy_set(ox1, oy1, ox2, oy2);
|
|
++i;
|
|
}
|
|
FPS_STD(NAME);
|
|
}
|
|
|
|
/* prepend special key handlers if interactive (before STD) */
|
|
static void _key(char *key)
|
|
{
|
|
KEY_STD;
|
|
}
|
|
|
|
extern "C" void FNAME(void)
|
|
{
|
|
ui_func_set(_key, _loop);
|
|
_setup();
|
|
}
|