wpf 응용 프로그램 및 이미지가 캔버스 안에 있습니다. 이미지는 0,0에 배치됩니다.애니메이션 번역 및 확대
나는 0,0에서 500,200으로 움직이는 이미지를 움직일 필요가 있고 동시에 성장하는 (나는 멀리에서 오는 것과 같은 효과를 내기를 좋아한다).
내가 이렇게 할 경우 :
TranslateTransform ttx = new TranslateTransform();
TranslateTransform tty = new TranslateTransform();
DoubleAnimationUsingKeyFrames dax = new DoubleAnimationUsingKeyFrames();
dax.KeyFrames.Add(new LinearDoubleKeyFrame(500, KeyTime.FromTimeSpan(TimeSpan.FromSeconds(1))));
DoubleAnimationUsingKeyFrames day = new DoubleAnimationUsingKeyFrames();
day.KeyFrames.Add(new LinearDoubleKeyFrame(200, KeyTime.FromTimeSpan(TimeSpan.FromSeconds(1))));
TransformGroup tg = new TransformGroup();
tg.Children.Add(ttx);
tg.Children.Add(tty);
krug.RenderTransform = tg;
ttx.BeginAnimation(TranslateTransform.XProperty, dax);
tty.BeginAnimation(TranslateTransform.YProperty, day);
그리고 이것은 잘 작동합니다. 이미지 "krug"의 번역을 0,0에서 500,200으로 애니메이션합니다.
그러나이 같은 번역하는 동안 이미지를 확대하기위한 로직을 추가 할 때 :
ScaleTransform zoom = new ScaleTransform();
DoubleAnimationUsingKeyFrames zoomTimeline = new DoubleAnimationUsingKeyFrames();
zoomTimeline.KeyFrames.Add(new LinearDoubleKeyFrame(2, KeyTime.FromTimeSpan(TimeSpan.FromSeconds(1))));
tg.Children.Add(zoom);
zoom.BeginAnimation(ScaleTransform.ScaleXProperty, zoomTimeline);
zoom.BeginAnimation(ScaleTransform.ScaleYProperty, zoomTimeline);
그런 다음 이미지가 500 멈추지 않는다 (200)를하지만, 더 멀리 간다. 확대/축소 비율이 더 크면 번역이 더 많이 진행됩니다. 애니메이션을 500,200에서 멈추도록 제어하려면 어떻게해야합니까?
거기에 같은 문제가 있습니다. ScaleTransform을 추가하면 번역 끝 점이 증가합니다. – darpet