Silverlight Animations: What are KeySplines and why should you care?

If you’ve seen/read/heard anything about Silverlight, you probably know by now that it can do animations. In fact, Silverlight has fairly rich animation support.

I would like to point out right off that I am a developer, not a designer, and that this post is aimed at other developers. As developers we don’t typically have extensive knowledge about things such as easing and keysplines so I’ll try and phrase everything so we can all understand it.

What I’m going to talk about today is something known as easing and how you do it in Silverlight. In essence, easing is modifying the velocity over time of a given animation. This velocity modification is done using keysplines, which is the point of this post. A spline uses points to define a curve. In the case of Keysplines, you have a line defined as moving from point 0,0 to point 1,1. The default Keyspline has the spline definition points at those same locations. By modifying the location of those points, you can change the line into a curve. The shape of the curve determines the speed of the animation at a given point in time. The basic rule is that if the x of the slope is greater than the y, the animation is slow but if the y is greater than the x it is fast.

Confused yet? Don’t worry, I’ve got examples and pictures to help it make sense.

KeySpline Example

[Note: If you are seeing this text you are either in a feed reader or don't have Silverlight installed. Please view in a browser with Silverlight enabled to see the example.]

KeySpline Details

Now that you (hopefully) can see the difference between the different spline values I have in place, why don’t we take a look at how to use them in your own animations. The first task is to actually find where in Expression Blend you actually set the KeySpline value. It may be intuitive for designers, but us developers need a hand finding this the first time, so here’s your helping hand. Basically, all you need to do is to click the keyframe indicator for a particular object and Blend will open the easing window in the properties tab. Still lost eh? Here’s a couple pictures.

If you are using the default (design) workspace if should look something like the screenshot below. I’ve circled the areas mentioned above.

OpenSpline

Here’s another screenshot for the same tasks but in the animation workspace.

OpenSpline2

And don’t worry if you don’t have/don’t want Blend, KeySplines are actually very to add directly to the XAML yourself. All you need to do is add a “KeySpline” attribute to a Key Frame based animation. The elements with this attribute available are SplineColorKeyFrame, SplineDoubleKeyFrame, and SplinePointKeyFrame. If you don’t know how to hand code those elements then I would advise you to use Expression Blend to do it for you the first time, you can always go tweak the generated XAML. Adding the attribute looks something like this:

<SplineDoubleKeyFrame KeyTime="00:00:04" Value="458" KeySpline="0,0.5,0.5,1"/>

So now that you have an idea of how to create a keyspline, what do the values do for you? Here’s a description of the different values I used in the sample app above.

 

No Easing

If you don’t use keysplines this is what you get. In many cases this will be fine, especially in very short/fast animations. Typically though, using some sort of easing makes an animation more pleasing to the eye and thus “feels” nicer to the viewer. NoSpline

Spline 1

In this example we see the ball start quickly and then slow down as it approaches the end of the animation. This is probably the most common one I use as it allows for a fairly natural feel when animating scenes sliding into view.

Value:
KeySpline="0,0.5,0.5,1"

Spline1

Spline 2

This spline value causes the opposite effect of the previous one. In this case the Animation starts incredibly slow and the gets faster as it moves. This is useful when moving objects out of view or for a “dropped” object.

Value:
KeySpline="0.5,0,1,0.5"

Spline2

Spline 3

In this example the movement starts quickly, slows down and then speeds back up again. I’m not sure when you would use this one, it’s more of an example showing that is doesn’t need to be a consistent curve, you can modify it along the way. 

Value:
KeySpline="0,0.5,1,0.5"

Spline3

Spline 4

Have we have the animation begin incredibly fast, appear to stop completely, and then resume at a steady pace. Personally I would never use anything like this (except obviously in a blog post) but it shows that you can create some extreme effects just by modifying the spline.

Value:
KeySpline="0,1,0.5,0.03"

Spline4

Finally

Generally, I add easing to nearly every animation I create to give it a more natural feel. It’s amazing how the appropriate keyspline can make an animation “feel” right, even if it’s too subtle to really be noticed. Hopefully from this article you can see both the value of using easing and how to add it to your animations.

In a future post I’ll be showing some more advanced effects you can create by using different easings on different parts of an animation. But don’t wait for me to show you how, crack open Blend and play with some, I’m sure you can make something cool.

#1 ricky on 5.12.2009 at 10:54 PM

Interesting post, it helps me in my research, thanks!

#2 lissa on 5.25.2009 at 9:54 PM

Yup it does look very nice.

#3 mark on 6.17.2009 at 6:59 PM

Great post, definitely interested on it,.

#4 Stop Dreaming Start Action on 6.20.2009 at 7:04 PM

Interesting post, it helps me in my research, thanks!

#5 Rusli Zainal Sang Visioner on 6.20.2009 at 7:04 PM

Such an interesting post, thanks for sharing it, so useful to understand what happen all around us !

#6 cervical cancer on 6.25.2009 at 7:21 PM

Nice animations. Thanks for sharing

#7 how to play craps in casino rooms on 6.27.2009 at 6:30 AM

am on a mission to learn Expression Blend better ! Here are some of the “cool” things I discovered

#8 bud on 7.01.2009 at 10:38 PM

Nice and cool

#9 Rusli Zainal Sang Visioner on 7.02.2009 at 12:10 AM

Nice graphic animation :D

#10 stop dreaming start action on 7.06.2009 at 9:50 AM

Very nice tips

#11 online associate Degree on 7.07.2009 at 6:51 AM

it helps me in my research, thanks!

#12 online Bachelor Degree on 7.07.2009 at 6:51 AM

Expression Blend better ! Here are some of the “cool” things I discovered

#13 Online school on 7.07.2009 at 6:52 AM

it helps me in my research, thanks!

#14 Associate Degree on 7.07.2009 at 6:52 AM

Yup it does look very nice.

#15 Buy Essay on 7.09.2009 at 12:41 AM

These are the essays for the persons who need it and being a writer i could understand your information.

#16 badz on 7.12.2009 at 9:23 PM

Yup it does look very nice.

#17 drink recipes on 7.13.2009 at 5:19 AM

These are good objectives provided.This is probably the most common one I use as it allows for a fairly natural feel when animating scenes sliding into view.Thanks for sharing.

#18 belajar seo on 7.13.2009 at 6:13 AM

Yup it does look very nice.

#19 curahan pemula on 7.13.2009 at 6:13 AM

great info

#20 blog seo on 7.13.2009 at 6:13 AM

thnaks for sharing

#21 SEP on 7.13.2009 at 6:14 AM

Such an interesting post, thanks for sharing it, so useful to understand what happen all around us !

#22 latihan seo on 7.13.2009 at 6:14 AM

Very nice tips

#23 Kontes on 7.13.2009 at 6:15 AM

Great post, definitely interested on it,.

#24 euro casino bonus on 7.14.2009 at 1:50 AM

It is good to organize the free and fun games which brings the spirit to play for the viewers.

#25 Custom Research Paper on 7.14.2009 at 2:03 AM

Its amazing that it very help full to us in now a days that silver light app. will give cool light thanks for nice post.

Regards,

#26 tiffany co jewellery on 7.14.2009 at 4:15 AM

Tiffanysilvers provides the best Tiffany & Co jewelry, including Necklaces, Pendants, Bracelets, Earrings, Rings and Pocket Mirror at the lowest prices,

#27 free online games on 7.17.2009 at 9:44 AM

It may be intuitive for designers, but us developers need a hand finding this the first time, so here’s your helping hand

#28 sale handbags on 7.26.2009 at 12:00 AM

Good topic. Very interesting Posting. Thank for your share. Nice!!

#29 Free Glitter Graphics on 7.26.2009 at 12:01 AM

thank.. :)

