From 9a10979e0f943c44a1d2df1b17a146d49b7e0e3c Mon Sep 17 00:00:00 2001 From: Tomas Frydrych Date: Wed, 16 May 2007 13:46:54 +0000 Subject: [PATCH] Fixed clutter_sine_inc_func(); added clutter_sine_dec_func() --- ChangeLog | 7 ++++ clutter/clutter-alpha.c | 59 ++++++++++++++++++++++++++---- clutter/clutter-alpha.h | 7 +++- doc/reference/clutter-sections.txt | 4 ++ 4 files changed, 69 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6d4764892..8ba46d3c5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2007-05-16 Tomas Frydrych + + * clutter/clutter-alpha.h: + * clutter/clutter-alpha.c: + * doc/reference/clutter-sections.txt: + Fixed clutter_sine_inc(), added clutter_sine_dec(). + 2007-05-16 Tomas Frydrych * clutter/clutter-alpha.h: diff --git a/clutter/clutter-alpha.c b/clutter/clutter-alpha.c index 6f084ada8..adadf6b74 100644 --- a/clutter/clutter-alpha.c +++ b/clutter/clutter-alpha.c @@ -603,8 +603,9 @@ clutter_sine_func (ClutterAlpha *alpha, * @alpha: a #ClutterAlpha * @dummy: unused argument * - * Convenience alpha function for a sine wave. You can use this - * function as the alpha function for clutter_alpha_set_func(). + * Convenience alpha function for a sine wave over interval <0, pi/2>. + * You can use this function as the alpha function for + * clutter_alpha_set_func(). * * Return value: an alpha value. * @@ -614,11 +615,55 @@ guint32 clutter_sine_inc_func (ClutterAlpha *alpha, gpointer dummy) { -#if 0 - return sinc_func (alpha, 0.5, 1.0); -#else - return sincx1024_func (alpha, 256, CFX_ONE); -#endif + ClutterTimeline * timeline; + gint frame; + gint n_frames; + ClutterAngle x; + ClutterFixed sine; + + timeline = clutter_alpha_get_timeline (alpha); + frame = clutter_timeline_get_current_frame (timeline); + n_frames = clutter_timeline_get_n_frames (timeline); + + x = 256 * frame / n_frames; + + sine = clutter_sini (x) * CLUTTER_ALPHA_MAX_ALPHA; + + return CFX_INT (sine); +} + +/** + * clutter_sine_dec_func: + * @alpha: a #ClutterAlpha + * @dummy: unused argument + * + * Convenience alpha function for a sine wave over interval . + * You can use this function as the alpha function for + * clutter_alpha_set_func(). + * + * Return value: an alpha value. + * + * Since: 0.4 + */ +guint32 +clutter_sine_dec_func (ClutterAlpha *alpha, + gpointer dummy) +{ + ClutterTimeline * timeline; + gint frame; + gint n_frames; + ClutterAngle x; + ClutterFixed sine; + + timeline = clutter_alpha_get_timeline (alpha); + frame = clutter_timeline_get_current_frame (timeline); + n_frames = clutter_timeline_get_n_frames (timeline); + + x = 256 * frame / n_frames + 256; + + sine = clutter_sini (x) * CLUTTER_ALPHA_MAX_ALPHA; + + return CFX_INT (sine); } /** diff --git a/clutter/clutter-alpha.h b/clutter/clutter-alpha.h index cac98320e..fb4d40e01 100644 --- a/clutter/clutter-alpha.h +++ b/clutter/clutter-alpha.h @@ -106,7 +106,8 @@ ClutterTimeline *clutter_alpha_get_timeline (ClutterAlpha *alpha); #define CLUTTER_ALPHA_RAMP_DEC clutter_ramp_dec_func #define CLUTTER_ALPHA_RAMP clutter_ramp_func #define CLUTTER_ALPHA_SINE clutter_sine_func -/* FIXME add SINE_INC/DEC */ +#define CLUTTER_ALPHA_SINE_INC clutter_sine_inc_func +#define CLUTTER_ALPHA_SINE_DEC clutter_sine_dec_func #define CLUTTER_ALPHA_SQUARE clutter_square_func #define CLUTTER_ALPHA_SMOOTHSTEP clutter_smoothstep_func @@ -132,6 +133,10 @@ guint32 clutter_ramp_func (ClutterAlpha *alpha, gpointer dummy); guint32 clutter_sine_func (ClutterAlpha *alpha, gpointer dummy); +guint32 clutter_sine_inc_func (ClutterAlpha *alpha, + gpointer dummy); +guint32 clutter_sine_dec_func (ClutterAlpha *alpha, + gpointer dummy); guint32 clutter_square_func (ClutterAlpha *alpha, gpointer dummy); guint32 clutter_smoothstep_func (ClutterAlpha *alpha, diff --git a/doc/reference/clutter-sections.txt b/doc/reference/clutter-sections.txt index ca97a8e47..1621337e8 100644 --- a/doc/reference/clutter-sections.txt +++ b/doc/reference/clutter-sections.txt @@ -112,6 +112,10 @@ CLUTTER_ALPHA_RAMP clutter_ramp_func CLUTTER_ALPHA_SINE clutter_sine_func +CLUTTER_ALPHA_SINE_INC +clutter_sine_inc_func +CLUTTER_ALPHA_SINE_DEC +clutter_sine_dec_func CLUTTER_ALPHA_SQUARE clutter_square_func CLUTTER_ALPHA_SMOOTHSTEP