#ifndef GRAPHICS_FL_H #define GRAPHICS_FL_H #include #include #include #include #include USING_NS_CC; typedef unsigned int uint; static float random() { static const float maxRand = RAND_MAX; return (((float)rand()) / maxRand); } class GraphicsObj { // Triangulate a polygon, places results in STL vector static bool Process( const std::vector &polygon_verts, std::vector &triangle_verts ); static float Area( const std::vector &polygon_verts ); static bool InsideTriangle( float Ax, float Ay, float Bx, float By, float Cx, float Cy, float Px, float Py ); static bool Snip( const std::vector &contour, int u, int v, int w, int n, int *V ); std::vector m_fill_verts; // Process(...) Input: Polygon outline nodes std::vector m_triangulated_verts; // Process(...) Output: Triangulated nodes Vec2 m_pen_pos; int m_lineThickness; bool m_bFilling; Color4F m_fill_color; Color4F m_line_color; public: cocos2d::Sprite *m_cocosSprite; cocos2d::DrawNode *m_drawNode; void init( cocos2d::Scene *scene ); void lineStyle( int thickness, uint lineColour = 0xFFFFFFFF ); // Default: White line - RRGGBBAA void beginFill( uint fillColour = 0x000000FF ); // Default: Black fill - RRGGBBAA void endFill(); void moveTo( float x, float y ); void lineTo( float x, float y ); void clear(); }; #endif