#30 جيل on 7.27.2009 at 12:45 AM

thanks

http://www.jeel5.com/vb

#31 Lida on 7.31.2009 at 9:04 AM

Good on your

#32 stop dreaming start action on 8.03.2009 at 6:31 AM

thank you for screenshoot, that useful for understanding it

#33 stop dreaming start action on 8.03.2009 at 6:31 AM

thank you for useful guide

#34 بيتك هنا on 8.03.2009 at 11:19 AM

thank you for screenshoot, that useful for understanding it

#35 fandy on 8.05.2009 at 2:25 AM

this post is very useful, i understand

#36 fandy on 8.05.2009 at 2:25 AM

great job

#37 fandy on 8.05.2009 at 2:26 AM

this post is very useful, i like with your post. i like with your image

#38 carving on 8.06.2009 at 2:37 AM

helpful examples and pictures, thanks

#39 Web Design on 8.06.2009 at 7:05 AM

These are nice guidelines for silverlight animations.

Thank you

#40 Rusli Zainal Sang Visioner on 8.06.2009 at 11:49 PM

great post, ...thank you blog.cicurug.com/.../stop-dreaming-s

#41 Dissertation Writing on 8.07.2009 at 11:30 AM

That's nice post!

#42 Dissertation Writing on 8.07.2009 at 11:32 AM

