基于vs和C#的WPF应用之动画4---跳跳球

一、画布和图形

cs 复制代码
 <Canvas x:Name="canvas4" Grid.Row="1" Grid.Column="1"   Width="200" Height="200">
            <Canvas.Triggers>
                <EventTrigger RoutedEvent="Loaded">
                    <BeginStoryboard Storyboard="{StaticResource fourth_sb}"/>
                </EventTrigger>
            </Canvas.Triggers>
            
            <Label Content="Loading"
           FontSize="16"
           FontFamily="Times New Roman"
           Foreground="#ffb549"
           FontWeight="Bold"
           Width="200"
           HorizontalContentAlignment="Center"
           Canvas.Top="110"/>

            <Ellipse Name="fourth_e1" Canvas.Left="30" Canvas.Top="80" Style="{StaticResource fourthStyle_Ellipse}"/>
            <Ellipse Name="fourth_e2" Canvas.Left="60" Canvas.Top="80" Style="{StaticResource fourthStyle_Ellipse}"/>
            <Ellipse Name="fourth_e3" Canvas.Left="90" Canvas.Top="80" Style="{StaticResource fourthStyle_Ellipse}"/>
            <Ellipse Name="fourth_e4" Canvas.Left="120" Canvas.Top="80" Style="{StaticResource fourthStyle_Ellipse}"/>
            <Ellipse Name="fourth_e5" Canvas.Left="150" Canvas.Top="80" Style="{StaticResource fourthStyle_Ellipse}"/>
        </Canvas>

二、故事动画板

cs 复制代码
 <Storyboard x:Key="fourth_sb" Storyboard.TargetProperty="(UIElement.RenderTransform).(TranslateTransform.Y)" RepeatBehavior="Forever">
            <DoubleAnimation Storyboard.TargetName="fourth_e1" To="-50" BeginTime="0:0:0.0" Duration="0:0:0.2" AutoReverse="True" EasingFunction="{StaticResource fourth_PowerEase}"/>
            <DoubleAnimation Storyboard.TargetName="fourth_e2" To="-50" BeginTime="0:0:0.1" Duration="0:0:0.2" AutoReverse="True" EasingFunction="{StaticResource fourth_PowerEase}"/>
            <DoubleAnimation Storyboard.TargetName="fourth_e3" To="-50" BeginTime="0:0:0.2" Duration="0:0:0.2" AutoReverse="True" EasingFunction="{StaticResource fourth_PowerEase}"/>
            <DoubleAnimation Storyboard.TargetName="fourth_e4" To="-50" BeginTime="0:0:0.3" Duration="0:0:0.2" AutoReverse="True" EasingFunction="{StaticResource fourth_PowerEase}"/>
            <DoubleAnimation Storyboard.TargetName="fourth_e5" To="-50" BeginTime="0:0:0.4" Duration="0:0:0.2" AutoReverse="True" EasingFunction="{StaticResource fourth_PowerEase}"/>
        </Storyboard>

三、外部图形样式

cs 复制代码
<!--第四个动画圆的样式设计-->
<Style x:Key="fourthStyle_Ellipse" TargetType="Ellipse">
   <Setter Property="Width" Value="20"/>
   <Setter Property="Height" Value="20"/>
   <Setter Property="Fill" Value="Green"/>
   <Setter Property="RenderTransform">
       <Setter.Value>
       <!--平移变换-->
       <TranslateTransform X="0" Y="0"/>
       </Setter.Value>
   </Setter>
</Style>
<PowerEase x:Key="fourth_PowerEase" Power="2" EasingMode="EaseInOut"/>
相关推荐
Murphy20237 分钟前
.net4.0 调用API(form-data)上传文件及传参
开发语言·c#·api·httpwebrequest·form-data·uploadfile·multipart/form-
我曾经是个程序员17 分钟前
C#Directory类文件夹基本操作大全
服务器·开发语言·c#
白云~️19 分钟前
uniappX 移动端单行/多行文字隐藏显示省略号
开发语言·前端·javascript
编码浪子25 分钟前
构建一个rust生产应用读书笔记7-确认邮件2
开发语言·后端·rust
天之涯上上40 分钟前
JAVA开发 在 Spring Boot 中集成 Swagger
java·开发语言·spring boot
2402_8575834941 分钟前
“协同过滤技术实战”:网上书城系统的设计与实现
java·开发语言·vue.js·科技·mfc
爱学习的白杨树1 小时前
MyBatis的一级、二级缓存
java·开发语言·spring
OTWOL1 小时前
两道数组有关的OJ练习题
c语言·开发语言·数据结构·c++·算法
问道飞鱼1 小时前
【前端知识】强大的js动画组件anime.js
开发语言·前端·javascript·anime.js
拓端研究室1 小时前
R基于贝叶斯加法回归树BART、MCMC的DLNM分布滞后非线性模型分析母婴PM2.5暴露与出生体重数据及GAM模型对比、关键窗口识别
android·开发语言·kotlin