diff --git a/ChangeLog b/ChangeLog index 89900af34..5bd17e3dd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2007-05-17 Tomas Frydrych + + * clutter/clutter-alpha.h: + * clutter/clutter-alpha.c: + * doc/reference/clutter-sections.txt: + Added clutter_exp_inc_func() and clutter_exp_dec_func(). + 2007-05-16 Emmanuele Bassi * clutter/clutter-main.[ch]: Add clutter_base_init(), semi-private diff --git a/clutter/clutter-alpha.c b/clutter/clutter-alpha.c index 4a17cb150..bd8b048fa 100644 --- a/clutter/clutter-alpha.c +++ b/clutter/clutter-alpha.c @@ -851,3 +851,90 @@ clutter_smoothstep_func (ClutterAlpha * alpha, return CFX_INT (r * CLUTTER_ALPHA_MAX_ALPHA); } + +/** + * clutter_exp_inc_func: + * @alpha: a #ClutterAlpha + * @dummy: unused argument + * + * Convenience alpha function for a 2^x curve. You can use this function as the + * alpha function for clutter_alpha_set_func(). + * + * Return value: an alpha value. + * + * Since: 0.4 + */ +guint32 +clutter_exp_inc_func (ClutterAlpha *alpha, + gpointer dummy) +{ + ClutterTimeline * timeline; + gint frame; + gint n_frames; + ClutterFixed x; + ClutterFixed x_alpha_max = 0x100000; + guint32 result; + + /* + * Choose x_alpha_max such that + * + * (2^x_alpha_max) - 1 == CLUTTER_ALPHA_MAX_ALPHA + */ +#if CLUTTER_ALPHA_MAX_ALPHA != 0xffff +#error Adjust x_alpha_max to match CLUTTER_ALPHA_MAX_ALPHA +#endif + + timeline = clutter_alpha_get_timeline (alpha); + frame = clutter_timeline_get_current_frame (timeline); + n_frames = clutter_timeline_get_n_frames (timeline); + + x = x_alpha_max * frame / n_frames; + + result = clutter_pow2x (x) - 1; + + return result; +} + + +/** + * clutter_exp_dec_func: + * @alpha: a #ClutterAlpha + * @dummy: unused argument + * + * Convenience alpha function for a decreasing 2^x curve. You can use this + * function as the alpha function for clutter_alpha_set_func(). + * + * Return value: an alpha value. + * + * Since: 0.4 + */ +guint32 +clutter_exp_dec_func (ClutterAlpha *alpha, + gpointer dummy) +{ + ClutterTimeline * timeline; + gint frame; + gint n_frames; + ClutterFixed x; + ClutterFixed x_alpha_max = 0x100000; + guint32 result; + + /* + * Choose x_alpha_max such that + * + * (2^x_alpha_max) - 1 == CLUTTER_ALPHA_MAX_ALPHA + */ +#if CLUTTER_ALPHA_MAX_ALPHA != 0xffff +#error Adjust x_alpha_max to match CLUTTER_ALPHA_MAX_ALPHA +#endif + + timeline = clutter_alpha_get_timeline (alpha); + frame = clutter_timeline_get_current_frame (timeline); + n_frames = clutter_timeline_get_n_frames (timeline); + + x = (x_alpha_max * (n_frames - frame)) / n_frames; + + result = clutter_pow2x (x) - 1; + + return result; +} diff --git a/clutter/clutter-alpha.h b/clutter/clutter-alpha.h index ac1c14e1a..bf69ba1fb 100644 --- a/clutter/clutter-alpha.h +++ b/clutter/clutter-alpha.h @@ -111,6 +111,8 @@ ClutterTimeline *clutter_alpha_get_timeline (ClutterAlpha *alpha); #define CLUTTER_ALPHA_SINE_HALF clutter_sine_half_func #define CLUTTER_ALPHA_SQUARE clutter_square_func #define CLUTTER_ALPHA_SMOOTHSTEP clutter_smoothstep_func +#define CLUTTER_ALPHA_EXP_INC clutter_exp_inc_func +#define CLUTTER_ALPHA_EXP_DEC clutter_exp_dec_func #define CLUTTER_TYPE_SMOOTHSTEP (clutter_smoothstep_get_type ()) @@ -144,6 +146,10 @@ guint32 clutter_square_func (ClutterAlpha *alpha, gpointer dummy); guint32 clutter_smoothstep_func (ClutterAlpha *alpha, gpointer *data); +guint32 clutter_exp_inc_func (ClutterAlpha *alpha, + gpointer dummy); +guint32 clutter_exp_dec_func (ClutterAlpha *alpha, + gpointer dummy); G_END_DECLS diff --git a/doc/reference/clutter-sections.txt b/doc/reference/clutter-sections.txt index fae4b6979..b3d5dc501 100644 --- a/doc/reference/clutter-sections.txt +++ b/doc/reference/clutter-sections.txt @@ -122,6 +122,10 @@ CLUTTER_ALPHA_SQUARE clutter_square_func CLUTTER_ALPHA_SMOOTHSTEP clutter_smoothstep_func +CLUTTER_ALPHA_EXP_INC +clutter_exp_inc_func +CLUTTER_ALPHA_EXP_DEC +clutter_exp_dec_func CLUTTER_ALPHA CLUTTER_IS_ALPHA