DHJJ [Hatsune's Journal Japan] blog

Hatsune's Journal Japan blog

目次

Blog 利用状況

ニュース

最新ツイート

運営サイト

Hatsune's Journal Japan
DHJJ

著作など

資格など

OCP
MCP

書庫

日記カテゴリ

わんくま同盟

XAMLアニメーションで心地よいモーションを作る(EasingFunction編)

前回、Blendを使ってストーリーボードでKeyFrameを1つ1つ作成していきましたが、XAMLにはEasingFunctionといって、ある値からある値に変化を自動的にバウンドしながらアニメーションさせる機能があります。

それがEasingFunctionです。

ポヨン!プルン!という動き

まずはおさらいとして前回のストーリーボードを確認してみましょう。

        <Storyboard x:Name="SymbolStoryBoard">
             <DoubleAnimationUsingKeyFrames
                 EnableDependentAnimation="True"
                 Storyboard.TargetProperty="(FrameworkElement.Width)"
                 Storyboard.TargetName="ellipse">
                 <EasingDoubleKeyFrame KeyTime="0:0:0.0" Value="100"/>
                 <EasingDoubleKeyFrame KeyTime="0:0:0.1" Value="40"/>
                 <EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="120"/>
                 <EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="100"/>
                 <EasingDoubleKeyFrame KeyTime="0:0:0.4" Value="110"/>
                 <EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="100"/>
             </DoubleAnimationUsingKeyFrames>
         </Storyboard>
それでは同じような動きになる設定をEasingFunctionで定義してみましょう。
EasingFunctioは今回のように最初と最後に同じ値を指定しても全然アニメーションしてくれないので、100→40の部分まではKeyFrameで指定して40→100のところでバウンドしながら収束する動きにつかいます。
        <Storyboard x:Name="Symbol2StoryBoard">
             <DoubleAnimationUsingKeyFrames
                 EnableDependentAnimation="True"
                 Storyboard.TargetProperty="(FrameworkElement.Width)"
                Storyboard.TargetName="ellipse">
                 <EasingDoubleKeyFrame KeyTime="0:0:0.0" Value="100"/>
                 <EasingDoubleKeyFrame KeyTime="0:0:0.1" Value="40"/>
                 <EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="100">
                     <EasingDoubleKeyFrame.EasingFunction>
                         <ElasticEase Oscillations="1" EasingMode="EaseOut" Springiness="1" />
                     </EasingDoubleKeyFrame.EasingFunction>
                 </EasingDoubleKeyFrame>
             </DoubleAnimationUsingKeyFrames>
         </Storyboard>
プルンとオブジェクトがバネのように震える動き

同様に前回のストーリーボードは

        <Storyboard x:Name="BalloonStoryBoard">
             <DoubleAnimationUsingKeyFrames
                 Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.Rotation)"
                 Storyboard.TargetName="path">
                 <EasingDoubleKeyFrame KeyTime="0" Value="0"/>
                 <EasingDoubleKeyFrame KeyTime="0:0:0.1" Value="-6"/>
                 <EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="7"/>
                 <EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="-3"/>
                 <EasingDoubleKeyFrame KeyTime="0:0:0.4" Value="3"/>
                 <EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="-1"/>
                 <EasingDoubleKeyFrame KeyTime="0:0:0.6" Value="1"/>
                 <EasingDoubleKeyFrame KeyTime="0:0:0.7" Value="0"/>
             </DoubleAnimationUsingKeyFrames>
         </Storyboard>
それでは同じような動きになる設定をEasingFunctionで定義してみましょう。
こちらも同様に最初のぐにゅっとなるところまではKeyFrameで指定してそこから元に戻るところにEasingFunctionを適用します。
        <Storyboard x:Name="Balloon2StoryBoard">
             <DoubleAnimationUsingKeyFrames
                 EnableDependentAnimation="True"
                 Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.Rotation)"
                Storyboard.TargetName="path">
                 <EasingDoubleKeyFrame KeyTime="0:0:0.0" Value="0"/>
                 <EasingDoubleKeyFrame KeyTime="0:0:0.1" Value="-6"/>
                 <EasingDoubleKeyFrame KeyTime="0:0:0.7" Value="0">
                     <EasingDoubleKeyFrame.EasingFunction>
                         <ElasticEase Oscillations="3" EasingMode="EaseOut" Springiness="1" />
                     </EasingDoubleKeyFrame.EasingFunction>
                 </EasingDoubleKeyFrame>
             </DoubleAnimationUsingKeyFrames>
         </Storyboard>
動作確認
XAML StoryBoard EasingFunction Sample

 

EasingFunctionはMSDNのWebサイト上でパラメタをいろいろ変化させて確認することができます。

http://samples.msdn.microsoft.com/Silverlight/silverlight_next/Animations/easing_functions_gallery/testpage.html

ぜひこちらも活用してかっこいい動作をいろいろ定義してみましょう。

投稿日時 : 2013年3月30日 12:01

Feedback

# BQwsdfFUDfnTemvJQkgBBinnCoHgnKSxdzpXVc 2014/04/06 8:13 nwaez

-

# NPurtDDkdiw 2014/07/19 15:19 http://crorkz.com/

DaAWQB I appreciate you sharing this post.

# OObUMaDrbetXsTCH 2014/08/07 13:05 http://crorkz.com/

Dnkr84 I value the blog. Really Great.

# Cyabh Agn Aeiv Hyt Mqctem 2014/12/13 22:28 Robertmt

http://www.lakesregionwater.com/jias/20141210233703981.htmlInside of Having been quoted telling the incapability to let china and taiwan dollars to recognise can result in a genuine "massive bubble" on account of overinvestmenthttp://www.dbrine.com/jias/20141210233703564.html. Some pupil's beloved, this valuable service provider could be made satisfactory to take care of http://www.rhltt.com/jias/20141211020745612.htmltraveling with a laptop gadgets, articles, Luciano Louboutin Discount in addition to text message book. Like to carry the chanel bag Great deals http://www.cypresscultural.com/jias/20141210233703300.htmlAnd as well, Gucci Totes Good discounts you may quickly fork out countless big kinds http://www.tina-jenkins.com/jias/20141211020745493.htmlrestoration their own prospects your own. Ultimately causing the one year 1771 she or he given outside in several possibilities by using warming uphttp://www.hotdogwebs.com/jias/20141211020747732.html platinum and in addition mercury carbonates, gold and silver oxides, alkaline nitrates, drogue chemical, as well as dark-colored colored o2 connected with manganese. http://www.annikbrunet.com/jias/20141211022749539.html
http://www.collegedigest.com/jias/20141211021452180.html
http://www.pivotalgroup.com/jias/20141211020018181.html
http://www.jointsponsor.com/jias/20141211020437996.html
http://www.annikbrunet.com/jias/20141211020056698.html
http://www.design3000plus.com/jias/20141210231831407.html
http://www.dbrine.com/jias/20141210232543814.html
http://www.shielslumber.com/jias/20141210232656997.html
http://www.justplastics.com/jias/20141210235803975.html
http://www.deckersupply.com/jias/20141210234851857.html

タイトル
名前
Url
コメント