2017-09-12 01:49:40 -07:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include <config.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "Ecore.h"
|
|
|
|
#include "ecore_private.h"
|
|
|
|
|
2018-11-23 04:26:00 -08:00
|
|
|
#define MY_CLASS EFL_CUBIC_BEZIER_INTERPOLATOR_CLASS
|
2017-09-12 01:49:40 -07:00
|
|
|
|
2018-11-23 04:26:00 -08:00
|
|
|
typedef struct _Efl_Cubic_Bezier_Interpolator_Data Efl_Cubic_Bezier_Interpolator_Data;
|
2017-09-12 01:49:40 -07:00
|
|
|
|
2018-11-23 04:26:00 -08:00
|
|
|
struct _Efl_Cubic_Bezier_Interpolator_Data
|
2017-09-12 01:49:40 -07:00
|
|
|
{
|
2019-11-05 11:26:14 -08:00
|
|
|
double control_points[4];
|
2017-09-12 01:49:40 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
EOLIAN static double
|
2018-11-23 04:26:00 -08:00
|
|
|
_efl_cubic_bezier_interpolator_efl_interpolator_interpolate(Eo *eo_obj EINA_UNUSED,
|
|
|
|
Efl_Cubic_Bezier_Interpolator_Data *pd EINA_UNUSED,
|
2017-09-12 01:49:40 -07:00
|
|
|
double progress)
|
|
|
|
{
|
|
|
|
if ((progress < 0.0) || (progress > 1.0))
|
|
|
|
return progress;
|
|
|
|
|
|
|
|
return ecore_animator_pos_map_n(progress, ECORE_POS_MAP_CUBIC_BEZIER, 4,
|
2019-11-05 11:26:14 -08:00
|
|
|
pd->control_points);
|
2017-09-12 01:49:40 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static void
|
2019-11-05 11:26:14 -08:00
|
|
|
_efl_cubic_bezier_interpolator_control_points_set(Eo *eo_obj EINA_UNUSED,
|
2018-11-23 04:26:00 -08:00
|
|
|
Efl_Cubic_Bezier_Interpolator_Data *pd,
|
2019-11-05 11:26:14 -08:00
|
|
|
Eina_Vector2 p1, Eina_Vector2 p2)
|
2017-09-12 01:49:40 -07:00
|
|
|
{
|
2019-11-05 11:26:14 -08:00
|
|
|
pd->control_points[0] = p1.x;
|
|
|
|
pd->control_points[1] = p1.y;
|
|
|
|
pd->control_points[2] = p2.x;
|
|
|
|
pd->control_points[3] = p2.y;
|
2017-09-12 01:49:40 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static void
|
2019-11-05 11:26:14 -08:00
|
|
|
_efl_cubic_bezier_interpolator_control_points_get(const Eo *eo_obj EINA_UNUSED,
|
2018-11-23 04:26:00 -08:00
|
|
|
Efl_Cubic_Bezier_Interpolator_Data *pd,
|
2019-11-05 11:26:14 -08:00
|
|
|
Eina_Vector2 *p1, Eina_Vector2 *p2)
|
2017-09-12 01:49:40 -07:00
|
|
|
{
|
2019-11-05 11:26:14 -08:00
|
|
|
if (p1)
|
|
|
|
{
|
|
|
|
p1->x = pd->control_points[0];
|
|
|
|
p1->y = pd->control_points[1];
|
|
|
|
}
|
2017-09-12 01:49:40 -07:00
|
|
|
|
2019-11-05 11:26:14 -08:00
|
|
|
if (p2)
|
|
|
|
{
|
|
|
|
p2->x = pd->control_points[2];
|
|
|
|
p2->y = pd->control_points[3];
|
|
|
|
}
|
2017-09-12 01:49:40 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static Efl_Object *
|
2018-11-23 04:26:00 -08:00
|
|
|
_efl_cubic_bezier_interpolator_efl_object_constructor(Eo *eo_obj,
|
|
|
|
Efl_Cubic_Bezier_Interpolator_Data *pd)
|
2017-09-12 01:49:40 -07:00
|
|
|
{
|
|
|
|
eo_obj = efl_constructor(efl_super(eo_obj, MY_CLASS));
|
|
|
|
|
2019-11-05 11:26:14 -08:00
|
|
|
pd->control_points[0] = 1.0;
|
|
|
|
pd->control_points[1] = 1.0;
|
|
|
|
pd->control_points[2] = 1.0;
|
|
|
|
pd->control_points[3] = 1.0;
|
2017-09-12 01:49:40 -07:00
|
|
|
|
|
|
|
return eo_obj;
|
|
|
|
}
|
|
|
|
|
2018-11-23 04:26:00 -08:00
|
|
|
#include "efl_cubic_bezier_interpolator.eo.c"
|