Windows 8 Store Apps學習(19) 動畫 線性動畫, 主要畫面格動畫, 緩動動畫

來源:互聯網
上載者:User

介紹

重新想象 Windows 8 Store Apps 之 動畫

線性動畫 - 共有 3 種: ColorAnimation, DoubleAnimation, PointAnimation, 它們均繼承自 Timeline

主要畫面格動畫 - 共有 4 種:ColorAnimationUsingKeyFrames, DoubleAnimationUsingKeyFrames, PointAnimationUsingKeyFrames, ObjectAnimationUsingKeyFrames 它們均繼承自 Timeline

緩動動畫 - easing

樣本

1、示範線性動畫的應用

Animation/LinearAnimation.xaml

<Page    x:Class="XamlDemo.Animation.LinearAnimation"    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"    xmlns:local="using:XamlDemo.Animation"    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"    mc:Ignorable="d">        <Grid Background="Transparent">        <!--            線性動畫一共有 3 種:ColorAnimation, DoubleAnimation, PointAnimation, 它們均繼承自Timeline                        Storyboard.TargetName - 附加屬性,要進行動畫處理的對象的名稱            Storyboard.TargetProperty - 附加屬性,要進行動畫處理的對象的屬性            BeginTime - 時間軸在被觸發 BeginTime 的時間後才能開始播放                TimeSpan - [-][日.]時:分:秒[.1位到7為的秒後的小數](可為正;可為負;可為空白;預設值為 0)            From - 動畫的起始值            To - 動畫的結束值            By - 動畫從起始值開始計算,所需變化的總量(To 優先於 By)            Duration - 時間軸的期間                TimeSpan - [-][日.]時:分:秒[.1位到7為的秒後的小數]                Automatic - 自動確定                Forever - 無限長            AutoReverse - 動畫完成後是否要原路返回。預設值為 false            RepeatBehavior - 動畫重複播放的時間、次數或類型                TimeSpan - [-][日.]時:分:秒[.1位到7為的秒後的小數]                nx - 播放次數。1x, 2x, 3x                 Forever - 永久播放            SpeedRatio - 時間軸的速率的倍數。預設值 1            FillBehavior - 動畫結束後的行為(System.Windows.Media.Animation.FillBehavior 枚舉)                FillBehavior.HoldEnd - 動畫結束後,UI 保留動畫後的狀態。預設值                FillBehavior.Stop - 動畫結束後,UI 恢複為動畫前的狀態                                    注意:、在 WinRT 中為了流暢的體驗,部分動畫被最佳化成了“獨立式動畫”,即動畫不依賴於 UI 線程、但是也有一部分動畫無法最佳化成“獨立式動畫”,我們把這類動畫稱作“依賴動畫”,其需要在 UI 線程上運行、通過將 EnableDependentAnimation 設定為 true(預設為 false),開啟“依賴動畫”、通過將 Timeline.AllowDependentAnimations 設定為 false(預設為 true),可以全域禁止開啟“依賴動畫”                        Independent Animation - 獨立式動畫            Dependent Animation - 依賴動畫        -->            <Grid.Resources>            <BeginStoryboard x:Name="storyboardColor">                <Storyboard>                    <!--Color 值線性動畫-->                    <!--                        動畫要修改的屬性是 Ellipse.Fill,動畫後的結果值會賦予 SolidColorBrush.Color,然後 SolidColorBrush 就是動畫後 Fill 屬性的值                        類似的比如:(UIElement.RenderTransform).(CompositeTransform.TranslateY) 以及 (UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX) 等                    -->                    <ColorAnimation                        Storyboard.TargetName="ellipse"                        Storyboard.TargetProperty="(Ellipse.Fill).(SolidColorBrush.Color)"                        BeginTime="00:00:00"                        From="Red"                        To="Yellow"                        Duration="0:0:3"                        AutoReverse="true"                        RepeatBehavior="3x">                    </ColorAnimation>                </Storyboard>            </BeginStoryboard>                            <BeginStoryboard x:Name="storyboardDouble">                <Storyboard>                    <!--Double 值線性動畫-->                    <!--                        動畫要修改的屬性是 Canvas.Left                    -->                    <DoubleAnimation                        Storyboard.TargetName="rectangle"                        Storyboard.TargetProperty="(Canvas.Left)"                        From="100"                        By="100"                        BeginTime="0:0:0"                        Duration="00:00:03"                        AutoReverse="true"                        RepeatBehavior="Forever">                    </DoubleAnimation>                </Storyboard>            </BeginStoryboard>                <BeginStoryboard x:Name="storyboardPoint">                <Storyboard>                    <!--Point 值線性動畫-->                    <PointAnimation                         EnableDependentAnimation="True"                        Storyboard.TargetName="ellipseGeometry"                        Storyboard.TargetProperty="Center"                        BeginTime="00:00:00"                        From="50,50"                        To="200,200"                        Duration="00:00:03"                        AutoReverse="true"                        RepeatBehavior="Forever">                    </PointAnimation>                </Storyboard>            </BeginStoryboard>        </Grid.Resources>            <StackPanel Margin="120 0 0 0">                <Ellipse x:Name="ellipse" Fill="Orange" Width="200" Height="100" HorizontalAlignment="Left" />                <Canvas Width="400" Height="100" HorizontalAlignment="Left" Margin="0 10 0 0">                <Rectangle x:Name="rectangle" Fill="Orange" Width="200" Height="100" Canvas.Left="100" />            </Canvas>                            <Path Fill="Orange">                <Path.Data>                    <EllipseGeometry x:Name="ellipseGeometry" Center="50,50" RadiusX="15" RadiusY="15" />                </Path.Data>            </Path>                        </StackPanel>    </Grid></Page>

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.