45 #ifndef __CU_PATH_NODE_H__
46 #define __CU_PATH_NODE_H__
49 #include "../math/CUPoly2.h"
50 #include "CUTexturedNode.h"
51 #include "../math/polygon/CUPathExtruder.h"
52 #include "../math/polygon/CUPathOutliner.h"
55 #define PATH_SEGMENTS 8
134 #pragma mark Constructors
203 #pragma mark Static Constructors
211 static std::shared_ptr<PathNode>
alloc() {
212 std::shared_ptr<PathNode> node = std::make_shared<PathNode>();
213 return (node->init() ? node :
nullptr);
233 static std::shared_ptr<PathNode>
allocWithVertices(
const std::vector<Vec2>& vertices,
float stroke,
236 std::shared_ptr<PathNode> node = std::make_shared<PathNode>();
237 return (node->initWithVertices(vertices,stroke,joint,cap,closed) ? node :
nullptr);
259 std::shared_ptr<PathNode> node = std::make_shared<PathNode>();
260 return (node->initWithPoly(poly,stroke,joint,cap) ? node :
nullptr);
281 std::shared_ptr<PathNode> node = std::make_shared<PathNode>();
282 return (node->initWithPoly(
Poly2(rect,
false),stroke,joint,cap) ? node :
nullptr);
302 std::shared_ptr<PathNode> node = std::make_shared<PathNode>();
303 return (node->initWithPoly(
Poly2::createLine(origin, dest),stroke,joint,cap) ? node :
nullptr);
323 unsigned int segments = PATH_SEGMENTS,
326 std::shared_ptr<PathNode> node = std::make_shared<PathNode>();
333 #pragma mark Attributes
403 #pragma mark Polygons
414 virtual void setPolygon(
const std::vector<Vec2>& vertices)
override;
492 #pragma mark Rendering
516 virtual void draw(
const std::shared_ptr<SpriteBatch>& batch,
const Mat4& transform,
Color4 tint)
override;
520 #pragma mark Internal Helpers
525 virtual void generateRenderData()
override;
530 void updateExtrusion();
533 CU_DISALLOW_COPY_AND_ASSIGN(
PathNode);
Definition: CUTexturedNode.h:83
PathJoint
Definition: CUPathExtruder.h:65
Definition: CUPoly2.h:115
static PathOutliner _outliner
Definition: CUPathNode.h:116
const Size & getExtrudedContentSize() const
Definition: CUPathNode.h:474
static std::shared_ptr< PathNode > allocWithPoly(const Poly2 &poly, float stroke, PathJoint joint=PathJoint::NONE, PathCap cap=PathCap::NONE)
Definition: CUPathNode.h:256
static std::shared_ptr< PathNode > alloc()
Definition: CUPathNode.h:211
const Rect & getExtrudedContentBounds() const
Definition: CUPathNode.h:489
void setStroke(float stroke)
bool initWithVertices(const std::vector< Vec2 > &vertices, float stroke, PathJoint joint=PathJoint::NONE, PathCap cap=PathCap::NONE, bool closed=true)
~PathNode()
Definition: CUPathNode.h:152
Poly2 _extrusion
Definition: CUPathNode.h:119
float _stroke
Definition: CUPathNode.h:126
float getExtrudedContentHeight() const
Definition: CUPathNode.h:462
Rect _extrbounds
Definition: CUPathNode.h:121
Definition: CUPathNode.h:110
PathCap
Definition: CUPathExtruder.h:85
float width
Definition: CUSize.h:61
static Poly2 createLine(const Vec2 &origin, const Vec2 &dest)
PathJoint getJoint() const
Definition: CUPathNode.h:383
PathCap _endcap
Definition: CUPathNode.h:130
Definition: CUPathExtruder.h:129
void setClosed(bool closed)
float height
Definition: CUSize.h:63
PathJoint _joint
Definition: CUPathNode.h:128
static PathExtruder _extruder
Definition: CUPathNode.h:114
static std::shared_ptr< PathNode > allocWithLine(const Vec2 &origin, const Vec2 &dest, float stroke, PathJoint joint=PathJoint::NONE, PathCap cap=PathCap::NONE)
Definition: CUPathNode.h:299
static std::shared_ptr< PathNode > allocWithEllipse(const Vec2 ¢er, const Size &size, float stroke, unsigned int segments=PATH_SEGMENTS, PathJoint joint=PathJoint::NONE, PathCap cap=PathCap::NONE)
Definition: CUPathNode.h:322
bool _closed
Definition: CUPathNode.h:124
bool initWithPoly(const Poly2 &poly, float stroke, PathJoint joint=PathJoint::NONE, PathCap cap=PathCap::NONE)
virtual void setPolygon(const std::vector< Vec2 > &vertices) override
Size size
Definition: CURect.h:51
void setJoint(PathJoint joint)
float getStroke() const
Definition: CUPathNode.h:349
Definition: CUColor4.h:1104
Definition: CUPathOutliner.h:78
static std::shared_ptr< PathNode > allocWithVertices(const std::vector< Vec2 > &vertices, float stroke, PathJoint joint=PathJoint::NONE, PathCap cap=PathCap::NONE, bool closed=true)
Definition: CUPathNode.h:233
Definition: CUAnimationNode.h:52
bool getClosed() const
Definition: CUPathNode.h:366
virtual void draw(const std::shared_ptr< SpriteBatch > &batch, const Mat4 &transform, Color4 tint) override
float getExtrudedContentWidth() const
Definition: CUPathNode.h:450
PathCap getCap() const
Definition: CUPathNode.h:400
static Poly2 createEllipse(const Vec2 ¢er, const Size &size, unsigned int segments, bool solid=true)
static std::shared_ptr< PathNode > allocWithRect(const Rect &rect, float stroke, PathJoint joint=PathJoint::NONE, PathCap cap=PathCap::NONE)
Definition: CUPathNode.h:278