<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Everything Silverlight &#187; animation</title>
	<atom:link href="http://www.michaelsnow.com/tag/animation/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.michaelsnow.com</link>
	<description></description>
	<lastBuildDate>Thu, 28 Apr 2011 21:43:31 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Silverlight Tip of the Day #21 &#8211; Animation Easing</title>
		<link>http://www.michaelsnow.com/2010/05/18/silverlight-tip-of-the-day-21-animation-easing-2/</link>
		<comments>http://www.michaelsnow.com/2010/05/18/silverlight-tip-of-the-day-21-animation-easing-2/#comments</comments>
		<pubDate>Tue, 18 May 2010 20:34:33 +0000</pubDate>
		<dc:creator>Snowman</dc:creator>
				<category><![CDATA[silverlight, animation, easing]]></category>
		<category><![CDATA[animation]]></category>
		<category><![CDATA[easing]]></category>
		<category><![CDATA[silverlight]]></category>

		<guid isPermaLink="false">http://www.michaelsnow.com/2010/05/18/silverlight-tip-of-the-day-21-animation-easing-2/</guid>
		<description><![CDATA[Animation Easing allows for you to apply built in animation functions to your Silverlight controls. The result is a variety of animation effects that make your controls move in a more realistic way. For example, you can add springiness to your controls, set how many times you want it to bounce when it hits a [...]]]></description>
			<content:encoded><![CDATA[<p>Animation Easing allows for you to apply built in animation functions to your Silverlight controls. The result is a variety of animation effects that make your controls move in a more realistic way. For example, you can add springiness to your controls, set how many times you want it to bounce when it hits a destination point, etc.</p>
<p>The following Easing functions can be applied to your animations.</p>
<ul>
<li>BackEase – Moves the ball backwards by an amount specified through its amplitude before moving forward. </li>
<li>BounceEase – Creates an effect like a bouncing ball. </li>
<li>CircleEase – Accelerates the animation based upon a circular function. </li>
<li>CubicEase&#160; &#8211; Accelerates the animation based upon a cubic function. </li>
<li>ElasticEase – Uses springiness and oscillation to animate. </li>
<li>ExponentialEase – Accelerates the animation based upon an exponent value. </li>
<li>PowerEase – Accelerates the animation based upon a power of time. </li>
<li>QuadraticEase – Accelerates the animation based upon the square of time. </li>
<li>QuarticEase – Accelerates the animation based upon the cube of time. </li>
<li>QuinticEase – Accelerates the animation based upon the time to the power of 5. </li>
<li>SineEase – Accelerates the animation along a sine wave. </li>
</ul>
<p>Each of these has can have an EasingMode set to one of the following options:</p>
<ul>
<li>EaseOut – Ease takes place at the beginning of the animation. </li>
<li>EaseIn – Ease takes place at the end of the animation. </li>
<li>EaseInOut – EaseIn takes place for half the animation followed by EaseOut. </li>
</ul>
<p>The best way to visual these is to look at the charts provided by MSDN as follows:</p>
<p><a title="http://msdn.microsoft.com/en-us/library/system.windows.media.animation.easingmode.aspx" href="http://msdn.microsoft.com/en-us/library/system.windows.media.animation.easingmode.aspx">http://msdn.microsoft.com/en-us/library/system.windows.media.animation.easingmode.aspx</a></p>
<p>The follow properties are available to certain easing functions:</p>
<ul>
<li>Amplitude: This affects the retraction before and/or after the animation. Default is 1. </li>
</ul>
<p><img alt="Demonstrates different aplitude values." src="http://i.msdn.microsoft.com/dynimg/IC270182.png" /></p>
<ul>
<li>Bounces:&#160; Number of bounces to occur. Default is 3. </li>
<li>Bounciness: Determines how bouncy a bounce is. Default is 2. </li>
<li>Oscillations: Number of times the object slides back and forth to its target destination. Default is 3. </li>
<li>Springiness: The smaller this value, the stiffer the spring and the faster the elasticity decreases in intensity over each oscillation. Default is 3. </li>
</ul>
<p><img alt="Demonstrates different Springiness values." src="http://i.msdn.microsoft.com/dynimg/IC270199.png" /></p>
<ul>
<li>Exponent: The exponent used to determine the interpolation of the animation. Default is 2. </li>
</ul>
<p><img alt="Different values for the Exponent property." src="http://i.msdn.microsoft.com/dynimg/IC270171.png" /></p>
<ul>
<li>Power: The exponential power of the objects animation interpolation. Default is 2. </li>
</ul>
<p>Now, on to the code! I set up a Storyboard object with a DoubleAnimation. The DoubleAnimation is an animation sequences that moves the object from Top=30 to Top=250 over a period of 5 seconds.</p>
<div class="csharpcode">
<pre class="alt">&lt;Canvas&gt;</pre>
<pre>     &lt;Canvas.Resources&gt; </pre>
<pre class="alt">        &lt;Storyboard x:Name=<span class="str">&quot;EaseSB&quot;</span>&gt; </pre>
<pre>            &lt;DoubleAnimation x:Name=<span class="str">&quot;EaseAnimation&quot;</span> From=<span class="str">&quot;30&quot;</span> To=<span class="str">&quot;250&quot;</span> Duration=<span class="str">&quot;0:0:05&quot;</span> </pre>
<pre>              Storyboard.TargetName=<span class="str">&quot;TargetBall&quot;</span> Storyboard.TargetProperty=<span class="str">&quot;(Canvas.Top)&quot;</span>&gt; </pre>
<pre class="alt">            &lt;/DoubleAnimation&gt; </pre>
<pre>        &lt;/Storyboard&gt; </pre>
<pre class="alt">    &lt;/Canvas.Resources&gt; </pre>
<pre>    &lt;Image x:Name=<span class="str">&quot;TargetBall&quot;</span> Source=<span class="str">&quot;soccerball.png&quot;</span> Width=<span class="str">&quot;48&quot;</span> Canvas.Top=<span class="str">&quot;30&quot;</span> </pre>
<pre>         Canvas.Left=<span class="str">&quot;50&quot;</span>&gt;&lt;/Image&gt; </pre>
<pre class="alt">&lt;/Canvas&gt; </pre>
</div>
<style type="text/css">
<p>.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p>
  <br />This animation is targetting TargetBall which is simply an Image of a ball:</p>
<div class="csharpcode">
<pre class="alt">&lt;Image x:Name=<span class="str">&quot;TargetBall&quot;</span> Source=<span class="str">&quot;soccerball.png&quot;</span> Width=<span class="str">&quot;48&quot;</span> Canvas.Top=<span class="str">&quot;30&quot;</span>         </pre>
<pre>Canvas.Left=<span class="str">&quot;50&quot;</span>/&gt; </pre>
</div>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p>&#160;</p>
<p>When you run the demo below, the appropriate function is called to execute the animation. For example, when I run the BackEase animation I call this function:</p>
<p>This animation is targetting TargetBall which is simply an Image of a ball:</p>
<p><font color="#80ff80"></font></p>
<div class="csharpcode">
<pre class="alt"><span class="kwrd">private</span> voidBackEase() </pre>
<pre>{ </pre>
<pre class="alt">    BackEase backEase = newBackEase(); </pre>
<pre>    <span class="kwrd">try</span> </pre>
<pre class="alt">   { </pre>
<pre>        backEase.Amplitude = Convert.ToDouble(AmplitudeTB.Text); </pre>
<pre class="alt">    } </pre>
<pre>    <span class="kwrd">catch</span>{ } </pre>
<pre class="alt">    backEase.EasingMode = GetEasingMode(); </pre>
<pre>&#160;</pre>
<pre class="alt">    EaseAnimation.EasingFunction = backEase; </pre>
<pre>    EaseSB.Begin(); </pre>
<pre class="alt">}</pre>
</div>
<style type="text/css">
<p>.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>The following demo lets you try out each of these functions setting the properties they expose.</p>
<p>[silverlight: Tip21_AnimationEasing.xap]</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:fb3a1972-4489-4e52-abe7-25a00bb07fdf:7a99d42f-73c3-43c1-97f8-fc4b82971880" class="wlWriterSmartContent">
<p>Source: <a href="http://www.michaelsnow.com/wp-content/uploads/2010/05/Tip21_AnimationEasing2.zip" target="_blank">Tip21_AnimationEasing.zip</a></p>
</div>
<p>Thanks,<br />
  <br />&#8211;Mike</p>
]]></content:encoded>
			<wfw:commentRss>http://www.michaelsnow.com/2010/05/18/silverlight-tip-of-the-day-21-animation-easing-2/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

