Android paint cap join
I checked a lot of information on the Internet, but it was not very thorough about the enumeration class cap join in the paint. Here I will do a more in-depth study.
First of all, Cap is used to control the last image left by the paint brush when it leaves the canvas, such as a rectangle or a circle. Don't you understand? Then let's look down.
First look at the source code:
/** * The Cap specifies the treatment for the beginning and ending of * stroked lines and paths. The default is BUTT. */ public enum Cap { /** * The stroke ends with the path, and does not project beyond it. */ BUTT (0), /** * The stroke projects out as a semicircle, with the center at the * end of the path. */ ROUND (1), /** * The stroke projects out as a square, with the center at the end * of the path. */ SQUARE (2); private Cap(int nativeInt) { this.nativeInt = nativeInt; } final int nativeInt; }
This is the cap source code. From the source code, we can see that BUTT is the default setting, but we cannot see the difference between BUTT, ROUND, and SQUARE.
I want to understand the use of Cap.
The above table shows the differences between the three styles. The vertical line is the paint brush end. The difference is obvious in the figure and will not be repeated here.
Then let's look at Join. Join is easy to understand. It is used to control the style of the drawing when it comes to contact.
View Source Code:
/** * The Join specifies the treatment where lines and curve segments * join on a stroked path. The default is MITER. */ public enum Join { /** * The outer edges of a join meet at a sharp angle */ MITER (0), /** * The outer edges of a join meet in a circular arc. */ ROUND (1), /** * The outer edges of a join meet with a straight line */ BEVEL (2); private Join(int nativeInt) { this.nativeInt = nativeInt; } final int nativeInt; }
Similar to Cap, the source code shows that the default is MITER, and other specific shapes are hard to understand. See the figure below:
The above table shows the differences among the three styles. The differences are obvious and we will not repeat them here.