Created
January 27, 2017 16:57
-
-
Save nanjizal/4a63f926ec07e254420e563a0929ba8b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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