Animation path-Path
The path has a date attribute, which is used to obtain or set the geometry of the specified shape.
So we draw a circle and an elliptical path. The circle moves on the elliptical path. First we draw a circle.
<Ellipse X: Name ="E1"Stroke ="Black"Width ="50"Height ="50"Fill ="Red"Margin ="0, 0, 228,211"> </Ellipse>
Draw a path
<Path X: Name ="P1"Stroke ="Blue"> <Path. Data> <ellipsegeometry X: Name ="Eg1"Center ="120,100"Radiusx ="100"Radiusy ="50"> </Ellipsegeometry> </path. Data> </path>
Here, the ellipsegeometry in this path is named eg1, which will be used later. Now we can perform rendertransform On This ellipse, as shown below: Code .
<Ellipse X: Name ="E1"Stroke ="Black"Width ="50"Height ="50"Fill ="Red"Margin ="0, 0, 228,211">
<Ellipse. rendertransform>
<Transformgroup>
<Translatetransform x ="-25"Y ="-15"/>
<Matrixtransform X: Name ="M1"/>
</Transformgroup>
</Ellipse. rendertransform>
<Ellipse. triggers>
<Eventtrigger routedevent ="Page. Loaded">
<Beginstoryboard>
<Storyboard X: Name ="S1"Repeatbehavior ="Forever">
<Matrixanimationusingpath X: Name ="Ma1"
Storyboard. targetname ="M1"
Storyboard. targetproperty ="Matrix"
Duration ="0: 0: 5"/>
</Storyboard>
</Beginstoryboard>
</Eventtrigger>
</Ellipse. triggers>
</Ellipse>
Here we use matrixanimationusingpath in storyboard,
You can use pathgeometry to generate an animation value to animation the value of the matrix attribute. This animation can be used to move a visual object along a path.
Matrixanimationusingpath is bound to M1 and its attribute is matrix. M1 is matrixtransform, which is
Creates an arbitrary ry matrix transformation to operate objects or coordinate systems in a two-dimensional plane.
<Translatetransform x ="-25"Y ="-15"/> Is to adjust the degree of translation for the circle to rotate along the elliptical path.
Translatetransform: You can change the origin of the coordinate system by making the translation of the transformation matrix of graphics left by the specified translation.
We also need to use a button to load and start this path.
Private VoidButton#click (ObjectSender, routedeventargs e) {pathgeometry =NewPathgeometry (); pathgeometry. addgeometry (eg1); ma1.pathgeometry = pathgeometry; s1.begin (E1 );}
Press F5 for debugging.