If you think that the method for drawing various geometric figures discussed above is too complicated, let's take a look at it now. Of course, we are very easy. This tutorial does not require exams or class rankings. It only provides readers with a new idea.
In this section, we will talk about the path marking method. With this stuff, you will feel that it will be much easier to draw the path, and it is not too late. How convenient is the path marking method? Let's look at an instance first.
[HTML]View plaincopyprint?
- <Path verticalalignment = "stretch" horizontalalignment = "stretch"
- Stroke = "lightgreen" strokethickness = "6"
- Data = "M12, 2 L35, 28 175, 69 h80 v260 m185, 400 60, 40 135,100 300,250"/>
Look.
How is it? Is it much more concise?
I. Mobile commands
This is easy to understand, that is, moving to a certain point, the next series of graphics are drawn with the point as the starting point, the syntax is as follows:
[HTML]View plaincopyprint?
- M <coordinate point> or M <coordinate point>
M indicates absolute positioning, and M indicates the offset relative to the previous vertex. If the instruction is moved and then multiple vertices are followed, a straight line connecting these points is created. See the following example.
[HTML]View plaincopyprint?
- <Path horizontalalignment = "stretch"
- Verticalalignment = "stretch"
- Stroke = "yellow" strokethickness = "6"
- Data = "M50, 26 145 95,335, 97 m200,"/>
Check the running effect first.
Note the difference between M and M above. It is an offset between the X axis + 200 and the Y axis + 145 at the last ending point.
Ii. Drawing commands
Here I will only list a few examples. For details, refer to msdn.
1. draw a straight line.
Syntax:
[HTML]View plaincopyprint?
- L <End Point> or L <End Point>
Example:
[HTML]View plaincopyprint?
- <Path horizontalalignment = "stretch"
- Verticalalignment = "stretch"
- Stroke = "yellow"
- Strokethickness = "6"
- Data = "m21, 15 L30, 17 150,300, 79 160,410"/>
Running effect.
2. besell Curve
(1) cubic besell Curve
Syntax: C Control Point 1 Control Point 2 end point, or C Control Point 1 Control Point 2 end point.
Example:
[HTML]View plaincopyprint?
- <Path horizontalalignment = "stretch"
- Verticalalignment = "stretch"
- Stroke = "yellow"
- Strokethickness = "6"
- Data = "M10, 5 60, 75 150,160 30,200"/>
(2) Secondary besell Curve
Syntax: Q Control Point End Point or Q Control Point End Point
Example:
[HTML]View plaincopyprint?
- <Path horizontalalignment = "stretch"
- Verticalalignment = "stretch"
- Stroke = "yellow"
- Strokethickness = "6"
- Data = "M10, 5 q200, 55 200,385"/>
3. Draw an arc
Syntax:
A size rotationangle islargearcflag sweepdireflaflag endpoint
-Or-
A size rotationangle islargearcflag sweepdireflaflag endpoint
Size: the arc size. X indicates the radius length on the X axis, and y indicates the radius degree on the Y axis.
Rotationangle: the arc angle.
Islargearcflag: If the arc angle is greater than or equal to 180 degrees, set it to 1; otherwise, set it to 0.
Sweepdireflag: If the arc is drawn in the positive direction, it is set to 1; otherwise, it is set to 0.
Endpoint: end point.
Example:
[HTML]View plaincopyprint?
- <Path horizontalalignment = "stretch"
- Verticalalignment = "stretch"
- Stroke = "yellow"
- Strokethickness = "6"
- Data = "M10, 30 a185, 230 90 0 1 200,435"/>
You may find that although this method is used, it is not convenient to draw a picture. Now, I understand why I do not focus on the reasons for this content. For a manual diagram of XAML, I just introduced it in a simple way. In actual development, it is not efficient and difficult.
In the next section, I will introduce you to a simpler plotting scheme.