~eda-qa/dhlib/main

« back to all changes in this revision

Viewing changes to lib/draw/fragments/Polygon.shx

  • Committer: edA-qa mort-ora-y
  • Date: 2010-02-16 05:36:32 UTC
  • Revision ID: eda-qa@disemia.com-20100216053632-60lt7fndfi3fgblw
first

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* <license>
 
2
 * This file is part of the dis-Emi-A HaXe Library. Copyright © edA-qa mort-ora-y
 
3
 * For full copyright and license information please refer to doc/license.txt.
 
4
 * </license> 
 
5
 */
 
6
package draw.fragments;
 
7
 
 
8
//TODO: Merge with Actor Polygon (with new Shape framework we can make the actor now use this Shape)
 
9
DEFSHAPE(Polygon)
 
10
 
 
11
        PARAM(sides,Int,5,`The number of sides for the polygon')
 
12
        PARAM(angleStart,Float,0,`Which orientation the polygon has, where the first vertex is drawn')
 
13
        
 
14
        ONDRAW()        
 
15
        {
 
16
                var angD = Math.PI*2 / sides;
 
17
                var pts = new Array<Point2>();
 
18
                for( i in 0...sides )
 
19
                        pts.push(
 
20
                                Point2.at( 
 
21
                                        Math.cos( angleStart + i * angD )/2.0,
 
22
                                        Math.sin( angleStart + i * angD )/2.0
 
23
                                        )
 
24
                                );
 
25
                gfx.polyLine( pts, true );              
 
26
        }
 
27
 
 
28
ENDSHAPE()