适用于C#的跨平台属性动画API

时间:2014-03-06 23:06:54

标签: c# api animation time properties

我正在寻找一种能够与android的Property Animation框架相同的API。我搜索但没有发现任何相关内容,我不想要像QT或WPF这样的大型库(反正不是跨平台),Windows动画管理器看起来有点复杂并且看起来不像它兼容单。

我发现了一些关于动画的主题,但答案指向了SDL链接或类似的东西。在我的情况下,我已经在做渲染部分,只需要一些简单快速的东西来随时间推移改变对象的属性,所以我不是在寻找图形动画API或类似的东西。

来自android的Property Animation框架是我想要的最好的例子(从我看到的)但是没有找到好的,简单的和小的东西。也许我正在搜索错误的术语,或者我可能从正确的角度看不到我想做的事情,或者说这可能很简单。

我可以写一个,但我想先看看它是否不存在。

一点澄清:跨平台我指的是Windows,Linux和Mac;这是一个桌面应用程序。

2 个答案:

答案 0 :(得分:1)

如果您想要定位WP8,Windows应用商店,WPF或Silverlight,我认为您正在寻找Storyboard课程。您可以在Visual Studio上手动编写它或使用Blend

来自msdnColorAnimation示例。

XAML

<StackPanel MouseLeftButtonUp="Rectangle_Tapped">
<StackPanel.Resources>
    <Storyboard x:Name="myStoryboard">
    <!-- Animate the background color of the canvas from red to green over 4 seconds. -->
        <ColorAnimation Storyboard.TargetName="mySolidColorBrush"
            Storyboard.TargetProperty="Color"
            From="Red" To="Green" Duration="0:0:4" />
    </Storyboard>
</StackPanel.Resources>
<StackPanel.Background>
    <SolidColorBrush x:Name="mySolidColorBrush" Color="Red" />
</StackPanel.Background>
</StackPanel>

C#

// When the user taps the rectangle, the animation begins.
private void Rectangle_Tapped(object sender, MouseEventArgs e)
{
    myStoryboard.Begin();
}

答案 1 :(得分:0)

由于我的问题在没有解释的情况下被否决,我真的不知道该做什么,所以我做了这样的小事:

// class TransitionValue inherit from Transition<T>
// Length is the length of the transition in seconds.
// Additional parameters : Restart, Rewind
// Events: OnFinish, OnRestart, Onrewind
TransitionValue value = new TransitionValue(startValue, endValue, length)

// Update with ElapsedTime
value.Update(stopWatch.Elapsed);

// Choose the function to use.
Console.WriteLine("F(x) = {0}", value.Linear());

我正在寻找一些简单易用的东西,并且确定它已经存在但是我找不到我想要的东西..无论如何。

相关问题