Advertisement
Guest User

Untitled

a guest
Apr 6th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Haxe 0.86 KB | None | 0 0
  1.     private function drawPath()
  2.     {  
  3.         var coords : Array<Float> = [ 100.0, 100.0, 200, 100, 200, 200, 150, 200, 150, 150, 180, 150, 180,
  4.             120, 120, 120, 120, 150, 150, 150, 150, 200, 100, 200, 100, 100 ];
  5.         var holeIn : Int = 4;
  6.         var holeOut : Int = 10;
  7.        
  8.         var s = new Shape();
  9.         var g = s.graphics;
  10.        
  11.         var data = new Vector<Float>();
  12.         var cmds = new Vector<Int>();
  13.        
  14.         var i :Int = 0;
  15.         while ( i < coords.length ) {
  16.             data.push(coords[i]);
  17.             data.push(coords[i + 1]);
  18.            
  19.             if ((i == 0) ||(i == holeIn * 2) || (i == holeOut * 2)) {
  20.                 cmds.push(1); //moveto
  21.             } else {
  22.                 cmds.push(2); //lineto
  23.             }
  24.             i += 2;
  25.         }
  26.        
  27.         g.lineStyle(1, 0x0, 1, true, LineScaleMode.NORMAL, CapsStyle.SQUARE, JointStyle.MITER);
  28.         g.beginFill( 0x00ccbb, 1.0 );
  29.         g.drawPath(cmds, data,GraphicsPathWinding.NON_ZERO);
  30.         g.endFill();
  31.        
  32.         addChild(s);
  33.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement