45 #ifndef __CU_PATH_NODE_H__
46 #define __CU_PATH_NODE_H__
49 #include <cugl/2d/CUTexturedNode.h>
50 #include <cugl/math/CUPoly2.h>
51 #include <cugl/math/polygon/CUPathExtruder.h>
52 #include <cugl/math/polygon/CUPathOutliner.h>
55 #define PATH_SEGMENTS 8
134 #pragma mark Constructors
236 #pragma mark Static Constructors
244 static std::shared_ptr<PathNode>
alloc() {
245 std::shared_ptr<PathNode> node = std::make_shared<PathNode>();
246 return (node->init() ? node :
nullptr);
266 static std::shared_ptr<PathNode>
allocWithVertices(
const std::vector<Vec2>& vertices,
float stroke,
269 std::shared_ptr<PathNode> node = std::make_shared<PathNode>();
270 return (node->initWithVertices(vertices,stroke,joint,cap,closed) ? node :
nullptr);
292 std::shared_ptr<PathNode> node = std::make_shared<PathNode>();
293 return (node->initWithPoly(poly,stroke,joint,cap) ? node :
nullptr);
314 std::shared_ptr<PathNode> node = std::make_shared<PathNode>();
315 return (node->initWithPoly(
Poly2(rect,
false),stroke,joint,cap) ? node :
nullptr);
335 std::shared_ptr<PathNode> node = std::make_shared<PathNode>();
336 return (node->initWithPoly(
Poly2::createLine(origin, dest),stroke,joint,cap) ? node :
nullptr);
356 unsigned int segments = PATH_SEGMENTS,
359 std::shared_ptr<PathNode> node = std::make_shared<PathNode>();
395 const std::shared_ptr<JsonValue> data) {
396 std::shared_ptr<PathNode> result = std::make_shared<PathNode>();
397 if (!result->initWithData(loader,data)) { result =
nullptr; }
398 return std::dynamic_pointer_cast<
Node>(result);
403 #pragma mark Attributes
473 #pragma mark Polygons
484 virtual void setPolygon(
const std::vector<Vec2>& vertices)
override;
562 #pragma mark Rendering
586 virtual void draw(
const std::shared_ptr<SpriteBatch>& batch,
const Mat4& transform,
Color4 tint)
override;
590 #pragma mark Internal Helpers
595 virtual void generateRenderData()
override;
600 void updateExtrusion();
603 CU_DISALLOW_COPY_AND_ASSIGN(
PathNode);
Definition: CUTexturedNode.h:84
PathJoint
Definition: CUPathExtruder.h:65
Definition: CUPoly2.h:115
static PathOutliner _outliner
Definition: CUPathNode.h:116
const Size & getExtrudedContentSize() const
Definition: CUPathNode.h:544
static std::shared_ptr< PathNode > allocWithPoly(const Poly2 &poly, float stroke, PathJoint joint=PathJoint::NONE, PathCap cap=PathCap::NONE)
Definition: CUPathNode.h:289
static std::shared_ptr< PathNode > alloc()
Definition: CUPathNode.h:244
const Rect & getExtrudedContentBounds() const
Definition: CUPathNode.h:559
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:532
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:453
virtual void dispose() override
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 std::shared_ptr< Node > allocWithData(const SceneLoader *loader, const std::shared_ptr< JsonValue > data)
Definition: CUPathNode.h:394
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:332
Definition: CUSceneLoader.h:77
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:355
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
virtual bool initWithData(const SceneLoader *loader, const std::shared_ptr< JsonValue > data) override
void setJoint(PathJoint joint)
float getStroke() const
Definition: CUPathNode.h:419
Definition: CUColor4.h:1084
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:266
Definition: CUAction.h:51
bool getClosed() const
Definition: CUPathNode.h:436
virtual void draw(const std::shared_ptr< SpriteBatch > &batch, const Mat4 &transform, Color4 tint) override
float getExtrudedContentWidth() const
Definition: CUPathNode.h:520
PathCap getCap() const
Definition: CUPathNode.h:470
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:311