Author: toshok
Date: 2007-06-07 13:29:35 -0400 (Thu, 07 Jun 2007)
New Revision: 78870

Modified:
   trunk/moon/src/ChangeLog
   trunk/moon/src/animation.cpp
   trunk/moon/src/animation.h
   trunk/moon/src/runtime.h
Log:
        * animation.cpp: switch all the various linear interpolation
        expressions to using the LERP macro, and add the PointAnimation
        implementation.

        * animation.h: add PointAnimation.

        * runtime.h: add Value::POINTANIMATION.

2007-06-07  Chris Toshok  <[EMAIL PROTECTED]>



Modified: trunk/moon/src/ChangeLog
===================================================================
--- trunk/moon/src/ChangeLog    2007-06-07 17:18:46 UTC (rev 78869)
+++ trunk/moon/src/ChangeLog    2007-06-07 17:29:35 UTC (rev 78870)
@@ -1,5 +1,15 @@
 2007-06-07  Chris Toshok  <[EMAIL PROTECTED]>
 
+       * animation.cpp: switch all the various linear interpolation
+       expressions to using the LERP macro, and add the PointAnimation
+       implementation.
+
+       * animation.h: add PointAnimation.
+
+       * runtime.h: add Value::POINTANIMATION.
+
+2007-06-07  Chris Toshok  <[EMAIL PROTECTED]>
+
        * runtime.h (Value): add COLORANIMATION to the list of types.
        Also, add a Kind constructor so we can use that for nullable type
        default values in the ::RegisterProperty calls.  That is,

Modified: trunk/moon/src/animation.cpp
===================================================================
--- trunk/moon/src/animation.cpp        2007-06-07 17:18:46 UTC (rev 78869)
+++ trunk/moon/src/animation.cpp        2007-06-07 17:29:35 UTC (rev 78870)
@@ -11,6 +11,8 @@
 
 #include "animation.h"
 
+#define LERP(f,t,p) ((f) + (p) * ((t) - (f)))
+
 static guint64
 get_now ()
 {
@@ -669,7 +671,7 @@
 
        double progress = animationClock->GetCurrentProgress ();
 
-       Value *v = new Value (from + (to-from) * progress);
+       Value *v = new Value (LERP (from, to, progress));
        // printf ("Sending %g from=%g to=%g progresss=%g\n", v->u.d, from, to, 
progress);
        return v;
 }
@@ -742,10 +744,10 @@
 
        double progress = animationClock->GetCurrentProgress ();
 
-       Value *v = new Value (Color (from->r + (to->r - from->r) * progress,
-                                    from->g + (to->g - from->g) * progress,
-                                    from->b + (to->b - from->b) * progress,
-                                    from->a + (to->a - from->a) * progress));
+       Value *v = new Value (Color (LERP (from->r, to->r, progress),
+                                    LERP (from->g, to->g, progress),
+                                    LERP (from->b, to->b, progress),
+                                    LERP (from->a, to->a, progress)));
 
        // printf ("Sending %g from=%g to=%g progresss=%g\n", v->u.d, from, to, 
progress);
        return v;
@@ -800,6 +802,80 @@
 
 
 
