common: redesigned interfaces

PaintNode -> Paint
ShapeNode -> Shape
SceneNode -> Scene

We can keep clean and neat shorter names.

Change-Id: Ic8521d456d947985e5fbe1ba2bde06faa1f52469
This commit is contained in:
Hermet Park 2020-05-02 18:16:45 +09:00
parent 1b3661a0b0
commit 42c56757df
25 changed files with 112 additions and 112 deletions

View file

@ -61,17 +61,17 @@ struct Point
/**
* @class PaintNode
* @class Paint
*
* @ingroup TizenVG
*
* @brief description...
*
*/
class TIZENVG_EXPORT PaintNode
class TIZENVG_EXPORT Paint
{
public:
virtual ~PaintNode() {}
virtual ~Paint() {}
virtual int update(RenderMethod*) = 0;
};
@ -91,7 +91,7 @@ public:
virtual ~Canvas();
int reserve(size_t n) noexcept;
virtual int push(std::unique_ptr<PaintNode> paint) noexcept;
virtual int push(std::unique_ptr<Paint> paint) noexcept;
virtual int clear() noexcept;
virtual int update() noexcept;
virtual int draw(bool async = true) noexcept;
@ -104,17 +104,17 @@ public:
/**
* @class ShapeNode
* @class Shape
*
* @ingroup TizenVG
*
* @brief description...
*
*/
class TIZENVG_EXPORT ShapeNode final : public PaintNode
class TIZENVG_EXPORT Shape final : public Paint
{
public:
~ShapeNode();
~Shape();
int update(RenderMethod* engine) noexcept override;
int reset() noexcept;
@ -134,35 +134,35 @@ public:
int pathCoords(const Point** pts) const noexcept;
int fill(size_t* r, size_t* g, size_t* b, size_t* a) const noexcept;
static std::unique_ptr<ShapeNode> gen() noexcept;
static std::unique_ptr<Shape> gen() noexcept;
//FIXME: Ugly... Better design?
void *engine() noexcept;
_TIZENVG_DECLARE_PRIVATE(ShapeNode);
_TIZENVG_DECLARE_PRIVATE(Shape);
};
/**
* @class SceneNode
* @class Scene
*
* @ingroup TizenVG
*
* @brief description...
*
*/
class TIZENVG_EXPORT SceneNode final : public PaintNode
class TIZENVG_EXPORT Scene final : public Paint
{
public:
~SceneNode();
~Scene();
int update(RenderMethod* engine) noexcept override;
int push(std::unique_ptr<ShapeNode> shape) noexcept;
int push(std::unique_ptr<Shape> shape) noexcept;
static std::unique_ptr<SceneNode> gen() noexcept;
static std::unique_ptr<Scene> gen() noexcept;
_TIZENVG_DECLARE_PRIVATE(SceneNode);
_TIZENVG_DECLARE_PRIVATE(Scene);
};

View file

