2
C#으로 애니메이션을 만드는 방법을 배우고 있습니다. 나는 쉽게 기능을 만들 수 있어요프로그래밍 가능한 이징 함수 만들기 C#
test(someObject, FrameworkElement.MarginProperty);
/// <summary>
/// animate margin of an object
/// </summary>
/// <param name="target">what object do you whant to animate?</param>
/// <param name="property">what property do you want to animate</param>
public void test(DependencyObject target, DependencyProperty property)
{
ThicknessAnimation animation = new ThicknessAnimation();
animation.To = new Thickness(0,0,0,0); // final value
//animation.From = new Thickness(50,50,50,50);
//make animation last 5 seconds
animation.BeginTime = TimeSpan.FromSeconds(0);
animation.Duration = TimeSpan.FromSeconds(5);
// set the ease function
BounceEase b = new BounceEase();
animation.EasingFunction = b;
//note that I would like to add an easeIn function
//start animating
Storyboard.SetTarget(animation, target); // what object will be animated?
Storyboard.SetTargetProperty(animation, new PropertyPath(property)); // what property will be animated
Storyboard sb = new Storyboard();
sb.Children.Add(animation);
sb.Begin();
}
참고 : 나는 예를 들어 물체의 여백 애니메이션을하고 있다면 그럼 나는 여백의 애니메이션을 다음과 같은 방법을 사용합니다. 하지만 EaseInOut easing 함수를 만들고 싶다면 어떻게해야할까요? EaseInOut 접근법을 사용하여 객체에 애니메이션을 적용하려면 내 테스트 메소드에 무엇을 추가해야합니까?