1, using the path to draw graphics (PathGeometry)
Sometimes the graphics we need to draw can be complex and not quite so, and then we need to break the graph down into smaller pieces (break into segments, arcs, Bezier curves, and so on), and then combine these small parts with PathGeometry to achieve the final rendering.
A PathGeometry object consists of several Pathfingure objects and is saved in its Fingures property, and a Pathfingure object is composed of several pathsegment objects and stored in its segments property. PathSegment, however, represents some of the most basic curves and segments. The classes that inherit the PathSegment are: LineSegment straight segment, ArcSegment arc segment, BezierSegment Bezier curve segment, etc. Conversely, we are composed of a number of basic curves and segments connected to each other to form pathfingure (you can look at a separate child graph), and then we are composed of several pathfingure to form the final complex figure.
Refer to the following code:
<page xmlns= "http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x= http:// Schemas.microsoft.com/winfx/2006/xaml ""
<path stroke= "Black" strokethickness= "1"
<path.data& Gt
<pathgeometry>
<pathgeometry.figures>
<pathfigurecollection>
<pathfigure startpoint= "100,50"
<pathfigure.segments>
<pa Thsegmentcollection>
<linesegment point= "200,50"/>
<linesegment P Oint= "150,100"/>
</pathsegmentcollection>
</pathfigure.segments>
</pathfigure>
</pathfigurecollection>
</pathgeometry.figures>
</pathgeometry>
</path.data>
</path>
</page>
In the above code, we define a graph, which consists of a pathfingure, the starting point of the pathfingure is (100,50), and if we use a pen to draw the pathfingure, we now have to move the pen to the points (200,50). Draw a linesegment between the starting point and the point, and then move the pen to (150,100), drawing a linesegment between the end of the last drawing (200,50) and the A pity dorado, and you get the graphic in the following figure:
The reason for this result is to understand that the phrase "We are connected by some basic curves and segments to form pathfingure (you can look at a separate child graph)". We have the right to choose whether such a linked curve is closed (connecting the starting and ending points with a straight segment), we just need to set the Pahtfigure isclosed property to True or false. If we startpoint= the <pathfigure in the above code to the "100,50" >
Modified to <pathfigure startpoint= "100,50" isclosed= "True", you will get the following graphic:
In this way, we use a number of pathfigure separately responsible for the shape of the child graphics and choose the appropriate color and fill, you can draw the final complex graphics, you can believe that the following such a beautiful figure is so drawn out?