@ -42,7 +42,7 @@ bool GlRenderer::clear()
return true;
}
bool GlRenderer::render(const ShapeNode& shape, void *data)
bool GlRenderer::render(const Shape& shape, void *data)
{
GlShape* sdata = static_cast<GlShape*>(data);
if (!sdata) return false;
@ -53,7 +53,7 @@ bool GlRenderer::render(const ShapeNode& shape, void *data)
}
bool GlRenderer::dispose(const ShapeNode& shape, void *data)
bool GlRenderer::dispose(const Shape& shape, void *data)
{
GlShape* sdata = static_cast<GlShape*>(data);
if (!sdata) return false;
@ -65,7 +65,7 @@ bool GlRenderer::dispose(const ShapeNode& shape, void *data)
}
void* GlRenderer::prepare(const ShapeNode& shape, void* data, UpdateFlag flags)
void* GlRenderer::prepare(const Shape& shape, void* data, UpdateFlag flags)
{
//prepare shape data
GlShape* sdata = static_cast<GlShape*>(data);

View file

@ -23,9 +23,9 @@ namespace tvg
class GlRenderer : public RenderMethod
{
public:
void* prepare(const ShapeNode& shape, void* data, UpdateFlag flags) override;
bool dispose(const ShapeNode& shape, void *data) override;
bool render(const ShapeNode& shape, void *data) override;
void* prepare(const Shape& shape, void* data, UpdateFlag flags) override;
bool dispose(const Shape& shape, void *data) override;
bool render(const Shape& shape, void *data) override;
bool clear() override;
size_t ref() override;
size_t unref() override;

View file

@ -9,8 +9,8 @@ source_file = [
'tvgCanvas.cpp',
'tvgSwCanvas.cpp',
'tvgGlCanvas.cpp',
'tvgSceneNode.cpp',
'tvgShapeNode.cpp'
'tvgScene.cpp',
'tvgShape.cpp'
]
src_dep = declare_dependency(

View file

@ -93,10 +93,10 @@ struct SwShape
};
void shapeReset(SwShape& sdata);
bool shapeGenOutline(const ShapeNode& shape, SwShape& sdata);
void shapeDelOutline(const ShapeNode& shape, SwShape& sdata);
bool shapeGenRle(const ShapeNode& shape, SwShape& sdata, const SwSize& clip);
bool shapeTransformOutline(const ShapeNode& shape, SwShape& sdata);
bool shapeGenOutline(const Shape& shape, SwShape& sdata);
void shapeDelOutline(const Shape& shape, SwShape& sdata);
bool shapeGenRle(const Shape& shape, SwShape& sdata, const SwSize& clip);
bool shapeTransformOutline(const Shape& shape, SwShape& sdata);
SwRleData* rleRender(const SwShape& sdata, const SwSize& clip);
bool rasterShape(Surface& surface, SwShape& sdata, uint8_t r, uint8_t g, uint8_t b, uint8_t a);

View file

@ -58,7 +58,7 @@ bool SwRenderer::target(uint32_t* buffer, size_t stride, size_t w, size_t h)
}
bool SwRenderer::render(const ShapeNode& shape, void *data)
bool SwRenderer::render(const Shape& shape, void *data)
{
SwShape* sdata = static_cast<SwShape*>(data);
if (!sdata) return false;
@ -72,7 +72,7 @@ bool SwRenderer::render(const ShapeNode& shape, void *data)
}
bool SwRenderer::dispose(const ShapeNode& shape, void *data)
bool SwRenderer::dispose(const Shape& shape, void *data)
{
SwShape* sdata = static_cast<SwShape*>(data);
if (!sdata) return false;
@ -81,7 +81,7 @@ bool SwRenderer::dispose(const ShapeNode& shape, void *data)
return true;
}
void* SwRenderer::prepare(const ShapeNode& shape, void* data, UpdateFlag flags)
void* SwRenderer::prepare(const Shape& shape, void* data, UpdateFlag flags)
{
//prepare shape data
SwShape* sdata = static_cast<SwShape*>(data);

View file

@ -22,9 +22,9 @@ class SwRenderer : public RenderMethod
public:
Surface surface;
void* prepare(const ShapeNode& shape, void* data, UpdateFlag flags) override;
bool dispose(const ShapeNode& shape, void *data) override;
bool render(const ShapeNode& shape, void *data) override;
void* prepare(const Shape& shape, void* data, UpdateFlag flags) override;
bool dispose(const Shape& shape, void *data) override;
bool render(const Shape& shape, void *data) override;
bool target(uint32_t* buffer, size_t stride, size_t w, size_t h);
bool clear() override;
size_t ref() override;

View file

@ -228,14 +228,14 @@ void _deleteOutline(SwShape& sdata)
/* External Class Implementation */
/************************************************************************/
bool shapeTransformOutline(const ShapeNode& shape, SwShape& sdata)
bool shapeTransformOutline(const Shape& shape, SwShape& sdata)
{
//TODO:
return true;
}
bool shapeGenRle(const ShapeNode& shape, SwShape& sdata, const SwSize& clip)
bool shapeGenRle(const Shape& shape, SwShape& sdata, const SwSize& clip)
{
if (sdata.outline->ptsCnt == 0 || sdata.outline->cntrsCnt <= 0) goto end;
if (!_updateBBox(sdata)) goto end;
@ -262,7 +262,7 @@ void shapeReset(SwShape& sdata)
}
bool shapeGenOutline(const ShapeNode& shape, SwShape& sdata)
bool shapeGenOutline(const Shape& shape, SwShape& sdata)
{
const PathCommand* cmds = nullptr;
auto cmdCnt = shape.pathCommands(&cmds);

View file

@ -26,10 +26,10 @@
struct Canvas::Impl
{
vector<PaintNode*> nodes;
vector<Paint*> nodes;
RenderMethod* renderer;
Impl(RenderMethod *pRenderer):renderer(pRenderer)
Impl(RenderMethod* pRenderer):renderer(pRenderer)
{
renderer->ref();
}
@ -47,9 +47,9 @@ struct Canvas::Impl
return 0;
}
int push(unique_ptr<PaintNode> paint)
int push(unique_ptr<Paint> paint)
{
PaintNode *node = paint.release();
Paint* node = paint.release();
assert(node);
nodes.push_back(node);
return node->update(renderer);
@ -60,9 +60,9 @@ struct Canvas::Impl
assert(renderer);
for (auto node : nodes) {
if (SceneNode *scene = dynamic_cast<SceneNode *>(node)) {
if (Scene* scene = dynamic_cast<Scene*>(node)) {
cout << "TODO: " << scene << endl;
} else if (ShapeNode *shape = dynamic_cast<ShapeNode *>(node)) {
} else if (Shape *shape = dynamic_cast<Shape*>(node)) {
if (!renderer->dispose(*shape, shape->engine())) return -1;
}
delete(node);
@ -91,9 +91,9 @@ struct Canvas::Impl
if (!renderer->clear()) return -1;
for(auto node: nodes) {
if (SceneNode *scene = dynamic_cast<SceneNode *>(node)) {
if (Scene* scene = dynamic_cast<Scene*>(node)) {
cout << "TODO: " << scene << endl;
} else if (ShapeNode *shape = dynamic_cast<ShapeNode *>(node)) {
} else if (Shape *shape = dynamic_cast<Shape*>(node)) {
if (!renderer->render(*shape, shape->engine())) return -1;
}
}
@ -125,7 +125,7 @@ int Canvas::reserve(size_t n) noexcept
}
int Canvas::push(unique_ptr<PaintNode> paint) noexcept
int Canvas::push(unique_ptr<Paint> paint) noexcept
{
auto impl = pImpl.get();
assert(impl);

View file

@ -33,9 +33,9 @@ class RenderMethod
public:
enum UpdateFlag { None = 0, Path = 1, Fill = 2, All = 3 };
virtual ~RenderMethod() {}
virtual void* prepare(const ShapeNode& shape, void* data, UpdateFlag flags) = 0;
virtual bool dispose(const ShapeNode& shape, void *data) = 0;
virtual bool render(const ShapeNode& shape, void *data) = 0;
virtual void* prepare(const Shape& shape, void* data, UpdateFlag flags) = 0;
virtual bool dispose(const Shape& shape, void *data) = 0;
virtual bool render(const Shape& shape, void *data) = 0;
virtual bool clear() = 0;
virtual size_t ref() = 0;
virtual size_t unref() = 0;

View file

@ -14,8 +14,8 @@
* limitations under the License.
*
*/
#ifndef _TVG_SCENE_NODE_CPP_
#define _TVG_SCENE_NODE_CPP_
#ifndef _TVG_SCENE_CPP_
#define _TVG_SCENE_CPP_
#include "tvgCommon.h"
@ -23,7 +23,7 @@
/* Internal Class Implementation */
/************************************************************************/
struct SceneNode::Impl
struct Scene::Impl
{
};
@ -34,34 +34,34 @@ struct SceneNode::Impl
/* External Class Implementation */
/************************************************************************/
SceneNode::SceneNode() : pImpl(make_unique<Impl>())
Scene::Scene() : pImpl(make_unique<Impl>())
{
}
SceneNode::~SceneNode()
Scene::~Scene()
{
cout << "SceneNode(" << this << ") destroyed!" << endl;
cout << "Scene(" << this << ") destroyed!" << endl;
}
unique_ptr<SceneNode> SceneNode::gen() noexcept
unique_ptr<Scene> Scene::gen() noexcept
{
return unique_ptr<SceneNode>(new SceneNode);
return unique_ptr<Scene>(new Scene);
}
int SceneNode::push(unique_ptr<ShapeNode> shape) noexcept
int Scene::push(unique_ptr<Shape> shape) noexcept
{
return 0;
}
int SceneNode::update(RenderMethod* engine) noexcept
int Scene::update(RenderMethod* engine) noexcept
{
return 0;
}
#endif /* _TVG_SCENE_NODE_CPP_ */
#endif /* _TVG_SCENE_CPP_ */

View file

@ -14,8 +14,8 @@
* limitations under the License.
*
*/
#ifndef _TVG_SHAPE_NODE_CPP_
#define _TVG_SHAPE_NODE_CPP_
#ifndef _TVG_SHAPE_CPP_
#define _TVG_SHAPE_CPP_
#include "tvgCommon.h"
#include "tvgShapePath.h"
@ -41,7 +41,7 @@ struct ShapeTransform
};
struct ShapeNode::Impl
struct Shape::Impl
{
ShapeTransform *transform = nullptr;
ShapeFill *fill = nullptr;
@ -68,23 +68,23 @@ struct ShapeNode::Impl
/* External Class Implementation */
/************************************************************************/
ShapeNode :: ShapeNode() : pImpl(make_unique<Impl>())
Shape :: Shape() : pImpl(make_unique<Impl>())
{
}
ShapeNode :: ~ShapeNode()
Shape :: ~Shape()
{
}
unique_ptr<ShapeNode> ShapeNode::gen() noexcept
unique_ptr<Shape> Shape::gen() noexcept
{
return unique_ptr<ShapeNode>(new ShapeNode);
return unique_ptr<Shape>(new Shape);
}
void* ShapeNode::engine() noexcept
void* Shape::engine() noexcept
{
auto impl = pImpl.get();
assert(impl);
@ -92,7 +92,7 @@ void* ShapeNode::engine() noexcept
}
int ShapeNode::update(RenderMethod* engine) noexcept
int Shape::update(RenderMethod* engine) noexcept
{
auto impl = pImpl.get();
assert(impl);
@ -103,7 +103,7 @@ int ShapeNode::update(RenderMethod* engine) noexcept
}
int ShapeNode::reset() noexcept
int Shape::reset() noexcept
{
auto impl = pImpl.get();
assert(impl);
@ -114,7 +114,7 @@ int ShapeNode::reset() noexcept
}
int ShapeNode::pathCommands(const PathCommand** cmds) const noexcept
int Shape::pathCommands(const PathCommand** cmds) const noexcept
{
auto impl = pImpl.get();
assert(impl && cmds);
@ -125,7 +125,7 @@ int ShapeNode::pathCommands(const PathCommand** cmds) const noexcept
}
int ShapeNode::pathCoords(const Point** pts) const noexcept
int Shape::pathCoords(const Point** pts) const noexcept
{
auto impl = pImpl.get();
assert(impl && pts);
@ -136,7 +136,7 @@ int ShapeNode::pathCoords(const Point** pts) const noexcept
}
int ShapeNode::appendPath(const PathCommand *cmds, size_t cmdCnt, const Point* pts, size_t ptsCnt) noexcept
int Shape::appendPath(const PathCommand *cmds, size_t cmdCnt, const Point* pts, size_t ptsCnt) noexcept
{
if (cmdCnt < 0 || ptsCnt < 0) return -1;
assert(cmds && pts);
@ -151,7 +151,7 @@ int ShapeNode::appendPath(const PathCommand *cmds, size_t cmdCnt, const Point* p
}
int ShapeNode::moveTo(float x, float y) noexcept
int Shape::moveTo(float x, float y) noexcept
{
auto impl = pImpl.get();
assert(impl);
@ -162,7 +162,7 @@ int ShapeNode::moveTo(float x, float y) noexcept
}
int ShapeNode::lineTo(float x, float y) noexcept
int Shape::lineTo(float x, float y) noexcept
{
auto impl = pImpl.get();
assert(impl);
@ -173,7 +173,7 @@ int ShapeNode::lineTo(float x, float y) noexcept
}
int ShapeNode::cubicTo(float cx1, float cy1, float cx2, float cy2, float x, float y) noexcept
int Shape::cubicTo(float cx1, float cy1, float cx2, float cy2, float x, float y) noexcept
{
auto impl = pImpl.get();
assert(impl);
@ -184,7 +184,7 @@ int ShapeNode::cubicTo(float cx1, float cy1, float cx2, float cy2, float x, floa
}
int ShapeNode::close() noexcept
int Shape::close() noexcept
{
auto impl = pImpl.get();
assert(impl);
@ -195,7 +195,7 @@ int ShapeNode::close() noexcept
}
int ShapeNode::appendCircle(float cx, float cy, float radiusW, float radiusH) noexcept
int Shape::appendCircle(float cx, float cy, float radiusW, float radiusH) noexcept
{
auto impl = pImpl.get();
assert(impl);
@ -215,7 +215,7 @@ int ShapeNode::appendCircle(float cx, float cy, float radiusW, float radiusH) no
}
int ShapeNode::appendRect(float x, float y, float w, float h, float cornerRadius) noexcept
int Shape::appendRect(float x, float y, float w, float h, float cornerRadius) noexcept
{
auto impl = pImpl.get();
assert(impl);
@ -254,7 +254,7 @@ int ShapeNode::appendRect(float x, float y, float w, float h, float cornerRadius
}
int ShapeNode::fill(size_t r, size_t g, size_t b, size_t a) noexcept
int Shape::fill(size_t r, size_t g, size_t b, size_t a) noexcept
{
auto impl = pImpl.get();
assert(impl);
@ -268,7 +268,7 @@ int ShapeNode::fill(size_t r, size_t g, size_t b, size_t a) noexcept
}
int ShapeNode::fill(size_t* r, size_t* g, size_t* b, size_t* a) const noexcept
int Shape::fill(size_t* r, size_t* g, size_t* b, size_t* a) const noexcept
{
auto impl = pImpl.get();
assert(impl);
@ -281,4 +281,4 @@ int ShapeNode::fill(size_t* r, size_t* g, size_t* b, size_t* a) const noexcept
return 0;
}
#endif //_TVG_SHAPE_NODE_CPP_
#endif //_TVG_SHAPE_CPP_

View file

@ -19,25 +19,25 @@ void tvgtest()
canvas->reserve(5);
//Prepare Round Rectangle
auto shape1 = tvg::ShapeNode::gen();
auto shape1 = tvg::Shape::gen();
shape1->appendRect(0, 0, 400, 400, 50); //x, y, w, h, cornerRadius
shape1->fill(0, 255, 0, 255); //r, g, b, a
canvas->push(move(shape1));
//Prepare Circle
auto shape2 = tvg::ShapeNode::gen();
auto shape2 = tvg::Shape::gen();
shape2->appendCircle(400, 400, 200, 200); //cx, cy, radiusW, radiusH
shape2->fill(170, 170, 0, 170); //r, g, b, a
canvas->push(move(shape2));
//Prepare Ellipse
auto shape3 = tvg::ShapeNode::gen();
auto shape3 = tvg::Shape::gen();
shape3->appendCircle(400, 400, 250, 100); //cx, cy, radiusW, radiusH
shape3->fill(100, 100, 100, 100); //r, g, b, a
canvas->push(move(shape3));
//Prepare Star
auto shape4 = tvg::ShapeNode::gen();
auto shape4 = tvg::Shape::gen();
shape4->moveTo(199, 234);
shape4->lineTo(253, 343);
shape4->lineTo(374, 360);
@ -53,7 +53,7 @@ void tvgtest()
canvas->push(move(shape4));
//Prepare Opaque Ellipse
auto shape5 = tvg::ShapeNode::gen();
auto shape5 = tvg::Shape::gen();
shape5->appendCircle(600, 650, 200, 150);
shape5->fill(0, 0, 255, 255);
canvas->push(move(shape5));

View file

@ -19,31 +19,31 @@ void tvgtest()
canvas->reserve(5); //reserve 5 shape nodes (optional)
//Prepare Shape1
auto shape1 = tvg::ShapeNode::gen();
auto shape1 = tvg::Shape::gen();
shape1->appendRect(-100, -100, 1000, 1000, 50);
shape1->fill(255, 255, 255, 255);
canvas->push(move(shape1));
//Prepare Shape2
auto shape2 = tvg::ShapeNode::gen();
auto shape2 = tvg::Shape::gen();
shape2->appendRect(-100, -100, 250, 250, 50);
shape2->fill(0, 0, 255, 255);
canvas->push(move(shape2));
//Prepare Shape3
auto shape3 = tvg::ShapeNode::gen();
auto shape3 = tvg::Shape::gen();
shape3->appendRect(500, 500, 550, 550, 0);
shape3->fill(0, 255, 255, 255);
canvas->push(move(shape3));
//Prepare Shape4
auto shape4 = tvg::ShapeNode::gen();
auto shape4 = tvg::Shape::gen();
shape4->appendCircle(800, 100, 200, 200);
shape4->fill(255, 255, 0, 255);
canvas->push(move(shape4));
//Prepare Shape5
auto shape5 = tvg::ShapeNode::gen();
auto shape5 = tvg::Shape::gen();
shape5->appendCircle(200, 650, 250, 200);
shape5->fill(0, 0, 0, 255);
canvas->push(move(shape5));

View file

@ -22,7 +22,7 @@ int main(int argc, char **argv)
auto canvas2 = tvg::SwCanvas::gen(buffer, WIDTH, HEIGHT);
//Create a Shape
auto shape = tvg::ShapeNode::gen();
auto shape = tvg::Shape::gen();
shape->composite(canvas, tvg::CompMaskAdd);
//Draw the Scene onto the Canvas

View file

@ -8,7 +8,7 @@ using namespace std;
static uint32_t buffer[WIDTH * HEIGHT];
unique_ptr<tvg::SwCanvas> canvas = nullptr;
tvg::ShapeNode* pShape = nullptr;
tvg::Shape* pShape = nullptr;
void tvgtest()
{
@ -17,7 +17,7 @@ void tvgtest()
canvas->target(buffer, WIDTH, WIDTH, HEIGHT);
//Shape
auto shape = tvg::ShapeNode::gen();
auto shape = tvg::Shape::gen();
/* Acquire shape pointer to access it again.
instead, you should consider not to interrupt this pointer life-cycle. */

View file

@ -16,7 +16,7 @@ int main(int argc, char **argv)
auto canvas = tvg::SwCanvas::gen(buffer, WIDTH, HEIGHT);
//Prepare a Shape
auto shape1 = tvg::ShapeNode::gen();
auto shape1 = tvg::Shape::gen();
shape1->rect(0, 0, 400, 400, 0.1); //x, y, w, h, corner_radius
//Linear Gradient Fill
@ -30,7 +30,7 @@ int main(int argc, char **argv)
canvas->push(move(shape1));
//Prepare Circle
auto shape2 = tvg::ShapeNode::gen();
auto shape2 = tvg::Shape::gen();
shape2->circle(400, 400, 200); //cx, cy, radius
//Radial Gradient Fill

View file

@ -18,7 +18,7 @@ void tvgtest()
canvas->target(buffer, WIDTH, WIDTH, HEIGHT);
//Prepare a Shape (Rectangle + Rectangle + Circle + Circle)
auto shape1 = tvg::ShapeNode::gen();
auto shape1 = tvg::Shape::gen();
shape1->appendRect(0, 0, 200, 200, 0); //x, y, w, h, cornerRadius
shape1->appendRect(100, 100, 300, 300, 100); //x, y, w, h, cornerRadius
shape1->appendCircle(400, 400, 100, 100); //cx, cy, radiusW, radiusH

View file

@ -19,19 +19,19 @@ void tvgtest()
canvas->reserve(3); //reserve 3 shape nodes (optional)
//Prepare Round Rectangle
auto shape1 = tvg::ShapeNode::gen();
auto shape1 = tvg::Shape::gen();
shape1->appendRect(0, 0, 400, 400, 50); //x, y, w, h, cornerRadius
shape1->fill(0, 255, 0, 255); //r, g, b, a
canvas->push(move(shape1));
//Prepare Circle
auto shape2 = tvg::ShapeNode::gen();
auto shape2 = tvg::Shape::gen();
shape2->appendCircle(400, 400, 200, 200); //cx, cy, radiusW, radiusH
shape2->fill(255, 255, 0, 255); //r, g, b, a
canvas->push(move(shape2));
//Prepare Ellipse
auto shape3 = tvg::ShapeNode::gen();
auto shape3 = tvg::Shape::gen();
shape3->appendCircle(600, 600, 150, 100); //cx, cy, radiusW, radiusH
shape3->fill(0, 255, 255, 255); //r, g, b, a
canvas->push(move(shape3));

View file

@ -18,7 +18,7 @@ void tvgtest()
canvas->target(buffer, WIDTH, WIDTH, HEIGHT);
//Star
auto shape1 = tvg::ShapeNode::gen();
auto shape1 = tvg::Shape::gen();
//Appends Paths
shape1->moveTo(199, 34);
@ -36,7 +36,7 @@ void tvgtest()
canvas->push(move(shape1));
//Circle
auto shape2 = tvg::ShapeNode::gen();
auto shape2 = tvg::Shape::gen();
auto cx = 550.0f;
auto cy = 550.0f;

View file

@ -46,7 +46,7 @@ void tvgtest()
pts[8] = {26, 161}; //LineTo
pts[9] = {146, 143}; //LineTo
auto shape1 = tvg::ShapeNode::gen();
auto shape1 = tvg::Shape::gen();
shape1->appendPath(cmds, 11, pts, 10); //copy path data
shape1->fill(0, 255, 0, 255);
canvas->push(move(shape1));
@ -87,7 +87,7 @@ void tvgtest()
pts2[11] = {cx - halfRadius, cy - radius}; //Ctrl2
pts2[12] = {cx, cy - radius}; //To
auto shape2 = tvg::ShapeNode::gen();
auto shape2 = tvg::Shape::gen();
shape2->appendPath(cmds2, 6, pts2, 13); //copy path data
shape2->fill(255, 255, 0, 255);
canvas->push(move(shape2));

View file

@ -16,25 +16,25 @@ int main(int argc, char **argv)
auto canvas = tvg::SwCanvas::gen(buffer, WIDTH, HEIGHT);
//Create a Scene
auto scene = tvg::SceneNode::gen();
auto scene = tvg::Scene::gen();
scene->reserve(3); //reserve 3 shape nodes (optional)
//Shape1
auto shape1 = tvg::ShapeNode::gen();
auto shape1 = tvg::Shape::gen();
shape1->rect(0, 0, 400, 400, 0.1);
shape1->fill(255, 0, 0, 255);
shape1->rotate(0, 0, 45); //axis x, y, z
scene->push(move(shape1));
//Shape2
auto shape2 = tvg::ShapeNode::gen();
auto shape2 = tvg::Shape::gen();
shape2->rect(0, 0, 400, 400, 0.1);
shape2->fill(0, 255, 0, 255);
shape2->transform(matrix); //by matrix (var matrix[4 * 4];)
scene->push(move(shape2));
//Shape3
auto shape3 = tvg::ShapeNode::gen();
auto shape3 = tvg::Shape::gen();
shape3->rect(0, 0, 400, 400, 0.1);
shape3->fill(0, 0, 255, 255);
shape3->origin(100, 100); //offset

View file

@ -18,7 +18,7 @@ void tvgtest()
canvas->target(buffer, WIDTH, WIDTH, HEIGHT);
//Prepare a Shape (Rectangle)
auto shape1 = tvg::ShapeNode::gen();
auto shape1 = tvg::Shape::gen();
shape1->appendRect(100, 100, 400, 400, 0); //x, y, w, h, cornerRadius
shape1->fill(255, 0, 0, 255); //r, g, b, a

View file

@ -16,7 +16,7 @@ int main(int argc, char **argv)
auto canvas = tvg::SwCanvas::gen(buffer, WIDTH, HEIGHT);
//Prepare a Shape
auto shape1 = tvg::ShapeNode::gen();
auto shape1 = tvg::Shape::gen();
shape1->rect(0, 0, 400, 400, 0.1); //x, y, w, h, cornerRadius
shape1->fill(0, 255, 0, 255);

View file

@ -16,7 +16,7 @@ void tvgtest()
canvas->target(buffer, WIDTH, WIDTH, HEIGHT);
//Shape
auto shape = tvg::ShapeNode::gen();
auto shape = tvg::Shape::gen();
shape->appendRect(-100, -100, 200, 200, 0);
shape->fill(255, 255, 255, 255);
canvas->push(move(shape));
@ -32,7 +32,7 @@ void transit_cb(Elm_Transit_Effect *effect, Elm_Transit* transit, double progres
canvas->clear();
//Shape
auto shape = tvg::ShapeNode::gen();
auto shape = tvg::Shape::gen();
shape->appendRect(-100 + (800 * progress), -100 + (800 * progress), 200, 200, (100 * progress));
shape->fill(rand()%255, rand()%255, rand()%255, 255);
canvas->push(move(shape));