That's nice post!

#43 Free Essays on 8.07.2009 at 11:37 AM

IMHO it is quite interesting information. Simply saying i'm impressed. Thanks and good luck!

#44 My IP Address on 8.07.2009 at 11:39 AM

Searched Google and found your blog. I like it. Keep up the good work.

#45 college papers on 8.07.2009 at 11:42 AM

I greatly appreciate all the info I've read here. I will spread the word about your blog to other people. Cheers.

#46 testking cisco on 8.08.2009 at 2:38 PM

The timing and animation features provided by HTML+TIME (Timed Interactive Multimedia Extensions) make it easier to add basic animations to Web pages—just set values for a particular property of a target element over a simple duration, and you've created an animation. What's not immediately obvious is that HTML+TIME also incorporates some of the vector-drawing capabilities of the Scalable Vector Graphics (SVG) syntax to provide Web authors with more sophisticated control over timing intervals and paths. Using the keyTimes and keySplines attributes, you can divide an animation element's simple duration into multiple segments, speed up or slow down the animation at multiple rates during a single duration, and specify values for the animation to reach at particular points in its duration. Even better, HTML+TIME makes it possible to use these features without writing script. Animating with keyTimes and keySplines enables you to do the following:

Apply spline interpolation to timing segments of an animation. In other words, you can vary the rate at which the animation function calculates the values that drive the animation. This provides much closer control over timing and positioning during animations, but keeps your code remarkably simple.

Match time values with Bézier control points to include multiple smooth changes in element motion over the course of a single animation.

Use splines to set varied rates of change when animating colors.

#47 Tax Relief on 8.09.2009 at 6:01 AM

That means you can have your working application, or a video explaining it or maybe just a neat hero bar talking about the virtues of your project.

Regards,

#48 Graphic Design on 8.09.2009 at 6:11 AM

That is a great post, would really helpful for silverlight animators.

#49 Ivybot on 8.09.2009 at 1:49 PM

Wow! This is a powerful tool for spline actions! Thanks for the tutorial!

#50 links of london on 8.09.2009 at 10:03 PM

It was a very nice idea! Just wanna say thank you for the information you have shared. Just continue writing this kind of post. I will be your loyal reader.

Thanks again.

#51 canada sildenafil on 8.10.2009 at 9:49 AM

Is it difficult to learn working with Silverlight?

#52 fdg on 8.12.2009 at 6:06 AM

<a href="http://www.mynktrading.com/GarmentAccessories.aspx">garment accessories</a>

#53 fdg on 8.12.2009 at 6:06 AM

<a href="http://www.mynktrading.com/GarmentAccessories.aspx">garment accessories</a>

#54 SEO on 8.12.2009 at 6:11 AM

ASP.NET supports creating reusable components through the creation of User controls. A user control follows the same structure as a Web form, except that such controls are derived from the System.Web.UI.UserControl class, and are stored in ASCX files. Like ASPX files, an ASCX file contains static HTML or XHTML markup, as well as markup defining web control and other user controls. The code-behind model can be used.

#55 rugs on 8.12.2009 at 3:20 PM

<p><a href="http://www.homedecors.com.au" title=" home decor" target="_blank"> home decor</a> or any community of people indispensable.</p>

<a href="http://www.leatherlounges.net.au" title="leather lounges" target="_blank">leather lounges</a> or any community of people indispensable.</p>

