2024年3月13日发(作者:)

private void btnAnimo_Click(object sender, RoutedEventArgs e)

{

AnimationByPath(cvsMain, path1,Thickness);

}

///

///

路径动画

///

///

画板

///

路径

///

动画对象

///

时间

private void AnimationByPath(Canvas cvs, Path path,double targetWidth, int duration = 5)

{

#region 创建动画对象

Rectangle target = new Rectangle();

= targetWidth;

= targetWidth;

= new SolidColorBrush();

(target);

t(target, -targetWidth / 2);

(target, -targetWidth / 2);

TransformOrigin = new Point(0.5, 0.5);

#endregion

MatrixTransform matrix = new MatrixTransform();

TransformGroup groups = new TransformGroup();

(matrix);

Transform = groups;

string registname = "matrix" + d().ToString().Replace("-", "");

erName(registname, matrix);

MatrixAnimationUsingPath matrixAnimation = new MatrixAnimationUsingPath();

ometry = FromGeometry((ng()));

on = new Duration(conds(duration));

tateWithTangent = true;//

跟随路径旋转

Behavior = r;//

循环

Storyboard story = new Storyboard();

(matrixAnimation);

getName(matrixAnimation, registname);

getProperty(matrixAnimation, new PropertyPath(Property));

havior = ;

(target, true);

}