Polygon Tools - Winding Rules

http://www.glprogramming.com/red/chapter11.html

HTML

<script src="https://fpcdn.s3.amazonaws.com/apps/polygon-tools/0.4.0/polygon-tools.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pixi.js/4.5.1/pixi.min.js"></script>
<a href="#" onclick="set1(this)">POLYGON SET 1</a>
<a href="#" onclick="set2(this)">polygon set 2</a>
<a href="#" onclick="set3(this)">polygon set 3</a>
<pre>see http://www.glprogramming.com/red/chapter11.html</pre>
<img src="https://content.screencast.com/users/TimKnip/folders/Jing/media/dfad1aee-5b03-4cb2-bdce-9a4f4ef12234/2017-04-26_1920.png" />
<hr />
<a href="#" onclick="odd(this)">ODD</a>
<a href="#" onclick="nonzero(this)">nonzero</a>
<a href="#" onclick="positive(this)">positive</a>
<a href="#" onclick="negative(this)">negative</a>
<a href="#" onclick="abs_geq_two(this)">abs_geq_two</a>
<hr />

JavaScript

/**
 * The winding rule classifies a region as inside if its winding number 
 * belongs to the chosen category (odd, nonzero, positive, negative, 
 * or "absolute value of greater than or equal to two"). 
 * The odd and nonzero rules are common ways to define the interior. 
 * The positive, negative, and "absolute value>=2" winding rules have 
 * some limited use for polygon CSG (computational solid geometry) operations.
 */
var stage = new PIXI.Container();
var renderer = new PIXI.WebGLRenderer(500, 500);

document.body.appendChild(renderer.view);


const POLY_B = [
	[100, 100],
  [300, 100],
  [300, 300],
  [100, 300]
];

const POLY_B_REV = [
	[100, 300],
  [300, 300],
  [300, 100],
  [100, 100]
];

const POLY_C = [
	[[[0.75791, 0.42874], [0.74686, 0.44876], [0.73127, 0.46761], [0.72282, 0.48881], [0.71827, 0.50766], [0.71437, 0.53357], [0.71307, 0.56184], [0.71307, 0.59953], [0.71437, 0.61249], [0.72347, 0.64664], [0.73647, 0.70671], [0.73777, 0.71849], [0.73907, 0.72203], [0.74166, 0.7609], [0.74361, 0.77267], [0.74946, 0.78563], [0.75596, 0.79152], [0.76311, 0.79388], [0.76896, 0.7927], [0.77025, 0.79034], [0.7696, 0.77974], [0.76506, 0.76325], [0.76311, 0.73969], [0.75986, 0.72556], [0.75986, 0.71731], [0.76441, 0.702], [0.76766, 0.69611], [0.7813, 0.69729], [0.78585, 0.70789], [0.7852, 0.71378], [0.7891, 0.69611], [0.7943, 0.68433], [0.80014, 0.67845], [0.81054, 0.67609], [0.81704, 0.6808], [0.82419, 0.67609], [0.82678, 0.67609], [0.83198, 0.6808], [0.83848, 0.69258], [0.84238, 0.70671], [0.84498, 0.72909], [0.84498, 0.74794], [0.84628, 0.76561], [0.84433, 0.78563], [0.84498, 0.78799], [0.85018, 0.78916], [0.85537, 0.78799], [0.85667, 0.78563], [0.85667, 0.77503], [0.85797, 0.76796], [0.85732, 0.73734], [0.85992, 0.70436], [0.86447, 0.67845], [0.86707, 0.67491], [0.87032, 0.66313], [0.87032, 0.65489], [0.87487, 0.67256], [0.87552, 0.68316], [0.87942, 0.70318], [0.88007, 0.71378], [0.88526, 0.73734], [0.88721, 0.71614], [0.88721, 0.65018], [0.88202,...