Featured Posts

VS2010+SL3VS2010 beta + Silverlight 3 It keeps showing "Unable to Start Debugging. The Silverlight managed debugging package isn't installed".Finally the problem can be solved by installing Developer Runtime.

Readmore

An image in a post Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Quisque sed felis. Aliquam sit amet felis. Mauris semper, velit semper laoreet dictum, quam diam dictum urna, nec...

Readmore

Cash-Out Refinance For many, their homes are just not dwellings that protect them against rain, sun, and wind. But they are piggy banks, which can be used to raise some urgent money, even if...

Readmore

Saturday, November 15, 2008

4
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

[sourcecode language='xml']




[/sourcecode]

...

[sourcecode language='xml']














[/sourcecode]

C#:

[sourcecode language='csharp'] 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)
{

}[/sourcecode]

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!

4 comments:

Steve Wong said...

Author: Michael Tim

I love your site!

_____________________
Experiencing a slow PC recently? Fix it now!

Steve Wong said...

Author: How to Get Six Pack Fast

After reading through the article, I feel that I need more information on the topic. Could you share some resources please?

Steve Wong said...

Author: Liza

I can tell that this is not the first time you write about this topic. Why have you chosen it again?

Steve Wong said...

Author: 3water

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.

Post a Comment