We can live without Motion Path

For Silverlight, many agree it is not perfect enough coz it doesnt include many features that inside WPF. Well, as we all know, Silverlight is an engine for us to create a web-based program/application. In my opinion, being a web-based application, it should be lite but not simple of course. As I remember, last week, someone ask how to create a motion path in Silverlight in order to make a picture flying around an ellipse (circular motion). Yesterday, another post has been created where people keep on discussing the problem of silverlight without motion path.

I think all we can do is to relate Math and Programming together.
Fortunately, my PureMath teacher has taught about a set of parametric equations which declare a path of circle. Then I try to implement it on Silverlight. Finally, it works, and I my extremely happy with that. Here is the solution.

XAML

    
        
            
            
        
    

        
            
                
                     
                     
                 
             
             
             
              
              
              
              
             
             
        

C#:

        int t = 0;
        double AniX;
        double AniY;

        void Page_Loaded(object sender, RoutedEventArgs e)
        {
            Ellipse_ani_X.From = Ellipse_ani_Y.From = 0;
            Ellipse_ani_Y.To = Ellipse_ani_X.To = AniX = AniY = 0;
            t++;
            myStory_Ellipse.Begin();
        }

        private void Ellipse_ani_X_Completed(object sender, EventArgs e)
        {
            myStory_Ellipse.Stop();
            Ellipse_ani_X.From = AniX;
            Ellipse_ani_X.To= AniX = Math.Cos(t * Math.PI / 50 ) * 100;
            Ellipse_ani_Y.From = AniY;
            Ellipse_ani_Y.To = AniY = Math.Sin(t  * Math.PI / 50 ) * 100;
            t++;
            myStory_Ellipse.Begin();

        }

        private void Ellipse_ani_Y_Completed(object sender, EventArgs e)
        {

        }

I am trying to work out the motion path solution. I hope it will help all of you.

Regards,
Steve Wong(Hong Kong)
Live with Light!

Advertisements

4 thoughts on “We can live without Motion Path

  1. What do you mean by chosen it again?
    Actually, I am the first time write about this. I dont know if someone has written it or not.

    Reply
  2. Hey, I recently found this blog – thank you for the good work. I wanted to inform you that it’s not showing up correctly on the BlackBerry Browser (I have a Bold). Either way, I am now subscribed to your RSS feed on my laptop, so thank you!

    Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s