+DependencyProperty* PointAnimation::ByProperty;
+DependencyProperty* PointAnimation::FromProperty;
+DependencyProperty* PointAnimation::ToProperty;
+
+PointAnimation::PointAnimation ()
+{
+       SetObjectType (Value::POINTANIMATION);
+}
+
+Value*
+PointAnimation::GetCurrentValue (Value *defaultOriginValue, Value 
*defaultDestinationValue,
+                                AnimationClock* animationClock)
+{
+       Point *by = point_animation_get_by (this);
+       Point *from = point_animation_get_from (this);
+       Point *to = point_animation_get_to (this);
+
+       double progress = animationClock->GetCurrentProgress ();
+
+       Value *v = new Value (Point (LERP (from->x, to->x, progress),
+                                    LERP (from->y, to->y, progress)));
+
+       return v;
+}
+
+PointAnimation *
+point_animation_new ()
+{
+       return new PointAnimation ();
+}
+
+void
+point_animation_set_by (PointAnimation *da, Point by)
+{
+       da->SetValue (PointAnimation::ByProperty, Value(by));
+}
+
+Point*
+point_animation_get_by (PointAnimation *da)
+{
+       Value *v = da->GetValue (PointAnimation::ByProperty);
+       return v == NULL ? NULL : v->u.point;
+}
+
+void
+point_animation_set_from (PointAnimation *da, Point from)
+{
+       da->SetValue (PointAnimation::FromProperty, Value(from));
+}
+
+Point*
+point_animation_get_from (PointAnimation *da)
+{
+       Value *v = da->GetValue (PointAnimation::FromProperty);
+       return v == NULL ? NULL : v->u.point;
+}
+
+void
+point_animation_set_to (PointAnimation *da, Point to)
+{
+       da->SetValue (PointAnimation::ToProperty, Value(to));
+}
+
+Point*
+point_animation_get_to (PointAnimation *da)
+{
+       Value *v = da->GetValue (PointAnimation::ToProperty);
+       return v == NULL ? NULL : v->u.point;
+}
+
+
+
+
+
 RepeatBehavior RepeatBehavior::Forever (RepeatBehavior::FOREVER);
 Duration Duration::Automatic (Duration::AUTOMATIC);
 Duration Duration::Forever (Duration::FOREVER);
@@ -827,6 +903,11 @@
        ColorAnimation::FromProperty = DependencyObject::Register 
(Value::COLORANIMATION, "From", new Value (Value::COLOR));
        ColorAnimation::ToProperty   = DependencyObject::Register 
(Value::COLORANIMATION, "To",   new Value (Value::COLOR));
 
+       /* PointAnimation properties */
+       PointAnimation::ByProperty   = DependencyObject::Register 
(Value::POINTANIMATION, "By",   new Value (Value::POINT)); // null defaults
+       PointAnimation::FromProperty = DependencyObject::Register 
(Value::POINTANIMATION, "From", new Value (Value::POINT));
+       PointAnimation::ToProperty   = DependencyObject::Register 
(Value::POINTANIMATION, "To",   new Value (Value::POINT));
+
        /* Storyboard properties */
        Storyboard::TargetPropertyProperty = DependencyObject::Register 
(Value::STORYBOARD, "TargetProperty", 
                                                                         
Value::STRING);

Modified: trunk/moon/src/animation.h
===================================================================
--- trunk/moon/src/animation.h  2007-06-07 17:18:46 UTC (rev 78869)
+++ trunk/moon/src/animation.h  2007-06-07 17:29:35 UTC (rev 78870)
@@ -432,6 +432,34 @@
 
 
 
+class PointAnimation : public Animation/*Timeline*/ {
+ public:
+
+       PointAnimation ();
+
+       static DependencyProperty* ByProperty;
+       static DependencyProperty* FromProperty;
+       static DependencyProperty* ToProperty;
+
+       virtual Value *GetCurrentValue (Value *defaultOriginValue, Value 
*defaultDestinationValue,
+                                       AnimationClock* animationClock);
+};
+
+PointAnimation * point_animation_new ();
+
+void   point_animation_set_by (PointAnimation *da, Point by);
+Point* point_animation_get_by (PointAnimation *da);
+
+void   point_animation_set_from (PointAnimation *da, Point from);
+Point* point_animation_get_from (PointAnimation *da);
+
+void   point_animation_set_to (PointAnimation *da, Point to);
+Point* point_animation_get_to (PointAnimation *da);
+
+
+
+
+
 class Storyboard : public ParallelTimeline {
  public:
        Storyboard ();

Modified: trunk/moon/src/runtime.h
===================================================================
--- trunk/moon/src/runtime.h    2007-06-07 17:18:46 UTC (rev 78869)
+++ trunk/moon/src/runtime.h    2007-06-07 17:29:35 UTC (rev 78870)
@@ -179,6 +179,7 @@
                STORYBOARD,
                DOUBLEANIMATION,
                COLORANIMATION,
+               POINTANIMATION,
                SHAPE,
                ELLIPSE,
                LINE,

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to