<p><a href="http://www.onlineauctions.net.au" title="online auctions" target="_blank">online auctions</a> or any community of people indispensable.</p>

<p><a href="http://www.kidonlinegames.net/43/Race-Games/Dune-Buggy-Game" title="dune buggy game" target="_blank">dune buggy game</a> or any community of people indispensable.</p>

#56 leather lounges on 8.12.2009 at 3:22 PM

very nice

#57 home decor on 8.12.2009 at 3:22 PM

thanks

#58 online auctions on 8.12.2009 at 3:23 PM

thanks admin

#59 dune buggy game on 8.12.2009 at 3:24 PM

good jobs thansk admin

#60 Belajar Seo on 8.13.2009 at 6:43 AM

great info, thanks for sharing this

#61 Hosting Murah on 8.13.2009 at 6:44 AM

thanks for taking the to sharing this with us

#62 Stop Dreaming Start Action on 8.13.2009 at 1:35 PM

This is so great post, thanks

#63 Apex Professionals LLC on 8.13.2009 at 2:39 PM

What really separates silverlight from say.. flash? Is there any reason to use it over previously released technologies?

#64 online on 8.14.2009 at 11:27 AM

Thanks for sharing this information. I found it very informative as I have been researching a lot lately on practical matters such as you talk about...

#65 tiffany jewellery on 8.14.2009 at 8:44 PM

thanks for sharning this information,its useful

#66 توبيكات on 8.15.2009 at 10:11 PM

These are nice guidelines for silverlight animations.

#67 Free Advertising on 8.16.2009 at 12:56 AM

Interesting post, it helps me in my research, Thanks for sharing this information,its useful

#68 Tiffany on 8.17.2009 at 1:37 AM

Oh yeah.

#69 Tiffany Jewellery on 8.17.2009 at 1:37 AM

OH yeah,That's great

#70 Tiffany Necklaces on 8.17.2009 at 1:39 AM

Hello

#71 Tiffany Co on 8.17.2009 at 1:39 AM

These are nice guidelines for silverlight animations.

#72 Tiffany Sets on 8.17.2009 at 1:40 AM

I think so too.

#73 Tiffany Bracelets on 8.17.2009 at 1:40 AM

OK,I will do

#74 Tiffany Pendants on 8.17.2009 at 1:40 AM

thanks a lot

#75 Tiffany Rings on 8.17.2009 at 1:41 AM

You are right

#76 Tiffany on 8.17.2009 at 1:42 AM

As we all know ,that good

#77 Tiffany Jewelry on 8.17.2009 at 1:42 AM

OH yeah,That's great

#78 Tiffany necklaces on 8.17.2009 at 1:43 AM

GOOD POST

#79 Tiffany rings on 8.17.2009 at 1:43 AM

OK,I believe you

#80 Tiffany bracelets on 8.17.2009 at 1:44 AM

like you post ,speed up

#81 Tiffany pendants on 8.17.2009 at 1:45 AM

Look here ,you will find a lot of new things

#82 Tiffany on 8.17.2009 at 1:46 AM

www.tiffanyfree.com

#83 Tiffany Jewelry on 8.17.2009 at 1:46 AM

OH yeah,That's great

#84 Tiffany Co on 8.17.2009 at 1:47 AM

Tiffany Co Tiffany Co Tiffany Co

#85 Tiffany Necklaces on 8.17.2009 at 1:48 AM

www.tiffanyfree.com/.../tiffany-necklac

#86 Tiffany Bracelets on 8.17.2009 at 1:48 AM

www.tiffanyfree.com/.../tiffany-bracele

#87 Tiffany Pendants on 8.17.2009 at 1:49 AM

www.tiffanyfree.com/.../tiffany-pendant , you know?

#88 Christian Audigier on 8.17.2009 at 1:54 AM

WHO?

#89 Ed Hardy on 8.17.2009 at 1:54 AM

www.edhardyuk.co.uk/.../ed-hardy-mens.h you want be fashion,please look this

#90 Links of London on 8.17.2009 at 1:55 AM

!!!!!!!!!!!!!!!!!

#91 Ed Hardy shirts on 8.17.2009 at 1:55 AM

p///??????????

