expedite/src/bin/cxx/rect_blend_pow2_few.cc

88 lines
1.8 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 "rect_blend_pow2_few_capi.h"
#undef OBNUM
#define OBNUM 3
/* standard var */
static int done = 0;
/* private data */
static efl::eina::list<evas::rectangle> rectangles;
/* setup */
static void _setup(void)
{
evas::canvas canvas(::eo_ref(G_evas));
srnd();
for (int i = 0; i < OBNUM; i++)
{
evas::rectangle o(efl::eo::parent = canvas);
rectangles.push_back(o);
int a = 256 - (1 << ((rnd() % 8) + 1));
if (a < 128) a = 128;
int r = ((rnd()&0xff) * a) / 255;
int g = ((rnd()&0xff) * a) / 255;
int b = ((rnd()&0xff) * a) / 255;
o.evas::object::color_set(r, g, b, a);
o.visibility_set(true);
}
done = 0;
}
/* cleanup */
static void _cleanup(void)
{
for (evas::rectangle& rec : rectangles)
rec.parent_set(efl::eo::base(nullptr));
rectangles.clear();
}
/* loop - do things */
static void _loop(double t, int f)
{
int i = 0;
for (evas::rectangle& rec : rectangles)
{
Evas_Coord w0 = 80;
Evas_Coord h0 = 80;
Evas_Coord w = 5 + ((1.0 + ::cos((double)(f + (i * 10)) / (7.4 * SLOW) )) * w0 * 2);
Evas_Coord h = 5 + ((1.0 + ::sin((double)(f + (i * 19)) / (12.6 * SLOW) )) * h0 * 2);
Evas_Coord x = (win_w / 2) - (w / 2);
x += ::sin((double)(f + (i * 113)) / (36.7 * SLOW)) * (w0 / 2);
Evas_Coord y = (win_h / 2) - (h / 2);
y += ::cos((double)(f + (i * 228)) / (43.8 * SLOW)) * (h0 / 2);
rec.evas::object::position_set(x, y);
rec.evas::object::size_set(w, h);
++i;
}
FPS_STD(NAME);
}
static void _key(char *key)
{
KEY_STD;
}
extern "C" void FNAME(void)
{
ui_func_set(_key, _loop);
_setup();
}