public static Storyboard GetSpreadAnimaion(Point startPoint, Panel objectsCanvas)
{
var spreading = new Storyboard();
for (int i = 0; i < ObjectFactory.PyramidsCount; i++)
{
FrameworkElement randomObject = ObjectFactory.CreatePyramid();
CompositeTransform transform;
randomObject.EnsureTransform(out transform);
transform.TranslateX = startPoint.X;
transform.TranslateY = startPoint.Y;
transform.ScaleX = transform.ScaleY = .5;
objectsCanvas.Children.Add(randomObject);
var translateXAnimation = transform.CreateTranslateXAnimation(startPoint.X + RandomHelper.Next(-Radius, Radius),Seconds);
var translateYAnimation = transform.CreateTranslateYAnimation(startPoint.Y + RandomHelper.Next(-Radius, Radius), Seconds);
var scaleXAnimation = transform.CreateScaleXAnimation(3, Seconds);
var scaleYAnimation = transform.CreateScaleYAnimation(3, Seconds);
var opacityAnimation = randomObject.CreateOpacityAnimation(0, OpacityBeginTime, Seconds - OpacityBeginTime);
translateXAnimation.EasingFunction =
translateYAnimation.EasingFunction =
scaleXAnimation.EasingFunction = scaleYAnimation.EasingFunction = new CubicEase
{
EasingMode = EasingMode.EaseIn
};
spreading.Children.Add(translateXAnimation);
spreading.Children.Add(translateYAnimation);
spreading.Children.Add(scaleXAnimation);
spreading.Children.Add(scaleYAnimation);
spreading.Children.Add(opacityAnimation);
}
spreading.Completed += (s, e1) => objectsCanvas.Children.Clear();
return spreading;
}