Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>To understand polygon filling in general you have to understand <strong>edge direction</strong>, <strong>winding order</strong> and the selected <strong>polygon fill rule</strong>.</p> <p>Edge direction is determined by the order that vertices have been declared. For example ...</p> <pre><code>Polygon poly= new Polygon(); poly.addPoint(10, 10); poly.addPoint(100, 10); poly.addPoint(100, 100); poly.addPoint(10, 100); </code></pre> <p>Polygons are drawn by joining adjacent vertices (from an ordered list of vertices) to form edges. The last vertex in the list is also joining the first (as if the list were circular). The first edge in the polygon above is constructed from the first two vertices - Point(10,10) and Point(100,10).</p> <p>Whenever polygons self-intersect or overlap, to understand how the polygons will be drawn, you need a knowledge of both <strong>winding order</strong> and the applied <strong>polygon filling rule</strong>. When polygons overlap, polygon sub-regions are created - discrete regions that are enclosed by edges. The winding order of these sub-regions and the applied polygon filling rule determine whether these sub-regions are filled or not.</p> <p><a href="http://www.angusj.com/delphi/clipper/documentation/Images/winding_number.png" rel="nofollow noreferrer">http://www.angusj.com/delphi/clipper/documentation/Images/winding_number.png</a></p> <p>The winding number for any given polygon sub-region can be derived by:</p> <ul> <li>set the winding count to zero</li> <li>from a point (P1) that's within the sub-region, draw an imaginary line to another point that's outside the polygon or polygons (P2) </li> <li>while traversing the line from P1 to P2, for each polygon edge that crosses the line from right to left increment the winding count, and for each polygon edge that crosses the line from left to right decrement the winding count.</li> </ul> <p>According to the Java Graphics2D <a href="http://docs.oracle.com/javase/1.4.2/docs/api/java/awt/Graphics.html#fillPolygon%28java.awt.Polygon%29" rel="nofollow noreferrer">documentation</a>, <strong>fillPolygon</strong> only uses the <strong>even-odd fill rule</strong> where only odd numbered sub-regions are filled.</p> <p><a href="http://www.angusj.com/delphi/clipper/documentation/Images/evenodd.png" rel="nofollow noreferrer">http://www.angusj.com/delphi/clipper/documentation/Images/evenodd.png</a></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload