Windows的API里有B样条曲线的函数吗?顺便谈谈WPF的动画技术
我希望有API,能直接根据X算出B样条曲线的Y值,不想要GDI+的,最好是API,或者开源的函数。
最近实现了WPF中的From/To/By动画技术、关键帧动画技术和属性动画技术,可以通过XML或者脚本直接创建2D/3D动画,在时间线的控制上还缺乏样条控制功能(意思是时间值不一定均匀分布,而是通过样条决定时间快慢),只是还未找到轻量级的样条曲线函数,有经验的朋友帮忙提供一点线索。
WPF中还有路径动画技术,这个比较简单,只是现在还没有实现,留待以后吧。WPF的动画依赖高效定时器,我也实现了一个多线程的高精度定时器,效率很高。
动画都是相通的。WPF的动画功能很全,据我观察,在3DSMAX中支持的动画技术都能在WPF中实现,所以对于我而言,WPF是一个非常好的参照平台,可以少走很多弯路,我会尽可能把WPF的特性都COPY过来,并非求全,但是精髓一定要有。同时,因为有专用设计工具,XAML文件看起来很庞大且过于复杂,不利于手写,但我没设计工具,只好在用XML描述时尽量减少大小。
描述一段动画的例子:
WPF用XAML描述:
我用XML描述:
最近实现了WPF中的From/To/By动画技术、关键帧动画技术和属性动画技术,可以通过XML或者脚本直接创建2D/3D动画,在时间线的控制上还缺乏样条控制功能(意思是时间值不一定均匀分布,而是通过样条决定时间快慢),只是还未找到轻量级的样条曲线函数,有经验的朋友帮忙提供一点线索。
WPF中还有路径动画技术,这个比较简单,只是现在还没有实现,留待以后吧。WPF的动画依赖高效定时器,我也实现了一个多线程的高精度定时器,效率很高。
动画都是相通的。WPF的动画功能很全,据我观察,在3DSMAX中支持的动画技术都能在WPF中实现,所以对于我而言,WPF是一个非常好的参照平台,可以少走很多弯路,我会尽可能把WPF的特性都COPY过来,并非求全,但是精髓一定要有。同时,因为有专用设计工具,XAML文件看起来很庞大且过于复杂,不利于手写,但我没设计工具,只好在用XML描述时尽量减少大小。
描述一段动画的例子:
WPF用XAML描述:
<!-- 这是From/To/By动画例子 -->
<Rectangle Name="fromToAnimatedRectangle"
Height="10" Width="100" HorizontalAlignment="Left"
Fill="Black">
<Rectangle.Triggers>
<EventTrigger RoutedEvent="Rectangle.MouseLeftButtonDown">
<BeginStoryboard>
<Storyboard>
<!-- Demonstrates the From and To properties used together.
Animates the rectangle's Width property from 50 to 300 over 10 seconds. -->
<DoubleAnimation
Storyboard.TargetName="fromToAnimatedRectangle"
Storyboard.TargetProperty="Width"
From="50" To="300" Duration="0:0:10" />
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Rectangle.Triggers>
</Rectangle>
<!-- 这是关键帧动画例子 -->
<Border Background="#99FFFFFF" BorderThickness="28"
Margin="0,60,0,20" Padding="20" >
<Border.BorderBrush>
<SolidColorBrush x:Name="MyAnimatedBrush" Color="Green" />
</Border.BorderBrush>
<Border.Triggers>
<EventTrigger RoutedEvent="Border.Loaded">
<BeginStoryboard>
<Storyboard>
<!-- Animate from green to red using a linear key frame, from red to
yellow using a discrete key frame, and from yellow back to green with
a spline key frame. This animation repeats forever. -->
<ColorAnimationUsingKeyFrames
Storyboard.TargetProperty="Color"
Storyboard.TargetName="MyAnimatedBrush"
Duration="0:0:6" FillBehavior="HoldEnd" RepeatBehavior="Forever">
<ColorAnimationUsingKeyFrames.KeyFrames>
<!-- Go from green to red in the first 2 seconds. LinearColorKeyFrame creates
a smooth, linear animation between values. -->
<LinearColorKeyFrame Value="Red" KeyTime="0:0:2" />
<!-- In the next half second, go to yellow. DiscreteColorKeyFrame creates a
sudden jump between values. -->
<DiscreteColorKeyFrame Value="Yellow" KeyTime="0:0:2.5" />
<!-- In the final 2 seconds of the animation, go from yellow back to green. SplineColorKeyFrame
creates a variable transition between values depending on the KeySpline property. In this example,
the animation starts off slow but toward the end of the time segment, it speeds up exponentially.-->
<SplineColorKeyFrame Value="Green" KeyTime="0:0:4.5" KeySpline="0.6,0.0 0.9,0.00" />
</ColorAnimationUsingKeyFrames.KeyFrames>
</ColorAnimationUsingKeyFrames>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Border.Triggers>
<TextBlock>
This example shows how to use the ColorAnimationUsingKeyFrames to create
an animation on the BorderBrush property of a Border.
</TextBlock>
</Border>
我用XML描述:
<!-- From/To/By 动画XML描述例子 -->
<StoryBoard>
<FrameSet TargetType="Int" Target="myimg" TargetAttribute="left" Reverse="true" Repeat="forever"
From="0" To="125" Duration="0:0:5" />
<FrameSet TargetType="Int" Target="myimg" TargetAttribute="top" Reverse="true" Repeat="forever"
From="20" To="120" Duration="0:0:8.2" />
</StoryBoard>
<!-- 关键帧动画XML描述例子 -->
<StoryBoard>
<KeyFrameSet TargetType="Int" Target="myimg2" TargetAttribute="left" Reverse="true" Repeat="forever">
<KeyFrame KeyTime="0" KeyValue="120" />
<KeyFrame KeyTime="2" KeyValue="160" />
<KeyFrame KeyTime="0:3" KeyValue="210" />
<KeyFrame KeyTime="0:0:5.0" KeyValue="250" />
</KeyFrameSet>
<KeyFrameSet TargetType="Int" Target="myimg2" TargetAttribute="top" Reverse="true" Repeat="forever">
<KeyFrame KeyTime="0" KeyValue="120" />
<KeyFrame KeyTime="3" KeyValue="170" />
<KeyFrame KeyTime="10.0" KeyValue="200" />
<KeyFrame KeyTime="0:0:13" KeyValue="250" />
</KeyFrameSet>
</StoryBoard>
...全文
相关推荐
windows8 WinRT PointAnimationUsingPath(WPF 路径动画 PathAnimation 的移植)
在Windows 8中,开发人员面临的一个挑战是将传统的Windows Presentation Foundation (WPF)功能迁移到新的Windows Runtime (WinRT)平台。
如何在WPF应用程序中通过HttpClient调用Web API
在WPF(Windows Presentation Foundation)应用程序中,与Web API进行交互是常见的需求,尤其是在需要从服务器获取数据或发送用户操作到后端时。
一个基于Windows Vista speech API5.3以及WPF技术的语音识别代码
在本文中,我们将深入探讨如何使用Windows Vista Speech API 5.3(也称为SAPI 5.3)和Windows Presentation Foundation (WPF) 技术实现语音识别功能
c#之利用API函数实现动画窗体的方法详解
Animate Window函数是Windows API中的一个函数,位于user32.dll库中,它可以用来为窗口添加平滑的动画效果。
一个基于Windows Vista speech API5.3以及WPF技术的语音朗读代码
在IT领域,Windows Vista Speech API 5.3(也称为SAPI 5.3)是一项重要的技术,用于实现语音合成和语音识别功能。


图形处理/算法
