Android ApiDemos example resolution (70): Graphics-& gt; PathFillTypes

Source: Internet
Author: User

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

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.