forked from enlightenment/efl
Efl.Interpolator*: More sensible API names and docs
Summary: OK, so, ALL interpolator parameters were called "factor" and the docs literally said "First factor, Second factor, ..." After diving into the actual implementation, proper names (and types) for the parameters were found and proper docs written. I am afraid I could not make any sense of the Divisor interpolator code. Those docs still need writing. Test Plan: Everything still builds and passes tests. No functional changes. Reviewers: zmike, cedric, bu5hm4n, Jaehyun_Cho Reviewed By: bu5hm4n Subscribers: #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D10603
This commit is contained in:
parent
17a81bee4a
commit
9ca84821fc
|
@ -33,32 +33,35 @@ _interpolator_create(int index, Evas_Object *win)
|
|||
else if (index == 1)
|
||||
{
|
||||
interp = efl_add(EFL_SINUSOIDAL_INTERPOLATOR_CLASS, win);
|
||||
efl_sinusoidal_interpolator_factor_set(interp, 1.0);
|
||||
efl_sinusoidal_interpolator_slope_set(interp, 1.0);
|
||||
}
|
||||
else if (index == 2)
|
||||
{
|
||||
interp = efl_add(EFL_DECELERATE_INTERPOLATOR_CLASS, win);
|
||||
efl_decelerate_interpolator_factor_set(interp, 1.0);
|
||||
efl_decelerate_interpolator_slope_set(interp, 1.0);
|
||||
}
|
||||
else if (index == 3)
|
||||
{
|
||||
interp = efl_add(EFL_ACCELERATE_INTERPOLATOR_CLASS, win);
|
||||
efl_accelerate_interpolator_factor_set(interp, 1.0);
|
||||
efl_accelerate_interpolator_slope_set(interp, 1.0);
|
||||
}
|
||||
else if (index == 4)
|
||||
{
|
||||
interp = efl_add(EFL_DIVISOR_INTERPOLATOR_CLASS, win);
|
||||
efl_divisor_interpolator_factors_set(interp, 1.0, 1.0);
|
||||
efl_divisor_interpolator_divisor_set(interp, 1.0);
|
||||
efl_divisor_interpolator_power_set(interp, 1);
|
||||
}
|
||||
else if (index == 5)
|
||||
{
|
||||
interp = efl_add(EFL_BOUNCE_INTERPOLATOR_CLASS, win);
|
||||
efl_bounce_interpolator_factors_set(interp, 1.0, 1.0);
|
||||
efl_bounce_interpolator_rigidness_set(interp, 1.0);
|
||||
efl_bounce_interpolator_bounces_set(interp, 1);
|
||||
}
|
||||
else if (index == 6)
|
||||
{
|
||||
interp = efl_add(EFL_SPRING_INTERPOLATOR_CLASS, win);
|
||||
efl_spring_interpolator_factors_set(interp, 1.0, 1.0);
|
||||
efl_spring_interpolator_decay_set(interp, 1.0);
|
||||
efl_spring_interpolator_oscillations_set(interp, 1);
|
||||
}
|
||||
|
||||
return interp;
|
||||
|
|
|
@ -11,7 +11,7 @@ typedef struct _Efl_Accelerate_Interpolator_Data Efl_Accelerate_Interpolator_Dat
|
|||
|
||||
struct _Efl_Accelerate_Interpolator_Data
|
||||
{
|
||||
double factor;
|
||||
double slope;
|
||||
};
|
||||
|
||||
EOLIAN static double
|
||||
|
@ -23,22 +23,22 @@ _efl_accelerate_interpolator_efl_interpolator_interpolate(Eo *eo_obj EINA_UNUSED
|
|||
return progress;
|
||||
|
||||
return ecore_animator_pos_map(progress, ECORE_POS_MAP_ACCELERATE_FACTOR,
|
||||
pd->factor, 0);
|
||||
pd->slope, 0);
|
||||
}
|
||||
|
||||
EOLIAN static void
|
||||
_efl_accelerate_interpolator_factor_set(Eo *eo_obj EINA_UNUSED,
|
||||
_efl_accelerate_interpolator_slope_set(Eo *eo_obj EINA_UNUSED,
|
||||
Efl_Accelerate_Interpolator_Data *pd,
|
||||
double factor)
|
||||
double slope)
|
||||
{
|
||||
pd->factor = factor;
|
||||
pd->slope = slope;
|
||||
}
|
||||
|
||||
EOLIAN static double
|
||||
_efl_accelerate_interpolator_factor_get(const Eo *eo_obj EINA_UNUSED,
|
||||
_efl_accelerate_interpolator_slope_get(const Eo *eo_obj EINA_UNUSED,
|
||||
Efl_Accelerate_Interpolator_Data *pd EINA_UNUSED)
|
||||
{
|
||||
return pd->factor;
|
||||
return pd->slope;
|
||||
}
|
||||
|
||||
EOLIAN static Efl_Object *
|
||||
|
@ -47,7 +47,7 @@ _efl_accelerate_interpolator_efl_object_constructor(Eo *eo_obj,
|
|||
{
|
||||
eo_obj = efl_constructor(efl_super(eo_obj, MY_CLASS));
|
||||
|
||||
pd->factor = 1.0;
|
||||
pd->slope = 1.0;
|
||||
|
||||
return eo_obj;
|
||||
}
|
||||
|
|
|
@ -1,19 +1,23 @@
|
|||
class @beta Efl.Accelerate_Interpolator extends Efl.Object implements Efl.Interpolator
|
||||
{
|
||||
[[Efl accelerate interpolator class
|
||||
[[Accelerated interpolator. It starts slow and accelerates, stopping abruptly when
|
||||
it reaches $[1.0].
|
||||
|
||||
output = 1 - sin(Pi / 2 + input * Pi / 2);
|
||||
Internally it uses the first half of a sinus rise (from 0 to 0.5) and the steepness
|
||||
can be customized.
|
||||
]]
|
||||
data: Efl_Accelerate_Interpolator_Data;
|
||||
methods {
|
||||
@property factor {
|
||||
[[Factor property]]
|
||||
@property slope {
|
||||
[[Customize the acceleration effect.]]
|
||||
set {
|
||||
}
|
||||
get {
|
||||
}
|
||||
values {
|
||||
factor: double; [[Factor of the interpolation function.]]
|
||||
slope: double; [[How steep is the effect. $[0] performs a linear interpolation,
|
||||
$[1] corresponds to a sinus function and higher numbers produce
|
||||
an increasingly steep effect.]]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,8 @@ typedef struct _Efl_Bounce_Interpolator_Data Efl_Bounce_Interpolator_Data;
|
|||
|
||||
struct _Efl_Bounce_Interpolator_Data
|
||||
{
|
||||
double factor[2];
|
||||
double rigidness;
|
||||
int bounces;
|
||||
};
|
||||
|
||||
EOLIAN static double
|
||||
|
@ -23,28 +24,37 @@ _efl_bounce_interpolator_efl_interpolator_interpolate(Eo *eo_obj EINA_UNUSED,
|
|||
return progress;
|
||||
|
||||
return ecore_animator_pos_map(progress, ECORE_POS_MAP_BOUNCE,
|
||||
pd->factor[0], pd->factor[1]);
|
||||
pd->rigidness, (double)pd->bounces);
|
||||
}
|
||||
|
||||
EOLIAN static void
|
||||
_efl_bounce_interpolator_factors_set(Eo *eo_obj EINA_UNUSED,
|
||||
Efl_Bounce_Interpolator_Data *pd,
|
||||
double factor1, double factor2)
|
||||
_efl_bounce_interpolator_rigidness_set(Eo *eo_obj EINA_UNUSED,
|
||||
Efl_Bounce_Interpolator_Data *pd,
|
||||
double rigidness)
|
||||
{
|
||||
pd->factor[0] = factor1;
|
||||
pd->factor[1] = factor2;
|
||||
pd->rigidness = rigidness;
|
||||
}
|
||||
|
||||
EOLIAN static double
|
||||
_efl_bounce_interpolator_rigidness_get(const Eo *eo_obj EINA_UNUSED,
|
||||
Efl_Bounce_Interpolator_Data *pd)
|
||||
{
|
||||
return pd->rigidness;
|
||||
}
|
||||
|
||||
EOLIAN static void
|
||||
_efl_bounce_interpolator_factors_get(const Eo *eo_obj EINA_UNUSED,
|
||||
_efl_bounce_interpolator_bounces_set(Eo *eo_obj EINA_UNUSED,
|
||||
Efl_Bounce_Interpolator_Data *pd,
|
||||
double *factor1, double *factor2)
|
||||
int bounces)
|
||||
{
|
||||
if (factor1)
|
||||
*factor1 = pd->factor[0];
|
||||
pd->bounces = bounces;
|
||||
}
|
||||
|
||||
if (factor2)
|
||||
*factor2 = pd->factor[1];
|
||||
EOLIAN static int
|
||||
_efl_bounce_interpolator_bounces_get(const Eo *eo_obj EINA_UNUSED,
|
||||
Efl_Bounce_Interpolator_Data *pd)
|
||||
{
|
||||
return pd->bounces;
|
||||
}
|
||||
|
||||
EOLIAN static Efl_Object *
|
||||
|
@ -53,8 +63,8 @@ _efl_bounce_interpolator_efl_object_constructor(Eo *eo_obj,
|
|||
{
|
||||
eo_obj = efl_constructor(efl_super(eo_obj, MY_CLASS));
|
||||
|
||||
pd->factor[0] = 1.0;
|
||||
pd->factor[1] = 1.0;
|
||||
pd->rigidness = 1.0;
|
||||
pd->bounces = 1;
|
||||
|
||||
return eo_obj;
|
||||
}
|
||||
|
|
|
@ -1,17 +1,31 @@
|
|||
class @beta Efl.Bounce_Interpolator extends Efl.Object implements Efl.Interpolator
|
||||
{
|
||||
[[Efl bounce interpolator class]]
|
||||
[[Bouncing interpolator. The value quickly reaches $[1.0] and then bounces back
|
||||
a number of times before stopping at $[1.0].
|
||||
|
||||
The number of bounces and how far it goes back on every bounce can be customized.
|
||||
]]
|
||||
data: Efl_Bounce_Interpolator_Data;
|
||||
methods {
|
||||
@property factors {
|
||||
[[Factors property]]
|
||||
@property bounces {
|
||||
[[Customize the number of bounces.]]
|
||||
set {
|
||||
}
|
||||
get {
|
||||
}
|
||||
values {
|
||||
factor1: double; [[First factor of the interpolation function.]]
|
||||
factor2: double; [[Second factor of the interpolation function.]]
|
||||
bounces: int; [[Number of bounces before stopping.]]
|
||||
}
|
||||
}
|
||||
@property rigidness {
|
||||
[[Customize the rigidness.]]
|
||||
set {
|
||||
}
|
||||
get {
|
||||
}
|
||||
values {
|
||||
rigidness: double; [[How much energy is lost on every bounce.
|
||||
Higher numbers result in smaller bounces (lesser bounciness).]]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ typedef struct _Efl_Cubic_Bezier_Interpolator_Data Efl_Cubic_Bezier_Interpolator
|
|||
|
||||
struct _Efl_Cubic_Bezier_Interpolator_Data
|
||||
{
|
||||
double factor[4];
|
||||
double control_points[4];
|
||||
};
|
||||
|
||||
EOLIAN static double
|
||||
|
@ -23,38 +23,36 @@ _efl_cubic_bezier_interpolator_efl_interpolator_interpolate(Eo *eo_obj EINA_UNUS
|
|||
return progress;
|
||||
|
||||
return ecore_animator_pos_map_n(progress, ECORE_POS_MAP_CUBIC_BEZIER, 4,
|
||||
pd->factor);
|
||||
pd->control_points);
|
||||
}
|
||||
|
||||
EOLIAN static void
|
||||
_efl_cubic_bezier_interpolator_factors_set(Eo *eo_obj EINA_UNUSED,
|
||||
_efl_cubic_bezier_interpolator_control_points_set(Eo *eo_obj EINA_UNUSED,
|
||||
Efl_Cubic_Bezier_Interpolator_Data *pd,
|
||||
double factor1, double factor2,
|
||||
double factor3, double factor4)
|
||||
Eina_Vector2 p1, Eina_Vector2 p2)
|
||||
{
|
||||
pd->factor[0] = factor1;
|
||||
pd->factor[1] = factor2;
|
||||
pd->factor[2] = factor3;
|
||||
pd->factor[3] = factor4;
|
||||
pd->control_points[0] = p1.x;
|
||||
pd->control_points[1] = p1.y;
|
||||
pd->control_points[2] = p2.x;
|
||||
pd->control_points[3] = p2.y;
|
||||
}
|
||||
|
||||
EOLIAN static void
|
||||
_efl_cubic_bezier_interpolator_factors_get(const Eo *eo_obj EINA_UNUSED,
|
||||
_efl_cubic_bezier_interpolator_control_points_get(const Eo *eo_obj EINA_UNUSED,
|
||||
Efl_Cubic_Bezier_Interpolator_Data *pd,
|
||||
double *factor1, double *factor2,
|
||||
double *factor3, double *factor4)
|
||||
Eina_Vector2 *p1, Eina_Vector2 *p2)
|
||||
{
|
||||
if (factor1)
|
||||
*factor1 = pd->factor[0];
|
||||
if (p1)
|
||||
{
|
||||
p1->x = pd->control_points[0];
|
||||
p1->y = pd->control_points[1];
|
||||
}
|
||||
|
||||
if (factor2)
|
||||
*factor2 = pd->factor[1];
|
||||
|
||||
if (factor3)
|
||||
*factor3 = pd->factor[2];
|
||||
|
||||
if (factor4)
|
||||
*factor4 = pd->factor[3];
|
||||
if (p2)
|
||||
{
|
||||
p2->x = pd->control_points[2];
|
||||
p2->y = pd->control_points[3];
|
||||
}
|
||||
}
|
||||
|
||||
EOLIAN static Efl_Object *
|
||||
|
@ -63,10 +61,10 @@ _efl_cubic_bezier_interpolator_efl_object_constructor(Eo *eo_obj,
|
|||
{
|
||||
eo_obj = efl_constructor(efl_super(eo_obj, MY_CLASS));
|
||||
|
||||
pd->factor[0] = 1.0;
|
||||
pd->factor[1] = 1.0;
|
||||
pd->factor[2] = 1.0;
|
||||
pd->factor[3] = 1.0;
|
||||
pd->control_points[0] = 1.0;
|
||||
pd->control_points[1] = 1.0;
|
||||
pd->control_points[2] = 1.0;
|
||||
pd->control_points[3] = 1.0;
|
||||
|
||||
return eo_obj;
|
||||
}
|
||||
|
|
|
@ -1,19 +1,31 @@
|
|||
class @beta Efl.Cubic_Bezier_Interpolator extends Efl.Object implements Efl.Interpolator
|
||||
{
|
||||
[[Efl cubic_bezier interpolator class]]
|
||||
[[Cubic Bezier interpolator. It starts slow, then moves quickly and then slows down
|
||||
again before stopping.
|
||||
|
||||
The exact shape of the mapping curve can be modified through the @.control_points
|
||||
property.
|
||||
]]
|
||||
data: Efl_Cubic_Bezier_Interpolator_Data;
|
||||
methods {
|
||||
@property factors {
|
||||
[[Factors property]]
|
||||
@property control_points {
|
||||
[[Cubic Bezier curves are described by 4 2D control points
|
||||
(https://en.wikipedia.org/wiki/B%C3%A9zier_curve).
|
||||
For each control point, the X coordinate is an input value and the Y coordinate is the
|
||||
corresponding output value.
|
||||
The first one, P0, is set to $[(0,0)]: The input $[0.0] is mapped to the $[0.0] output.
|
||||
The last one, P3, is set to $[(1,1)]: The input $[1.0] is mapped to the $[1.0] output.
|
||||
The other two control points can be set through this property and control the shape of
|
||||
the curve. Note that the control points do not need to be in the $[0...1] range, and
|
||||
neither do the output values of the curve.
|
||||
]]
|
||||
set {
|
||||
}
|
||||
get {
|
||||
}
|
||||
values {
|
||||
factor1: double; [[First factor of the interpolation function.]]
|
||||
factor2: double; [[Second factor of the interpolation function.]]
|
||||
factor3: double; [[Third factor of the interpolation function.]]
|
||||
factor4: double; [[Fourth factor of the interpolation function.]]
|
||||
p1: Eina.Vector2; [[P1 control point.]]
|
||||
p2: Eina.Vector2; [[P2 control point.]]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ typedef struct _Efl_Decelerate_Interpolator_Data Efl_Decelerate_Interpolator_Dat
|
|||
|
||||
struct _Efl_Decelerate_Interpolator_Data
|
||||
{
|
||||
double factor;
|
||||
double slope;
|
||||
};
|
||||
|
||||
EOLIAN static double
|
||||
|
@ -23,22 +23,22 @@ _efl_decelerate_interpolator_efl_interpolator_interpolate(Eo *eo_obj EINA_UNUSED
|
|||
return progress;
|
||||
|
||||
return ecore_animator_pos_map(progress, ECORE_POS_MAP_DECELERATE_FACTOR,
|
||||
pd->factor, 0);
|
||||
pd->slope, 0);
|
||||
}
|
||||
|
||||
EOLIAN static void
|
||||
_efl_decelerate_interpolator_factor_set(Eo *eo_obj EINA_UNUSED,
|
||||
_efl_decelerate_interpolator_slope_set(Eo *eo_obj EINA_UNUSED,
|
||||
Efl_Decelerate_Interpolator_Data *pd,
|
||||
double factor)
|
||||
double slope)
|
||||
{
|
||||
pd->factor = factor;
|
||||
pd->slope = slope;
|
||||
}
|
||||
|
||||
EOLIAN static double
|
||||
_efl_decelerate_interpolator_factor_get(const Eo *eo_obj EINA_UNUSED,
|
||||
_efl_decelerate_interpolator_slope_get(const Eo *eo_obj EINA_UNUSED,
|
||||
Efl_Decelerate_Interpolator_Data *pd EINA_UNUSED)
|
||||
{
|
||||
return pd->factor;
|
||||
return pd->slope;
|
||||
}
|
||||
|
||||
EOLIAN static Efl_Object *
|
||||
|
@ -47,7 +47,7 @@ _efl_decelerate_interpolator_efl_object_constructor(Eo *eo_obj,
|
|||
{
|
||||
eo_obj = efl_constructor(efl_super(eo_obj, MY_CLASS));
|
||||
|
||||
pd->factor = 1.0;
|
||||
pd->slope = 1.0;
|
||||
|
||||
return eo_obj;
|
||||
}
|
||||
|
|
|
@ -1,19 +1,23 @@
|
|||
class @beta Efl.Decelerate_Interpolator extends Efl.Object implements Efl.Interpolator
|
||||
{
|
||||
[[Efl decelerate interpolator class
|
||||
[[Decelerated interpolator. It starts fast and decelerates, stopping smoothly when
|
||||
it reaches $[1.0].
|
||||
|
||||
output = sin(input * Pi / 2);
|
||||
Internally it uses the second half of a sinus rise (from 0.5 to 1.0) and the steepness
|
||||
can be customized.
|
||||
]]
|
||||
data: Efl_Decelerate_Interpolator_Data;
|
||||
methods {
|
||||
@property factor {
|
||||
[[Factor property]]
|
||||
@property slope {
|
||||
[[Customize the deceleration effect.]]
|
||||
set {
|
||||
}
|
||||
get {
|
||||
}
|
||||
values {
|
||||
factor: double; [[Factor of the interpolation function.]]
|
||||
slope: double; [[How steep is the effect. $[0] performs a linear interpolation,
|
||||
$[1] corresponds to a sinus function and higher numbers produce
|
||||
an increasingly steep effect.]]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,8 @@ typedef struct _Efl_Divisor_Interpolator_Data Efl_Divisor_Interpolator_Data;
|
|||
|
||||
struct _Efl_Divisor_Interpolator_Data
|
||||
{
|
||||
double factor[2];
|
||||
double divisor;
|
||||
int power;
|
||||
};
|
||||
|
||||
EOLIAN static double
|
||||
|
@ -23,28 +24,36 @@ _efl_divisor_interpolator_efl_interpolator_interpolate(Eo *eo_obj EINA_UNUSED,
|
|||
return progress;
|
||||
|
||||
return ecore_animator_pos_map(progress, ECORE_POS_MAP_DIVISOR_INTERP,
|
||||
pd->factor[0], pd->factor[1]);
|
||||
pd->divisor, (double)pd->power);
|
||||
}
|
||||
|
||||
EOLIAN static void
|
||||
_efl_divisor_interpolator_factors_set(Eo *eo_obj EINA_UNUSED,
|
||||
_efl_divisor_interpolator_divisor_set(Eo *eo_obj EINA_UNUSED,
|
||||
Efl_Divisor_Interpolator_Data *pd,
|
||||
double factor1, double factor2)
|
||||
double divisor)
|
||||
{
|
||||
pd->factor[0] = factor1;
|
||||
pd->factor[1] = factor2;
|
||||
pd->divisor = divisor;
|
||||
}
|
||||
|
||||
EOLIAN static void
|
||||
_efl_divisor_interpolator_factors_get(const Eo *eo_obj EINA_UNUSED,
|
||||
Efl_Divisor_Interpolator_Data *pd,
|
||||
double *factor1, double *factor2)
|
||||
EOLIAN static double
|
||||
_efl_divisor_interpolator_divisor_get(const Eo *eo_obj EINA_UNUSED,
|
||||
Efl_Divisor_Interpolator_Data *pd)
|
||||
{
|
||||
if (factor1)
|
||||
*factor1 = pd->factor[0];
|
||||
return pd->divisor;
|
||||
}
|
||||
EOLIAN static void
|
||||
_efl_divisor_interpolator_power_set(Eo *eo_obj EINA_UNUSED,
|
||||
Efl_Divisor_Interpolator_Data *pd,
|
||||
int power)
|
||||
{
|
||||
pd->power = power;
|
||||
}
|
||||
|
||||
if (factor2)
|
||||
*factor2 = pd->factor[1];
|
||||
EOLIAN static int
|
||||
_efl_divisor_interpolator_power_get(const Eo *eo_obj EINA_UNUSED,
|
||||
Efl_Divisor_Interpolator_Data *pd)
|
||||
{
|
||||
return pd->power;
|
||||
}
|
||||
|
||||
EOLIAN static Efl_Object *
|
||||
|
@ -53,8 +62,8 @@ _efl_divisor_interpolator_efl_object_constructor(Eo *eo_obj,
|
|||
{
|
||||
eo_obj = efl_constructor(efl_super(eo_obj, MY_CLASS));
|
||||
|
||||
pd->factor[0] = 1.0;
|
||||
pd->factor[1] = 1.0;
|
||||
pd->divisor = 1.0;
|
||||
pd->power = 1;
|
||||
|
||||
return eo_obj;
|
||||
}
|
||||
|
|
|
@ -1,17 +1,27 @@
|
|||
class @beta Efl.Divisor_Interpolator extends Efl.Object implements Efl.Interpolator
|
||||
{
|
||||
[[Efl divisor interpolator class]]
|
||||
[[Divisor interpolator.
|
||||
]]
|
||||
data: Efl_Divisor_Interpolator_Data;
|
||||
methods {
|
||||
@property factors {
|
||||
[[Factors property]]
|
||||
@property divisor {
|
||||
[[Customize divisor factor.]]
|
||||
set {
|
||||
}
|
||||
get {
|
||||
}
|
||||
values {
|
||||
factor1: double; [[First factor of the interpolation function.]]
|
||||
factor2: double; [[Second factor of the interpolation function.]]
|
||||
divisor: double; [[Divisor.]]
|
||||
}
|
||||
}
|
||||
@property power {
|
||||
[[Customize power factor.]]
|
||||
set {
|
||||
}
|
||||
get {
|
||||
}
|
||||
values {
|
||||
power: int; [[Exponent.]]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
class @beta Efl.Linear_Interpolator extends Efl.Object implements Efl.Interpolator
|
||||
{
|
||||
[[Efl linear interpolator class]]
|
||||
[[Linear interpolation (pass-through). Input values are used unmodified as output.
|
||||
]]
|
||||
data: Efl_Linear_Interpolator_Data;
|
||||
implements {
|
||||
Efl.Interpolator.interpolate;
|
||||
|
|
|
@ -11,7 +11,7 @@ typedef struct _Efl_Sinusoidal_Interpolator_Data Efl_Sinusoidal_Interpolator_Dat
|
|||
|
||||
struct _Efl_Sinusoidal_Interpolator_Data
|
||||
{
|
||||
double factor;
|
||||
double slope;
|
||||
};
|
||||
|
||||
EOLIAN static double
|
||||
|
@ -23,22 +23,22 @@ _efl_sinusoidal_interpolator_efl_interpolator_interpolate(Eo *eo_obj EINA_UNUSED
|
|||
return progress;
|
||||
|
||||
return ecore_animator_pos_map(progress, ECORE_POS_MAP_SINUSOIDAL_FACTOR,
|
||||
pd->factor, 0);
|
||||
pd->slope, 0);
|
||||
}
|
||||
|
||||
EOLIAN static void
|
||||
_efl_sinusoidal_interpolator_factor_set(Eo *eo_obj EINA_UNUSED,
|
||||
_efl_sinusoidal_interpolator_slope_set(Eo *eo_obj EINA_UNUSED,
|
||||
Efl_Sinusoidal_Interpolator_Data *pd,
|
||||
double factor)
|
||||
double slope)
|
||||
{
|
||||
pd->factor = factor;
|
||||
pd->slope = slope;
|
||||
}
|
||||
|
||||
EOLIAN static double
|
||||
_efl_sinusoidal_interpolator_factor_get(const Eo *eo_obj EINA_UNUSED,
|
||||
_efl_sinusoidal_interpolator_slope_get(const Eo *eo_obj EINA_UNUSED,
|
||||
Efl_Sinusoidal_Interpolator_Data *pd EINA_UNUSED)
|
||||
{
|
||||
return pd->factor;
|
||||
return pd->slope;
|
||||
}
|
||||
|
||||
EOLIAN static Efl_Object *
|
||||
|
@ -47,7 +47,7 @@ _efl_sinusoidal_interpolator_efl_object_constructor(Eo *eo_obj,
|
|||
{
|
||||
eo_obj = efl_constructor(efl_super(eo_obj, MY_CLASS));
|
||||
|
||||
pd->factor = 1.0;
|
||||
pd->slope = 1.0;
|
||||
|
||||
return eo_obj;
|
||||
}
|
||||
|
|
|
@ -1,19 +1,22 @@
|
|||
class @beta Efl.Sinusoidal_Interpolator extends Efl.Object implements Efl.Interpolator
|
||||
{
|
||||
[[Efl sinusoidal interpolator class
|
||||
[[Sinusoidal interpolator. It starts slow, then moves quickly and then slows down
|
||||
again before stopping.
|
||||
|
||||
output = (1 - cos(input * Pi)) / 2;
|
||||
How long it stays in the quick zone (the slope of the curve) can be customized.
|
||||
]]
|
||||
data: Efl_Sinusoidal_Interpolator_Data;
|
||||
methods {
|
||||
@property factor {
|
||||
[[Factor property]]
|
||||
@property slope {
|
||||
[[Customize the sinusoidal effect.]]
|
||||
set {
|
||||
}
|
||||
get {
|
||||
}
|
||||
values {
|
||||
factor: double; [[Factor of the interpolation function.]]
|
||||
slope: double; [[How steep is the effect. $[0] performs a linear interpolation,
|
||||
$[1] corresponds to a sinus function and higher numbers produce
|
||||
an increasingly steep effect.]]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,40 +11,50 @@ typedef struct _Efl_Spring_Interpolator_Data Efl_Spring_Interpolator_Data;
|
|||
|
||||
struct _Efl_Spring_Interpolator_Data
|
||||
{
|
||||
double factor[2];
|
||||
double decay;
|
||||
int oscillations;
|
||||
};
|
||||
|
||||
EOLIAN static double
|
||||
_efl_spring_interpolator_efl_interpolator_interpolate(Eo *obj EINA_UNUSED,
|
||||
Efl_Spring_Interpolator_Data *pd EINA_UNUSED,
|
||||
Efl_Spring_Interpolator_Data *pd,
|
||||
double progress)
|
||||
{
|
||||
if ((progress < 0.0) || (progress > 1.0))
|
||||
return progress;
|
||||
|
||||
return ecore_animator_pos_map(progress, ECORE_POS_MAP_SPRING,
|
||||
pd->factor[0], pd->factor[1]);
|
||||
pd->decay, (double)pd->oscillations);
|
||||
}
|
||||
|
||||
EOLIAN static void
|
||||
_efl_spring_interpolator_factors_set(Eo *eo_obj EINA_UNUSED,
|
||||
Efl_Spring_Interpolator_Data *pd,
|
||||
double factor1, double factor2)
|
||||
_efl_spring_interpolator_decay_set(Eo *eo_obj EINA_UNUSED,
|
||||
Efl_Spring_Interpolator_Data *pd,
|
||||
double decay)
|
||||
{
|
||||
pd->factor[0] = factor1;
|
||||
pd->factor[1] = factor2;
|
||||
pd->decay = decay;
|
||||
}
|
||||
|
||||
EOLIAN static double
|
||||
_efl_spring_interpolator_decay_get(const Eo *eo_obj EINA_UNUSED,
|
||||
Efl_Spring_Interpolator_Data *pd)
|
||||
{
|
||||
return pd->decay;
|
||||
}
|
||||
|
||||
EOLIAN static void
|
||||
_efl_spring_interpolator_factors_get(const Eo *eo_obj EINA_UNUSED,
|
||||
Efl_Spring_Interpolator_Data *pd,
|
||||
double *factor1, double *factor2)
|
||||
_efl_spring_interpolator_oscillations_set(Eo *eo_obj EINA_UNUSED,
|
||||
Efl_Spring_Interpolator_Data *pd,
|
||||
int oscillations)
|
||||
{
|
||||
if (factor1)
|
||||
*factor1 = pd->factor[0];
|
||||
pd->oscillations = oscillations;
|
||||
}
|
||||
|
||||
if (factor2)
|
||||
*factor2 = pd->factor[1];
|
||||
EOLIAN static int
|
||||
_efl_spring_interpolator_oscillations_get(const Eo *eo_obj EINA_UNUSED,
|
||||
Efl_Spring_Interpolator_Data *pd)
|
||||
{
|
||||
return pd->oscillations;
|
||||
}
|
||||
|
||||
EOLIAN static Efl_Object *
|
||||
|
@ -53,8 +63,8 @@ _efl_spring_interpolator_efl_object_constructor(Eo *eo_obj,
|
|||
{
|
||||
eo_obj = efl_constructor(efl_super(eo_obj, MY_CLASS));
|
||||
|
||||
pd->factor[0] = 1.0;
|
||||
pd->factor[1] = 1.0;
|
||||
pd->decay = 1.0;
|
||||
pd->oscillations = 1;
|
||||
|
||||
return eo_obj;
|
||||
}
|
||||
|
|
|
@ -1,17 +1,31 @@
|
|||
class @beta Efl.Spring_Interpolator extends Efl.Object implements Efl.Interpolator
|
||||
{
|
||||
[[Efl spring interpolator class]]
|
||||
[[Spring interpolator. The value quickly reaches $[1.0] and then oscillates
|
||||
around it a number of times before stopping (as if linked with a spring).
|
||||
|
||||
The number of oscillations and how quickly it stops can be customized.
|
||||
]]
|
||||
data: Efl_Spring_Interpolator_Data;
|
||||
methods {
|
||||
@property factors {
|
||||
[[Factors property]]
|
||||
@property decay {
|
||||
[[Customize the decay factor.]]
|
||||
set {
|
||||
}
|
||||
get {
|
||||
}
|
||||
values {
|
||||
factor1: double; [[First factor of the interpolation function.]]
|
||||
factor2: double; [[Second factor of the interpolation function.]]
|
||||
decay: double; [[How quickly energy is lost.
|
||||
Higher numbers result in smaller oscillations.]]
|
||||
}
|
||||
}
|
||||
@property oscillations {
|
||||
[[Customize number of oscillations.]]
|
||||
set {
|
||||
}
|
||||
get {
|
||||
}
|
||||
values {
|
||||
oscillations: int; [[Number of oscillations before stopping.]]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,25 @@
|
|||
interface @beta Efl.Interpolator
|
||||
{
|
||||
[[Efl interpolator interface]]
|
||||
[[Interface providing interpolation capabilities.
|
||||
|
||||
In the context of EFL, interpolation is defined as the mapping of values in the
|
||||
$[0, 1] range to another range (typically close).
|
||||
|
||||
This is used for example in animations, where the timer moves linearly from $[0.0]
|
||||
to $[1.0] but the property being animated can accelerate, decelerate, bounce or
|
||||
even move slightly out-of-bounds and come back.
|
||||
|
||||
For example implementations see @Efl.Accelerate_Interpolator, @Efl.Decelerate_Interpolator
|
||||
or @Efl.Bounce_Interpolator.
|
||||
]]
|
||||
methods {
|
||||
interpolate {
|
||||
[[Interpolate the given value.]]
|
||||
return: double; [[Output value calculated by interpolating the input value.]]
|
||||
[[Performs the mapping operation.]]
|
||||
return: double; [[Output mapped value. Its range is unrestricted. In particular,
|
||||
it might be outside the input $[0, 1] range.]]
|
||||
params {
|
||||
@in progress: double; [[Input value mapped from 0.0 to 1.0.]]
|
||||
@in progress: double; [[Input value between $[0.0] and $[1.0]. Values outside this range
|
||||
might yield unpredictable results.]]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue