For a simple closed image (the path does not have an intersection), the exterior and interior of the image are easy to judge. However, if the path has an intersection, it corresponds to the overlapping part, different fill modes are used, and internal and external definitions are different. There are two filling modes:
EVEN_ODD means that when a straight line is used to traverse the image, the external and internal appear alternately.
WINDING corresponds to a curve C and a specified vertex P, and creates a straight line that is infinitely extending in any direction starting from P. Locate the intersection of curve C and this line. Calculates the number of intersections between the clockwise and the curve, and then calculates the number of intersections between the clockwise and the curve. If the two numbers are equal, the point is inside the curve, this point is outside the curve.
In addition to the above two modes, the Path. FillType of Android also supports the reverse modes of the above two modes. Four modes are defined: EVEN_ODD, INVERSE_EVEN_ODD, WINDING, and INVERSE_WINDING.
In this example, the basic graph is two intersecting circles, and the above four modes are used to fill the graph:
[Java] www.2cto.com
ShowPath (canvas, 0, 0,
Path. FillType. WINDING, paint );
ShowPath (canvas, 160, 0,
Path. FillType. EVEN_ODD, paint );
ShowPath (canvas, 0,160,
Path. FillType. INVERSE_WINDING, paint );
ShowPath (canvas, 160,160,
Path. FillType. INVERSE_EVEN_ODD, paint );
ShowPath (canvas, 0, 0,
Path. FillType. WINDING, paint );
ShowPath (canvas, 160, 0,
Path. FillType. EVEN_ODD, paint );
ShowPath (canvas, 0,160,
Path. FillType. INVERSE_WINDING, paint );
ShowPath (canvas, 160,160,
Path. FillType. INVERSE_EVEN_ODD, paint );
Author: mapdigit