Skip to content

Instantly share code, notes, and snippets.

@nanjizal
Created January 27, 2017 16:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nanjizal/4a63f926ec07e254420e563a0929ba8b to your computer and use it in GitHub Desktop.
Save nanjizal/4a63f926ec07e254420e563a0929ba8b to your computer and use it in GitHub Desktop.
#if poly2trihx
import org.poly2tri.SweepContext;
import org.poly2tri.Sweep;
//import org.poly2tri.Point;
#end
#if poly2trihx
var sweepContext = new SweepContext();
var sweep = new Sweep( sweepContext );
var p: Point;
var arr = new Array<org.poly2tri.Point>();
var count = 0;
for( pp0 in ppp_ ){
for( i in 0...pp0.length ){
p = pp0[ i ];
arr.push( new org.poly2tri.Point( p.x, p.y ) );
}
}
sweepContext.addPolyline( arr );
sweep.triangulate();
var p3: Array<org.poly2tri.Point>;
var a: org.poly2tri.Point;
var b: org.poly2tri.Point;
var c: org.poly2tri.Point;
for( tri in sweepContext.triangles ){
p3 = tri.points;
a = p3[ 0 ];
b = p3[ 1 ];
c = p3[ 2 ];
Draw.drawTri( id, false , { x: a.x, y: a.y }
, { x: b.x, y: b.y }
, { x: c.x, y: c.y }
, Draw.colorFill_id );
}
#else
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment