/** * @author Adrien Brault */ /** * @class Polygon * @constructor * @param points* {Array|Array|Point...|Number...} This can be an array of Points that form the polygon, * a flat array of numbers that will be interpreted as [x,y, x,y, ...], or the arguments passed can be * all the points of the polygon e.g. `new PIXI.Polygon(new PIXI.Point(), new PIXI.Point(), ...)`, or the * arguments passed can be flat x,y values e.g. `new PIXI.Polygon(x,y, x,y, x,y, ...)` where `x` and `y` are * Numbers. */ PIXI.Polygon = function(points) { //if points isn't an array, use arguments as the array if(!(points instanceof Array)) points = Array.prototype.slice.call(arguments); //if this is a flat array of numbers, convert it to points if(typeof points[0] === 'number') { var p = []; for(var i = 0, il = points.length; i < il; i+=2) { p.push( new PIXI.Point(points[i], points[i + 1]) ); } points = p; } this.points = points; }; /** * Creates a clone of this polygon * * @method clone * @return {Polygon} a copy of the polygon */ PIXI.Polygon.prototype.clone = function() { var points = []; for (var i=0; i y) !== (yj > y)) && (x < (xj - xi) * (y - yi) / (yj - yi) + xi); if(intersect) inside = !inside; } return inside; }; // constructor PIXI.Polygon.prototype.constructor = PIXI.Polygon;