wpf动画总结:
12:27
今天又弄了一天动画,终于有点成果了.完成了一个色彩,大小,transform都带变换的有些3d效果的动画.做的还可以吧.对wpf的动画有了基本的了解,可以写xaml或c#实现些基本的动画了.下周就开始用Blend设计动画了,新的挑战来临了,努力.下面把今天的一点代码贴上,这是带颜色变化的动画大小改变的xaml程序.
运用了DoubleAnimation,PointAnimation,ColorAnimation。
<Canvas>
<Rectangle Name="rect" Canvas.Left="96" Canvas.Top="96" Width="192" Height="192" Stroke="Black">
<Rectangle.Fill>
<LinearGradientBrush x:Name="brush">
<GradientStop Offset="0" Color="Red"/>
<GradientStop Offset="1" Color="Blue"/>
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
<Canvas.Triggers>
<EventTrigger RoutedEvent="Canvas.Loaded">
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetName="rect" Storyboard.TargetProperty="Width"
From="192" To="204" Duration="0:0:1" AutoReverse="True" RepeatBehavior="Forever"/>
<DoubleAnimation Storyboard.TargetName="rect" Storyboard.TargetProperty="Height"
From="192" To="204" Duration="0:0:1" AutoReverse="True" RepeatBehavior="Forever"/>
<DoubleAnimation Storyboard.TargetName="rect" Storyboard.TargetProperty="(Canvas.Left)"
From="96" To="90" Duration="0:0:1" AutoReverse="True" RepeatBehavior="Forever"/>
<DoubleAnimation Storyboard.TargetName="rect" Storyboard.TargetProperty="(Canvas.Top)"
From="96" To="90" Duration="0:0:1" AutoReverse="True" RepeatBehavior="Forever"/>
<PointAnimation Storyboard.TargetName="brush" Storyboard.TargetProperty="StartPoint"
From="0 0" To="1 0" Duration="0:0:5" AutoReverse="True" RepeatBehavior="Forever"/>
<PointAnimation Storyboard.TargetName="brush" Storyboard.TargetProperty="EndPoint"
From="1 1" To="0 1" Duration="0:0:5" AutoReverse="True" RepeatBehavior="Forever"/>
<ColorAnimation Storyboard.TargetName="brush" Storyboard.TargetProperty="GradientStops[0].Color"
From="Red" To="Blue" Duration="0:0:1" AutoReverse="True" RepeatBehavior="Forever"/>
<ColorAnimation Storyboard.TargetName="brush" Storyboard.TargetProperty="GradientStops[1].Color"
From="Blue" To="Red" Duration="0:0:1" AutoReverse="True" RepeatBehavior="Forever"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Canvas.Triggers>
</Canvas>
posted on 2008-12-27 00:02 luckapple2 阅读(730) 评论(0) 编辑 收藏 举报