#92 Links of London on 8.17.2009 at 1:56 AM

Today is fine.

#93 Links of London rings on 8.17.2009 at 1:59 AM

Today is monday?

#94 Links of London on 8.17.2009 at 2:02 AM

a ha,are you kidding?

#95 Abercrombie and Fitch on 8.17.2009 at 2:04 AM

Forgive me ,I just for the work.

#96 Links London on 8.17.2009 at 2:04 AM

I like your post very much

#97 Abercrombie and Fitch on 8.17.2009 at 2:05 AM

I am free worker

#98 Hollister clothing on 8.17.2009 at 2:06 AM

These are the essays for the persons who need it and being a writer i could understand your information.

#99 Hollister on 8.17.2009 at 2:06 AM

hahahaha,fuck

#100 Ruehl on 8.17.2009 at 2:08 AM

Yup it does look very nice.

#101 fandy on 8.18.2009 at 5:28 AM

I'm look but very nice..

#102 منتديات on 8.19.2009 at 10:57 PM

thanks

#103 دليل مواقع on 8.19.2009 at 10:58 PM

wooow

#104 فحص البيج رانك on 8.19.2009 at 10:58 PM

thank you

#105 web marketing on 8.21.2009 at 4:38 AM

What is 'Silverlight'? I have downloaded it from MSN, but don't know what are its usage and how it is used.?

#106 Kenali dan Kunjungi Objek Wisata di Pandeglang on 8.23.2009 at 12:03 AM

In truth, immediately i didn’t understand the essence. But after re-reading all at once became clear.

#107 Mizwar on 8.23.2009 at 12:06 AM

You know, I have to tell you, I really enjoy this blog and the insight from everyone who participates. I find it to be refreshing and very informative. I wish there were more blogs like it. Anyway, I felt it was about time I posted, I?ve spent most of my time here just lurking and reading, but today for some reason I just felt compelled to say this.

#108 acne removal on 8.23.2009 at 10:29 AM

very nice tips. thanks for sharing

#109 العاب on 8.23.2009 at 6:35 PM

good

#110 توبيكات on 8.23.2009 at 6:35 PM

good

#111 خلفيات on 8.23.2009 at 6:36 PM

good

#112 Business Mailing Lists on 8.24.2009 at 10:44 AM

great stuff cheers

#113 Geouge on 8.24.2009 at 7:14 PM

Silverlight got so many cool features. KeySplines is one of them. Nice Microsoft.

#114 cheap juicy jewelry on 8.25.2009 at 6:01 AM

tgawqgwq

#115 juicy couture jewelry on 8.25.2009 at 6:01 AM

regeaaq

#116 juicy couture charms on 8.25.2009 at 6:01 AM

dsgasd

#117 juicy necklace on 8.25.2009 at 6:01 AM

I like

#118 juicy charms on 8.25.2009 at 6:01 AM

sdgffasd

#119 Tiffanys on 8.25.2009 at 9:15 PM

╮(╯▽╰)╭

#120 Tiffany Bangles&Bracelets on 8.25.2009 at 9:15 PM

发噶三分公司地方

#121 Tiffany Co on 8.25.2009 at 9:15 PM

╭(╯3╰)╮

#122 Tiffany Jewelry on 8.25.2009 at 9:15 PM

o_O???

#123 Tiffany on 8.25.2009 at 9:15 PM

(O_O)?

#124 Tiffany Earrings on 8.25.2009 at 9:16 PM

kghjghjyrtyr

#125 Tiffany Rings on 8.25.2009 at 9:16 PM

fdgdffgdaasd

#126 Tiffany Sets on 8.25.2009 at 9:16 PM

dddddddddddddddddddddd

#127 Tiffany Accessories on 8.25.2009 at 9:17 PM

fgdfgdgdfg

#128 Tiffany Pendants on 8.25.2009 at 9:17 PM

dfaserrwerccc

#129 Tiffany Necklaces on 8.25.2009 at 9:17 PM

fghtryrtyrtyrt

#130 Tiffany Charms on 8.25.2009 at 9:18 PM

dfggggggggggggdfg

#131 links of london on 8.25.2009 at 10:57 PM

Thanks for your information!