From 4ae37921640e559039d93144835ad810ee9851de Mon Sep 17 00:00:00 2001 From: aismann Date: Fri, 6 Sep 2024 15:31:18 +0200 Subject: [PATCH] DrawNode V2 (#2124) * DrawNodeV2 ready4merge * Update README.md * Lua stuff * Update DrawNode.h * Update DrawNode.cpp * Update DrawNode.cpp * Update DrawNode.cpp * Add the cocos2dx test again, add some improvements * Some improvements * Remove CandyMix from Android devices * Update DrawNodeTest.cpp * Clean tester code --- CMakeOptions.md | 1 - core/2d/DrawNode.cpp | 1633 +++++--- core/2d/DrawNode.h | 460 ++- core/CMakeLists.txt | 2 - extensions/CMakeLists.txt | 4 - extensions/DrawNodeEx/CMakeLists.txt | 8 - extensions/README.md | 5 - .../lua-bindings/auto/axlua_base_auto.cpp | 1094 ++++- tests/cpp-tests/CMakeLists.txt | 15 +- .../Source/DrawNodeTest/DrawNodeTest.cpp | 3563 +++++++++++++++++ .../Source/DrawNodeTest/DrawNodeTest.h | 438 ++ .../DrawPrimitivesTest/DrawPrimitivesTest.cpp | 5 +- tests/cpp-tests/Source/controller.cpp | 7 +- tests/cpp-tests/Source/tests.h | 6 +- tests/unit-tests/CMakeLists.txt | 4 - 15 files changed, 6464 insertions(+), 781 deletions(-) delete mode 100644 extensions/DrawNodeEx/CMakeLists.txt create mode 100644 tests/cpp-tests/Source/DrawNodeTest/DrawNodeTest.cpp create mode 100644 tests/cpp-tests/Source/DrawNodeTest/DrawNodeTest.h diff --git a/CMakeOptions.md b/CMakeOptions.md index 89135c7d4a94..6ccd0498aab3 100644 --- a/CMakeOptions.md +++ b/CMakeOptions.md @@ -35,7 +35,6 @@ - AX_ENABLE_EXT_EFFEKSEER: the effekseer extension, default: `FALSE` - AX_ENABLE_EXT_JSONDEFAULT: the UserDefault based on json, default: `FALSE` - AX_ENABLE_EXT_LUA: the lua extension, default: `TRUE` - - AX_ENABLE_EXT_DRAWNODEEX: the DrawNodeEx extension, default: `TRUE` - AX_WITH_XXX: usually user don't need care it - AX_USE_COMPAT_GL: whether use compat gl as renderer backend, default: win32: `TRUE`, others: `FALSE` - win32: whether use ANGLE GLES backend diff --git a/core/2d/DrawNode.cpp b/core/2d/DrawNode.cpp index 43d5a6fd6f8d..5ca46ef6ab85 100644 --- a/core/2d/DrawNode.cpp +++ b/core/2d/DrawNode.cpp @@ -24,7 +24,7 @@ */ #include "2d/DrawNode.h" -#include // offsetof +#include #include "base/Types.h" #include "base/EventType.h" #include "base/Configuration.h" @@ -41,68 +41,65 @@ namespace ax { -static inline Tex2F v2ToTex2F(const Vec2& v) -{ - return {v.x, v.y}; -} +#if defined(_WIN32) +# pragma push_macro("TRANSPARENT") +# undef TRANSPARENT +#endif /** Is a polygon convex? * @param verts A pointer to point coordinates. * @param count The number of verts measured in points. */ -inline bool isConvex(const Vec2* verts, int count) +static bool isConvex(const Vec2* verts, int count) { bool isPositive = false, isNegative = false; - for (int i = 0; i < count; i++) + for (unsigned int i = 0; i < count; i++) { - Vec2 A = verts[i]; - Vec2 B = verts[(i + 1) % count]; - Vec2 C = verts[(i + 2) % count]; + auto& A = verts[i]; + auto& B = verts[(i + 1) % count]; + auto& C = verts[(i + 2) % count]; double crossProduct = (B.x - A.x) * (C.y - B.y) - (B.y - A.y) * (C.x - B.x); if (crossProduct > 0) - { isPositive = true; - } else if (crossProduct < 0) - { isNegative = true; - } if (isPositive && isNegative) - return false; // Polygon is concave + return false; // is concave } - - return true; // Polygon is convex + return true; // is convex } -// implementation of DrawNode - -DrawNode::DrawNode(float lineWidth) : _lineWidth(lineWidth), _defaultLineWidth(lineWidth), _isConvex(false) +DrawNode::DrawNode(float lineWidth) : _lineWidth(lineWidth), _defaultLineWidth(lineWidth) { _blendFunc = BlendFunc::ALPHA_PREMULTIPLIED; + + properties.setDefaultValues(); + #if AX_ENABLE_CACHE_TEXTURE_DATA // TODO new-renderer: interface setupBuffer removal // Need to listen the event only when not use batchnode, because it will use VBO -// auto listener = EventListenerCustom::create(EVENT_RENDERER_RECREATED, [this](EventCustom* event){ -// /** listen the event that renderer was recreated on Android/WP8 */ -// this->setupBuffer(); -// }); + // auto listener = EventListenerCustom::create(EVENT_RENDERER_RECREATED, [this](EventCustom* event){ + // /** listen the event that renderer was recreated on Android/WP8 */ + // this->setupBuffer(); + // }); -// _eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this); + // _eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this); #endif } DrawNode::~DrawNode() { AX_SAFE_FREE(_bufferTriangle); - AX_SAFE_FREE(_bufferPoint); - AX_SAFE_FREE(_bufferLine); - freeShaderInternal(_customCommandTriangle); + + AX_SAFE_FREE(_bufferPoint); freeShaderInternal(_customCommandPoint); + + AX_SAFE_FREE(_bufferLine); freeShaderInternal(_customCommandLine); } @@ -117,11 +114,10 @@ DrawNode* DrawNode::create(float defaultLineWidth) { AX_SAFE_DELETE(ret); } - return ret; } -void DrawNode::ensureCapacity(int count) +void DrawNode::ensureCapacityTriangle(int count) { AXASSERT(count >= 0, "capacity must be >= 0"); @@ -136,7 +132,7 @@ void DrawNode::ensureCapacity(int count) } } -void DrawNode::ensureCapacityGLPoint(int count) +void DrawNode::ensureCapacityPoint(int count) { AXASSERT(count >= 0, "capacity must be >= 0"); @@ -151,7 +147,7 @@ void DrawNode::ensureCapacityGLPoint(int count) } } -void DrawNode::ensureCapacityGLLine(int count) +void DrawNode::ensureCapacityLine(int count) { AXASSERT(count >= 0, "capacity must be >= 0"); @@ -170,13 +166,13 @@ bool DrawNode::init() { _blendFunc = BlendFunc::ALPHA_PREMULTIPLIED; updateShader(); - ensureCapacity(512); - ensureCapacityGLPoint(64); - ensureCapacityGLLine(256); - + ensureCapacityTriangle(512); _dirtyTriangle = true; - _dirtyLine = true; - _dirtyPoint = true; + + ensureCapacityPoint(64); + ensureCapacityLine(256); + _dirtyLine = true; + _dirtyPoint = true; return true; } @@ -282,101 +278,64 @@ void DrawNode::draw(Renderer* renderer, const Mat4& transform, uint32_t flags) } } -void DrawNode::drawPoint(const Vec2& position, const float pointSize, const Color4B& color) +void DrawNode::drawPoint(const Vec2& position, + const float pointSize, + const Color4B& color, + const DrawNode::PointType pointType) { - ensureCapacityGLPoint(1); - - V2F_C4B_T2F* point = _bufferPoint + _bufferCountPoint; - *point = {position, color, Tex2F(pointSize, 0)}; + if (pointSize <= 0.0f) + return; - _customCommandPoint.updateVertexBuffer(point, _bufferCountPoint * sizeof(V2F_C4B_T2F), sizeof(V2F_C4B_T2F)); - _bufferCountPoint += 1; - _dirtyPoint = true; - _customCommandPoint.setVertexDrawInfo(0, _bufferCountPoint); + _drawPoint(position, pointSize, color, pointType); } -void DrawNode::drawPoints(const Vec2* position, unsigned int numberOfPoints, const Color4B& color) +void DrawNode::drawPoints(const Vec2* position, + unsigned int numberOfPoints, + const Color4B& color, + const DrawNode::PointType pointType) { - drawPoints(position, numberOfPoints, 1.0, color); + _drawPoints(position, numberOfPoints, 1.0f, color, pointType); } void DrawNode::drawPoints(const Vec2* position, unsigned int numberOfPoints, const float pointSize, - const Color4B& color) -{ - ensureCapacityGLPoint(numberOfPoints); - - V2F_C4B_T2F* point = _bufferPoint + _bufferCountPoint; - for (unsigned int i = 0; i < numberOfPoints; i++) - { - *(point + i) = {position[i], color, Tex2F(pointSize, 0)}; - } - - _customCommandPoint.updateVertexBuffer(point, _bufferCountPoint * sizeof(V2F_C4B_T2F), - numberOfPoints * sizeof(V2F_C4B_T2F)); - _bufferCountPoint += numberOfPoints; - _dirtyPoint = true; - _customCommandPoint.setVertexDrawInfo(0, _bufferCountPoint); -} - -void DrawNode::drawLine(const Vec2& origin, const Vec2& destination, const Color4B& color) -{ - ensureCapacityGLLine(2); - - V2F_C4B_T2F* point = _bufferLine + _bufferCountLine; - - *point = {origin, color, Tex2F(0.0, 0.0)}; - *(point + 1) = {destination, color, Tex2F(0.0, 0.0)}; - - _customCommandLine.updateVertexBuffer(point, _bufferCountLine * sizeof(V2F_C4B_T2F), 2 * sizeof(V2F_C4B_T2F)); - _bufferCountLine += 2; - _dirtyLine = true; - _customCommandLine.setVertexDrawInfo(0, _bufferCountLine); -} - -void DrawNode::drawRect(const Vec2& origin, const Vec2& destination, const Color4B& color) + const Color4B& color, + const DrawNode::PointType pointType) { - drawLine(origin, Vec2(destination.x, origin.y), color); - drawLine(Vec2(destination.x, origin.y), destination, color); - drawLine(destination, Vec2(origin.x, destination.y), color); - drawLine(Vec2(origin.x, destination.y), origin, color); + if (pointSize <= 0.0f) + return; + _drawPoints(position, numberOfPoints, pointSize, color, pointType); } -void DrawNode::drawPoly(const Vec2* poli, unsigned int numberOfPoints, bool closePolygon, const Color4B& color) +void DrawNode::drawLine(const Vec2& origin, + const Vec2& destination, + const Color4B& color, + float thickness, + DrawNode::EndType etStart, + DrawNode::EndType etEnd) { - unsigned int vertex_count; - if (closePolygon) + if (thickness <= 0.0f) { - vertex_count = 2 * numberOfPoints; - ensureCapacityGLLine(vertex_count); - } - else - { - vertex_count = 2 * (numberOfPoints - 1); - ensureCapacityGLLine(vertex_count); + AXLOGW("{}: thickness <= 0", __FUNCTION__); + return; } - V2F_C4B_T2F* point = _bufferLine + _bufferCountLine; - V2F_C4B_T2F* cursor = point; + _drawSegment(origin, destination, color, thickness, etStart, etEnd); +} - unsigned int i = 0; - for (; i < numberOfPoints - 1; i++) - { - *point = {poli[i], color, Tex2F(0.0, 0.0)}; - *(point + 1) = {poli[i + 1], color, Tex2F(0.0, 0.0)}; - point += 2; - } - if (closePolygon) +void DrawNode::drawPoly(const Vec2* poli, + unsigned int numberOfPoints, + bool closedPolygon, + const Color4B& color, + float thickness) +{ + if (thickness <= 0.0f) { - *point = {poli[i], color, Tex2F(0.0, 0.0)}; - *(point + 1) = {poli[0], color, Tex2F(0.0, 0.0)}; + AXLOGW("{}: thickness <= 0", __FUNCTION__); + return; } - - _customCommandLine.updateVertexBuffer(cursor, _bufferCountLine * sizeof(V2F_C4B_T2F), - vertex_count * sizeof(V2F_C4B_T2F)); - _bufferCountLine += vertex_count; - _customCommandLine.setVertexDrawInfo(0, _bufferCountLine); + _drawPoly(poli, numberOfPoints, closedPolygon, color, thickness); } void DrawNode::drawCircle(const Vec2& center, @@ -387,34 +346,14 @@ void DrawNode::drawCircle(const Vec2& center, float scaleX, float scaleY, const Color4B& color, - float threshold) + float thickness) { - const float coef = 2.0f * (float)M_PI / segments; - - auto vertices = _abuf.get(segments + 2); - - for (unsigned int i = 0; i <= segments; i++) - { - float rads = i * coef; - vertices[i].x = radius * cosf(rads + angle) * scaleX + center.x; - vertices[i].y = radius * sinf(rads + angle) * scaleY + center.y; - } - if (_lineWidth > threshold) - { - _isConvex = true; - drawPolygon(vertices, segments, Color4B(1.0f, 0.0f, 0.0f, 1.0f), _lineWidth/4, color); - _isConvex = false; - } - else + if (thickness <= 0.0f) { - if (drawLineToCenter) - { - vertices[segments + 1] = center; - drawPoly(vertices, segments + 2, true, color); - } - else - drawPoly(vertices, segments + 1, true, color); + AXLOGW("{}: thickness <= 0", __FUNCTION__); + return; } + _drawCircle(center, radius, angle, segments, drawLineToCenter, scaleX, scaleY, color, Color4B(), false, thickness); } void DrawNode::drawCircle(const Vec2& center, @@ -423,30 +362,73 @@ void DrawNode::drawCircle(const Vec2& center, unsigned int segments, bool drawLineToCenter, const Color4B& color, - float threshold) + float thickness) +{ + if (thickness <= 0.0f) + { + AXLOGW("{}: thickness <= 0", __FUNCTION__); + return; + } + _drawCircle(center, radius, angle, segments, drawLineToCenter, 1.0f, 1.0f, color, color, false, thickness); +} + +void DrawNode::drawStar(const Vec2& center, + float radiusI, + float radiusO, + unsigned int segments, + const Color4B& color, + float thickness) +{ + if (thickness <= 0.0f) + { + AXLOGW("{}: thickness <= 0", __FUNCTION__); + return; + } + _drawAStar(center, radiusI, radiusO, segments, color, color, thickness, false); +} + +void DrawNode::drawSolidStar(const Vec2& center, + float radiusI, // inner + float radiusO, // outer + unsigned int segments, + const Color4B& color, + const Color4B& filledColor, + float thickness) { - drawCircle(center, radius, angle, segments, drawLineToCenter, 1.0f, 1.0f, color, threshold); + if (thickness < 0.0f) + { + AXLOGW("{}: thickness < 0, changed to 0", __FUNCTION__); + thickness = 0.0f; + } + _drawAStar(center, radiusI, radiusO, segments, color, filledColor, thickness, true); } void DrawNode::drawQuadBezier(const Vec2& origin, const Vec2& control, const Vec2& destination, unsigned int segments, - const Color4B& color) + const Color4B& color, + float thickness) { - Vec2* vertices = _abuf.get(segments + 1); + if (thickness <= 0.0f) + { + AXLOGW("{}: thickness <= 0", __FUNCTION__); + return; + } + + Vec2* _vertices = _abuf.get(segments + 1); float t = 0.0f; for (unsigned int i = 0; i < segments; i++) { - vertices[i].x = powf(1 - t, 2) * origin.x + 2.0f * (1 - t) * t * control.x + t * t * destination.x; - vertices[i].y = powf(1 - t, 2) * origin.y + 2.0f * (1 - t) * t * control.y + t * t * destination.y; + _vertices[i].x = powf(1.0f - t, 2.0f) * origin.x + 2.0f * (1.0f - t) * t * control.x + t * t * destination.x; + _vertices[i].y = powf(1.0f - t, 2.0f) * origin.y + 2.0f * (1.0f - t) * t * control.y + t * t * destination.y; t += 1.0f / segments; } - vertices[segments].x = destination.x; - vertices[segments].y = destination.y; + _vertices[segments].x = destination.x; + _vertices[segments].y = destination.y; - drawPoly(vertices, segments + 1, false, color); + _drawPoly(_vertices, segments + 1, false, color, thickness, false); } void DrawNode::drawCubicBezier(const Vec2& origin, @@ -454,36 +436,52 @@ void DrawNode::drawCubicBezier(const Vec2& origin, const Vec2& control2, const Vec2& destination, unsigned int segments, - const Color4B& color) + const Color4B& color, + float thickness) { - Vec2* vertices = _abuf.get(segments + 1); + if (thickness <= 0.0f) + { + AXLOGW("{}: thickness <= 0", __FUNCTION__); + return; + } + + Vec2* _vertices = _abuf.get(segments + 1); - float t = 0; + float t = 0.0f; for (unsigned int i = 0; i < segments; i++) { - vertices[i].x = powf(1 - t, 3) * origin.x + 3.0f * powf(1 - t, 2) * t * control1.x + - 3.0f * (1 - t) * t * t * control2.x + t * t * t * destination.x; - vertices[i].y = powf(1 - t, 3) * origin.y + 3.0f * powf(1 - t, 2) * t * control1.y + - 3.0f * (1 - t) * t * t * control2.y + t * t * t * destination.y; + _vertices[i].x = powf(1.0f - t, 3.0f) * origin.x + 3.0f * powf(1.0f - t, 2.0f) * t * control1.x + + 3.0f * (1 - t) * t * t * control2.x + t * t * t * destination.x; + _vertices[i].y = powf(1.0f - t, 3.0f) * origin.y + 3.0f * powf(1.0f - t, 2.0f) * t * control1.y + + 3.0f * (1 - t) * t * t * control2.y + t * t * t * destination.y; t += 1.0f / segments; } - vertices[segments].x = destination.x; - vertices[segments].y = destination.y; + _vertices[segments].x = destination.x; + _vertices[segments].y = destination.y; - drawPoly(vertices, segments + 1, false, color); + _drawPoly(_vertices, segments + 1, false, color, thickness, true); } -void DrawNode::drawCardinalSpline(PointArray* config, float tension, unsigned int segments, const Color4B& color) +void DrawNode::drawCardinalSpline(PointArray* config, + float tension, + unsigned int segments, + const Color4B& color, + float thickness) { - Vec2* vertices = _abuf.get(segments + 1); + if (thickness <= 0.0f) + { + AXLOGW("{}: thickness <= 0", __FUNCTION__); + return; + } + + Vec2* _vertices = _abuf.get(segments); ssize_t p; float lt; float deltaT = 1.0f / config->count(); - for (unsigned int i = 0; i < segments + 1; i++) + for (unsigned int i = 0; i < segments; i++) { - float dt = (float)i / segments; // border @@ -504,258 +502,172 @@ void DrawNode::drawCardinalSpline(PointArray* config, float tension, unsigned in Vec2 pp2 = config->getControlPointAtIndex(p + 1); Vec2 pp3 = config->getControlPointAtIndex(p + 2); - Vec2 newPos = ccCardinalSplineAt(pp0, pp1, pp2, pp3, tension, lt); - vertices[i].x = newPos.x; - vertices[i].y = newPos.y; + Vec2 newPos = ccCardinalSplineAt(pp0, pp1, pp2, pp3, tension, lt); + _vertices[i].x = newPos.x; + _vertices[i].y = newPos.y; + if (newPos == config->getControlPointAtIndex(config->count() - 1) && i > 0) + { + segments = i + 1; + break; + } } - drawPoly(vertices, segments + 1, false, color); + _drawPoly(_vertices, segments, false, color, thickness, true); } -void DrawNode::drawCatmullRom(PointArray* points, unsigned int segments, const Color4B& color) +void DrawNode::drawCatmullRom(PointArray* points, unsigned int segments, const Color4B& color, float thickness) { - drawCardinalSpline(points, 0.5f, segments, color); + if (thickness <= 0.0f) + { + AXLOGW("{}: thickness <= 0", __FUNCTION__); + return; + } + drawCardinalSpline(points, 0.5f, segments, color, thickness); } void DrawNode::drawDot(const Vec2& pos, float radius, const Color4B& color) { - unsigned int vertex_count = 2 * 3; - ensureCapacity(vertex_count); - - V2F_C4B_T2F a = {Vec2(pos.x - radius, pos.y - radius), color, Tex2F(-1.0, -1.0)}; - V2F_C4B_T2F b = {Vec2(pos.x - radius, pos.y + radius), color, Tex2F(-1.0, 1.0)}; - V2F_C4B_T2F c = {Vec2(pos.x + radius, pos.y + radius), color, Tex2F(1.0, 1.0)}; - V2F_C4B_T2F d = {Vec2(pos.x + radius, pos.y - radius), color, Tex2F(1.0, -1.0)}; - - V2F_C4B_T2F_Triangle* triangles = (V2F_C4B_T2F_Triangle*)(_bufferTriangle + _bufferCountTriangle); - V2F_C4B_T2F_Triangle triangle0 = {a, b, c}; - V2F_C4B_T2F_Triangle triangle1 = {a, c, d}; - triangles[0] = triangle0; - triangles[1] = triangle1; - - _customCommandTriangle.updateVertexBuffer(triangles, _bufferCountTriangle * sizeof(V2F_C4B_T2F), - vertex_count * sizeof(V2F_C4B_T2F)); - _bufferCountTriangle += vertex_count; - _dirtyTriangle = true; - _customCommandTriangle.setVertexDrawInfo(0, _bufferCountTriangle); + if (radius <= 0.0f) + { + AXLOGW("{}: radius <= 0", __FUNCTION__); + return; + } + _drawDot(pos, radius, color); } -void DrawNode::drawRect(const Vec2& p1, const Vec2& p2, const Vec2& p3, const Vec2& p4, const Color4B& color) +void DrawNode::drawRect(const Vec2& p1, + const Vec2& p2, + const Vec2& p3, + const Vec2& p4, + const Color4B& color, + float thickness) { - drawLine(p1, p2, color); - drawLine(p2, p3, color); - drawLine(p3, p4, color); - drawLine(p4, p1, color); + if (thickness <= 0.0f) + { + AXLOGW("{}: thickness <= 0", __FUNCTION__); + return; + } + + Vec2 line[5] = {p1, p2, p3, p4, p1}; + _drawPoly(line, 5, false, color, thickness, true); } -void DrawNode::drawSegment(const Vec2& from, const Vec2& to, float radius, const Color4B& color) +void DrawNode::drawRect(const Vec2& origin, const Vec2& destination, const Color4B& color, float thickness) { - unsigned int vertex_count = 6 * 3; - ensureCapacity(vertex_count); - - Vec2 a = from; - Vec2 b = to; - - Vec2 n = ((b - a).getPerp()).getNormalized(); - Vec2 t = n.getPerp(); - - Vec2 nw = n * radius; - Vec2 tw = t * radius; - Vec2 v0 = b - (nw + tw); - Vec2 v1 = b + (nw - tw); - Vec2 v2 = b - nw; - Vec2 v3 = b + nw; - Vec2 v4 = a - nw; - Vec2 v5 = a + nw; - Vec2 v6 = a - (nw - tw); - Vec2 v7 = a + (nw + tw); - - V2F_C4B_T2F_Triangle* triangles = (V2F_C4B_T2F_Triangle*)(_bufferTriangle + _bufferCountTriangle); - - V2F_C4B_T2F_Triangle triangles0 = { - {v0, color, v2ToTex2F(-(n + t))}, - {v1, color, v2ToTex2F(n - t)}, - {v2, color, v2ToTex2F(-n)}, - }; - triangles[0] = triangles0; - - V2F_C4B_T2F_Triangle triangles1 = { - {v3, color, v2ToTex2F(n)}, - {v1, color, v2ToTex2F(n - t)}, - {v2, color, v2ToTex2F(-n)}, - }; - triangles[1] = triangles1; - - V2F_C4B_T2F_Triangle triangles2 = { - {v3, color, v2ToTex2F(n)}, - {v4, color, v2ToTex2F(-n)}, - {v2, color, v2ToTex2F(-n)}, - }; - triangles[2] = triangles2; - - V2F_C4B_T2F_Triangle triangles3 = { - {v3, color, v2ToTex2F(n)}, - {v4, color, v2ToTex2F(-n)}, - {v5, color, v2ToTex2F(n)}, - }; - triangles[3] = triangles3; - - V2F_C4B_T2F_Triangle triangles4 = { - {v6, color, v2ToTex2F(t - n)}, - {v4, color, v2ToTex2F(-n)}, - {v5, color, v2ToTex2F(n)}, - }; - triangles[4] = triangles4; + if (thickness <= 0.0f) + { + AXLOGW("{}: thickness <= 0", __FUNCTION__); + return; + } - V2F_C4B_T2F_Triangle triangles5 = { - {v6, color, v2ToTex2F(t - n)}, - {v7, color, v2ToTex2F(t + n)}, - {v5, color, v2ToTex2F(n)}, - }; - triangles[5] = triangles5; + Vec2 line[5] = {origin, Vec2(destination.x, origin.y), destination, Vec2(origin.x, destination.y), origin}; + _drawPoly(line, 5, false, color, thickness, true); +} - _customCommandTriangle.updateVertexBuffer(triangles, _bufferCountTriangle * sizeof(V2F_C4B_T2F), - vertex_count * sizeof(V2F_C4B_T2F)); - _bufferCountTriangle += vertex_count; - _dirtyTriangle = true; - _customCommandTriangle.setVertexDrawInfo(0, _bufferCountTriangle); +void DrawNode::drawSegment(const Vec2& from, + const Vec2& to, + float thickness, + const Color4B& color, + DrawNode::EndType etStart, + DrawNode::EndType etEnd) +{ + if (thickness <= 0.0f) + { + AXLOGW("{}: thickness <= 0", __FUNCTION__); + return; + } + _drawSegment(from, to, color, thickness, etStart, etEnd); } -void DrawNode::drawPolygon(const Vec2* verts, +void DrawNode::drawPolygon(Vec2* verts, int count, const Color4B& fillColor, - float borderWidth, - const Color4B& borderColor) + float thickness, + const Color4B& borderColor, + bool isconvex) { - AXASSERT(count >= 0, "invalid count value"); - - bool outline = (borderColor.a > 0.0f && borderWidth > 0.0f); - - auto triangle_count = outline ? (3 * count - 2) : (count - 2); - auto vertex_count = 3 * triangle_count; - ensureCapacity(vertex_count); - - V2F_C4B_T2F_Triangle* triangles = (V2F_C4B_T2F_Triangle*)(_bufferTriangle + _bufferCountTriangle); - V2F_C4B_T2F_Triangle* cursor = triangles; - - if (!_isConvex && count >= 3 && !isConvex(verts, count)) + if (thickness < 0.0f) { - std::vector p2pointsStorage; - p2pointsStorage.reserve(count); - std::vector p2points; - p2points.reserve(count); - - for (int i = 0; i < count; ++i) - { - p2points.emplace_back(&p2pointsStorage.emplace_back((double)verts[i].x, (double)verts[i].y)); - } - p2t::CDT cdt(p2points); - cdt.Triangulate(); - std::vector tris = cdt.GetTriangles(); - - if ((tris.size() * 3) > vertex_count) - { - ensureCapacity(static_cast(tris.size() * 3)); - triangles = (V2F_C4B_T2F_Triangle*)(_bufferTriangle + _bufferCountTriangle); - cursor = triangles; - } - - for (auto&& t : tris) - { - p2t::Point* vec1 = t->GetPoint(0); - p2t::Point* vec2 = t->GetPoint(1); - p2t::Point* vec3 = t->GetPoint(2); - - V2F_C4B_T2F_Triangle tmp = { - {Vec2(vec1->x, vec1->y), fillColor, Tex2F(0.0, 0.0)}, - {Vec2(vec2->x, vec2->y), fillColor, Tex2F(0.0, 0.0)}, - {Vec2(vec3->x, vec3->y), fillColor, Tex2F(0.0, 0.0)}, - }; - *cursor++ = tmp; - } + AXLOGW("{}: thickness < 0, changed to 0", __FUNCTION__); + thickness = 0.0f; } - else - { - for (int i = 0; i < count - 2; i++) - { - V2F_C4B_T2F_Triangle tmp = { - {verts[0], fillColor, v2ToTex2F(Vec2::ZERO)}, - {verts[i + 1], fillColor, v2ToTex2F(Vec2::ZERO)}, - {verts[i + 2], fillColor, v2ToTex2F(Vec2::ZERO)}, - }; + _drawPolygon(verts, count, fillColor, borderColor, true, thickness, isconvex); +} - *cursor++ = tmp; - } - } - if (outline) +void DrawNode::drawPolygon(Vec2* verts, int count, float thickness, const Color4B& borderColor, bool isconvex) +{ + if (thickness < 0.0f) { - struct ExtrudeVerts - { - Vec2 offset, n; - }; - struct ExtrudeVerts* extrude = (struct ExtrudeVerts*)malloc(sizeof(struct ExtrudeVerts) * count); - - for (int i = 0; i < count; i++) - { - Vec2 v0 = verts[(i - 1 + count) % count]; - Vec2 v1 = verts[i]; - Vec2 v2 = verts[(i + 1) % count]; - - Vec2 n1 = ((v1 - v0).getPerp()).getNormalized(); - Vec2 n2 = ((v2 - v1).getPerp()).getNormalized(); - - Vec2 offset = (n1 + n2) * (1.0f / (Vec2::dot(n1, n2) + 1.0f)); - extrude[i] = {offset, n2}; - } - - for (int i = 0; i < count; i++) - { - int j = (i + 1) % count; - Vec2 v0 = verts[i]; - Vec2 v1 = verts[j]; - - Vec2 n0 = extrude[i].n; - - Vec2 offset0 = extrude[i].offset; - Vec2 offset1 = extrude[j].offset; - - Vec2 inner0 = v0 - offset0 * borderWidth; - Vec2 inner1 = v1 - offset1 * borderWidth; - Vec2 outer0 = v0 + offset0 * borderWidth; - Vec2 outer1 = v1 + offset1 * borderWidth; - - V2F_C4B_T2F_Triangle tmp1 = {{inner0, borderColor, v2ToTex2F(-n0)}, - {inner1, borderColor, v2ToTex2F(-n0)}, - {outer1, borderColor, v2ToTex2F(n0)}}; - *cursor++ = tmp1; - - V2F_C4B_T2F_Triangle tmp2 = {{inner0, borderColor, v2ToTex2F(-n0)}, - {outer0, borderColor, v2ToTex2F(n0)}, - {outer1, borderColor, v2ToTex2F(n0)}}; - *cursor++ = tmp2; - } + AXLOGW("{}: thickness < 0, changed to 0", __FUNCTION__); + thickness = 0.0f; + } + _drawPolygon(verts, count, Color4B::TRANSPARENT, borderColor, true, thickness, isconvex); +} - free(extrude); +void DrawNode::drawSolidPolygon(Vec2* verts, + int count, + const Color4B& fillColor, + float thickness, + const Color4B& borderColor, + bool isconvex) +{ + if (thickness < 0.0f) + { + AXLOGW("{}: thickness < 0, changed to 0", __FUNCTION__); + thickness = 0.0f; } + _drawPolygon(verts, count, fillColor, borderColor, true, thickness, isconvex); +} - _customCommandTriangle.updateVertexBuffer(triangles, _bufferCountTriangle * sizeof(V2F_C4B_T2F), - vertex_count * sizeof(V2F_C4B_T2F)); - _bufferCountTriangle += vertex_count; - _customCommandTriangle.setVertexDrawInfo(0, _bufferCountTriangle); - _dirtyTriangle = true; +void DrawNode::drawSolidRect(const Vec2& origin, + const Vec2& destination, + const Color4B& fillColor, + float thickness, + const Color4B& borderColor) +{ + if (thickness < 0.0f) + { + AXLOGW("{}: thickness < 0, changed to 0", __FUNCTION__); + thickness = 0.0f; + } + Vec2 _vertices[] = {origin, Vec2(destination.x, origin.y), destination, Vec2(origin.x, destination.y), origin}; + _drawPolygon(_vertices, 5, fillColor, borderColor, true, thickness, true); } -void DrawNode::drawSolidRect(const Vec2& origin, const Vec2& destination, const Color4B& color) +void DrawNode::drawSolidPoly(const Vec2* poli, + unsigned int numberOfPoints, + const Color4B& color, + float thickness, + const Color4B& borderColor, + bool isconvex) { - Vec2 vertices[] = {origin, Vec2(destination.x, origin.y), destination, Vec2(origin.x, destination.y)}; - _isConvex = true; // Fix issue #1546 of UILayout(#1549) - drawSolidPoly(vertices, 4, color); - _isConvex = false; + if (thickness < 0.0f) + { + AXLOGW("{}: thickness < 0, changed to 0", __FUNCTION__); + thickness = 0.0f; + } + _drawPolygon(poli, numberOfPoints, color, borderColor, true, thickness, isconvex); } -void DrawNode::drawSolidPoly(const Vec2* poli, unsigned int numberOfPoints, const Color4B& color) +void DrawNode::drawPie(const Vec2& center, + float radius, + float rotation, + int startAngle, + int endAngle, + float scaleX, + float scaleY, + const Color4B& fillColor, + const Color4B& borderColor, + DrawMode drawMode, + float thickness) { - drawPolygon(poli, numberOfPoints, color, 0.0, Color4B()); + if (thickness < 0.0f) + { + AXLOGW("{}: thickness < 0, changed to 0", __FUNCTION__); + thickness = 0.0f; + } + _drawPie(center, radius, rotation, startAngle, endAngle, scaleX, scaleY, fillColor, borderColor, drawMode, + thickness); } void DrawNode::drawPie(const Vec2& center, @@ -768,61 +680,26 @@ void DrawNode::drawPie(const Vec2& center, const Color4B& color, DrawMode drawMode) { - // not a real line! - if (startAngle == endAngle) - return; - -#define DEGREES 360 - - const float coef = 2.0f * (float)M_PI / DEGREES; - Vec2* vertices = _abuf.get(DEGREES + 2); - - int n = 0; - float rads = 0; - float _angle = AX_DEGREES_TO_RADIANS(angle); + _drawPie(center, radius, angle, startAngle, endAngle, scaleX, scaleY, Color4B::TRANSPARENT, color, drawMode, 1.0f); +} - if (startAngle > endAngle) +void DrawNode::drawSolidCircle(const Vec2& center, + float radius, + float angle, + unsigned int segments, + float scaleX, + float scaleY, + const Color4B& fillColor, + float thickness, + const Color4B& borderColor) +{ + if (thickness < 0.0f) { - int tmp = endAngle; - endAngle = startAngle; - startAngle = tmp; + AXLOGW("{}: thickness < 0, changed to 0", __FUNCTION__); + thickness = 0.0f; } - - for (int i = 0; i <= DEGREES; i++) - { - if (startAngle <= i && endAngle >= i) - { - rads = i * coef; - - float j = radius * cosf(rads + _angle) * scaleX + center.x; - float k = radius * sinf(rads + _angle) * scaleY + center.y; - - vertices[n].x = j; - vertices[n].y = k; - n++; - } - } - switch (drawMode) - { - case DrawMode::Fill: - vertices[n++] = center; - drawSolidPoly(vertices, n, color); - break; - case DrawMode::Outline: - vertices[n++] = center; - drawPoly(vertices, n, true, color); - break; - case DrawMode::Line: - drawPoly(vertices, n, false, color); - break; - case DrawMode::Semi: - drawPoly(vertices, n, true, color); - break; - - default: - break; - } -} + _drawCircle(center, radius, angle, segments, false, scaleX, scaleY, borderColor, fillColor, true, thickness); +} void DrawNode::drawSolidCircle(const Vec2& center, float radius, @@ -830,80 +707,73 @@ void DrawNode::drawSolidCircle(const Vec2& center, unsigned int segments, float scaleX, float scaleY, - const Color4B& fillColor, - float borderWidth, - const Color4B& borderColor) + const Color4B& color) { - const float coef = 2.0f * (float)M_PI / segments; - - Vec2* vertices = _abuf.get(segments); - - for (unsigned int i = 0; i < segments; i++) + if (radius < 0.0f) { - float rads = i * coef; - float j = radius * cosf(rads + angle) * scaleX + center.x; - float k = radius * sinf(rads + angle) * scaleY + center.y; - - vertices[i].x = j; - vertices[i].y = k; + AXLOGW("{}: radius < 0, changed to 0", __FUNCTION__); + radius = 0.0f; } - _isConvex = true; - drawPolygon(vertices, segments, fillColor, borderWidth, borderColor); - _isConvex = false; + _drawCircle(center, radius, angle, segments, false, scaleX, scaleY, Color4B(), color, true); } void DrawNode::drawSolidCircle(const Vec2& center, float radius, float angle, unsigned int segments, - float scaleX, - float scaleY, const Color4B& color) { - const float coef = 2.0f * (float)M_PI / segments; - - Vec2* vertices = _abuf.get(segments); - - for (unsigned int i = 0; i < segments; i++) + if (radius < 0.0f) { - float rads = i * coef; - float j = radius * cosf(rads + angle) * scaleX + center.x; - float k = radius * sinf(rads + angle) * scaleY + center.y; - - vertices[i].x = j; - vertices[i].y = k; + AXLOGW("{}: radius < 0, changed to 0", __FUNCTION__); + radius = 0.0f; } - - drawSolidPoly(vertices, segments, color); + _drawCircle(center, radius, angle, segments, false, 1.0f, 1.0f, Color4B(), color, true); } -void DrawNode::drawSolidCircle(const Vec2& center, - float radius, - float angle, - unsigned int segments, - const Color4B& color) +void DrawNode::drawTriangle(const Vec2* _vertices3, const Color4B& color, float thickness) { - drawSolidCircle(center, radius, angle, segments, 1.0f, 1.0f, color); + _drawTriangle(_vertices3, Color4B::TRANSPARENT, color, false, thickness); } -void DrawNode::drawTriangle(const Vec2& p1, const Vec2& p2, const Vec2& p3, const Color4B& color) +void DrawNode::drawTriangle(const Vec2& p1, const Vec2& p2, const Vec2& p3, const Color4B& color, float thickness) { - unsigned int vertex_count = 3; - ensureCapacity(vertex_count); - - V2F_C4B_T2F a = {p1, color, Tex2F(0.0, 0.0)}; - V2F_C4B_T2F b = {p2, color, Tex2F(0.0, 0.0)}; - V2F_C4B_T2F c = {p3, color, Tex2F(0.0, 0.0)}; + if (thickness <= 0.0f) + { + AXLOGW("{}: thickness <= 0", __FUNCTION__); + return; + } + Vec2 _vertices3[3] = {p1, p2, p3}; + _drawTriangle(_vertices3, Color4B::TRANSPARENT, color, false, thickness); +} - V2F_C4B_T2F_Triangle* triangles = (V2F_C4B_T2F_Triangle*)(_bufferTriangle + _bufferCountTriangle); - V2F_C4B_T2F_Triangle triangle = {a, b, c}; - triangles[0] = triangle; +void DrawNode::drawSolidTriangle(const Vec2* _vertices3, + const Color4B& fillColor, + const Color4B& borderColor, + float thickness) +{ + if (thickness < 0.0f) + { + AXLOGW("{}: thickness < 0, changed to 0", __FUNCTION__); + thickness = 0.0f; + } + _drawTriangle(_vertices3, fillColor, borderColor, true, thickness); +} - _customCommandTriangle.updateVertexBuffer(triangles, _bufferCountTriangle * sizeof(V2F_C4B_T2F), - vertex_count * sizeof(V2F_C4B_T2F)); - _bufferCountTriangle += vertex_count; - _dirtyTriangle = true; - _customCommandTriangle.setVertexDrawInfo(0, _bufferCountTriangle); +void DrawNode::drawSolidTriangle(const Vec2& p1, + const Vec2& p2, + const Vec2& p3, + const Color4B& fillColor, + const Color4B& borderColor, + float thickness) +{ + if (thickness < 0.0f) + { + AXLOGW("{}: thickness < 0, changed to 0", __FUNCTION__); + thickness = 0.0f; + } + Vec2 _vertices3[3] = {p1, p2, p3}; + _drawTriangle(_vertices3, fillColor, borderColor, false, thickness); } void DrawNode::clear() @@ -914,7 +784,8 @@ void DrawNode::clear() _dirtyLine = true; _bufferCountPoint = 0; _dirtyPoint = true; - _lineWidth = _defaultLineWidth; + + _lineWidth = _defaultLineWidth; } const BlendFunc& DrawNode::getBlendFunc() const @@ -929,12 +800,12 @@ void DrawNode::setBlendFunc(const BlendFunc& blendFunc) void DrawNode::setLineWidth(float lineWidth) { - _lineWidth = lineWidth; + _defaultLineWidth = lineWidth; } float DrawNode::getLineWidth() { - return this->_lineWidth; + return _defaultLineWidth; } void DrawNode::visit(Renderer* renderer, const Mat4& parentTransform, uint32_t parentFlags) @@ -950,4 +821,794 @@ void DrawNode::visit(Renderer* renderer, const Mat4& parentTransform, uint32_t p } } +void DrawNode::_drawPolygon(const Vec2* verts, + unsigned int count, + const Color4B& fillColor, + const Color4B& borderColor, + bool closedPolygon, + float thickness, + bool isconvex) +{ + AXASSERT(count >= 0, "invalid count value"); + + bool outline = (thickness != 0.0f); + + Vec2* _vertices = _transform(verts, count, closedPolygon); + + std::vector triangleList; + + int vertex_count = 0; + + // calculate the memory (important for correct drawing stuff) + if (closedPolygon && !isconvex && fillColor.a > 0.0f && !isConvex(_vertices, count) && count >= 3) + { + std::vector p2pointsStorage; + p2pointsStorage.reserve(count); + std::vector p2points; + p2points.reserve(count); + + for (unsigned int i = 0; i < count - 1; + i++) // count-1 is needed because of: _vertices[0] = _vertices[i < count] + { + p2points.emplace_back(&p2pointsStorage.emplace_back((float)_vertices[i].x, (float)_vertices[i].y)); + } + p2t::CDT cdt(p2points); + cdt.Triangulate(); + std::vector tris = cdt.GetTriangles(); + + vertex_count += tris.size(); + for (auto&& t : tris) // use it later; only one calculate!!! + { + p2t::Point* vec1 = t->GetPoint(0); + p2t::Point* vec2 = t->GetPoint(1); + p2t::Point* vec3 = t->GetPoint(2); + + V2F_C4B_T2F_Triangle triangle = { + {Vec2(vec1->x, vec1->y), fillColor, Vec2::ZERO}, + {Vec2(vec2->x, vec2->y), fillColor, Vec2::ZERO}, + {Vec2(vec3->x, vec3->y), fillColor, Vec2::ZERO}, + }; + triangleList.emplace_back(triangle); // use it for drawing later + } + } + else if (fillColor.a > 0.0f) + { + vertex_count += count - 2; + } + + if (outline) + { + if (thickness != 1.0f || properties.drawOrder) + { + vertex_count += 6 * (count - 1); + } + else + { + vertex_count += 2 * count; + } + } + + vertex_count *= 3; + ensureCapacityTriangle(vertex_count); + V2F_C4B_T2F_Triangle* triangles = (V2F_C4B_T2F_Triangle*)(_bufferTriangle + _bufferCountTriangle); + + // start drawing... + int ii = 0; + if (closedPolygon && !isconvex && fillColor.a > 0.0f && !isConvex(_vertices, count) && count >= 3) + { + for (auto&& t : triangleList) + { + triangles[ii++] = t; + } + } + else if (fillColor.a > 0.0f) + { + for (unsigned int i = 0; i < count - 2; i++) + { + triangles[ii++] = { + {_vertices[0], fillColor, Vec2::ZERO}, + {_vertices[i + 1], fillColor, Vec2::ZERO}, + {_vertices[i + 2], fillColor, Vec2::ZERO}, + }; + } + } + if (outline) + { + if (thickness != 1.0f || properties.drawOrder) + { + thickness *= properties.factor; + + for (unsigned int i = 1; i < (count); i++) + { + Vec2 a = _vertices[i - 1]; + Vec2 b = _vertices[i]; + Vec2 n = ((b - a).getPerp()).getNormalized(); + Vec2 t = n.getPerp(); + Vec2 nw = n * thickness; + Vec2 tw = t * thickness; + Vec2 v0 = b - (nw + tw); + Vec2 v1 = b + (nw - tw); + Vec2 v2 = b - nw; + Vec2 v3 = b + nw; + Vec2 v4 = a - nw; + Vec2 v5 = a + nw; + Vec2 v6 = a - (nw - tw); + Vec2 v7 = a + (nw + tw); + + { + triangles[ii++] = { + {v0, borderColor, -(n + t)}, + {v1, borderColor, n - t}, + {v2, borderColor, -n}, + }; + triangles[ii++] = { + {v3, borderColor, n}, + {v1, borderColor, n - t}, + {v2, borderColor, -n}, + }; + } + + triangles[ii++] = { + {v3, borderColor, n}, + {v4, borderColor, -n}, + {v2, borderColor, -n}, + }; + triangles[ii++] = { + {v3, borderColor, n}, + {v4, borderColor, -n}, + {v5, borderColor, n}, + }; + + { + triangles[ii++] = { + {v6, borderColor, t - n}, + {v4, borderColor, -n}, + {v5, borderColor, n}, + }; + triangles[ii++] = { + {v6, borderColor, t - n}, + {v7, borderColor, t + n}, + {v5, borderColor, n}, + }; + } + } + } + else + { + struct ExtrudeVerts + { + Vec2 offset, n; + }; + struct ExtrudeVerts* extrude = _abuf.get(sizeof(struct ExtrudeVerts) * count); + + int closeCount = count - ((closedPolygon) ? 0 : 1); + for (unsigned int i = 0; i < count; i++) + { + Vec2 v0 = _vertices[(i - 1 + count) % count]; + Vec2 v1 = _vertices[i]; + Vec2 v2 = _vertices[(i + 1) % count]; + + Vec2 n1 = ((v1 - v0).getPerp()).getNormalized(); + Vec2 n2 = ((v2 - v1).getPerp()).getNormalized(); + + Vec2 offset = (n1 + n2) * (1.0f / (Vec2::dot(n1, n2) + 1.0f)); + extrude[i] = {offset, n2}; + } + + for (unsigned int i = 0; i < closeCount; i++) + { + int j = (i + 1) % count; + Vec2 v0 = _vertices[i]; + Vec2 v1 = _vertices[j]; + + Vec2 n0 = extrude[i].n; + + Vec2 offset0 = extrude[i].offset; + Vec2 offset1 = extrude[j].offset; + + Vec2 inner0 = v0 - offset0 * thickness; + Vec2 inner1 = v1 - offset1 * thickness; + Vec2 outer0 = v0 + offset0 * thickness; + Vec2 outer1 = v1 + offset1 * thickness; + + triangles[ii++] = {{inner0, borderColor, -n0}, {inner1, borderColor, -n0}, {outer1, borderColor, n0}}; + + triangles[ii++] = {{inner0, borderColor, -n0}, {outer0, borderColor, n0}, {outer1, borderColor, n0}}; + } + } + } + + _customCommandTriangle.updateVertexBuffer(triangles, _bufferCountTriangle * sizeof(V2F_C4B_T2F), + vertex_count * sizeof(V2F_C4B_T2F)); + _bufferCountTriangle += vertex_count; + _customCommandTriangle.setVertexDrawInfo(0, _bufferCountTriangle); + _dirtyTriangle = true; + + AX_SAFE_DELETE_ARRAY(_vertices); +} + +void DrawNode::_drawPoly(const Vec2* verts, + unsigned int count, + bool closedPolygon, + const Color4B& color, + float thickness, + bool isconvex) +{ + if (thickness == 1.0f && !properties.drawOrder) + { + Vec2* _vertices = _transform(verts, count); + + unsigned int vertex_count = (closedPolygon) ? 2 * count : 2 * (count - 1); + + ensureCapacityLine(vertex_count); + V2F_C4B_T2F* line = _bufferLine + _bufferCountLine; + + int ii = 0; + for (unsigned int i = 0; i < count - 1; i++) + { + line[ii++] = {_vertices[i], color, Vec2::ZERO}; + line[ii++] = {_vertices[i + 1], color, Vec2::ZERO}; + } + if (closedPolygon) + { + line[ii++] = {_vertices[count - 1], color, Vec2::ZERO}; + line[ii++] = line[0]; + } + + _customCommandLine.updateVertexBuffer(line, _bufferCountLine * sizeof(V2F_C4B_T2F), + vertex_count * sizeof(V2F_C4B_T2F)); + _bufferCountLine += vertex_count; + _customCommandLine.setVertexDrawInfo(0, _bufferCountLine); + + AX_SAFE_DELETE_ARRAY(_vertices); + } + else + { + _drawPolygon(verts, count, Color4B::TRANSPARENT, color, closedPolygon, thickness, isconvex); + } } + +void DrawNode::_drawSegment(const Vec2& from, + const Vec2& to, + const Color4B& color, + float thickness, + DrawNode::EndType etStart, + DrawNode::EndType etEnd) +{ + if (thickness == 1.0f && !properties.drawOrder) + { + unsigned int count = 2; + Vec2 aLine[] = {from, to}; + + Vec2* _vertices = _transform(aLine, count, false); + + ensureCapacityLine(count); + + V2F_C4B_T2F* line = _bufferLine + _bufferCountLine; + + line[0] = {_vertices[0], color, Vec2::ZERO}; + line[1] = {_vertices[1], color, Vec2::ZERO}; + + _customCommandLine.updateVertexBuffer(line, _bufferCountLine * sizeof(V2F_C4B_T2F), 2 * sizeof(V2F_C4B_T2F)); + _bufferCountLine += count; + _dirtyLine = true; + _customCommandLine.setVertexDrawInfo(0, _bufferCountLine); + + AX_SAFE_DELETE_ARRAY(_vertices); + return; + } + + unsigned int count = 2; + Vec2 line[] = {from, to}; + + Vec2* _vertices = _transform(line, count, false); + + Vec2 a = _vertices[0]; + Vec2 b = _vertices[1]; + Vec2 n = ((b - a).getPerp()).getNormalized(); + Vec2 t = n.getPerp(); + Vec2 nw = n * thickness; + Vec2 tw = t * thickness; + Vec2 v0 = b - (nw + tw); + Vec2 v1 = b + (nw - tw); + Vec2 v2 = b - nw; + Vec2 v3 = b + nw; + Vec2 v4 = a - nw; + Vec2 v5 = a + nw; + Vec2 v6 = a - (nw - tw); + Vec2 v7 = a + (nw + tw); + + unsigned int vertex_count = + 3 * ((etStart != DrawNode::EndType::Butt) ? 2 : 0) + 3 * 2 + 3 * ((etEnd != DrawNode::EndType::Butt) ? 2 : 0); + ensureCapacityTriangle(vertex_count); + V2F_C4B_T2F_Triangle* triangles = (V2F_C4B_T2F_Triangle*)(_bufferTriangle + _bufferCountTriangle); + + int ii = 0; + switch (etEnd) + { + case DrawNode::EndType::Butt: + break; + + case DrawNode::EndType::Square: + triangles[ii++] = { + {v0, color, Vec2::ZERO}, + {v1, color, -n}, + {v2, color, n}, + }; + + triangles[ii++] = { + {v3, color, n}, + {v1, color, Vec2::ZERO}, + {v2, color, -n}, + }; + + break; + case DrawNode::EndType::Round: + triangles[ii++] = { + {v0, color, -(n + t)}, + {v1, color, n - t}, + {v2, color, -n}, + }; + + triangles[ii++] = { + {v3, color, n}, + {v1, color, n - t}, + {v2, color, -n}, + }; + break; + + default: + break; + } + + // BODY + triangles[ii++] = { + {v3, color, n}, + {v4, color, -n}, + {v2, color, -n}, + }; + + triangles[ii++] = { + {v3, color, n}, + {v4, color, -n}, + {v5, color, n}, + }; + + switch (etStart) + { + case DrawNode::EndType::Butt: + break; + + case DrawNode::EndType::Square: + triangles[ii++] = { + {v6, color, Vec2::ZERO}, + {v4, color, -n}, + {v5, color, n}, + }; + + triangles[ii++] = { + {v6, color, -n}, + {v7, color, Vec2::ZERO}, + {v5, color, n}, + }; + break; + + case DrawNode::EndType::Round: + triangles[ii++] = { + {v6, color, t - n}, + {v4, color, -n}, + {v5, color, n}, + }; + + triangles[ii++] = { + {v6, color, t - n}, + {v7, color, t + n}, + {v5, color, n}, + }; + break; + + default: + break; + } + + _customCommandTriangle.updateVertexBuffer(triangles, _bufferCountTriangle * sizeof(V2F_C4B_T2F), + vertex_count * sizeof(V2F_C4B_T2F)); + _bufferCountTriangle += vertex_count; // ii * 3; + _dirtyTriangle = true; + _customCommandTriangle.setVertexDrawInfo(0, _bufferCountTriangle); + + AX_SAFE_DELETE_ARRAY(_vertices); +} + +void DrawNode::_drawDot(const Vec2& pos, float radius, const Color4B& color) +{ + unsigned int vertex_count = 2 * 3; + ensureCapacityTriangle(vertex_count); + + V2F_C4B_T2F a = {Vec2(pos.x - radius, pos.y - radius), color, Vec2(-1.0f, -1.0f)}; + V2F_C4B_T2F b = {Vec2(pos.x - radius, pos.y + radius), color, Vec2(-1.0f, 1.0f)}; + V2F_C4B_T2F c = {Vec2(pos.x + radius, pos.y + radius), color, Vec2(1.0f, 1.0f)}; + V2F_C4B_T2F d = {Vec2(pos.x + radius, pos.y - radius), color, Vec2(1.0f, -1.0f)}; + + V2F_C4B_T2F_Triangle* triangles = (V2F_C4B_T2F_Triangle*)(_bufferTriangle + _bufferCountTriangle); + triangles[0] = {a, b, c}; + triangles[1] = {a, c, d}; + + _customCommandTriangle.updateVertexBuffer(triangles, _bufferCountTriangle * sizeof(V2F_C4B_T2F), + vertex_count * sizeof(V2F_C4B_T2F)); + _bufferCountTriangle += vertex_count; + _dirtyTriangle = true; + _customCommandTriangle.setVertexDrawInfo(0, _bufferCountTriangle); +} + +void DrawNode::_drawCircle(const Vec2& center, + float radius, + float angle, + unsigned int segments, + bool drawLineToCenter, + float scaleX, + float scaleY, + const Color4B& borderColor, + const Color4B& fillColor, + bool solid, + float thickness) +{ + const float coef = 2.0f * (float)M_PI / segments; + + Vec2* _vertices = new Vec2[segments + 2]; + + for (unsigned int i = 0; i < segments; i++) + { + float rads = i * coef; + float j = radius * cosf(rads + angle) * scaleX + center.x; + float k = radius * sinf(rads + angle) * scaleY + center.y; + + _vertices[i].x = j; + _vertices[i].y = k; + } + _vertices[segments] = _vertices[0]; + + if (solid) + { + _drawPolygon(_vertices, segments, fillColor, borderColor, false, thickness, true); + } + else + { + if (drawLineToCenter) + _vertices[++segments] = center; + _drawPoly(_vertices, segments + 1, false, borderColor, thickness, true); + } + AX_SAFE_DELETE_ARRAY(_vertices); +} + +void DrawNode::_drawTriangle(const Vec2* _vertices3, + const Color4B& borderColor, + const Color4B& fillColor, + bool solid, + float thickness) +{ + unsigned int vertex_count = 3; + + if (thickness != 1.0f) + { + _drawPolygon(_vertices3, vertex_count, Color4B::BLUE, Color4B::BLUE, true, thickness, true); + } + else + { + Vec2* _vertices = _transform(_vertices3, vertex_count, false); + + ensureCapacityTriangle(vertex_count); + + V2F_C4B_T2F_Triangle* triangles = (V2F_C4B_T2F_Triangle*)(_bufferTriangle + _bufferCountTriangle); + triangles[0] = {{_vertices[0], fillColor, Vec2::ZERO}, + {_vertices[1], fillColor, Vec2::ZERO}, + {_vertices[2], fillColor, Vec2::ZERO}}; + + _customCommandTriangle.updateVertexBuffer(triangles, _bufferCountTriangle * sizeof(V2F_C4B_T2F), + vertex_count * sizeof(V2F_C4B_T2F)); + _bufferCountTriangle += vertex_count; + _dirtyTriangle = true; + _customCommandTriangle.setVertexDrawInfo(0, _bufferCountTriangle); + + AX_SAFE_DELETE_ARRAY(_vertices); + } +} + +void DrawNode::_drawAStar(const Vec2& center, + float radiusI, // inner + float radiusO, // outer + unsigned int segments, + const Color4B& color, + const Color4B& filledColor, + float thickness, + bool solid) +{ + const float coef = 2.0f * (float)M_PI / segments; + float halfAngle = coef / 2.0f; + + auto _vertices = _abuf.get(segments * 2 + 1); + + int i = 0; + for (unsigned int a = 0; a < segments; a++) + { + float rads = a * coef; + _vertices[i++] = Vec2(center.x + cos(rads) * radiusO, center.y + sin(rads) * radiusO); + _vertices[i++] = Vec2(center.x + cos(rads + halfAngle) * radiusI, center.y + sin(rads + halfAngle) * radiusI); + } + + if (solid) + { + _drawPolygon(_vertices, i, filledColor, color, true, thickness, false); + } + else + { + _vertices[i++] = _vertices[0]; + _drawPoly(_vertices, i, true, color, thickness, false); + } +} + +void DrawNode::_drawPoints(const Vec2* position, + unsigned int numberOfPoints, + const float pointSize, + const Color4B& color, + const DrawNode::PointType pointType) +{ + if (properties.drawOrder == true) + { + float pointSize4 = pointSize * 0.25f; + Vec2 vec2Size4 = Vec2(pointSize4, pointSize4); + for (unsigned int i = 0; i < numberOfPoints; i++) + { + switch (pointType) + { + case PointType::Circle: + { + _drawCircle(position[i], pointSize4, 90, 32, false, 1.0f, 1.0f, Color4B(), color, true); + break; + } + case PointType::Rect: + { + Vec2 origin = position[i] - vec2Size4; + Vec2 destination = position[i] + vec2Size4; + Vec2 _vertices[] = {origin, Vec2(destination.x, origin.y), destination, Vec2(origin.x, destination.y), + origin}; + _drawPolygon(_vertices, 5, color, color, false, 0.0f, true); + } + break; + default: + break; + } + } + return; + } + ensureCapacityPoint(numberOfPoints); + + V2F_C4B_T2F* point = _bufferPoint + _bufferCountPoint; + for (unsigned int i = 0; i < numberOfPoints; i++) + { + *(point + i) = {position[i], color, Vec2(pointSize, 0.0f)}; + } + + _customCommandPoint.updateVertexBuffer(point, _bufferCountPoint * sizeof(V2F_C4B_T2F), + numberOfPoints * sizeof(V2F_C4B_T2F)); + _bufferCountPoint += numberOfPoints; + _dirtyPoint = true; + _customCommandPoint.setVertexDrawInfo(0, _bufferCountPoint); +} + +void DrawNode::_drawPoint(const Vec2& position, + const float pointSize, + const Color4B& color, + const DrawNode::PointType pointType) +{ + if (properties.drawOrder == true) + { + float pointSize4 = pointSize * 0.25f; + Vec2 vec2Size4 = Vec2(pointSize4, pointSize4); + + switch (pointType) + { + case PointType::Circle: + { + _drawCircle(position, pointSize4, 90, 32, false, 1.0f, 1.0f, Color4B(), color, true); + break; + } + case PointType::Rect: + { + Vec2 origin = position - vec2Size4; + Vec2 destination = position + vec2Size4; + Vec2 _vertices[] = {origin, Vec2(destination.x, origin.y), destination, Vec2(origin.x, destination.y), + origin}; + _drawPolygon(_vertices, 5, color, color, false, 0.0f, true); + } + break; + default: + break; + } + + return; + } + + if (properties.drawOrder == true) + { + float pointSize4 = pointSize * 0.25f; + Vec2 origin = position - Vec2(pointSize4, pointSize4); + Vec2 destination = position + Vec2(pointSize4, pointSize4); + Vec2 _vertices[] = {origin, Vec2(destination.x, origin.y), destination, Vec2(origin.x, destination.y)}; + _drawPolygon(_vertices, 4, color, color, false, 0.0f, true); + } + else + { + ensureCapacityPoint(1); + + V2F_C4B_T2F* point = _bufferPoint + _bufferCountPoint; + *point = {position, color, Vec2(pointSize, 0.0f)}; + + _customCommandPoint.updateVertexBuffer(point, _bufferCountPoint * sizeof(V2F_C4B_T2F), sizeof(V2F_C4B_T2F)); + _bufferCountPoint += 1; + _dirtyPoint = true; + _customCommandPoint.setVertexDrawInfo(0, _bufferCountPoint); + } +} + +void DrawNode::_drawPie(const Vec2& center, + float radius, + float rotation, + int startAngle, + int endAngle, + float scaleX, + float scaleY, + const Color4B& fillColor, + const Color4B& borderColor, + DrawMode drawMode, + float thickness) +{ +#define DEGREES 360 + + // Not a real line! + if (startAngle == endAngle) + return; + + // Its a circle? + if (MAX((startAngle - endAngle), (endAngle - startAngle)) == DEGREES) + { + switch (drawMode) + { + case DrawMode::Fill: + _drawCircle(center, radius, 0.0f, 360, false, scaleX, scaleY, borderColor, fillColor, true, thickness); + break; + case DrawMode::Outline: + _drawCircle(center, radius, 0.0f, 360, false, scaleX, scaleY, borderColor, Color4B::TRANSPARENT, true, + thickness); + break; + case DrawMode::Line: + _drawCircle(center, radius, 0.0f, 360, false, scaleX, scaleY, borderColor, Color4B::TRANSPARENT, true, + thickness); + break; + case DrawMode::Semi: + _drawCircle(center, radius, 0.0f, 360, false, scaleX, scaleY, borderColor, fillColor, true, thickness); + break; + default: + break; + } + return; + } + else + { + const float coef = 2.0f * (float)M_PI / DEGREES; + + auto _vertices = _abuf.get(DEGREES + 2); + + int n = 0; + float rads = 0.0f; + float _angle = AX_DEGREES_TO_RADIANS(rotation); + + if (startAngle > endAngle) + { + std::swap(endAngle, startAngle); + } + + for (int i = 0; i <= DEGREES; i++) + { + if (startAngle <= i && endAngle >= i) + { + rads = i * coef; + + float j = radius * cosf(rads + _angle) * scaleX + center.x; + float k = radius * sinf(rads + _angle) * scaleY + center.y; + + _vertices[n].x = j; + _vertices[n].y = k; + n++; + } + } + switch (drawMode) + { + case DrawMode::Fill: + _vertices[n++] = center; + _vertices[n++] = _vertices[0]; + _drawPolygon(_vertices, n, fillColor, borderColor, true, thickness, false); + break; + case DrawMode::Outline: + _vertices[n++] = center; + _vertices[n++] = _vertices[0]; + _drawPolygon(_vertices, n, Color4B::TRANSPARENT, borderColor, false, thickness, false); + break; + case DrawMode::Line: + _drawPolygon(_vertices, n - 1, Color4B::TRANSPARENT, borderColor, false, thickness, false); + break; + case DrawMode::Semi: + _drawPolygon(_vertices, n - 1, fillColor, borderColor, true, thickness, false); + break; + default: + break; + } + } +} + +Vec2* DrawNode::_transform(const Vec2* _vertices, unsigned int& count, bool closedPolygon) +{ + Vec2 vert0 = _vertices[0]; + int closedCounter = 0; + + if (closedPolygon && _vertices[0] != _vertices[count - 1]) + { + closedCounter = 1; + } + + Vec2* vert = new Vec2[count + closedCounter]; + AXASSERT(vert != nullptr, "DrawNode::transform: NO MEMORY"); + + if (properties.transform == false) + { + memcpy(vert, _vertices, count * sizeof(Vec2)); + if (closedCounter) + { + vert[count++] = vert0; + } + return vert; + } + + const float sinRot = sin(properties.rotation); + const float cosRot = cos(properties.rotation); + + for (unsigned int i = 0; i < count; i++) + { + if (properties.rotation == 0.0f) + { + vert[i].x = _vertices[i].x * properties.scale.x + properties.position.x; + vert[i].y = _vertices[i].y * properties.scale.y + properties.position.y; + } + else // https://stackoverflow.com/questions/2259476/rotating-a-point-about-another-point-2d + { + + // translate point back to origin: + vert[i].x = _vertices[i].x - properties.center.x; + vert[i].y = _vertices[i].y - properties.center.y; + + // rotate point + float xnew = vert[i].x * cosRot - vert[i].y * sinRot; + float ynew = vert[i].x * sinRot + vert[i].y * cosRot; + + // translate point back: + vert[i].x = xnew + properties.center.x; + vert[i].y = ynew + properties.center.y; + + // scale and position + vert[i].x = vert[i].x * properties.scale.x + properties.position.x; + vert[i].y = vert[i].y * properties.scale.y + properties.position.y; + } + } + + if (closedCounter) + { + vert[count++] = vert[0]; + } + + return vert; +} + +#if defined(_WIN32) +# pragma pop_macro("TRANSPARENT") +#endif +} // namespace ax diff --git a/core/2d/DrawNode.h b/core/2d/DrawNode.h index 9685a7df56d3..d460c4264c31 100644 --- a/core/2d/DrawNode.h +++ b/core/2d/DrawNode.h @@ -30,8 +30,8 @@ * */ -#ifndef __CCDRAWNODES_CCDRAW_NODE_H__ -#define __CCDRAWNODES_CCDRAW_NODE_H__ +#ifndef __DRAW_NODE_H__ +#define __DRAW_NODE_H__ #include "2d/Node.h" #include "base/Types.h" @@ -45,6 +45,7 @@ namespace ax static const int DEFAULT_LINE_WIDTH = 2; class PointArray; + /** * @addtogroup _2d * @{ @@ -58,7 +59,6 @@ class PointArray; class AX_DLL DrawNode : public Node { public: - /** Different draw modus types. * *. @@ -71,11 +71,26 @@ class AX_DLL DrawNode : public Node Semi, }; + enum PointType + { + Circle, + Rect, + }; + + // See also example on https://www.angusj.com/clipper2/Docs/Units/Clipper/Types/EndType.htm + enum EndType + { + Square, + Round, + Butt, + }; + /** creates and initialize a DrawNode node. * * @return Return an autorelease object. */ static DrawNode* create(float defaultLineWidth = DEFAULT_LINE_WIDTH); + // DrawNode(); /** Draw a point. * @@ -84,7 +99,10 @@ class AX_DLL DrawNode : public Node * @param color The point color. * @js NA */ - void drawPoint(const Vec2& point, const float pointSize, const Color4B& color); + void drawPoint(const Vec2& point, + const float pointSize, + const Color4B& color, + DrawNode::PointType pointType = DrawNode::PointType::Rect); /** Draw a group point. * @@ -93,7 +111,10 @@ class AX_DLL DrawNode : public Node * @param color The point color. * @js NA */ - void drawPoints(const Vec2* position, unsigned int numberOfPoints, const Color4B& color); + void drawPoints(const Vec2* position, + unsigned int numberOfPoints, + const Color4B& color, + DrawNode::PointType pointType = DrawNode::PointType::Rect); /** Draw a group point. * @@ -103,7 +124,11 @@ class AX_DLL DrawNode : public Node * @param color The point color. * @js NA */ - void drawPoints(const Vec2* position, unsigned int numberOfPoints, const float pointSize, const Color4B& color); + void drawPoints(const Vec2* position, + unsigned int numberOfPoints, + const float pointSize, + const Color4B& color, + DrawNode::PointType pointType = DrawNode::PointType::Rect); /** Draw an line from origin to destination with color. * @@ -112,7 +137,12 @@ class AX_DLL DrawNode : public Node * @param color The line color. * @js NA */ - void drawLine(const Vec2& origin, const Vec2& destination, const Color4B& color); + void drawLine(const Vec2& origin, + const Vec2& destination, + const Color4B& color, + float thickness = 1.0f, + DrawNode::EndType etStart = DrawNode::EndType::Round, + DrawNode::EndType etEnd = DrawNode::EndType::Round); /** Draws a rectangle given the origin and destination point measured in points. * The origin and the destination can not have the same x and y coordinate. @@ -121,7 +151,7 @@ class AX_DLL DrawNode : public Node * @param destination The rectangle destination. * @param color The rectangle color. */ - void drawRect(const Vec2& origin, const Vec2& destination, const Color4B& color); + void drawRect(const Vec2& origin, const Vec2& destination, const Color4B& color, float thickness = 1.0f); /** Draws a polygon given a pointer to point coordinates and the number of vertices measured in points. * The polygon can be closed or open. @@ -131,7 +161,11 @@ class AX_DLL DrawNode : public Node * @param closePolygon The polygon can be closed or open. * @param color The polygon color. */ - void drawPoly(const Vec2* poli, unsigned int numberOfPoints, bool closePolygon, const Color4B& color); + void drawPoly(const Vec2* poli, + unsigned int numberOfPoints, + bool closedPolygon, + const Color4B& color, + float thickness = 1.0f); /** Draws a circle given the center, radius and number of segments. * @@ -143,7 +177,7 @@ class AX_DLL DrawNode : public Node * @param scaleX The scale value in x. * @param scaleY The scale value in y. * @param color Set the circle color. - * @param threshold (optional) Set the threshold which will be draws a better rendered polygon. + * @param thickness (default 1.0f) */ void drawCircle(const Vec2& center, float radius, @@ -153,7 +187,7 @@ class AX_DLL DrawNode : public Node float scaleX, float scaleY, const Color4B& color, - float threshold = 500); // 500 should "simulate/save" the backwards compatibility + float thickness = 1.0f); /** Draws a circle given the center, radius and number of segments. * @@ -163,7 +197,7 @@ class AX_DLL DrawNode : public Node * @param segments The number of segments. * @param drawLineToCenter Whether or not draw the line from the origin to center. * @param color Set the circle color. - * @param threshold (optional) Set the threshold which will be draws a better rendered polygon. + * @param thickness (default 1.0f) */ void drawCircle(const Vec2& center, float radius, @@ -171,7 +205,40 @@ class AX_DLL DrawNode : public Node unsigned int segments, bool drawLineToCenter, const Color4B& color, - float threshold = 500); // 500 should "simulate/save" the backwards compatibility + float thickness = 1.0f); + + /** Draws a star given the center, radiusI, radiusO and number of segments. + * + * @param center The circle center point. + * @param radiusI The inner radius. + * @param radiusO The outer radius. + * @param segments The number of segments. + * @param color Set the star color. + * @param thickness (default = 1.0f) + */ + void drawStar(const Vec2& center, + float radiusI, + float radiusO, + unsigned int segments, + const Color4B& color, + float thickness = 1.0f); + + /** Draws a solid star given the center, radiusI, radiusO and number of segments. + * + * @param center The circle center point. + * @param radiusI The inner radius. + * @param radiusO The outer radius. + * @param segments The number of segments. + * @param color Set the star color. + * @param thickness (default = 1.0f) + */ + void drawSolidStar(const Vec2& center, + float radiusI, + float radiusO, + unsigned int segments, + const Color4B& color, + const Color4B& filledColor, + float thickness = 1.0f); /** Draws a quad bezier path. * @@ -185,7 +252,8 @@ class AX_DLL DrawNode : public Node const Vec2& control, const Vec2& destination, unsigned int segments, - const Color4B& color); + const Color4B& color, + float thickness = 1.0f); /** Draw a cubic bezier curve with color and number of segments * @@ -201,7 +269,8 @@ class AX_DLL DrawNode : public Node const Vec2& control2, const Vec2& destination, unsigned int segments, - const Color4B& color); + const Color4B& color, + float thickness = 1.0f); /** Draws a Cardinal Spline path. * @@ -210,7 +279,11 @@ class AX_DLL DrawNode : public Node * @param segments The number of segments. * @param color Set the Spline color. */ - void drawCardinalSpline(PointArray* config, float tension, unsigned int segments, const Color4B& color); + void drawCardinalSpline(PointArray* config, + float tension, + unsigned int segments, + const Color4B& color, + float thickness = 1.0f); /** Draws a Catmull Rom path. * @@ -218,7 +291,7 @@ class AX_DLL DrawNode : public Node * @param segments The number of segments. * @param color The Catmull Rom color. */ - void drawCatmullRom(PointArray* points, unsigned int segments, const Color4B& color); + void drawCatmullRom(PointArray* points, unsigned int segments, const Color4B& color, float thickness = 1.0f); /** draw a dot at a position, with a given radius and color. * @@ -236,7 +309,12 @@ class AX_DLL DrawNode : public Node * @param p4 The rectangle vertex point. * @param color The rectangle color. */ - void drawRect(const Vec2& p1, const Vec2& p2, const Vec2& p3, const Vec2& p4, const Color4B& color); + void drawRect(const Vec2& p1, + const Vec2& p2, + const Vec2& p3, + const Vec2& p4, + const Color4B& color, + float thickness = 1.0f); /** Draws a solid rectangle given the origin and destination point measured in points. * The origin and the destination can not have the same x and y coordinate. @@ -246,7 +324,11 @@ class AX_DLL DrawNode : public Node * @param color The rectangle color. * @js NA */ - void drawSolidRect(const Vec2& origin, const Vec2& destination, const Color4B& color); + void drawSolidRect(const Vec2& origin, + const Vec2& destination, + const Color4B& color, + float thickness = 0, + const Color4B& borderColor = Color4B(0, 0, 0, 0)); /** Draws a solid polygon given a pointer to CGPoint coordinates, the number of vertices measured in points, and a * color. @@ -256,7 +338,12 @@ class AX_DLL DrawNode : public Node * @param color The solid polygon color. * @js NA */ - void drawSolidPoly(const Vec2* poli, unsigned int numberOfPoints, const Color4B& color); + void drawSolidPoly(const Vec2* poli, + unsigned int numberOfPoints, + const Color4B& color, + float thickness = 0, + const Color4B& borderColor = Color4B(0, 0, 0, 0), + bool isconvex = false); /** Draws a solid circle given the center, radius and number of segments. * @param center The circle center point. @@ -266,7 +353,7 @@ class AX_DLL DrawNode : public Node * @param scaleX The scale value in x. * @param scaleY The scale value in y. * @param fillColor The color will fill in polygon. - * @param borderWidth The border of line width. + * @param thickness The border of line width. * @param borderColor The border of line color. * @js NA */ @@ -277,7 +364,7 @@ class AX_DLL DrawNode : public Node float scaleX, float scaleY, const Color4B& fillColor, - float borderWidth, + float thickness, const Color4B& borderColor); /** Draws a solid circle given the center, radius and number of segments. @@ -306,13 +393,35 @@ class AX_DLL DrawNode : public Node * @param color The solid circle color. * @js NA */ - void drawSolidCircle(const Vec2& center, + void drawSolidCircle(const Vec2& center, float radius, float angle, unsigned int segments, const Color4B& color); + + /** Draws a pie given the center, radius, angle, start angle, end angle and number of segments. + * @param center The circle center point. + * @param radius The circle rotate of radius. + * @param angle The circle angle. + * @param startAngle The start angle. + * @param endAngle The end angle. + * @param scaleX The scale value in x. + * @param scaleY The scale value in y. + * @param fillColor The solid circle color. + * @param borderColor The borderColor. + * @param DrawMode The draw mode + * @js NA + */ + void drawPie(const Vec2& center, float radius, - float angle, - unsigned int segments, - const Color4B& color); + float rotation, + int startAngle, + int endAngle, + float scaleX, + float scaleY, + const Color4B& fillColor, + const Color4B& borderColor, + DrawMode drawMode = DrawMode::Outline, + float thickness = 1.0f); - /** Draws a pie given the center, radius, angle, start angle, end angle and number of segments. + // Cocos2dx/Axmol 1.0 API backwards compatibhility + /** Draws a pie given the center, radius, angle, start angle, end angle and number of segments. * @param center The circle center point. * @param radius The circle rotate of radius. * @param angle The circle angle. @@ -332,16 +441,27 @@ class AX_DLL DrawNode : public Node float scaleX, float scaleY, const Color4B& color, - DrawMode drawMode); + DrawMode drawMode = DrawMode::Outline); + + void setIsConvex(bool isConvex) + { + AXLOGW("'setIsConvex()' No longer supported. Use the new drawPolygon API."); + }; + - /** draw a segment with a radius and color. + /** draw a segment with a radius and color. * * @param from The segment origin. * @param to The segment destination. * @param radius The segment radius. * @param color The segment color. */ - void drawSegment(const Vec2& from, const Vec2& to, float radius, const Color4B& color); + void drawSegment(const Vec2& from, + const Vec2& to, + float radius, + const Color4B& color, + DrawNode::EndType etStart = DrawNode::EndType::Round, + DrawNode::EndType etEnd = DrawNode::EndType::Round); /** draw a polygon with a fill color and line color * @code @@ -352,15 +472,25 @@ class AX_DLL DrawNode : public Node * @param verts A pointer to point coordinates. * @param count The number of verts measured in points. * @param fillColor The color will fill in polygon. - * @param borderWidth The border of line width. + * @param thickness The border of line width. * @param borderColor The border of line color. * @js NA */ - void drawPolygon(const Vec2* verts, + void drawPolygon(Vec2* verts, int count, const Color4B& fillColor, - float borderWidth, - const Color4B& borderColor); + float thickness, + const Color4B& borderColor, + bool isconvex = false); + + void drawPolygon(Vec2* verts, int count, float thickness, const Color4B& borderColor, bool isconvex = false); + + void drawSolidPolygon(Vec2* verts, + int count, + const Color4B& fillColor, + float thickness, + const Color4B& borderColor, + bool isconvex = false); /** draw a triangle with color. * @@ -371,7 +501,21 @@ class AX_DLL DrawNode : public Node * @js NA */ - void drawTriangle(const Vec2& p1, const Vec2& p2, const Vec2& p3, const Color4B& color); + void drawTriangle(const Vec2* vertices3, const Color4B& color, float thickness = 1.0f); + + void drawTriangle(const Vec2& p1, const Vec2& p2, const Vec2& p3, const Color4B& color, float thickness = 1.0f); + + void drawSolidTriangle(const Vec2* vertices3, + const Color4B& fillColor, + const Color4B& borderColor, + float thickness = 1.0f); + + void drawSolidTriangle(const Vec2& p1, + const Vec2& p2, + const Vec2& p3, + const Color4B& fillColor, + const Color4B& borderColor, + float thickness = 1.0f); /** Clear the geometry in the node's buffer. */ void clear(); @@ -394,12 +538,9 @@ class AX_DLL DrawNode : public Node virtual void visit(Renderer* renderer, const Mat4& parentTransform, uint32_t parentFlags) override; void setLineWidth(float lineWidth); - // Get CocosStudio guide lines width. float getLineWidth(); - void setIsConvex(bool isConvex) { _isConvex = isConvex; }; // Set backwards compatible with axmol 2.0 - /** * When isolated is set, the position of the node is no longer affected by parent nodes. * Which means it will be drawn just like a root node. @@ -413,9 +554,9 @@ class AX_DLL DrawNode : public Node virtual bool init() override; protected: - void ensureCapacity(int count); - void ensureCapacityGLPoint(int count); - void ensureCapacityGLLine(int count); + void ensureCapacityTriangle(int count); + void ensureCapacityPoint(int count); + void ensureCapacityLine(int count); void updateShader(); void updateShaderInternal(CustomCommand& cmd, @@ -432,38 +573,249 @@ class AX_DLL DrawNode : public Node int _bufferCapacityTriangle = 0; int _bufferCountTriangle = 0; V2F_C4B_T2F* _bufferTriangle = nullptr; + CustomCommand _customCommandTriangle; + bool _dirtyTriangle = false; int _bufferCapacityPoint = 0; int _bufferCountPoint = 0; V2F_C4B_T2F* _bufferPoint = nullptr; - Color4F _pointColor; + Color4B _pointColor; int _pointSize = 0; int _bufferCapacityLine = 0; int _bufferCountLine = 0; V2F_C4B_T2F* _bufferLine = nullptr; - BlendFunc _blendFunc; - - CustomCommand _customCommandTriangle; CustomCommand _customCommandPoint; CustomCommand _customCommandLine; + bool _dirtyPoint = false; + bool _dirtyLine = false; + + BlendFunc _blendFunc; - bool _dirtyTriangle = false; - bool _dirtyPoint = false; - bool _dirtyLine = false; bool _isolated = false; - float _lineWidth = 0.0f; - float _defaultLineWidth = 0.0f; + float _lineWidth = 1.0f; + float _defaultLineWidth = 1.0f; - ax::any_buffer _abuf; + any_buffer _abuf; - bool _isConvex = true; +private: + // Internal function _drawPoint + void _drawPoint(const Vec2& position, + const float pointSize, + const Color4B& color, + const DrawNode::PointType pointType); + + // Internal function _drawPoints + void _drawPoints(const Vec2* position, + unsigned int numberOfPoints, + const float pointSize, + const Color4B& color, + const DrawNode::PointType pointType); + + // Internal function _drawDot + void _drawDot(const Vec2& pos, float radius, const Color4B& color); + + // Internal function _drawTriangle + void _drawTriangle(const Vec2* vertices3, + const Color4B& borderColor, + const Color4B& fillColor, + bool solid = true, + float thickness = 0.0f); + + // Internal function _drawAStar + void _drawAStar(const Vec2& center, + float radiusI, + float radiusO, + unsigned int segments, + const Color4B& color, + const Color4B& filledColor, + float thickness = 1.0f, + bool solid = false); + + // Internal function _drawPoly + void _drawPoly(const Vec2* poli, + unsigned int numberOfPoints, + bool closedPolygon, + const Color4B& color, + float thickness = 1.0f, + bool isconvex = true); + + // Internal function _drawPolygon + void _drawPolygon(const Vec2* verts, + unsigned int count, + const Color4B& fillColor, + const Color4B& borderColor, + bool closedPolygon = true, + float thickness = 1.0f, + bool isconvex = true); + + // Internal function _drawSegment + void _drawSegment(const Vec2& origin, + const Vec2& destination, + const Color4B& color, + float thickness = 1.0f, + DrawNode::EndType etStart = DrawNode::EndType::Square, + DrawNode::EndType etEnd = DrawNode::EndType::Square); + + // Internal function _drawCircle + void _drawCircle(const Vec2& center, + float radius, + float angle, + unsigned int segments, + bool drawLineToCenter, + float scaleX, + float scaleY, + const Color4B& borderColor, + const Color4B& fillColor, + bool solid, + float thickness = 1.0f); + + // Internal function _drawPie + void _drawPie(const Vec2& center, + float radius, + float rotation, + int startAngle, + int endAngle, + float scaleX, + float scaleY, + const Color4B& fillColor, + const Color4B& borderColor, + DrawMode drawMode, + float thickness = 1.0f); + + /* Internal function _transform + * @param vertices A Vec2 vertices list. + * @param count The number of vertices. + * @param closedPolygon The closedPolygon flag. + * @js NA + */ + Vec2* _transform(const Vec2* vertices, unsigned int& count, bool closedPolygon = false); private: AX_DISALLOW_COPY_AND_ASSIGN(DrawNode); + +public: + class Properties + { + public: + float factor = 0.5f; /// set the lineWidth like Axmol 1.0 + + // transforming stuff + Vec2 scale; + Vec2 center; + float rotation; + Vec2 position; + + // Thickness stuff + float lineWidth; + float defaultLineWidth = 1.0f; + + // Drawing flags + bool transform = true; + bool drawOrder = false; + + /** Set the DrawNode drawOrder + * + * @param drawOrder. true/false = On/Off + * Its for performance there + * false = cocos2dx behaviour => faster but works only on 1.0f thickness + + * @js NA + */ + void setDrawOrder(bool dO) { drawOrder = dO; }; + + /** Get the DrawNode drawOrder + * + * @js NA + */ + bool getDrawOrder(void) { return drawOrder; }; + + /** Set the DrawNode transform + * + * @param transform. true/false = On/Off + * + * @js NA + */ + void setTransform(bool t) { transform = t; }; + + /** Get the DrawNode transform + * + * @js NA + */ + bool getTransform(void) { return transform; }; + + /** Set the DrawNode scale for each drawing primitive after this. + + * @js NA + */ + void setScale(Vec2 s) { scale = s; }; + + /** Set the DrawNode rotation for each drawing primitive after this. + + * @js NA + */ + void setRotation(float r) { rotation = r; }; + + /** Get the DrawNode rotation for each drawing primitive after this. + + * @js NA + */ + float getRotation() { return rotation; }; + + /** Set the DrawNode center of rotation for each drawing primitive after this. + + * @js NA + */ + void setCenter(Vec2 c) { center = c; }; + + /** Get the DrawNode center of rotation for each drawing primitive after this. + + * @js NA + */ + Vec2 getCenter() { return center; }; + + /** Set the DrawNode position for each drawing primitive after this. + + * @js NA + */ + void setPosition(Vec2 p) { position = p; }; + + /** Get the DrawNode position for drawing primitive. + + * @js NA + */ + Vec2 getPosition() { return position; }; + + /** Set the DrawNode line width for each drawing primitive after this. + + * @js NA + */ + void setLineWidth(float lw) { lineWidth = lw; }; + + /** Get the DrawNode line width for each drawing primitive after this. + + * @js NA + */ + float getLineWidth() { return lineWidth; }; + + /** Set all default DrawNode properties. + + * @js NA + */ + void setDefaultValues() + { + scale = Vec2(1.0f, 1.0f); + center = Vec2(0.0f, 0.0f); + rotation = 0.0f; + position = Vec2(0.0f, 0.0f); + lineWidth = 1.0f; + drawOrder = false; + }; + } properties; }; + /** @} */ -} +} // namespace ax -#endif // __CCDRAWNODES_CCDRAW_NODE_H__ +#endif // __DRAW_NODE_EX_H__ diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index ee53a6ec5449..abbd1d8be9b5 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -139,8 +139,6 @@ cmake_dependent_option(AX_ENABLE_EXT_SDFGEN "Build extension SDFGen" ${AX_EXT_HI option(AX_ENABLE_EXT_JSONDEFAULT "Build extension JSONDefault" ${AX_EXT_HINT}) -option(AX_ENABLE_EXT_DRAWNODEEX "Build extension DrawNodeEx" ${AX_EXT_HINT}) - set(_AX_THIRDPARTY_NAME "3rdparty" CACHE INTERNAL "" ) if (WIN32) diff --git a/extensions/CMakeLists.txt b/extensions/CMakeLists.txt index 9aea9854f31c..6ba7be79c8a2 100644 --- a/extensions/CMakeLists.txt +++ b/extensions/CMakeLists.txt @@ -127,8 +127,4 @@ if(AX_ENABLE_EXT_JSONDEFAULT) add_subdirectory(JSONDefault) endif() -if(AX_ENABLE_EXT_DRAWNODEEX) - add_subdirectory(DrawNodeEx) -endif() - message(STATUS "Enabled ${_AX_CORE_LIB} extensions:${_AX_EXTENSION_LIBS}") diff --git a/extensions/DrawNodeEx/CMakeLists.txt b/extensions/DrawNodeEx/CMakeLists.txt deleted file mode 100644 index f04c814bbd43..000000000000 --- a/extensions/DrawNodeEx/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -set(target_name DrawNodeEx) - -FILE(GLOB_RECURSE DRAWNODEEX_SOURCES *.h;*.cpp;./**/*.h;./**/*.cpp) - -add_library(${target_name} ${DRAWNODEEX_SOURCES}) -target_include_directories(${target_name} PUBLIC src) - -setup_ax_extension_config(${target_name}) diff --git a/extensions/README.md b/extensions/README.md index 569601fe5895..5c58e3bc8c8d 100644 --- a/extensions/README.md +++ b/extensions/README.md @@ -5,11 +5,6 @@ - Version: 4.5 - License: MIT -## DrawNodeEx => DrawNodeV2 -- Upstream: https://github.com/axmolengine/axmol -- Version: 0.95.1 -- License: MIT - ## Effekseer (OFF default) - [![Upstream](https://img.shields.io/github/v/release/effekseer/Effekseer?label=Upstream)](https://github.com/effekseer/EffekseerForCocos2d-x) - https://github.com/effekseer/EffekseerForCocos2d-x diff --git a/extensions/scripting/lua-bindings/auto/axlua_base_auto.cpp b/extensions/scripting/lua-bindings/auto/axlua_base_auto.cpp index 2242dc5641f7..3ada4dc9ee78 100644 --- a/extensions/scripting/lua-bindings/auto/axlua_base_auto.cpp +++ b/extensions/scripting/lua-bindings/auto/axlua_base_auto.cpp @@ -51690,6 +51690,29 @@ int lua_ax_base_DrawNode_drawPoint(lua_State* tolua_S) lua_settop(tolua_S, 1); return 1; } + if (argc == 4) + { + ax::Vec2 arg0; + double arg1; + ax::Color4B arg2; + ax::DrawNode::PointType arg3; + + ok &= luaval_to_vec2(tolua_S, 2, &arg0, "ax.DrawNode:drawPoint"); + + ok &= luaval_to_number(tolua_S, 3,&arg1, "ax.DrawNode:drawPoint"); + + ok &=luaval_to_color4b(tolua_S, 4, &arg2, "ax.DrawNode:drawPoint"); + + ok &= luaval_to_int32(tolua_S, 5,(int *)&arg3, "ax.DrawNode:drawPoint"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_ax_base_DrawNode_drawPoint'", nullptr); + return 0; + } + cobj->drawPoint(arg0, arg1, arg2, arg3); + lua_settop(tolua_S, 1); + return 1; + } luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ax.DrawNode:drawPoint",argc, 3); return 0; @@ -51746,6 +51769,84 @@ int lua_ax_base_DrawNode_drawLine(lua_State* tolua_S) lua_settop(tolua_S, 1); return 1; } + if (argc == 4) + { + ax::Vec2 arg0; + ax::Vec2 arg1; + ax::Color4B arg2; + double arg3; + + ok &= luaval_to_vec2(tolua_S, 2, &arg0, "ax.DrawNode:drawLine"); + + ok &= luaval_to_vec2(tolua_S, 3, &arg1, "ax.DrawNode:drawLine"); + + ok &=luaval_to_color4b(tolua_S, 4, &arg2, "ax.DrawNode:drawLine"); + + ok &= luaval_to_number(tolua_S, 5,&arg3, "ax.DrawNode:drawLine"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_ax_base_DrawNode_drawLine'", nullptr); + return 0; + } + cobj->drawLine(arg0, arg1, arg2, arg3); + lua_settop(tolua_S, 1); + return 1; + } + if (argc == 5) + { + ax::Vec2 arg0; + ax::Vec2 arg1; + ax::Color4B arg2; + double arg3; + ax::DrawNode::EndType arg4; + + ok &= luaval_to_vec2(tolua_S, 2, &arg0, "ax.DrawNode:drawLine"); + + ok &= luaval_to_vec2(tolua_S, 3, &arg1, "ax.DrawNode:drawLine"); + + ok &=luaval_to_color4b(tolua_S, 4, &arg2, "ax.DrawNode:drawLine"); + + ok &= luaval_to_number(tolua_S, 5,&arg3, "ax.DrawNode:drawLine"); + + ok &= luaval_to_int32(tolua_S, 6,(int *)&arg4, "ax.DrawNode:drawLine"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_ax_base_DrawNode_drawLine'", nullptr); + return 0; + } + cobj->drawLine(arg0, arg1, arg2, arg3, arg4); + lua_settop(tolua_S, 1); + return 1; + } + if (argc == 6) + { + ax::Vec2 arg0; + ax::Vec2 arg1; + ax::Color4B arg2; + double arg3; + ax::DrawNode::EndType arg4; + ax::DrawNode::EndType arg5; + + ok &= luaval_to_vec2(tolua_S, 2, &arg0, "ax.DrawNode:drawLine"); + + ok &= luaval_to_vec2(tolua_S, 3, &arg1, "ax.DrawNode:drawLine"); + + ok &=luaval_to_color4b(tolua_S, 4, &arg2, "ax.DrawNode:drawLine"); + + ok &= luaval_to_number(tolua_S, 5,&arg3, "ax.DrawNode:drawLine"); + + ok &= luaval_to_int32(tolua_S, 6,(int *)&arg4, "ax.DrawNode:drawLine"); + + ok &= luaval_to_int32(tolua_S, 7,(int *)&arg5, "ax.DrawNode:drawLine"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_ax_base_DrawNode_drawLine'", nullptr); + return 0; + } + cobj->drawLine(arg0, arg1, arg2, arg3, arg4, arg5); + lua_settop(tolua_S, 1); + return 1; + } luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ax.DrawNode:drawLine",argc, 3); return 0; @@ -51805,6 +51906,38 @@ int lua_ax_base_DrawNode_drawRect(lua_State* tolua_S) } }while(0); ok = true; + do{ + if (argc == 6) { + ax::Vec2 arg0; + ok &= luaval_to_vec2(tolua_S, 2, &arg0, "ax.DrawNode:drawRect"); + + if (!ok) { break; } + ax::Vec2 arg1; + ok &= luaval_to_vec2(tolua_S, 3, &arg1, "ax.DrawNode:drawRect"); + + if (!ok) { break; } + ax::Vec2 arg2; + ok &= luaval_to_vec2(tolua_S, 4, &arg2, "ax.DrawNode:drawRect"); + + if (!ok) { break; } + ax::Vec2 arg3; + ok &= luaval_to_vec2(tolua_S, 5, &arg3, "ax.DrawNode:drawRect"); + + if (!ok) { break; } + ax::Color4B arg4; + ok &=luaval_to_color4b(tolua_S, 6, &arg4, "ax.DrawNode:drawRect"); + + if (!ok) { break; } + double arg5; + ok &= luaval_to_number(tolua_S, 7,&arg5, "ax.DrawNode:drawRect"); + + if (!ok) { break; } + cobj->drawRect(arg0, arg1, arg2, arg3, arg4, arg5); + lua_settop(tolua_S, 1); + return 1; + } + }while(0); + ok = true; do{ if (argc == 3) { ax::Vec2 arg0; @@ -51825,6 +51958,30 @@ int lua_ax_base_DrawNode_drawRect(lua_State* tolua_S) } }while(0); ok = true; + do{ + if (argc == 4) { + ax::Vec2 arg0; + ok &= luaval_to_vec2(tolua_S, 2, &arg0, "ax.DrawNode:drawRect"); + + if (!ok) { break; } + ax::Vec2 arg1; + ok &= luaval_to_vec2(tolua_S, 3, &arg1, "ax.DrawNode:drawRect"); + + if (!ok) { break; } + ax::Color4B arg2; + ok &=luaval_to_color4b(tolua_S, 4, &arg2, "ax.DrawNode:drawRect"); + + if (!ok) { break; } + double arg3; + ok &= luaval_to_number(tolua_S, 5,&arg3, "ax.DrawNode:drawRect"); + + if (!ok) { break; } + cobj->drawRect(arg0, arg1, arg2, arg3); + lua_settop(tolua_S, 1); + return 1; + } + }while(0); + ok = true; luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ax.DrawNode:drawRect",argc, 3); return 0; @@ -52018,7 +52175,7 @@ int lua_ax_base_DrawNode_drawCircle(lua_State* tolua_S) return 0; } -int lua_ax_base_DrawNode_drawQuadBezier(lua_State* tolua_S) +int lua_ax_base_DrawNode_drawStar(lua_State* tolua_S) { int argc = 0; ax::DrawNode* cobj = nullptr; @@ -52038,7 +52195,7 @@ int lua_ax_base_DrawNode_drawQuadBezier(lua_State* tolua_S) #if _AX_DEBUG >= 1 if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_ax_base_DrawNode_drawQuadBezier'", nullptr); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_ax_base_DrawNode_drawStar'", nullptr); return 0; } #endif @@ -52047,40 +52204,69 @@ int lua_ax_base_DrawNode_drawQuadBezier(lua_State* tolua_S) if (argc == 5) { ax::Vec2 arg0; - ax::Vec2 arg1; - ax::Vec2 arg2; + double arg1; + double arg2; unsigned int arg3; ax::Color4B arg4; - ok &= luaval_to_vec2(tolua_S, 2, &arg0, "ax.DrawNode:drawQuadBezier"); + ok &= luaval_to_vec2(tolua_S, 2, &arg0, "ax.DrawNode:drawStar"); - ok &= luaval_to_vec2(tolua_S, 3, &arg1, "ax.DrawNode:drawQuadBezier"); + ok &= luaval_to_number(tolua_S, 3,&arg1, "ax.DrawNode:drawStar"); - ok &= luaval_to_vec2(tolua_S, 4, &arg2, "ax.DrawNode:drawQuadBezier"); + ok &= luaval_to_number(tolua_S, 4,&arg2, "ax.DrawNode:drawStar"); - ok &= luaval_to_uint32(tolua_S, 5,&arg3, "ax.DrawNode:drawQuadBezier"); + ok &= luaval_to_uint32(tolua_S, 5,&arg3, "ax.DrawNode:drawStar"); - ok &=luaval_to_color4b(tolua_S, 6, &arg4, "ax.DrawNode:drawQuadBezier"); + ok &=luaval_to_color4b(tolua_S, 6, &arg4, "ax.DrawNode:drawStar"); if(!ok) { - tolua_error(tolua_S,"invalid arguments in function 'lua_ax_base_DrawNode_drawQuadBezier'", nullptr); + tolua_error(tolua_S,"invalid arguments in function 'lua_ax_base_DrawNode_drawStar'", nullptr); return 0; } - cobj->drawQuadBezier(arg0, arg1, arg2, arg3, arg4); + cobj->drawStar(arg0, arg1, arg2, arg3, arg4); lua_settop(tolua_S, 1); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ax.DrawNode:drawQuadBezier",argc, 5); + if (argc == 6) + { + ax::Vec2 arg0; + double arg1; + double arg2; + unsigned int arg3; + ax::Color4B arg4; + double arg5; + + ok &= luaval_to_vec2(tolua_S, 2, &arg0, "ax.DrawNode:drawStar"); + + ok &= luaval_to_number(tolua_S, 3,&arg1, "ax.DrawNode:drawStar"); + + ok &= luaval_to_number(tolua_S, 4,&arg2, "ax.DrawNode:drawStar"); + + ok &= luaval_to_uint32(tolua_S, 5,&arg3, "ax.DrawNode:drawStar"); + + ok &=luaval_to_color4b(tolua_S, 6, &arg4, "ax.DrawNode:drawStar"); + + ok &= luaval_to_number(tolua_S, 7,&arg5, "ax.DrawNode:drawStar"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_ax_base_DrawNode_drawStar'", nullptr); + return 0; + } + cobj->drawStar(arg0, arg1, arg2, arg3, arg4, arg5); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ax.DrawNode:drawStar",argc, 5); return 0; #if _AX_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_ax_base_DrawNode_drawQuadBezier'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'lua_ax_base_DrawNode_drawStar'.",&tolua_err); #endif return 0; } -int lua_ax_base_DrawNode_drawCubicBezier(lua_State* tolua_S) +int lua_ax_base_DrawNode_drawSolidStar(lua_State* tolua_S) { int argc = 0; ax::DrawNode* cobj = nullptr; @@ -52100,7 +52286,7 @@ int lua_ax_base_DrawNode_drawCubicBezier(lua_State* tolua_S) #if _AX_DEBUG >= 1 if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_ax_base_DrawNode_drawCubicBezier'", nullptr); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_ax_base_DrawNode_drawSolidStar'", nullptr); return 0; } #endif @@ -52109,99 +52295,75 @@ int lua_ax_base_DrawNode_drawCubicBezier(lua_State* tolua_S) if (argc == 6) { ax::Vec2 arg0; - ax::Vec2 arg1; - ax::Vec2 arg2; - ax::Vec2 arg3; - unsigned int arg4; + double arg1; + double arg2; + unsigned int arg3; + ax::Color4B arg4; ax::Color4B arg5; - ok &= luaval_to_vec2(tolua_S, 2, &arg0, "ax.DrawNode:drawCubicBezier"); + ok &= luaval_to_vec2(tolua_S, 2, &arg0, "ax.DrawNode:drawSolidStar"); - ok &= luaval_to_vec2(tolua_S, 3, &arg1, "ax.DrawNode:drawCubicBezier"); + ok &= luaval_to_number(tolua_S, 3,&arg1, "ax.DrawNode:drawSolidStar"); - ok &= luaval_to_vec2(tolua_S, 4, &arg2, "ax.DrawNode:drawCubicBezier"); + ok &= luaval_to_number(tolua_S, 4,&arg2, "ax.DrawNode:drawSolidStar"); - ok &= luaval_to_vec2(tolua_S, 5, &arg3, "ax.DrawNode:drawCubicBezier"); + ok &= luaval_to_uint32(tolua_S, 5,&arg3, "ax.DrawNode:drawSolidStar"); - ok &= luaval_to_uint32(tolua_S, 6,&arg4, "ax.DrawNode:drawCubicBezier"); + ok &=luaval_to_color4b(tolua_S, 6, &arg4, "ax.DrawNode:drawSolidStar"); - ok &=luaval_to_color4b(tolua_S, 7, &arg5, "ax.DrawNode:drawCubicBezier"); + ok &=luaval_to_color4b(tolua_S, 7, &arg5, "ax.DrawNode:drawSolidStar"); if(!ok) { - tolua_error(tolua_S,"invalid arguments in function 'lua_ax_base_DrawNode_drawCubicBezier'", nullptr); + tolua_error(tolua_S,"invalid arguments in function 'lua_ax_base_DrawNode_drawSolidStar'", nullptr); return 0; } - cobj->drawCubicBezier(arg0, arg1, arg2, arg3, arg4, arg5); + cobj->drawSolidStar(arg0, arg1, arg2, arg3, arg4, arg5); lua_settop(tolua_S, 1); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ax.DrawNode:drawCubicBezier",argc, 6); - return 0; - -#if _AX_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_ax_base_DrawNode_drawCubicBezier'.",&tolua_err); -#endif - - return 0; -} -int lua_ax_base_DrawNode_drawDot(lua_State* tolua_S) -{ - int argc = 0; - ax::DrawNode* cobj = nullptr; - bool ok = true; - -#if _AX_DEBUG >= 1 - tolua_Error tolua_err; -#endif - + if (argc == 7) + { + ax::Vec2 arg0; + double arg1; + double arg2; + unsigned int arg3; + ax::Color4B arg4; + ax::Color4B arg5; + double arg6; -#if _AX_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ax.DrawNode",0,&tolua_err)) goto tolua_lerror; -#endif + ok &= luaval_to_vec2(tolua_S, 2, &arg0, "ax.DrawNode:drawSolidStar"); - cobj = (ax::DrawNode*)tolua_tousertype(tolua_S,1,0); + ok &= luaval_to_number(tolua_S, 3,&arg1, "ax.DrawNode:drawSolidStar"); -#if _AX_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_ax_base_DrawNode_drawDot'", nullptr); - return 0; - } -#endif + ok &= luaval_to_number(tolua_S, 4,&arg2, "ax.DrawNode:drawSolidStar"); - argc = lua_gettop(tolua_S)-1; - if (argc == 3) - { - ax::Vec2 arg0; - double arg1; - ax::Color4B arg2; + ok &= luaval_to_uint32(tolua_S, 5,&arg3, "ax.DrawNode:drawSolidStar"); - ok &= luaval_to_vec2(tolua_S, 2, &arg0, "ax.DrawNode:drawDot"); + ok &=luaval_to_color4b(tolua_S, 6, &arg4, "ax.DrawNode:drawSolidStar"); - ok &= luaval_to_number(tolua_S, 3,&arg1, "ax.DrawNode:drawDot"); + ok &=luaval_to_color4b(tolua_S, 7, &arg5, "ax.DrawNode:drawSolidStar"); - ok &=luaval_to_color4b(tolua_S, 4, &arg2, "ax.DrawNode:drawDot"); + ok &= luaval_to_number(tolua_S, 8,&arg6, "ax.DrawNode:drawSolidStar"); if(!ok) { - tolua_error(tolua_S,"invalid arguments in function 'lua_ax_base_DrawNode_drawDot'", nullptr); + tolua_error(tolua_S,"invalid arguments in function 'lua_ax_base_DrawNode_drawSolidStar'", nullptr); return 0; } - cobj->drawDot(arg0, arg1, arg2); + cobj->drawSolidStar(arg0, arg1, arg2, arg3, arg4, arg5, arg6); lua_settop(tolua_S, 1); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ax.DrawNode:drawDot",argc, 3); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ax.DrawNode:drawSolidStar",argc, 6); return 0; #if _AX_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_ax_base_DrawNode_drawDot'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'lua_ax_base_DrawNode_drawSolidStar'.",&tolua_err); #endif return 0; } -int lua_ax_base_DrawNode_drawSolidRect(lua_State* tolua_S) +int lua_ax_base_DrawNode_drawQuadBezier(lua_State* tolua_S) { int argc = 0; ax::DrawNode* cobj = nullptr; @@ -52221,19 +52383,263 @@ int lua_ax_base_DrawNode_drawSolidRect(lua_State* tolua_S) #if _AX_DEBUG >= 1 if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_ax_base_DrawNode_drawSolidRect'", nullptr); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_ax_base_DrawNode_drawQuadBezier'", nullptr); return 0; } #endif argc = lua_gettop(tolua_S)-1; - if (argc == 3) + if (argc == 5) { ax::Vec2 arg0; ax::Vec2 arg1; - ax::Color4B arg2; + ax::Vec2 arg2; + unsigned int arg3; + ax::Color4B arg4; - ok &= luaval_to_vec2(tolua_S, 2, &arg0, "ax.DrawNode:drawSolidRect"); + ok &= luaval_to_vec2(tolua_S, 2, &arg0, "ax.DrawNode:drawQuadBezier"); + + ok &= luaval_to_vec2(tolua_S, 3, &arg1, "ax.DrawNode:drawQuadBezier"); + + ok &= luaval_to_vec2(tolua_S, 4, &arg2, "ax.DrawNode:drawQuadBezier"); + + ok &= luaval_to_uint32(tolua_S, 5,&arg3, "ax.DrawNode:drawQuadBezier"); + + ok &=luaval_to_color4b(tolua_S, 6, &arg4, "ax.DrawNode:drawQuadBezier"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_ax_base_DrawNode_drawQuadBezier'", nullptr); + return 0; + } + cobj->drawQuadBezier(arg0, arg1, arg2, arg3, arg4); + lua_settop(tolua_S, 1); + return 1; + } + if (argc == 6) + { + ax::Vec2 arg0; + ax::Vec2 arg1; + ax::Vec2 arg2; + unsigned int arg3; + ax::Color4B arg4; + double arg5; + + ok &= luaval_to_vec2(tolua_S, 2, &arg0, "ax.DrawNode:drawQuadBezier"); + + ok &= luaval_to_vec2(tolua_S, 3, &arg1, "ax.DrawNode:drawQuadBezier"); + + ok &= luaval_to_vec2(tolua_S, 4, &arg2, "ax.DrawNode:drawQuadBezier"); + + ok &= luaval_to_uint32(tolua_S, 5,&arg3, "ax.DrawNode:drawQuadBezier"); + + ok &=luaval_to_color4b(tolua_S, 6, &arg4, "ax.DrawNode:drawQuadBezier"); + + ok &= luaval_to_number(tolua_S, 7,&arg5, "ax.DrawNode:drawQuadBezier"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_ax_base_DrawNode_drawQuadBezier'", nullptr); + return 0; + } + cobj->drawQuadBezier(arg0, arg1, arg2, arg3, arg4, arg5); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ax.DrawNode:drawQuadBezier",argc, 5); + return 0; + +#if _AX_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_ax_base_DrawNode_drawQuadBezier'.",&tolua_err); +#endif + + return 0; +} +int lua_ax_base_DrawNode_drawCubicBezier(lua_State* tolua_S) +{ + int argc = 0; + ax::DrawNode* cobj = nullptr; + bool ok = true; + +#if _AX_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if _AX_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ax.DrawNode",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (ax::DrawNode*)tolua_tousertype(tolua_S,1,0); + +#if _AX_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_ax_base_DrawNode_drawCubicBezier'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 6) + { + ax::Vec2 arg0; + ax::Vec2 arg1; + ax::Vec2 arg2; + ax::Vec2 arg3; + unsigned int arg4; + ax::Color4B arg5; + + ok &= luaval_to_vec2(tolua_S, 2, &arg0, "ax.DrawNode:drawCubicBezier"); + + ok &= luaval_to_vec2(tolua_S, 3, &arg1, "ax.DrawNode:drawCubicBezier"); + + ok &= luaval_to_vec2(tolua_S, 4, &arg2, "ax.DrawNode:drawCubicBezier"); + + ok &= luaval_to_vec2(tolua_S, 5, &arg3, "ax.DrawNode:drawCubicBezier"); + + ok &= luaval_to_uint32(tolua_S, 6,&arg4, "ax.DrawNode:drawCubicBezier"); + + ok &=luaval_to_color4b(tolua_S, 7, &arg5, "ax.DrawNode:drawCubicBezier"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_ax_base_DrawNode_drawCubicBezier'", nullptr); + return 0; + } + cobj->drawCubicBezier(arg0, arg1, arg2, arg3, arg4, arg5); + lua_settop(tolua_S, 1); + return 1; + } + if (argc == 7) + { + ax::Vec2 arg0; + ax::Vec2 arg1; + ax::Vec2 arg2; + ax::Vec2 arg3; + unsigned int arg4; + ax::Color4B arg5; + double arg6; + + ok &= luaval_to_vec2(tolua_S, 2, &arg0, "ax.DrawNode:drawCubicBezier"); + + ok &= luaval_to_vec2(tolua_S, 3, &arg1, "ax.DrawNode:drawCubicBezier"); + + ok &= luaval_to_vec2(tolua_S, 4, &arg2, "ax.DrawNode:drawCubicBezier"); + + ok &= luaval_to_vec2(tolua_S, 5, &arg3, "ax.DrawNode:drawCubicBezier"); + + ok &= luaval_to_uint32(tolua_S, 6,&arg4, "ax.DrawNode:drawCubicBezier"); + + ok &=luaval_to_color4b(tolua_S, 7, &arg5, "ax.DrawNode:drawCubicBezier"); + + ok &= luaval_to_number(tolua_S, 8,&arg6, "ax.DrawNode:drawCubicBezier"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_ax_base_DrawNode_drawCubicBezier'", nullptr); + return 0; + } + cobj->drawCubicBezier(arg0, arg1, arg2, arg3, arg4, arg5, arg6); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ax.DrawNode:drawCubicBezier",argc, 6); + return 0; + +#if _AX_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_ax_base_DrawNode_drawCubicBezier'.",&tolua_err); +#endif + + return 0; +} +int lua_ax_base_DrawNode_drawDot(lua_State* tolua_S) +{ + int argc = 0; + ax::DrawNode* cobj = nullptr; + bool ok = true; + +#if _AX_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if _AX_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ax.DrawNode",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (ax::DrawNode*)tolua_tousertype(tolua_S,1,0); + +#if _AX_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_ax_base_DrawNode_drawDot'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 3) + { + ax::Vec2 arg0; + double arg1; + ax::Color4B arg2; + + ok &= luaval_to_vec2(tolua_S, 2, &arg0, "ax.DrawNode:drawDot"); + + ok &= luaval_to_number(tolua_S, 3,&arg1, "ax.DrawNode:drawDot"); + + ok &=luaval_to_color4b(tolua_S, 4, &arg2, "ax.DrawNode:drawDot"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_ax_base_DrawNode_drawDot'", nullptr); + return 0; + } + cobj->drawDot(arg0, arg1, arg2); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ax.DrawNode:drawDot",argc, 3); + return 0; + +#if _AX_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_ax_base_DrawNode_drawDot'.",&tolua_err); +#endif + + return 0; +} +int lua_ax_base_DrawNode_drawSolidRect(lua_State* tolua_S) +{ + int argc = 0; + ax::DrawNode* cobj = nullptr; + bool ok = true; + +#if _AX_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if _AX_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ax.DrawNode",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (ax::DrawNode*)tolua_tousertype(tolua_S,1,0); + +#if _AX_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_ax_base_DrawNode_drawSolidRect'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 3) + { + ax::Vec2 arg0; + ax::Vec2 arg1; + ax::Color4B arg2; + + ok &= luaval_to_vec2(tolua_S, 2, &arg0, "ax.DrawNode:drawSolidRect"); ok &= luaval_to_vec2(tolua_S, 3, &arg1, "ax.DrawNode:drawSolidRect"); @@ -52247,6 +52653,55 @@ int lua_ax_base_DrawNode_drawSolidRect(lua_State* tolua_S) lua_settop(tolua_S, 1); return 1; } + if (argc == 4) + { + ax::Vec2 arg0; + ax::Vec2 arg1; + ax::Color4B arg2; + double arg3; + + ok &= luaval_to_vec2(tolua_S, 2, &arg0, "ax.DrawNode:drawSolidRect"); + + ok &= luaval_to_vec2(tolua_S, 3, &arg1, "ax.DrawNode:drawSolidRect"); + + ok &=luaval_to_color4b(tolua_S, 4, &arg2, "ax.DrawNode:drawSolidRect"); + + ok &= luaval_to_number(tolua_S, 5,&arg3, "ax.DrawNode:drawSolidRect"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_ax_base_DrawNode_drawSolidRect'", nullptr); + return 0; + } + cobj->drawSolidRect(arg0, arg1, arg2, arg3); + lua_settop(tolua_S, 1); + return 1; + } + if (argc == 5) + { + ax::Vec2 arg0; + ax::Vec2 arg1; + ax::Color4B arg2; + double arg3; + ax::Color4B arg4; + + ok &= luaval_to_vec2(tolua_S, 2, &arg0, "ax.DrawNode:drawSolidRect"); + + ok &= luaval_to_vec2(tolua_S, 3, &arg1, "ax.DrawNode:drawSolidRect"); + + ok &=luaval_to_color4b(tolua_S, 4, &arg2, "ax.DrawNode:drawSolidRect"); + + ok &= luaval_to_number(tolua_S, 5,&arg3, "ax.DrawNode:drawSolidRect"); + + ok &=luaval_to_color4b(tolua_S, 6, &arg4, "ax.DrawNode:drawSolidRect"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_ax_base_DrawNode_drawSolidRect'", nullptr); + return 0; + } + cobj->drawSolidRect(arg0, arg1, arg2, arg3, arg4); + lua_settop(tolua_S, 1); + return 1; + } luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ax.DrawNode:drawSolidRect",argc, 3); return 0; @@ -52422,7 +52877,7 @@ int lua_ax_base_DrawNode_drawPie(lua_State* tolua_S) #endif argc = lua_gettop(tolua_S)-1; - if (argc == 9) + if (argc == 10) { ax::Vec2 arg0; double arg1; @@ -52432,7 +52887,8 @@ int lua_ax_base_DrawNode_drawPie(lua_State* tolua_S) double arg5; double arg6; ax::Color4B arg7; - ax::DrawNode::DrawMode arg8; + ax::Color4B arg8; + ax::DrawNode::DrawMode arg9; ok &= luaval_to_vec2(tolua_S, 2, &arg0, "ax.DrawNode:drawPie"); @@ -52440,150 +52896,446 @@ int lua_ax_base_DrawNode_drawPie(lua_State* tolua_S) ok &= luaval_to_number(tolua_S, 4,&arg2, "ax.DrawNode:drawPie"); - ok &= luaval_to_int32(tolua_S, 5,(int *)&arg3, "ax.DrawNode:drawPie"); + ok &= luaval_to_int32(tolua_S, 5,(int *)&arg3, "ax.DrawNode:drawPie"); + + ok &= luaval_to_int32(tolua_S, 6,(int *)&arg4, "ax.DrawNode:drawPie"); + + ok &= luaval_to_number(tolua_S, 7,&arg5, "ax.DrawNode:drawPie"); + + ok &= luaval_to_number(tolua_S, 8,&arg6, "ax.DrawNode:drawPie"); + + ok &=luaval_to_color4b(tolua_S, 9, &arg7, "ax.DrawNode:drawPie"); + + ok &=luaval_to_color4b(tolua_S, 10, &arg8, "ax.DrawNode:drawPie"); + + ok &= luaval_to_int32(tolua_S, 11,(int *)&arg9, "ax.DrawNode:drawPie"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_ax_base_DrawNode_drawPie'", nullptr); + return 0; + } + cobj->drawPie(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9); + lua_settop(tolua_S, 1); + return 1; + } + if (argc == 11) + { + ax::Vec2 arg0; + double arg1; + double arg2; + int arg3; + int arg4; + double arg5; + double arg6; + ax::Color4B arg7; + ax::Color4B arg8; + ax::DrawNode::DrawMode arg9; + double arg10; + + ok &= luaval_to_vec2(tolua_S, 2, &arg0, "ax.DrawNode:drawPie"); + + ok &= luaval_to_number(tolua_S, 3,&arg1, "ax.DrawNode:drawPie"); + + ok &= luaval_to_number(tolua_S, 4,&arg2, "ax.DrawNode:drawPie"); + + ok &= luaval_to_int32(tolua_S, 5,(int *)&arg3, "ax.DrawNode:drawPie"); + + ok &= luaval_to_int32(tolua_S, 6,(int *)&arg4, "ax.DrawNode:drawPie"); + + ok &= luaval_to_number(tolua_S, 7,&arg5, "ax.DrawNode:drawPie"); + + ok &= luaval_to_number(tolua_S, 8,&arg6, "ax.DrawNode:drawPie"); + + ok &=luaval_to_color4b(tolua_S, 9, &arg7, "ax.DrawNode:drawPie"); + + ok &=luaval_to_color4b(tolua_S, 10, &arg8, "ax.DrawNode:drawPie"); + + ok &= luaval_to_int32(tolua_S, 11,(int *)&arg9, "ax.DrawNode:drawPie"); + + ok &= luaval_to_number(tolua_S, 12,&arg10, "ax.DrawNode:drawPie"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_ax_base_DrawNode_drawPie'", nullptr); + return 0; + } + cobj->drawPie(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ax.DrawNode:drawPie",argc, 10); + return 0; + +#if _AX_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_ax_base_DrawNode_drawPie'.",&tolua_err); +#endif + + return 0; +} +int lua_ax_base_DrawNode_drawSegment(lua_State* tolua_S) +{ + int argc = 0; + ax::DrawNode* cobj = nullptr; + bool ok = true; + +#if _AX_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if _AX_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ax.DrawNode",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (ax::DrawNode*)tolua_tousertype(tolua_S,1,0); + +#if _AX_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_ax_base_DrawNode_drawSegment'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 4) + { + ax::Vec2 arg0; + ax::Vec2 arg1; + double arg2; + ax::Color4B arg3; + + ok &= luaval_to_vec2(tolua_S, 2, &arg0, "ax.DrawNode:drawSegment"); + + ok &= luaval_to_vec2(tolua_S, 3, &arg1, "ax.DrawNode:drawSegment"); + + ok &= luaval_to_number(tolua_S, 4,&arg2, "ax.DrawNode:drawSegment"); + + ok &=luaval_to_color4b(tolua_S, 5, &arg3, "ax.DrawNode:drawSegment"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_ax_base_DrawNode_drawSegment'", nullptr); + return 0; + } + cobj->drawSegment(arg0, arg1, arg2, arg3); + lua_settop(tolua_S, 1); + return 1; + } + if (argc == 5) + { + ax::Vec2 arg0; + ax::Vec2 arg1; + double arg2; + ax::Color4B arg3; + ax::DrawNode::EndType arg4; + + ok &= luaval_to_vec2(tolua_S, 2, &arg0, "ax.DrawNode:drawSegment"); + + ok &= luaval_to_vec2(tolua_S, 3, &arg1, "ax.DrawNode:drawSegment"); + + ok &= luaval_to_number(tolua_S, 4,&arg2, "ax.DrawNode:drawSegment"); + + ok &=luaval_to_color4b(tolua_S, 5, &arg3, "ax.DrawNode:drawSegment"); + + ok &= luaval_to_int32(tolua_S, 6,(int *)&arg4, "ax.DrawNode:drawSegment"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_ax_base_DrawNode_drawSegment'", nullptr); + return 0; + } + cobj->drawSegment(arg0, arg1, arg2, arg3, arg4); + lua_settop(tolua_S, 1); + return 1; + } + if (argc == 6) + { + ax::Vec2 arg0; + ax::Vec2 arg1; + double arg2; + ax::Color4B arg3; + ax::DrawNode::EndType arg4; + ax::DrawNode::EndType arg5; + + ok &= luaval_to_vec2(tolua_S, 2, &arg0, "ax.DrawNode:drawSegment"); - ok &= luaval_to_int32(tolua_S, 6,(int *)&arg4, "ax.DrawNode:drawPie"); + ok &= luaval_to_vec2(tolua_S, 3, &arg1, "ax.DrawNode:drawSegment"); - ok &= luaval_to_number(tolua_S, 7,&arg5, "ax.DrawNode:drawPie"); + ok &= luaval_to_number(tolua_S, 4,&arg2, "ax.DrawNode:drawSegment"); - ok &= luaval_to_number(tolua_S, 8,&arg6, "ax.DrawNode:drawPie"); + ok &=luaval_to_color4b(tolua_S, 5, &arg3, "ax.DrawNode:drawSegment"); - ok &=luaval_to_color4b(tolua_S, 9, &arg7, "ax.DrawNode:drawPie"); + ok &= luaval_to_int32(tolua_S, 6,(int *)&arg4, "ax.DrawNode:drawSegment"); - ok &= luaval_to_int32(tolua_S, 10,(int *)&arg8, "ax.DrawNode:drawPie"); + ok &= luaval_to_int32(tolua_S, 7,(int *)&arg5, "ax.DrawNode:drawSegment"); if(!ok) { - tolua_error(tolua_S,"invalid arguments in function 'lua_ax_base_DrawNode_drawPie'", nullptr); + tolua_error(tolua_S,"invalid arguments in function 'lua_ax_base_DrawNode_drawSegment'", nullptr); return 0; } - cobj->drawPie(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8); + cobj->drawSegment(arg0, arg1, arg2, arg3, arg4, arg5); lua_settop(tolua_S, 1); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ax.DrawNode:drawPie",argc, 9); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ax.DrawNode:drawSegment",argc, 4); return 0; #if _AX_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_ax_base_DrawNode_drawPie'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'lua_ax_base_DrawNode_drawSegment'.",&tolua_err); #endif return 0; } -int lua_ax_base_DrawNode_drawSegment(lua_State* tolua_S) +int lua_ax_base_DrawNode_drawTriangle(lua_State* tolua_S) { int argc = 0; ax::DrawNode* cobj = nullptr; bool ok = true; - #if _AX_DEBUG >= 1 tolua_Error tolua_err; #endif - #if _AX_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ax.DrawNode",0,&tolua_err)) goto tolua_lerror; #endif - cobj = (ax::DrawNode*)tolua_tousertype(tolua_S,1,0); - #if _AX_DEBUG >= 1 - if (!cobj) + if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_ax_base_DrawNode_drawSegment'", nullptr); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_ax_base_DrawNode_drawTriangle'", nullptr); return 0; } #endif - argc = lua_gettop(tolua_S)-1; - if (argc == 4) - { - ax::Vec2 arg0; - ax::Vec2 arg1; - double arg2; - ax::Color4B arg3; + do{ + if (argc == 4) { + ax::Vec2 arg0; + ok &= luaval_to_vec2(tolua_S, 2, &arg0, "ax.DrawNode:drawTriangle"); - ok &= luaval_to_vec2(tolua_S, 2, &arg0, "ax.DrawNode:drawSegment"); + if (!ok) { break; } + ax::Vec2 arg1; + ok &= luaval_to_vec2(tolua_S, 3, &arg1, "ax.DrawNode:drawTriangle"); - ok &= luaval_to_vec2(tolua_S, 3, &arg1, "ax.DrawNode:drawSegment"); + if (!ok) { break; } + ax::Vec2 arg2; + ok &= luaval_to_vec2(tolua_S, 4, &arg2, "ax.DrawNode:drawTriangle"); - ok &= luaval_to_number(tolua_S, 4,&arg2, "ax.DrawNode:drawSegment"); + if (!ok) { break; } + ax::Color4B arg3; + ok &=luaval_to_color4b(tolua_S, 5, &arg3, "ax.DrawNode:drawTriangle"); - ok &=luaval_to_color4b(tolua_S, 5, &arg3, "ax.DrawNode:drawSegment"); - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_ax_base_DrawNode_drawSegment'", nullptr); - return 0; + if (!ok) { break; } + cobj->drawTriangle(arg0, arg1, arg2, arg3); + lua_settop(tolua_S, 1); + return 1; } - cobj->drawSegment(arg0, arg1, arg2, arg3); - lua_settop(tolua_S, 1); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ax.DrawNode:drawSegment",argc, 4); + }while(0); + ok = true; + do{ + if (argc == 5) { + ax::Vec2 arg0; + ok &= luaval_to_vec2(tolua_S, 2, &arg0, "ax.DrawNode:drawTriangle"); + + if (!ok) { break; } + ax::Vec2 arg1; + ok &= luaval_to_vec2(tolua_S, 3, &arg1, "ax.DrawNode:drawTriangle"); + + if (!ok) { break; } + ax::Vec2 arg2; + ok &= luaval_to_vec2(tolua_S, 4, &arg2, "ax.DrawNode:drawTriangle"); + + if (!ok) { break; } + ax::Color4B arg3; + ok &=luaval_to_color4b(tolua_S, 5, &arg3, "ax.DrawNode:drawTriangle"); + + if (!ok) { break; } + double arg4; + ok &= luaval_to_number(tolua_S, 6,&arg4, "ax.DrawNode:drawTriangle"); + + if (!ok) { break; } + cobj->drawTriangle(arg0, arg1, arg2, arg3, arg4); + lua_settop(tolua_S, 1); + return 1; + } + }while(0); + ok = true; + do{ + if (argc == 2) { + const ax::Vec2* arg0; + ok &= luaval_to_object(tolua_S, 2, "ax.Vec2",&arg0, "ax.DrawNode:drawTriangle"); + + if (!ok) { break; } + ax::Color4B arg1; + ok &=luaval_to_color4b(tolua_S, 3, &arg1, "ax.DrawNode:drawTriangle"); + + if (!ok) { break; } + cobj->drawTriangle(arg0, arg1); + lua_settop(tolua_S, 1); + return 1; + } + }while(0); + ok = true; + do{ + if (argc == 3) { + const ax::Vec2* arg0; + ok &= luaval_to_object(tolua_S, 2, "ax.Vec2",&arg0, "ax.DrawNode:drawTriangle"); + + if (!ok) { break; } + ax::Color4B arg1; + ok &=luaval_to_color4b(tolua_S, 3, &arg1, "ax.DrawNode:drawTriangle"); + + if (!ok) { break; } + double arg2; + ok &= luaval_to_number(tolua_S, 4,&arg2, "ax.DrawNode:drawTriangle"); + + if (!ok) { break; } + cobj->drawTriangle(arg0, arg1, arg2); + lua_settop(tolua_S, 1); + return 1; + } + }while(0); + ok = true; + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ax.DrawNode:drawTriangle",argc, 2); return 0; #if _AX_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_ax_base_DrawNode_drawSegment'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'lua_ax_base_DrawNode_drawTriangle'.",&tolua_err); #endif return 0; } -int lua_ax_base_DrawNode_drawTriangle(lua_State* tolua_S) +int lua_ax_base_DrawNode_drawSolidTriangle(lua_State* tolua_S) { int argc = 0; ax::DrawNode* cobj = nullptr; bool ok = true; - #if _AX_DEBUG >= 1 tolua_Error tolua_err; #endif - #if _AX_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"ax.DrawNode",0,&tolua_err)) goto tolua_lerror; #endif - cobj = (ax::DrawNode*)tolua_tousertype(tolua_S,1,0); - #if _AX_DEBUG >= 1 - if (!cobj) + if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_ax_base_DrawNode_drawTriangle'", nullptr); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_ax_base_DrawNode_drawSolidTriangle'", nullptr); return 0; } #endif - argc = lua_gettop(tolua_S)-1; - if (argc == 4) - { - ax::Vec2 arg0; - ax::Vec2 arg1; - ax::Vec2 arg2; - ax::Color4B arg3; + do{ + if (argc == 5) { + ax::Vec2 arg0; + ok &= luaval_to_vec2(tolua_S, 2, &arg0, "ax.DrawNode:drawSolidTriangle"); - ok &= luaval_to_vec2(tolua_S, 2, &arg0, "ax.DrawNode:drawTriangle"); + if (!ok) { break; } + ax::Vec2 arg1; + ok &= luaval_to_vec2(tolua_S, 3, &arg1, "ax.DrawNode:drawSolidTriangle"); - ok &= luaval_to_vec2(tolua_S, 3, &arg1, "ax.DrawNode:drawTriangle"); + if (!ok) { break; } + ax::Vec2 arg2; + ok &= luaval_to_vec2(tolua_S, 4, &arg2, "ax.DrawNode:drawSolidTriangle"); - ok &= luaval_to_vec2(tolua_S, 4, &arg2, "ax.DrawNode:drawTriangle"); + if (!ok) { break; } + ax::Color4B arg3; + ok &=luaval_to_color4b(tolua_S, 5, &arg3, "ax.DrawNode:drawSolidTriangle"); - ok &=luaval_to_color4b(tolua_S, 5, &arg3, "ax.DrawNode:drawTriangle"); - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_ax_base_DrawNode_drawTriangle'", nullptr); - return 0; + if (!ok) { break; } + ax::Color4B arg4; + ok &=luaval_to_color4b(tolua_S, 6, &arg4, "ax.DrawNode:drawSolidTriangle"); + + if (!ok) { break; } + cobj->drawSolidTriangle(arg0, arg1, arg2, arg3, arg4); + lua_settop(tolua_S, 1); + return 1; } - cobj->drawTriangle(arg0, arg1, arg2, arg3); - lua_settop(tolua_S, 1); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ax.DrawNode:drawTriangle",argc, 4); + }while(0); + ok = true; + do{ + if (argc == 6) { + ax::Vec2 arg0; + ok &= luaval_to_vec2(tolua_S, 2, &arg0, "ax.DrawNode:drawSolidTriangle"); + + if (!ok) { break; } + ax::Vec2 arg1; + ok &= luaval_to_vec2(tolua_S, 3, &arg1, "ax.DrawNode:drawSolidTriangle"); + + if (!ok) { break; } + ax::Vec2 arg2; + ok &= luaval_to_vec2(tolua_S, 4, &arg2, "ax.DrawNode:drawSolidTriangle"); + + if (!ok) { break; } + ax::Color4B arg3; + ok &=luaval_to_color4b(tolua_S, 5, &arg3, "ax.DrawNode:drawSolidTriangle"); + + if (!ok) { break; } + ax::Color4B arg4; + ok &=luaval_to_color4b(tolua_S, 6, &arg4, "ax.DrawNode:drawSolidTriangle"); + + if (!ok) { break; } + double arg5; + ok &= luaval_to_number(tolua_S, 7,&arg5, "ax.DrawNode:drawSolidTriangle"); + + if (!ok) { break; } + cobj->drawSolidTriangle(arg0, arg1, arg2, arg3, arg4, arg5); + lua_settop(tolua_S, 1); + return 1; + } + }while(0); + ok = true; + do{ + if (argc == 3) { + const ax::Vec2* arg0; + ok &= luaval_to_object(tolua_S, 2, "ax.Vec2",&arg0, "ax.DrawNode:drawSolidTriangle"); + + if (!ok) { break; } + ax::Color4B arg1; + ok &=luaval_to_color4b(tolua_S, 3, &arg1, "ax.DrawNode:drawSolidTriangle"); + + if (!ok) { break; } + ax::Color4B arg2; + ok &=luaval_to_color4b(tolua_S, 4, &arg2, "ax.DrawNode:drawSolidTriangle"); + + if (!ok) { break; } + cobj->drawSolidTriangle(arg0, arg1, arg2); + lua_settop(tolua_S, 1); + return 1; + } + }while(0); + ok = true; + do{ + if (argc == 4) { + const ax::Vec2* arg0; + ok &= luaval_to_object(tolua_S, 2, "ax.Vec2",&arg0, "ax.DrawNode:drawSolidTriangle"); + + if (!ok) { break; } + ax::Color4B arg1; + ok &=luaval_to_color4b(tolua_S, 3, &arg1, "ax.DrawNode:drawSolidTriangle"); + + if (!ok) { break; } + ax::Color4B arg2; + ok &=luaval_to_color4b(tolua_S, 4, &arg2, "ax.DrawNode:drawSolidTriangle"); + + if (!ok) { break; } + double arg3; + ok &= luaval_to_number(tolua_S, 5,&arg3, "ax.DrawNode:drawSolidTriangle"); + + if (!ok) { break; } + cobj->drawSolidTriangle(arg0, arg1, arg2, arg3); + lua_settop(tolua_S, 1); + return 1; + } + }while(0); + ok = true; + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ax.DrawNode:drawSolidTriangle",argc, 3); return 0; #if _AX_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_ax_base_DrawNode_drawTriangle'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'lua_ax_base_DrawNode_drawSolidTriangle'.",&tolua_err); #endif return 0; @@ -52829,56 +53581,6 @@ int lua_ax_base_DrawNode_getLineWidth(lua_State* tolua_S) return 0; } -int lua_ax_base_DrawNode_setIsConvex(lua_State* tolua_S) -{ - int argc = 0; - ax::DrawNode* cobj = nullptr; - bool ok = true; - -#if _AX_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if _AX_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ax.DrawNode",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (ax::DrawNode*)tolua_tousertype(tolua_S,1,0); - -#if _AX_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_ax_base_DrawNode_setIsConvex'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - bool arg0; - - ok &= luaval_to_boolean(tolua_S, 2,&arg0, "ax.DrawNode:setIsConvex"); - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_ax_base_DrawNode_setIsConvex'", nullptr); - return 0; - } - cobj->setIsConvex(arg0); - lua_settop(tolua_S, 1); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ax.DrawNode:setIsConvex",argc, 1); - return 0; - -#if _AX_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_ax_base_DrawNode_setIsConvex'.",&tolua_err); -#endif - - return 0; -} int lua_ax_base_DrawNode_setIsolated(lua_State* tolua_S) { int argc = 0; @@ -53094,6 +53796,8 @@ int lua_register_ax_base_DrawNode(lua_State* tolua_S) tolua_function(tolua_S,"drawLine",lua_ax_base_DrawNode_drawLine); tolua_function(tolua_S,"drawRect",lua_ax_base_DrawNode_drawRect); tolua_function(tolua_S,"drawCircle",lua_ax_base_DrawNode_drawCircle); + tolua_function(tolua_S,"drawStar",lua_ax_base_DrawNode_drawStar); + tolua_function(tolua_S,"drawSolidStar",lua_ax_base_DrawNode_drawSolidStar); tolua_function(tolua_S,"drawQuadBezier",lua_ax_base_DrawNode_drawQuadBezier); tolua_function(tolua_S,"drawCubicBezier",lua_ax_base_DrawNode_drawCubicBezier); tolua_function(tolua_S,"drawDot",lua_ax_base_DrawNode_drawDot); @@ -53102,12 +53806,12 @@ int lua_register_ax_base_DrawNode(lua_State* tolua_S) tolua_function(tolua_S,"drawPie",lua_ax_base_DrawNode_drawPie); tolua_function(tolua_S,"drawSegment",lua_ax_base_DrawNode_drawSegment); tolua_function(tolua_S,"drawTriangle",lua_ax_base_DrawNode_drawTriangle); + tolua_function(tolua_S,"drawSolidTriangle",lua_ax_base_DrawNode_drawSolidTriangle); tolua_function(tolua_S,"clear",lua_ax_base_DrawNode_clear); tolua_function(tolua_S,"getBlendFunc",lua_ax_base_DrawNode_getBlendFunc); tolua_function(tolua_S,"setBlendFunc",lua_ax_base_DrawNode_setBlendFunc); tolua_function(tolua_S,"setLineWidth",lua_ax_base_DrawNode_setLineWidth); tolua_function(tolua_S,"getLineWidth",lua_ax_base_DrawNode_getLineWidth); - tolua_function(tolua_S,"setIsConvex",lua_ax_base_DrawNode_setIsConvex); tolua_function(tolua_S,"setIsolated",lua_ax_base_DrawNode_setIsolated); tolua_function(tolua_S,"isIsolated",lua_ax_base_DrawNode_isIsolated); tolua_function(tolua_S,"create", lua_ax_base_DrawNode_create); diff --git a/tests/cpp-tests/CMakeLists.txt b/tests/cpp-tests/CMakeLists.txt index 83465d34b263..5774de44e9ba 100644 --- a/tests/cpp-tests/CMakeLists.txt +++ b/tests/cpp-tests/CMakeLists.txt @@ -189,6 +189,8 @@ list(APPEND GAME_HEADER Source/ExtensionsTest/TableViewTest/TableViewTestScene.h Source/MeshRendererTest/MeshRendererTest.h Source/MeshRendererTest/DrawNode3D.h + Source/DrawNodeTest/DrawNodeTest.h + Source/DrawPrimitivesTest/DrawPrimitivesTest.h Source/BaseTest.h Source/SceneTest/SceneTest.h Source/ReleasePoolTest/ReleasePoolTest.h @@ -221,7 +223,6 @@ list(APPEND GAME_HEADER Source/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest.h Source/UITest/CocoStudioGUITest/UIFocusTest/UIFocusTest.h Source/UITest/CocoStudioGUITest/UITextTest/UITextTest.h - Source/DrawPrimitivesTest/DrawPrimitivesTest.h Source/BillBoardTest/BillBoardTest.h Source/SpriteFrameCacheTest/SpriteFrameCacheTest.h Source/EffectsAdvancedTest/EffectsAdvancedTest.h @@ -286,7 +287,6 @@ list(APPEND GAME_SOURCE Source/NetworkTest/DownloaderTest/DownloaderTest.cpp Source/NetworkTest/HttpClientTest/HttpClientTest.cpp Source/NetworkTest/WebSocketTest/WebSocketTest.cpp - Source/DrawPrimitivesTest/DrawPrimitivesTest.cpp Source/EffectsAdvancedTest/EffectsAdvancedTest.cpp Source/EffectsTest/EffectsTest.cpp Source/ExtensionsTest/AssetsManagerExTest/AssetsManagerExTest.cpp @@ -323,6 +323,8 @@ list(APPEND GAME_SOURCE Source/SpineTest/SpineTest.cpp # Source/Scene3DTest/Scene3DTest.cpp Source/MeshRendererTest/DrawNode3D.cpp + Source/DrawNodeTest/DrawNodeTest.cpp + Source/DrawPrimitivesTest/DrawPrimitivesTest.cpp Source/MeshRendererTest/MeshRendererTest.cpp Source/SpritePolygonTest/SpritePolygonTest.cpp Source/SpriteTest/SpriteTest.cpp @@ -536,12 +538,6 @@ if (AX_ENABLE_EXT_EFFEKSEER) list(APPEND GAME_SOURCE Source/EffekseerTest/EffekseerTest.cpp) endif() -if (AX_ENABLE_EXT_DRAWNODEEX) - list(APPEND GAME_HEADER Source/DrawNodeExTest/DrawNodeExTest.h) - list(APPEND GAME_SOURCE Source/DrawNodeExTest/DrawNodeExTest.cpp) -endif() - - list(APPEND GAME_SOURCE Source/UITest/CocoStudioGUITest/UIEditBoxTest.cpp ) @@ -571,9 +567,6 @@ if (AX_ENABLE_EXT_EFFEKSEER) target_compile_definitions(${APP_NAME} PRIVATE AX_ENABLE_EXT_EFFEKSEER=1) endif() -if (AX_ENABLE_EXT_DRAWNODEEX) - target_compile_definitions(${APP_NAME} PRIVATE AX_ENABLE_EXT_DRAWNODE=1) -endif() # mark app resources ax_setup_app_config(${APP_NAME}) diff --git a/tests/cpp-tests/Source/DrawNodeTest/DrawNodeTest.cpp b/tests/cpp-tests/Source/DrawNodeTest/DrawNodeTest.cpp new file mode 100644 index 000000000000..c9590713a081 --- /dev/null +++ b/tests/cpp-tests/Source/DrawNodeTest/DrawNodeTest.cpp @@ -0,0 +1,3563 @@ +/**************************************************************************** +Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.. +Copyright (c) 2019-present Axmol Engine contributors (see AUTHORS.md). + +https://axmol.dev/ + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do size., subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ + +#include "DrawNodeTest.h" +#include "renderer/Renderer.h" +#include "renderer/CustomCommand.h" + +#if defined(_WIN32) +# pragma push_macro("TRANSPARENT") +# undef TRANSPARENT +#endif + +USING_NS_AX; +using namespace std; + +Vec2 vertices1[] = { + {45.750000f, 144.375000f}, {75.500000f, 136.875000f}, {75.500000f, 159.125000f}, {100.250000f, 161.375000f}, + {65.500000f, 181.375000f}, {102.250000f, 179.125000f}, {95.000000f, 215.125000f}, {129.331467f, 189.926208f}, + {131.371460f, 206.366196f}, {139.651474f, 192.446198f}, {161.851471f, 200.606201f}, {151.000000f, 220.375000f}, + {110.500000f, 244.375000f}, {153.750000f, 238.125000f}, {142.500000f, 253.875000f}, {220.750000f, 259.375000f}, + {250.500000f, 244.375000f}, {168.750000f, 241.875000f}, {182.250000f, 154.125000f}, {190.250000f, 227.375000f}, + {196.500000f, 197.375000f}, {208.750000f, 210.625000f}, {220.750000f, 194.375000f}, {208.750000f, 176.375000f}, + {253.250000f, 173.875000f}, {243.750000f, 154.125000f}, {213.750000f, 161.375000f}, {202.250000f, 139.875000f}, + {236.000000f, 131.875000f}, {218.500000f, 120.875000f}, {206.500000f, 125.625000f}, {184.500000f, 110.375000f}, + {157.000000f, 108.625000f}, {147.500000f, 96.625000f}, {153.750000f, 85.125000f}, {147.500000f, 75.375000f}, + {126.500000f, 74.125000f}, {110.500000f, 86.625000f}, {127.750000f, 85.125000f}, {135.250000f, 91.125000f}, + {135.250000f, 97.875000f}, {124.000000f, 93.875000f}, {115.500000f, 100.875000f}, {115.500000f, 111.875000f}, + {135.250000f, 108.625000f}, {151.000000f, 124.125000f}, {90.500000f, 131.875000f}, {113.250000f, 120.875000f}, + {88.000000f, 116.875000f}, {106.000000f, 103.875000f}, {88.000000f, 97.875000f}}; + +Vec2 vertices2[] = { + {290.250000f, 98.1250000f}, {235.000000f, 90.8750000f}, {270.500000f, 109.875000f}, {235.000000f, 119.125000f}, + {275.250000f, 145.875000f}, {249.500000f, 145.875000f}, {249.500000f, 178.125000f}, {275.250000f, 187.375015f}, + {294.750488f, 168.333344f}, {311.250000f, 181.125000f}, {257.000000f, 213.625015f}, {338.500000f, 193.125000f}, + {300.000000f, 211.125015f}, {333.750000f, 211.125015f}, {368.250000f, 206.625000f}, {377.000000f, 178.125000f}, + {421.750000f, 170.125000f}, {416.250000f, 115.375000f}, {391.250000f, 157.875000f}, {338.500000f, 131.625000f}, + {362.750000f, 131.625000f}, {362.750000f, 106.875000f}, {306.500000f, 119.125000f}, {324.250000f, 85.1250000f}, + {227.500000f, 61.8750000}}; + +Vec2 vertices21[] = { + {290.250000f, 98.1250000f}, {235.000000f, 90.8750000f}, {270.500000f, 109.875000f}, {235.000000f, 119.125000f}, + {275.250000f, 145.875000f}, {249.500000f, 145.875000f}, {249.500000f, 178.125000f}, {275.250000f, 187.375015f}, + {294.750488f, 168.333344f}, {311.250000f, 181.125000f}, {257.000000f, 213.625015f}, {338.500000f, 193.125000f}, + {300.000000f, 211.125015f}, {333.750000f, 211.125015f}, {368.250000f, 206.625000f}, {377.000000f, 178.125000f}, + {421.750000f, 170.125000f}, {416.250000f, 115.375000f}, {391.250000f, 157.875000f}, {338.500000f, 131.625000f}, + {362.750000f, 131.625000f}, {362.750000f, 106.875000f}, {306.500000f, 119.125000f}, {324.250000f, 85.1250000f}, + {227.500000f, 61.8750000}}; + +Vec2 vertices24[] = { + {45.750000f, 144.375000f}, {75.500000f, 136.875000f}, {75.500000f, 159.125000f}, {100.250000f, 161.375000f}, + {65.500000f, 181.375000f}, {102.250000f, 179.125000f}, {95.000000f, 215.125000f}, {129.331467f, 189.926208f}, + {131.371460f, 206.366196f}, {139.651474f, 192.446198f}, {161.851471f, 200.606201f}, {151.000000f, 220.375000f}, + {110.500000f, 244.375000f}, {153.750000f, 238.125000f}, {142.500000f, 253.875000f}, {220.750000f, 259.375000f}, + {250.500000f, 244.375000f}, {168.750000f, 241.875000f}, {182.250000f, 154.125000f}, {190.250000f, 227.375000f}, + {196.500000f, 197.375000f}, {208.750000f, 210.625000f}, {220.750000f, 194.375000f}, {208.750000f, 176.375000f}, + {253.250000f, 173.875000f}, {243.750000f, 154.125000f}, {213.750000f, 161.375000f}, {202.250000f, 139.875000f}, + {236.000000f, 131.875000f}, {218.500000f, 120.875000f}, {206.500000f, 125.625000f}, {184.500000f, 110.375000f}, + {157.000000f, 108.625000f}, {147.500000f, 96.625000f}, {153.750000f, 85.125000f}, {147.500000f, 75.375000f}, + {126.500000f, 74.125000f}, {110.500000f, 86.625000f}, {127.750000f, 85.125000f}, {135.250000f, 91.125000f}, + {135.250000f, 97.875000f}, {124.000000f, 93.875000f}, {115.500000f, 100.875000f}, {115.500000f, 111.875000f}, + {135.250000f, 108.625000f}, {151.000000f, 124.125000f}, {90.500000f, 131.875000f}, {113.250000f, 120.875000f}, + {88.000000f, 116.875000f}, {106.000000f, 103.875000f}, {88.000000f, 97.875000f}, +}; + +// Original https : // www.purebasic.fr/english/viewtopic.php?t=82915 +float verticesHead[] = {107.f, 9.f, + 0.3333333433f, 0.3411764801f, + 0.3686274588f, 255.f, + 81.f, 599.f, + 116.f, 571.f, + 180.f, 562.f, + 255.f, 559.f, + 213.f, 586.f, + 199.f, 599.f, + 0.f, 7.f, + 0.3333333433f, 0.3411764801f, + 0.3686274588f, 255.f, + 765.f, 584.f, + 782.f, 590.f, + 794.f, 599.f, + 772.f, 599.f, + 0.f, 13.f, + 0.4156862795f, 0.4313725531f, + 0.4549019635f, 255.f, + 278.f, 573.f, + 287.f, 599.f, + 199.f, 599.f, + 217.f, 582.f, + 256.f, 557.f, + 313.f, 532.f, + 352.f, 508.f, + 366.f, 512.f, + 368.f, 545.f, + 285.f, 598.f, + 0.f, 8.f, + 0.4156862795f, 0.4313725531f, + 0.4549019635f, 255.f, + 760.f, 591.f, + 754.f, 579.f, + 766.f, 584.f, + 773.f, 599.f, + 751.f, 599.f, + 0.f, 12.f, + 0.400000006f, 0.4117647111f, + 0.4196078479f, 255.f, + 701.f, 563.f, + 615.f, 599.f, + 652.f, 558.f, + 705.f, 507.f, + 716.f, 534.f, + 753.f, 577.f, + 760.f, 591.f, + 752.f, 599.f, + 613.f, 599.f, + 0.f, 10.f, + 0.400000006f, 0.4117647111f, + 0.4196078479f, 255.f, + 704.f, 506.f, + 701.f, 493.f, + 686.f, 488.f, + 688.f, 503.f, + 692.f, 514.f, + 691.f, 528.f, + 708.f, 518.f, + 0.f, 8.f, + 0.4784313738f, 0.3647058904f, + 0.2156862766f, 255.f, + 285.f, 599.f, + 309.f, 579.f, + 365.f, 546.f, + 375.f, 578.f, + 378.f, 599.f, + 0.f, 16.f, + 0.4784313738f, 0.3647058904f, + 0.2156862766f, 255.f, + 471.f, 599.f, + 377.f, 599.f, + 365.f, 546.f, + 360.f, 511.f, + 394.f, 515.f, + 428.f, 507.f, + 492.f, 471.f, + 553.f, 417.f, + 568.f, 397.f, + 562.f, 422.f, + 552.f, 462.f, + 547.f, 487.f, + 524.f, 529.f, + 0.f, 19.f, + 0.5921568871f, 0.4980392158f, + 0.3647058904f, 255.f, + 614.f, 599.f, + 683.f, 531.f, + 690.f, 512.f, + 686.f, 493.f, + 684.f, 429.f, + 656.f, 245.f, + 654.f, 242.f, + 644.f, 273.f, + 628.f, 288.f, + 621.f, 288.f, + 592.f, 308.f, + 571.f, 378.f, + 554.f, 454.f, + 543.f, 494.f, + 514.f, 542.f, + 469.f, 599.f, + 0.f, 12.f, + 0.5921568871f, 0.4980392158f, + 0.3647058904f, 255.f, + 598.f, 259.f, + 602.f, 233.f, + 619.f, 236.f, + 624.f, 250.f, + 630.f, 257.f, + 629.f, 269.f, + 623.f, 291.f, + 603.f, 312.f, + 589.f, 311.f, + 0.f, 15.f, + 0.4784313738f, 0.3647058904f, + 0.2156862766f, 255.f, + 642.f, 211.f, + 606.f, 197.f, + 609.f, 236.f, + 621.f, 236.f, + 621.f, 246.f, + 630.f, 256.f, + 627.f, 279.f, + 626.f, 286.f, + 636.f, 282.f, + 641.f, 274.f, + 649.f, 250.f, + 656.f, 221.f, + 0.f, 24.f, + 0.4784313738f, 0.3647058904f, + 0.2156862766f, 255.f, + 309.f, 333.f, + 334.f, 269.f, + 346.f, 207.f, + 347.f, 169.f, + 323.f, 42.f, + 265.f, 39.f, + 256.f, 156.f, + 272.f, 212.f, + 276.f, 302.f, + 292.f, 372.f, + 323.f, 469.f, + 334.f, 500.f, + 350.f, 509.f, + 365.f, 511.f, + 358.f, 472.f, + 370.f, 451.f, + 382.f, 438.f, + 382.f, 433.f, + 389.f, 392.f, + 382.f, 309.f, + 315.f, 291.f, + 0.f, 35.f, + 0.5921568871f, 0.4980392158f, + 0.3647058904f, 255.f, + 439.f, 399.f, + 384.f, 393.f, + 354.f, 396.f, + 349.f, 395.f, + 348.f, 405.f, + 349.f, 421.f, + 352.f, 428.f, + 363.f, 434.f, + 383.f, 435.f, + 364.f, 458.f, + 358.f, 473.f, + 360.f, 499.f, + 364.f, 512.f, + 382.f, 516.f, + 407.f, 514.f, + 437.f, 506.f, + 476.f, 482.f, + 534.f, 437.f, + 562.f, 408.f, + 571.f, 382.f, + 581.f, 346.f, + 598.f, 0.f, + 333.f, 0.f, + 345.f, 190.f, + 336.f, 249.f, + 379.f, 333.f, + 373.f, 347.f, + 347.f, 353.f, + 347.f, 371.f, + 354.f, 377.f, + 387.f, 384.f, + 389.f, 396.f, + 0.f, 7.f, + 0.5921568871f, 0.4980392158f, + 0.3647058904f, 255.f, + 370.f, 309.f, + 322.f, 296.f, + 333.f, 268.f, + 339.f, 238.f, + 0.f, 10.f, + 0.5921568871f, 0.4980392158f, + 0.3647058904f, 255.f, + 341.f, 289.f, + 323.f, 293.f, + 314.f, 317.f, + 324.f, 328.f, + 352.f, 326.f, + 390.f, 332.f, + 388.f, 288.f, + 0.f, 12.f, + 0.4784313738f, 0.3647058904f, + 0.2156862766f, 255.f, + 440.f, 145.f, + 520.f, 146.f, + 464.f, 167.f, + 429.f, 220.f, + 422.f, 222.f, + 400.f, 206.f, + 392.f, 188.f, + 390.f, 173.f, + 393.f, 160.f, + 0.f, 15.f, + 0.7960784435f, 0.7490196228f, + 0.6705882549f, 255.f, + 460.f, 194.f, + 489.f, 189.f, + 500.f, 199.f, + 499.f, 211.f, + 489.f, 217.f, + 467.f, 223.f, + 445.f, 224.f, + 431.f, 217.f, + 422.f, 209.f, + 420.f, 200.f, + 436.f, 181.f, + 491.f, 189.f, + 0.f, 12.f, + 0.7960784435f, 0.7490196228f, + 0.6705882549f, 255.f, + 342.f, 199.f, + 343.f, 211.f, + 337.f, 218.f, + 322.f, 222.f, + 306.f, 221.f, + 292.f, 212.f, + 288.f, 197.f, + 297.f, 186.f, + 332.f, 189.f, + 0.f, 13.f, + 0.4470588267f, 0.3764705956f, + 0.2666666806f, 255.f, + 461.f, 182.f, + 445.f, 184.f, + 442.f, 196.f, + 446.f, 210.f, + 454.f, 218.f, + 462.f, 219.f, + 472.f, 217.f, + 480.f, 207.f, + 480.f, 196.f, + 477.f, 185.f, + 0.f, 11.f, + 0.4470588267f, 0.3764705956f, + 0.2666666806f, 255.f, + 309.f, 186.f, + 306.f, 192.f, + 307.f, 204.f, + 313.f, 213.f, + 325.f, 216.f, + 334.f, 210.f, + 336.f, 197.f, + 332.f, 189.f, + 0.f, 9.f, + 0.4470588267f, 0.3764705956f, + 0.2666666806f, 255.f, + 433.f, 186.f, + 422.f, 199.f, + 416.f, 199.f, + 432.f, 179.f, + 475.f, 183.f, + 470.f, 185.f, + 0.f, 9.f, + 0.4470588267f, 0.3764705956f, + 0.2666666806f, 255.f, + 470.f, 183.f, + 491.f, 187.f, + 497.f, 194.f, + 482.f, 188.f, + 433.f, 184.f, + 436.f, 181.f, + 0.f, 10.f, + 0.4470588267f, 0.3764705956f, + 0.2666666806f, 255.f, + 331.f, 190.f, + 340.f, 199.f, + 342.f, 197.f, + 333.f, 188.f, + 296.f, 184.f, + 292.f, 186.f, + 296.f, 186.f, + 0.f, 7.f, + 0.4470588267f, 0.3764705956f, + 0.2666666806f, 255.f, + 299.f, 187.f, + 291.f, 198.f, + 287.f, 198.f, + 296.f, 185.f, + 0.f, 9.f, + 0.4470588267f, 0.3764705956f, + 0.2666666806f, 255.f, + 312.f, 176.f, + 297.f, 178.f, + 297.f, 181.f, + 312.f, 177.f, + 326.f, 181.f, + 326.f, 179.f, + 0.f, 11.f, + 0.4470588267f, 0.3764705956f, + 0.2666666806f, 255.f, + 439.f, 172.f, + 470.f, 174.f, + 488.f, 180.f, + 457.f, 176.f, + 432.f, 176.f, + 423.f, 180.f, + 423.f, 178.f, + 431.f, 173.f, + 0.f, 10.f, + 0.7843137383f, 0.7254902124f, + 0.6078431606f, 255.f, + 467.f, 186.f, + 464.f, 189.f, + 464.f, 194.f, + 467.f, 199.f, + 473.f, 198.f, + 477.f, 193.f, + 477.f, 188.f, + 0.f, 10.f, + 0.7843137383f, 0.7254902124f, + 0.6078431606f, 255.f, + 332.f, 191.f, + 334.f, 194.f, + 332.f, 198.f, + 327.f, 198.f, + 323.f, 196.f, + 322.f, 192.f, + 324.f, 188.f, + 0.f, 8.f, + 0.4470588267f, 0.3764705956f, + 0.2666666806f, 255.f, + 398.f, 195.f, + 399.f, 204.f, + 401.f, 208.f, + 400.f, 198.f, + 400.f, 194.f, + 0.f, 9.f, + 0.4470588267f, 0.3764705956f, + 0.2666666806f, 255.f, + 365.f, 434.f, + 350.f, 427.f, + 350.f, 427.f, + 356.f, 433.f, + 372.f, 437.f, + 382.f, 434.f, + 0.f, 7.f, + 0.4470588267f, 0.3764705956f, + 0.2666666806f, 255.f, + 389.f, 393.f, + 418.f, 401.f, + 420.f, 403.f, + 390.f, 396.f, + 0.f, 7.f, + 0.4470588267f, 0.3764705956f, + 0.2666666806f, 255.f, + 391.f, 397.f, + 355.f, 397.f, + 356.f, 396.f, + 388.f, 393.f, + 0.f, 8.f, + 0.4470588267f, 0.3764705956f, + 0.2666666806f, 255.f, + 354.f, 397.f, + 344.f, 393.f, + 343.f, 390.f, + 355.f, 396.f, + 358.f, 396.f, + 0.f, 8.f, + 0.4470588267f, 0.3764705956f, + 0.2666666806f, 255.f, + 343.f, 392.f, + 335.f, 393.f, + 337.f, 391.f, + 344.f, 389.f, + 346.f, 392.f, + 0.f, 9.f, + 0.4470588267f, 0.3764705956f, + 0.2666666806f, 255.f, + 354.f, 379.f, + 345.f, 372.f, + 346.f, 370.f, + 355.f, 377.f, + 361.f, 373.f, + 361.f, 377.f, + 0.f, 11.f, + 0.4470588267f, 0.3764705956f, + 0.2666666806f, 255.f, + 368.f, 336.f, + 375.f, 337.f, + 373.f, 340.f, + 367.f, 337.f, + 360.f, 340.f, + 356.f, 346.f, + 356.f, 342.f, + 363.f, 336.f, + 0.f, 9.f, + 0.4470588267f, 0.3764705956f, + 0.2666666806f, 255.f, + 338.f, 337.f, + 348.f, 351.f, + 345.f, 351.f, + 336.f, 339.f, + 324.f, 327.f, + 329.f, 328.f, + 0.f, 7.f, + 0.4470588267f, 0.3764705956f, + 0.2666666806f, 255.f, + 367.f, 325.f, + 326.f, 327.f, + 330.f, 330.f, + 367.f, 327.f, + 0.f, 7.f, + 0.4470588267f, 0.3764705956f, + 0.2666666806f, 255.f, + 367.f, 326.f, + 378.f, 331.f, + 378.f, 328.f, + 367.f, 325.f, + 0.f, 9.f, + 0.4470588267f, 0.3764705956f, + 0.2666666806f, 255.f, + 325.f, 327.f, + 316.f, 317.f, + 315.f, 319.f, + 322.f, 328.f, + 329.f, 332.f, + 329.f, 329.f, + 0.f, 10.f, + 0.4470588267f, 0.3764705956f, + 0.2666666806f, 255.f, + 336.f, 256.f, + 329.f, 284.f, + 315.f, 312.f, + 316.f, 312.f, + 331.f, 267.f, + 343.f, 213.f, + 345.f, 214.f, + 0.f, 8.f, + 0.4470588267f, 0.3764705956f, + 0.2666666806f, 255.f, + 654.f, 243.f, + 644.f, 272.f, + 635.f, 283.f, + 647.f, 261.f, + 651.f, 238.f, + 0.f, 8.f, + 0.4470588267f, 0.3764705956f, + 0.2666666806f, 255.f, + 634.f, 282.f, + 617.f, 290.f, + 608.f, 301.f, + 625.f, 287.f, + 634.f, 286.f, + 0.f, 8.f, + 0.4470588267f, 0.3764705956f, + 0.2666666806f, 255.f, + 605.f, 310.f, + 609.f, 302.f, + 616.f, 294.f, + 610.f, 295.f, + 605.f, 307.f, + 0.f, 10.f, + 0.4470588267f, 0.3764705956f, + 0.2666666806f, 255.f, + 556.f, 578.f, + 569.f, 550.f, + 569.f, 544.f, + 556.f, 576.f, + 539.f, 599.f, + 543.f, 599.f, + 559.f, 576.f, + 0.f, 9.f, + 0.4470588267f, 0.3764705956f, + 0.2666666806f, 255.f, + 572.f, 548.f, + 582.f, 507.f, + 582.f, 496.f, + 583.f, 496.f, + 577.f, 537.f, + 575.f, 552.f, + 0.f, 10.f, + 0.4470588267f, 0.3764705956f, + 0.2666666806f, 255.f, + 588.f, 497.f, + 589.f, 474.f, + 590.f, 468.f, + 592.f, 467.f, + 589.f, 499.f, + 582.f, 527.f, + 581.f, 521.f, + 0.f, 7.f, + 0.4470588267f, 0.3764705956f, + 0.2666666806f, 255.f, + 572.f, 376.f, + 574.f, 376.f, + 563.f, 411.f, + 560.f, 411.f, + 0.f, 7.f, + 0.4470588267f, 0.3764705956f, + 0.2666666806f, 255.f, + 562.f, 406.f, + 540.f, 432.f, + 552.f, 422.f, + 564.f, 409.f, + 0.f, 8.f, + 0.4470588267f, 0.3764705956f, + 0.2666666806f, 255.f, + 547.f, 425.f, + 504.f, 463.f, + 501.f, 463.f, + 530.f, 443.f, + 551.f, 424.f, + 0.f, 7.f, + 0.4470588267f, 0.3764705956f, + 0.2666666806f, 255.f, + 503.f, 462.f, + 467.f, 488.f, + 468.f, 489.f, + 502.f, 465.f, + 0.f, 8.f, + 0.4470588267f, 0.3764705956f, + 0.2666666806f, 255.f, + 464.f, 489.f, + 438.f, 504.f, + 438.f, 506.f, + 452.f, 501.f, + 470.f, 490.f, + 0.f, 7.f, + 0.4470588267f, 0.3764705956f, + 0.2666666806f, 255.f, + 441.f, 503.f, + 406.f, 513.f, + 406.f, 515.f, + 431.f, 509.f, + 0.f, 7.f, + 0.4470588267f, 0.3764705956f, + 0.2666666806f, 255.f, + 409.f, 513.f, + 377.f, 513.f, + 377.f, 516.f, + 397.f, 516.f, + 0.f, 7.f, + 0.4470588267f, 0.3764705956f, + 0.2666666806f, 255.f, + 378.f, 514.f, + 357.f, 510.f, + 358.f, 513.f, + 383.f, 517.f, + 0.f, 9.f, + 0.4470588267f, 0.3764705956f, + 0.2666666806f, 255.f, + 622.f, 282.f, + 623.f, 289.f, + 625.f, 288.f, + 625.f, 281.f, + 632.f, 269.f, + 631.f, 264.f, + 0.f, 7.f, + 0.4470588267f, 0.3764705956f, + 0.2666666806f, 255.f, + 631.f, 267.f, + 630.f, 257.f, + 627.f, 247.f, + 629.f, 266.f, + 0.f, 7.f, + 0.4470588267f, 0.3764705956f, + 0.2666666806f, 255.f, + 628.f, 251.f, + 621.f, 239.f, + 618.f, 239.f, + 624.f, 250.f, + 0.f, 7.f, + 0.4470588267f, 0.3764705956f, + 0.2666666806f, 255.f, + 620.f, 241.f, + 621.f, 231.f, + 619.f, 229.f, + 617.f, 241.f, + 0.f, 10.f, + 0.4470588267f, 0.3764705956f, + 0.2666666806f, 255.f, + 620.f, 231.f, + 627.f, 226.f, + 633.f, 218.f, + 633.f, 215.f, + 624.f, 226.f, + 619.f, 229.f, + 617.f, 237.f, + 0.f, 8.f, + 0.4470588267f, 0.3764705956f, + 0.2666666806f, 255.f, + 636.f, 274.f, + 638.f, 260.f, + 635.f, 252.f, + 638.f, 267.f, + 635.f, 275.f, + 0.f, 11.f, + 0.4470588267f, 0.3764705956f, + 0.2666666806f, 255.f, + 631.f, 251.f, + 636.f, 257.f, + 636.f, 259.f, + 639.f, 257.f, + 634.f, 250.f, + 625.f, 249.f, + 628.f, 253.f, + 634.f, 253.f, + 0.f, 11.f, + 0.4470588267f, 0.3764705956f, + 0.2666666806f, 255.f, + 598.f, 339.f, + 595.f, 334.f, + 594.f, 328.f, + 597.f, 328.f, + 601.f, 337.f, + 611.f, 339.f, + 611.f, 341.f, + 602.f, 342.f, + 0.f, 7.f, + 0.4470588267f, 0.3764705956f, + 0.2666666806f, 255.f, + 341.f, 198.f, + 339.f, 187.f, + 337.f, 187.f, + 338.f, 197.f, + 0.f, 9.f, + 0.4470588267f, 0.3764705956f, + 0.2666666806f, 255.f, + 360.f, 512.f, + 364.f, 546.f, + 378.f, 599.f, + 379.f, 599.f, + 374.f, 572.f, + 366.f, 547.f, + 0.f, 7.f, + 0.4470588267f, 0.3764705956f, + 0.2666666806f, 255.f, + 373.f, 583.f, + 370.f, 599.f, + 378.f, 599.f, + 374.f, 577.f, + 0.f, 19.f, + 0.1882352978f, 0.1686274558f, + 0.0862745121f, 255.f, + 684.f, 453.f, + 685.f, 478.f, + 691.f, 473.f, + 701.f, 460.f, + 717.f, 414.f, + 713.f, 382.f, + 709.f, 374.f, + 724.f, 312.f, + 718.f, 299.f, + 758.f, 118.f, + 754.f, 83.f, + 685.f, 48.f, + 657.f, 247.f, + 654.f, 281.f, + 652.f, 289.f, + 621.f, 328.f, + 0.f, 10.f, + 0.1882352978f, 0.1686274558f, + 0.0862745121f, 255.f, + 710.f, 443.f, + 708.f, 402.f, + 718.f, 405.f, + 713.f, 443.f, + 708.f, 460.f, + 706.f, 460.f, + 710.f, 438.f, + 0.f, 11.f, + 0.1882352978f, 0.1686274558f, + 0.0862745121f, 255.f, + 726.f, 378.f, + 732.f, 402.f, + 734.f, 419.f, + 732.f, 420.f, + 727.f, 392.f, + 720.f, 381.f, + 702.f, 371.f, + 698.f, 344.f, + 0.f, 14.f, + 0.1882352978f, 0.1686274558f, + 0.0862745121f, 255.f, + 722.f, 308.f, + 730.f, 328.f, + 728.f, 354.f, + 725.f, 365.f, + 726.f, 348.f, + 722.f, 359.f, + 721.f, 361.f, + 717.f, 339.f, + 716.f, 357.f, + 712.f, 359.f, + 706.f, 282.f, + 0.f, 10.f, + 0.1882352978f, 0.1686274558f, + 0.0862745121f, 255.f, + 730.f, 292.f, + 742.f, 281.f, + 744.f, 275.f, + 740.f, 278.f, + 727.f, 287.f, + 706.f, 292.f, + 712.f, 301.f, + 0.f, 11.f, + 0.1882352978f, 0.1686274558f, + 0.0862745121f, 255.f, + 719.f, 284.f, + 729.f, 274.f, + 748.f, 237.f, + 758.f, 208.f, + 761.f, 182.f, + 761.f, 142.f, + 757.f, 110.f, + 691.f, 262.f, + 0.f, 10.f, + 0.1882352978f, 0.1686274558f, + 0.0862745121f, 255.f, + 661.f, 433.f, + 666.f, 445.f, + 672.f, 456.f, + 671.f, 453.f, + 668.f, 433.f, + 674.f, 424.f, + 643.f, 349.f, + 0.f, 10.f, + 0.1882352978f, 0.1686274558f, + 0.0862745121f, 255.f, + 646.f, 432.f, + 662.f, 407.f, + 655.f, 356.f, + 649.f, 412.f, + 642.f, 431.f, + 634.f, 443.f, + 636.f, 444.f, + 0.f, 14.f, + 0.1882352978f, 0.1686274558f, + 0.0862745121f, 255.f, + 643.f, 413.f, + 647.f, 404.f, + 658.f, 389.f, + 644.f, 314.f, + 637.f, 328.f, + 641.f, 402.f, + 636.f, 422.f, + 633.f, 427.f, + 634.f, 428.f, + 642.f, 417.f, + 650.f, 401.f, + 0.f, 8.f, + 0.1882352978f, 0.1686274558f, + 0.0862745121f, 255.f, + 642.f, 385.f, + 634.f, 377.f, + 619.f, 329.f, + 627.f, 322.f, + 652.f, 323.f, + 0.f, 16.f, + 0.1882352978f, 0.1686274558f, + 0.0862745121f, 255.f, + 622.f, 373.f, + 632.f, 383.f, + 636.f, 385.f, + 636.f, 382.f, + 627.f, 374.f, + 626.f, 367.f, + 633.f, 364.f, + 622.f, 326.f, + 609.f, 340.f, + 610.f, 348.f, + 612.f, 359.f, + 623.f, 376.f, + 631.f, 382.f, + 0.f, 21.f, + 0.1882352978f, 0.1686274558f, + 0.0862745121f, 255.f, + 682.f, 97.f, + 660.f, 248.f, + 652.f, 242.f, + 648.f, 234.f, + 647.f, 227.f, + 641.f, 223.f, + 633.f, 216.f, + 624.f, 206.f, + 580.f, 194.f, + 579.f, 179.f, + 565.f, 159.f, + 558.f, 133.f, + 560.f, 123.f, + 539.f, 93.f, + 529.f, 68.f, + 521.f, 16.f, + 529.f, 0.f, + 698.f, 0.f, + 0.f, 13.f, + 0.1882352978f, 0.1686274558f, + 0.0862745121f, 255.f, + 514.f, 48.f, + 517.f, 92.f, + 519.f, 106.f, + 521.f, 106.f, + 519.f, 81.f, + 521.f, 59.f, + 527.f, 39.f, + 526.f, 7.f, + 520.f, 16.f, + 516.f, 32.f, + 0.f, 8.f, + 0.1882352978f, 0.1686274558f, + 0.0862745121f, 255.f, + 449.f, 59.f, + 464.f, 36.f, + 471.f, 16.f, + 472.f, 1.f, + 466.f, 13.f, + 0.f, 8.f, + 0.1882352978f, 0.1686274558f, + 0.0862745121f, 255.f, + 472.f, 0.f, + 468.f, 21.f, + 460.f, 31.f, + 461.f, 6.f, + 458.f, 0.f, + 0.f, 20.f, + 0.1882352978f, 0.1686274558f, + 0.0862745121f, 255.f, + 458.f, 0.f, + 451.f, 26.f, + 441.f, 52.f, + 428.f, 76.f, + 414.f, 92.f, + 399.f, 103.f, + 387.f, 116.f, + 389.f, 113.f, + 411.f, 75.f, + 418.f, 45.f, + 399.f, 76.f, + 319.f, 131.f, + 315.f, 112.f, + 309.f, 98.f, + 316.f, 83.f, + 323.f, 51.f, + 246.f, 0.f, + 0.f, 12.f, + 0.1882352978f, 0.1686274558f, + 0.0862745121f, 255.f, + 327.f, 149.f, + 339.f, 172.f, + 349.f, 189.f, + 354.f, 194.f, + 352.f, 188.f, + 347.f, 167.f, + 350.f, 123.f, + 353.f, 114.f, + 318.f, 128.f, + 0.f, 8.f, + 0.1882352978f, 0.1686274558f, + 0.0862745121f, 255.f, + 396.f, 77.f, + 377.f, 96.f, + 348.f, 121.f, + 321.f, 131.f, + 318.f, 116.f, + 0.f, 15.f, + 0.1882352978f, 0.1686274558f, + 0.0862745121f, 255.f, + 299.f, 59.f, + 305.f, 88.f, + 312.f, 105.f, + 312.f, 84.f, + 315.f, 62.f, + 327.f, 44.f, + 326.f, 23.f, + 121.f, 0.f, + 287.f, 56.f, + 290.f, 78.f, + 299.f, 101.f, + 302.f, 107.f, + 0.f, 14.f, + 0.1882352978f, 0.1686274558f, + 0.0862745121f, 255.f, + 207.f, 0.f, + 286.f, 50.f, + 270.f, 86.f, + 257.f, 144.f, + 256.f, 244.f, + 237.f, 220.f, + 227.f, 206.f, + 211.f, 191.f, + 197.f, 161.f, + 128.f, 56.f, + 142.f, 0.f, + 0.f, 12.f, + 0.1882352978f, 0.1686274558f, + 0.0862745121f, 255.f, + 179.f, 168.f, + 196.f, 198.f, + 210.f, 221.f, + 212.f, 219.f, + 201.f, 200.f, + 196.f, 174.f, + 202.f, 148.f, + 169.f, 96.f, + 171.f, 141.f, + 0.f, 16.f, + 0.1882352978f, 0.1686274558f, + 0.0862745121f, 255.f, + 152.f, 157.f, + 158.f, 178.f, + 168.f, 198.f, + 172.f, 206.f, + 172.f, 202.f, + 165.f, 178.f, + 164.f, 154.f, + 173.f, 121.f, + 129.f, 48.f, + 126.f, 78.f, + 130.f, 108.f, + 133.f, 121.f, + 144.f, 146.f, + 0.f, 10.f, + 0.1882352978f, 0.1686274558f, + 0.0862745121f, 255.f, + 254.f, 155.f, + 269.f, 202.f, + 272.f, 221.f, + 273.f, 258.f, + 262.f, 243.f, + 259.f, 248.f, + 240.f, 222.f, + 0.f, 14.f, + 0.1882352978f, 0.1686274558f, + 0.0862745121f, 255.f, + 112.f, 33.f, + 121.f, 12.f, + 124.f, 0.f, + 145.f, 0.f, + 134.f, 34.f, + 127.f, 38.f, + 118.f, 58.f, + 112.f, 92.f, + 108.f, 100.f, + 107.f, 86.f, + 106.f, 63.f, + 0.f, 24.f, + 0.1882352978f, 0.1686274558f, + 0.0862745121f, 255.f, + 298.f, 146.f, + 293.f, 134.f, + 284.f, 132.f, + 272.f, 136.f, + 272.f, 138.f, + 267.f, 140.f, + 264.f, 149.f, + 266.f, 158.f, + 272.f, 157.f, + 274.f, 159.f, + 289.f, 154.f, + 303.f, 157.f, + 324.f, 171.f, + 334.f, 176.f, + 340.f, 181.f, + 332.f, 171.f, + 330.f, 162.f, + 328.f, 153.f, + 311.f, 146.f, + 298.f, 136.f, + 290.f, 133.f, + 0.f, 22.f, + 0.1882352978f, 0.1686274558f, + 0.0862745121f, 255.f, + 485.f, 139.f, + 487.f, 130.f, + 509.f, 129.f, + 532.f, 137.f, + 544.f, 152.f, + 549.f, 168.f, + 543.f, 164.f, + 543.f, 168.f, + 522.f, 159.f, + 496.f, 155.f, + 470.f, 156.f, + 435.f, 164.f, + 407.f, 173.f, + 391.f, 171.f, + 384.f, 168.f, + 379.f, 156.f, + 413.f, 151.f, + 414.f, 148.f, + 489.f, 129.f, + 0.f, 16.f, + 0.1882352978f, 0.1686274558f, + 0.0862745121f, 255.f, + 607.f, 191.f, + 606.f, 241.f, + 606.f, 275.f, + 596.f, 314.f, + 592.f, 314.f, + 581.f, 350.f, + 574.f, 364.f, + 574.f, 364.f, + 580.f, 328.f, + 577.f, 326.f, + 577.f, 312.f, + 583.f, 247.f, + 579.f, 164.f, + 0.f, 13.f, + 0.1568627506f, 0.1686274558f, + 0.2352941185f, 255.f, + 756.f, 68.f, + 754.f, 97.f, + 749.f, 104.f, + 734.f, 107.f, + 715.f, 100.f, + 701.f, 102.f, + 696.f, 97.f, + 682.f, 26.f, + 661.f, 0.f, + 736.f, 0.f, + 0.f, 11.f, + 0.1568627506f, 0.1686274558f, + 0.2352941185f, 255.f, + 689.f, 76.f, + 687.f, 88.f, + 683.f, 99.f, + 676.f, 99.f, + 674.f, 78.f, + 669.f, 39.f, + 659.f, 0.f, + 705.f, 0.f, + 0.f, 9.f, + 0.1568627506f, 0.1686274558f, + 0.2352941185f, 255.f, + 652.f, 0.f, + 651.f, 16.f, + 646.f, 29.f, + 642.f, 31.f, + 638.f, 24.f, + 631.f, 0.f, + 0.f, 9.f, + 0.1568627506f, 0.1686274558f, + 0.2352941185f, 255.f, + 628.f, 0.f, + 628.f, 20.f, + 625.f, 27.f, + 619.f, 29.f, + 616.f, 19.f, + 616.f, 0.f, + 0.f, 12.f, + 0.1568627506f, 0.1686274558f, + 0.2352941185f, 255.f, + 415.f, 0.f, + 403.f, 31.f, + 392.f, 54.f, + 376.f, 68.f, + 364.f, 74.f, + 362.f, 70.f, + 365.f, 61.f, + 390.f, 25.f, + 400.f, 0.f, + 0.f, 12.f, + 0.1568627506f, 0.1686274558f, + 0.2352941185f, 255.f, + 352.f, 42.f, + 341.f, 66.f, + 339.f, 82.f, + 344.f, 81.f, + 350.f, 70.f, + 364.f, 44.f, + 381.f, 21.f, + 380.f, 16.f, + 368.f, 19.f, + 0.f, 11.f, + 0.1568627506f, 0.1686274558f, + 0.2352941185f, 255.f, + 344.f, 0.f, + 365.f, 0.f, + 353.f, 21.f, + 341.f, 49.f, + 332.f, 62.f, + 329.f, 58.f, + 329.f, 51.f, + 344.f, 0.f, + 0.f, 10.f, + 0.1568627506f, 0.1686274558f, + 0.2352941185f, 255.f, + 333.f, 2.f, + 329.f, 17.f, + 323.f, 23.f, + 318.f, 18.f, + 319.f, 6.f, + 320.f, 0.f, + 331.f, 0.f, + 0.f, 11.f, + 0.1764705926f, 0.1960784346f, + 0.2666666806f, 255.f, + 760.f, 0.f, + 761.f, 39.f, + 757.f, 80.f, + 750.f, 86.f, + 709.f, 69.f, + 692.f, 47.f, + 692.f, 26.f, + 696.f, 0.f, + 0.f, 7.f, + 0.160784319f, 0.1764705926f, + 0.1882352978f, 255.f, + 278.f, 599.f, + 324.f, 554.f, + 322.f, 557.f, + 283.f, 599.f, + 0.f, 9.f, + 0.160784319f, 0.1764705926f, + 0.1882352978f, 255.f, + 758.f, 589.f, + 753.f, 577.f, + 755.f, 577.f, + 762.f, 591.f, + 756.f, 599.f, + 754.f, 599.f, + 0.f, 7.f, + 0.160784319f, 0.1764705926f, + 0.1882352978f, 255.f, + 773.f, 599.f, + 765.f, 583.f, + 763.f, 583.f, + 770.f, 599.f, + 0.f, 10.f, + 0.160784319f, 0.1764705926f, + 0.1882352978f, 255.f, + 694.f, 507.f, + 694.f, 498.f, + 691.f, 498.f, + 694.f, 509.f, + 690.f, 519.f, + 693.f, 521.f, + 696.f, 507.f, + 0.f, 9.f, + 0.160784319f, 0.1764705926f, + 0.1882352978f, 255.f, + 215.f, 583.f, + 256.f, 556.f, + 253.f, 556.f, + 216.f, 579.f, + 198.f, 599.f, + 200.f, 599.f, + 0.f, 0.f}; + +float verticesFB[] = { + {0.842}, {1.052}, {0.842}, {1.649}, {5.296}, {1.649}, {5.595}, {1.855}, {5.913}, {2.028}, {6.233}, + {2.194}, {6.541}, {2.384}, {6.733}, {2.576}, {6.906}, {2.851}, {7.060}, {3.190}, {7.197}, {3.573}, + {7.317}, {3.981}, {7.423}, {4.397}, {7.516}, {4.800}, {7.597}, {5.173}, {7.668}, {5.496}, {7.729}, + {5.751}, {7.782}, {5.918}, {7.815}, {5.974}, {7.876}, {6.075}, {7.981}, {6.274}, {8.143}, {6.622}, + {8.373}, {7.172}, {8.686}, {7.976}, {8.960}, {8.571}, {9.034}, {8.733}, {8.830}, {8.824}, {8.392}, + {8.659}, {7.954}, {8.508}, {7.784}, {8.487}, {7.601}, {8.471}, {7.395}, {8.460}, {7.153}, {8.453}, + {6.867}, {8.449}, {6.116}, {8.449}, {5.630}, {8.451}, {5.057}, {8.452}, {4.384}, {8.453}, {4.144}, + {8.119}, {3.980}, {7.715}, {4.065}, {7.361}, {4.215}, {7.044}, {4.420}, {6.761}, {4.668}, {6.505}, + {4.948}, {6.271}, {5.250}, {6.055}, {5.562}, {5.850}, {5.778}, {5.645}, {6.015}, {5.478}, {6.421}, + {5.367}, {6.742}, {5.271}, {6.921}, {5.178}, {7.105}, {4.836}, {7.123}, {4.472}, {7.005}, {4.183}, + {6.803}, {3.964}, {6.641}, {3.871}, {6.487}, {3.890}, {6.309}, {4.005}, {6.077}, {4.200}, {5.758}, + {4.459}, {5.321}, {4.768}, {4.735}, {5.110}, {4.641}, {5.211}, {4.445}, {5.452}, {4.177}, {5.794}, + {3.868}, {6.198}, {3.548}, {6.624}, {3.246}, {7.033}, {2.993}, {7.387}, {2.819}, {7.644}, {2.753}, + {7.767}, {2.774}, {8.165}, {2.859}, {8.538}, {3.020}, {8.867}, {3.272}, {9.131}, {3.625}, {9.311}, + {4.420}, {9.563}, {5.023}, {9.750}, {5.461}, {9.885}, {5.756}, {9.979}, {5.933}, {10.040}, {6.017}, + {10.090}, {6.032}, {10.140}, {5.946}, {10.470}, {5.873}, {10.810}, {5.830}, {11.140}, {5.835}, {11.460}, + {5.904}, {11.790}, {6.054}, {12.120}, {6.226}, {12.400}, {6.409}, {12.670}, {6.591}, {12.950}, {6.763}, + {13.240}, {6.912}, {13.530}, {7.030}, {13.850}, {7.101}, {14.260}, {7.094}, {14.700}, {7.023}, {15.130}, + {6.902}, {15.510}, {6.747}, {15.810}, {6.570}, {15.970}, {6.403}, {15.930}, {6.092}, {15.770}, {5.735}, + {15.550}, {5.431}, {15.310}, {5.277}, {15.100}, {5.174}, {14.540}, {5.157}, {14.260}, {5.122}, {14.130}, + {4.885}, {13.950}, {4.557}, {13.890}, {4.191}, {13.920}, {3.841}, {14.020}, {3.559}, {14.170}, {3.428}, + {14.300}, {3.353}, {14.480}, {3.322}, {14.740}, {3.318}, {15.080}, {3.326}, {15.520}, {3.332}, {16.100}, + {3.530}, {16.370}, {3.655}, {16.700}, {3.728}, {17.090}, {3.771}, {17.500}, {3.805}, {17.900}, {3.853}, + {18.270}, {3.934}, {18.590}, {4.072}, {18.810}, {4.357}, {19.060}, {4.706}, {19.310}, {5.085}, {19.520}, + {5.459}, {19.680}, {5.794}, {19.750}, {6.056}, {19.710}, {6.208}, {19.540}, {6.733}, {19.540}, {7.059}, + {19.540}, {7.265}, {19.540}, {7.431}, {19.540}, {7.637}, {19.540}, {7.963}, {19.540}, {8.488}, {19.540}, + {8.782}, {19.390}, {9.234}, {19.250}, {9.553}, {19.080}, {9.893}, {18.880}, {10.230}, {18.650}, {10.560}, + {18.420}, {10.840}, {18.190}, {11.070}, {17.990}, {11.230}, {17.820}, {11.700}, {17.160}, {11.970}, {16.690}, + {12.110}, {16.370}, {12.150}, {16.170}, {12.150}, {16.050}, {12.170}, {15.980}, {12.350}, {15.740}, {12.570}, + {15.550}, {12.820}, {15.420}, {13.100}, {15.330}, {13.400}, {15.280}, {13.730}, {15.270}, {14.070}, {15.280}, + {14.430}, {15.330}, {14.800}, {15.390}, {15.180}, {15.470}, {15.560}, {15.560}, {15.950}, {15.650}, {16.330}, + {15.750}, {16.710}, {15.840}, {17.080}, {15.920}, {17.450}, {15.990}, {17.790}, {16.030}, {18.040}, {16.040}, + {18.310}, {16.040}, {18.630}, {16.010}, {18.980}, {15.960}, {19.390}, {15.890}, {19.860}, {15.800}, {20.180}, + {15.740}, {20.450}, {15.700}, {20.700}, {15.690}, {20.940}, {15.720}, {21.190}, {15.800}, {21.470}, {15.930}, + {21.810}, {16.130}, {22.210}, {16.410}, {22.700}, {16.770}, {23.010}, {16.960}, {23.330}, {17.080}, {23.660}, + {17.150}, {23.990}, {17.170}, {24.330}, {17.130}, {24.660}, {17.040}, {24.980}, {16.910}, {25.280}, {16.730}, + {25.560}, {16.510}, {25.800}, {16.300}, {25.950}, {16.120}, {26.040}, {15.890}, {26.120}, {15.490}, {26.210}, + {14.830}, {26.270}, {14.420}, {26.320}, {14.030}, {26.370}, {13.660}, {26.390}, {13.300}, {26.380}, {12.940}, + {26.330}, {12.580}, {26.290}, {12.470}, {26.200}, {12.280}, {26.080}, {12.030}, {25.930}, {11.740}, {25.750}, + {11.400}, {25.550}, {11.030}, {25.340}, {10.650}, {25.120}, {10.270}, {24.900}, {9.897}, {24.680}, {9.544}, + {24.480}, {9.224}, {24.300}, {8.949}, {24.140}, {8.731}, {23.850}, {8.298}, {23.660}, {7.941}, {23.530}, + {7.660}, {23.420}, {7.457}, {23.290}, {7.331}, {23.290}, {6.946}, {23.300}, {6.569}, {23.310}, {6.198}, + {23.340}, {5.830}, {23.380}, {5.501}, {23.300}, {5.389}, {23.050}, {5.526}, {22.840}, {5.731}, {22.680}, + {5.993}, {22.560}, {6.302}, {22.480}, {6.647}, {22.430}, {7.017}, {22.410}, {7.401}, {22.410}, {7.788}, + {22.440}, {8.166}, {22.480}, {8.526}, {22.540}, {8.856}, {22.600}, {9.146}, {22.700}, {9.459}, {22.830}, + {9.787}, {22.990}, {10.120}, {23.160}, {10.460}, {23.330}, {10.790}, {23.480}, {11.110}, {23.620}, {11.400}, + {23.730}, {11.660}, {23.800}, {11.890}, {23.850}, {12.260}, {23.880}, {12.640}, {23.860}, {13.020}, {23.810}, + {13.390}, {23.720}, {13.730}, {23.590}, {14.050}, {23.410}, {14.320}, {23.190}, {14.540}, {22.920}, {14.690}, + {22.620}, {14.790}, {22.300}, {14.850}, {21.970}, {14.880}, {21.640}, {14.880}, {21.310}, {14.880}, {20.980}, + {14.870}, {21.110}, {14.550}, {21.250}, {14.230}, {21.390}, {13.900}, {21.520}, {13.580}, {21.640}, {13.250}, + {21.740}, {12.920}, {21.810}, {12.590}, {21.850}, {12.260}, {21.850}, {11.920}, {21.810}, {11.580}, {21.710}, + {11.240}, {21.550}, {10.880}, {21.320}, {10.540}, {21.040}, {10.220}, {20.740}, {9.924}, {20.430}, {9.648}, + {20.130}, {9.397}, {19.860}, {9.172}, {19.650}, {8.976}, {19.500}, {8.811}, {19.440}, {8.678}, {19.450}, + {8.382}, {19.640}, {7.984}, {19.840}, {7.710}, {20.060}, {7.419}, {20.270}, {7.119}, {20.440}, {6.816}, + {20.520}, {6.520}, {20.480}, {6.237}, {20.350}, {5.983}, {20.160}, {5.736}, {19.930}, {5.491}, {19.670}, + {5.243}, {19.400}, {4.989}, {19.110}, {4.724}, {18.830}, {4.442}, {18.560}, {4.139}, {18.410}, {3.906}, + {18.220}, {3.581}, {18.010}, {3.235}, {17.790}, {2.940}, {17.590}, {2.767}, {17.040}, {2.553}, {16.920}, + {2.444}, {16.820}, {2.143}, {16.630}, {1.806}, {16.420}, {1.766}, {16.020}, {1.824}, {15.580}, {1.951}, + {15.220}, {2.118}, {15.260}, {2.258}, {15.450}, {2.568}, {15.710}, {2.802}, {16.020}, {2.986}, {16.360}, + {3.150}, {16.680}, {3.320}, {16.970}, {3.524}, {17.060}, {3.622}, {17.240}, {3.838}, {17.490}, {4.138}, + {17.780}, {4.490}, {18.080}, {4.859}, {18.370}, {5.213}, {18.610}, {5.518}, {18.770}, {5.741}, {18.840}, + {5.849}, {18.890}, {6.150}, {18.880}, {6.406}, {18.780}, {6.694}, {18.570}, {7.094}, {18.260}, {7.045}, + {18.290}, {6.817}, {18.130}, {6.445}, {17.970}, {6.185}, {17.750}, {5.942}, {17.500}, {5.701}, {17.220}, + {5.447}, {16.940}, {5.167}, {16.670}, {4.846}, {16.510}, {4.623}, {16.340}, {4.356}, {16.170}, {4.058}, + {15.980}, {3.741}, {15.780}, {3.416}, {15.560}, {3.096}, {15.330}, {2.794}, {15.080}, {2.520}, {14.800}, + {2.287}, {14.510}, {2.107}, {14.300}, {1.982}, {14.240}, {1.649}, {27.220}, {1.649}, {27.220}, {1.052}, + {0.842}, {1.052}, {0.842}, {1.649}, {7.541}, {1.649}, {7.700}, {1.941}, {7.767}, {2.217}, {7.837}, + {2.566}, {7.918}, {2.911}, {8.010}, {3.251}, {8.111}, {3.587}, {8.222}, {3.919}, {8.342}, {4.246}, + {8.472}, {4.570}, {8.610}, {4.890}, {8.756}, {5.205}, {8.910}, {5.518}, {9.071}, {5.826}, {9.240}, + {6.131}, {9.415}, {6.432}, {9.597}, {6.730}, {9.785}, {7.025}, {9.979}, {7.317}, {10.180}, {7.605}, + {10.380}, {7.891}, {10.590}, {8.173}, {10.800}, {8.453}, {11.990}, {8.453}, {12.400}, {8.456}, {12.720}, + {8.465}, {12.970}, {8.481}, {13.180}, {8.508}, {13.370}, {8.548}, {13.570}, {8.602}, {13.800}, {8.674}, + {14.090}, {8.765}, {14.460}, {8.878}, {14.780}, {8.817}, {15.180}, {8.588}, {15.470}, {8.326}, {15.600}, + {8.139}, {15.850}, {7.769}, {16.140}, {7.335}, {16.380}, {6.959}, {16.490}, {6.761}, {16.530}, {6.380}, + {16.470}, {6.004}, {16.340}, {5.647}, {16.170}, {5.322}, {16.050}, {5.134}, {15.880}, {4.893}, {15.670}, + {4.617}, {15.430}, {4.323}, {15.200}, {4.030}, {14.970}, {3.755}, {14.760}, {3.515}, {14.690}, {3.464}, + {14.540}, {3.373}, {14.330}, {3.236}, {14.050}, {3.047}, {13.730}, {2.800}, {13.360}, {2.489}, {12.950}, + {2.107}, {12.520}, {1.649}, {0.842}, {1.649}, {27.220}, {1.649}, {27.220}, {1.052}}; + +DrawNodeTests::DrawNodeTests() +{ + ADD_TEST_CASE(DrawNodeMethodsTest); + + ADD_TEST_CASE(DrawNodeSpLinesTest); + + ADD_TEST_CASE(DrawNodeAxmolTest2); + +#if defined(AX_PLATFORM_PC) + ADD_TEST_CASE(CandyMixEeffect); +#endif + ADD_TEST_CASE(DrawNodePictureTest); + + ADD_TEST_CASE(DrawNodeMorphTest_Polygon); + ADD_TEST_CASE(DrawNodeMorphTest_SolidPolygon); + + ADD_TEST_CASE(DrawNodePieTest); + + ADD_TEST_CASE(DrawNodeDrawInWrongOrder_Issue1888); + + ADD_TEST_CASE(DrawNodeThicknessTest); + ADD_TEST_CASE(DrawNodeThicknessStressTest); + + ADD_TEST_CASE(DrawNodeIssueTester); + +} + +DrawNodeBaseTest::DrawNodeBaseTest() +{ + auto director = Director::getInstance(); + director->setClearColor(Color4F(0, 0, 0, 0)); + + origin = director->getVisibleOrigin(); + size = director->getVisibleSize(); + center = Vec2(origin.x + size.width / 2, origin.y + size.height / 2); + + screen = Director::getInstance()->getVisibleSize(); + sixth = Vec2(screen.width / 6, screen.height / 6); + sixth.y; + + defY = (int)(center.y + sixth.y); + defY2 = (int)(center.y - sixth.y); + dev = sixth.y; + + pts = PointArray::create(n); + pts2 = PointArray::create(n); + pts->retain(); + pts2->retain(); + for (int i = 0; i < n; ++i) + { + pts->insertControlPoint(Vec2(0, 0), i); + pts2->insertControlPoint(Vec2(0, 0), i); + } + + generateDataPoints(); + + if (!drawNode) + { + drawNode = DrawNode::create(); + addChild(drawNode); + } + menuItemDrawOrder->setFontSize(10); + menuItemTransform->setFontSize(10); + menuItemDrawOrder = MenuItemFont::create("drawOrder: false", AX_CALLBACK_1(DrawNodeBaseTest::setDrawOrder, this)); + menuItemTransform = MenuItemFont::create("transform: true", AX_CALLBACK_1(DrawNodeBaseTest::setTransform, this)); + + auto menu = Menu::create(menuItemDrawOrder, menuItemTransform, nullptr); + menu->alignItemsVerticallyWithPadding(4); + menu->setPosition(Vec2(size.x - 50, size.y / 2 - 20)); + addChild(menu, 1000); +} + +void DrawNodeBaseTest::generateDataPoints() +{ + for (int i = 0; i < n; ++i) + { + float yy1 = RandomHelper::random_real(defY - dev, defY + dev); + float yy2 = RandomHelper::random_real(defY2 - dev, defY2 + dev); + pts->replaceControlPoint(Vec2(margin + i * (screen.width - 3 * margin) / n, yy1), i); + pts2->replaceControlPoint(Vec2(margin + i * (screen.width - 3 * margin) / n, yy2), i); + } +} + +void DrawNodeBaseTest::setTransform(Object* sender) +{ + bool ret = drawNode->properties.getTransform(); + if (ret) + { + menuItemTransform->setString("transform: false"); + drawNode->properties.setTransform(false); + } + else + { + menuItemTransform->setString("transform: true"); + drawNode->properties.setTransform(true); + } +} + +void DrawNodeBaseTest::setDrawOrder(Object* sender) +{ + bool ret = drawNode->properties.getDrawOrder(); + if (ret) + { + menuItemDrawOrder->setString("drawOrder: false"); + drawNode->properties.setDrawOrder(false); + } + else + { + menuItemDrawOrder->setString("drawOrder: true"); + drawNode->properties.setDrawOrder(true); + } +} + +void DrawNodeBaseTest::listviewCallback(ax::Object* sender, ax::ui::ListView::EventType type) +{ + // clear all text to white + auto listview = static_cast(sender); + for (auto&& item : listview->getItems()) + { + static_cast(item)->setColor(ax::Color3B::WHITE); + } + _currentSeletedItemIndex = (int)listview->getCurSelectedIndex(); + listview->getItem(_currentSeletedItemIndex)->setColor(ax::Color3B::RED); +} + +void DrawNodeBaseTest::onChangedRadioButtonSelect(ui::RadioButton* radioButton, ui::RadioButton::EventType type) +{ + if (radioButton == nullptr) + return; + + switch (type) + { + case ui::RadioButton::EventType::SELECTED: + { + selectedRadioButton = radioButton->getTag(); + break; + } + + case ui::RadioButton::EventType::UNSELECTED: + { + break; + } + default: + break; + } +} + +void DrawNodeBaseTest::update(float dt) +{ + drawNode->clear(); +} + +string DrawNodeBaseTest::title() const +{ + return ""; +} + +void DrawNodeBaseTest::drawDirection(const Vec2* vec, const int size, Vec2 offset) +{ + for (size_t i = 0; i < size; i++) + { + auto label = Label::createWithTTF(std::to_string(i).c_str(), "fonts/Marker Felt.ttf", 10); + addChild(label); + label->setPosition(vec[i] + offset); + } +} + +void DrawNodeBaseTest::changeEndAngle(ax::Object* pSender, ax::ui::Slider::EventType type) +{ + if (type == ax::ui::Slider::EventType::ON_PERCENTAGE_CHANGED) + { + slider[sliderType::AngleEnd] = dynamic_cast(pSender); + sliderValue[sliderType::AngleEnd] = slider[sliderType::AngleEnd]->getPercent() * 3.6; + sliderLabel[sliderType::AngleEnd]->setString("endAngle: (" + + Value(sliderValue[sliderType::AngleEnd]).asString() + ")"); + } +} + +void DrawNodeBaseTest::changeStartAngle(ax::Object* pSender, ax::ui::Slider::EventType type) +{ + if (type == ax::ui::Slider::EventType::ON_PERCENTAGE_CHANGED) + { + slider[sliderType::AngleStart] = dynamic_cast(pSender); + sliderValue[sliderType::AngleStart] = slider[sliderType::AngleStart]->getPercent() * 3.6; + sliderLabel[sliderType::AngleStart]->setString("startAngle: (" + + Value(sliderValue[sliderType::AngleStart]).asString() + ")"); + } +} + +void DrawNodeBaseTest::changeRotation(ax::Object* pSender, ax::ui::Slider::EventType type) +{ + if (type == ax::ui::Slider::EventType::ON_PERCENTAGE_CHANGED) + { + slider[sliderType::Rotation] = dynamic_cast(pSender); + sliderValue[sliderType::Rotation] = slider[sliderType::Rotation]->getPercent() * 3.6; + sliderLabel[sliderType::Rotation]->setString("Rotation: (" + + Value(sliderValue[sliderType::Rotation]).asString() + ")"); + } +} + +void DrawNodeBaseTest::changeThickness(ax::Object* pSender, ax::ui::Slider::EventType type) +{ + if (type == ax::ui::Slider::EventType::ON_PERCENTAGE_CHANGED) + { + slider[sliderType::Thickness] = dynamic_cast(pSender); + sliderValue[sliderType::Thickness] = slider[sliderType::Thickness]->getPercent() * 0.1; + sliderLabel[sliderType::Thickness]->setString("Thickness: (" + + Value(sliderValue[sliderType::Thickness]).asString() + ")"); + } +} + +void DrawNodeBaseTest::initSliders() +{ + _currentSeletedItemIndex = 0; + + std::string text[sliderType::sliderTypeLast] = {"AngleStart", "AngleEnd", "Rotation", "Thickness"}; + + auto ttfConfig = TTFConfig("fonts/arial.ttf", 5); + for (int i = 0; i < (sliderType::sliderTypeLast); i++) + { + slider[i] = ax::ui::Slider::create(); + slider[i]->setAnchorPoint(Vec2::ANCHOR_MIDDLE_LEFT); + slider[i]->loadBarTexture("cocosui/sliderTrack.png"); + slider[i]->loadSlidBallTextures("ccs-res/cocosui/sliderballnormal.png", "ccs-res/cocosui/sliderballpressed.png", + ""); + slider[i]->loadProgressBarTexture("cocosui/sliderProgress.png"); + slider[i]->setPosition(Vec2(size.width - slider[i]->getContentSize().x / 2 - 10, size.height / 6 + i * 16)); + slider[i]->setPercent(sliderValue[i]); + + slider[i]->setEnabled(false); + slider[i]->setScale(0.5f); + addChild(slider[i], 20); + + sliderLabel[i] = Label::createWithTTF(ttfConfig, text[i] + ": (" + Value(sliderValue[i]).asString() + ")"); + sliderLabel[i]->setAnchorPoint(Vec2::ANCHOR_MIDDLE_LEFT); + sliderLabel[i]->setPosition(slider[i]->getPosition() + Vec2(0, 8)); + addChild(sliderLabel[i], 20); + } + + slider[sliderType::AngleStart]->addEventListener(AX_CALLBACK_2(DrawNodeBaseTest::changeStartAngle, this)); + slider[sliderType::AngleEnd]->addEventListener(AX_CALLBACK_2(DrawNodeBaseTest::changeEndAngle, this)); + slider[sliderType::Rotation]->addEventListener(AX_CALLBACK_2(DrawNodeBaseTest::changeRotation, this)); + slider[sliderType::Thickness]->addEventListener(AX_CALLBACK_2(DrawNodeBaseTest::changeThickness, this)); +} + +DrawNodeMorphTest_SolidPolygon::DrawNodeMorphTest_SolidPolygon() +{ + const float coef = 2.0f * (float)M_PI / segments; + float scaleX = 1.0f; + float scaleY = 1.0f; + + const float angle = 360 / segments; + + for (size_t n = 0; n < 10; n++) + { + + drawNodeArray[n] = DrawNode::create(); + addChild(drawNodeArray[n]); + drawNodeArray[n]->setPosition( + Vec2(AXRANDOM_MINUS1_1() * size.width / 4, AXRANDOM_MINUS1_1() * size.height / 4) + Vec2(100, 100)); + color[n] = Color4F(AXRANDOM_0_1(), AXRANDOM_0_1(), AXRANDOM_0_1(), 1.0f); + rad[n] = 90 + AXRANDOM_0_1() * 10; + state[n] = (AXRANDOM_0_1() > 0.5f) ? false : true; + + verticesObj1[n] = new Vec2[segments]; // circle + verticesObj2[n] = new Vec2[segments]; // square + verticesObjMorph[n] = new Vec2[segments]; + + for (unsigned int i = 0; i < segments; i++) // + { + float rads = i * coef + angle; + int radius = 150 + AXRANDOM_MINUS1_1() * 50; + if (n > 2) + { + verticesObj1[n][i].x = radius * cosf(rads) * scaleX + center.x + AXRANDOM_0_1() * 30; + verticesObj1[n][i].y = radius * sinf(rads) * scaleY + center.y + AXRANDOM_0_1() * 30; + } + else + { + verticesObj1[n][i].x = radius * cosf(rads) * scaleX + center.x; + verticesObj1[n][i].y = radius * sinf(rads) * scaleY + center.y; + } + verticesObjMorph[n][i] = verticesObj1[n][i]; + } + + // A verticesObj2 is a bunch of vertices along straight lines + int i = 0; + float delta = segments / 4; + // Left side of verticesObj2 + for (float y = 50; y > -50; y -= delta) + { + verticesObj2[n][i++] = center + Vec2(-50, y); + } + // top + for (float x = -50; x < 50; x += delta) + { + verticesObj2[n][i++] = center + Vec2(x, -50); + } + // Right side + for (float y = -50; y < 50; y += delta) + { + verticesObj2[n][i++] = center + Vec2(50, y); + } + // Bottom + for (float x = 50; x > -50; x -= delta) + { + verticesObj2[n][i++] = center + Vec2(x, 50); + } + } + + initSliders(); + slider[sliderType::Thickness]->setEnabled(true); + + scheduleUpdate(); +} +void DrawNodeMorphTest_SolidPolygon::update(float dt) +{ + for (int n = 0; n < 10; n++) + { + drawNodeArray[n]->clear(); + + Vec2 v1, v2; + float totalDistance = 0; + for (int i = 0; i < segments; i++) + { + if (state[n]) + { + v1 = verticesObj1[n][i]; + v2 = verticesObj2[n][i]; + } + else + { + v2 = verticesObj1[n][i]; + v1 = verticesObj2[n][i]; + } + v2 = verticesObjMorph[n][i]; + verticesObjMorph[n][i] = v2.lerp(v1, 0.05f); + totalDistance += v1.distance(v2); + } + // If all the vertices are close, switch shape + if (totalDistance < 300.0) + { + state[n] = !state[n]; + } + + drawNodeArray[n]->properties.setScale(Vec2(0.5f, 0.5f)); + drawNodeArray[n]->drawSolidPolygon(verticesObjMorph[n], segments, color[n], sliderValue[sliderType::Thickness], + Color4B::YELLOW); + } +} + +void DrawNodeMorphTest_SolidPolygon::onEnter() +{ + for (int i = 0; i < sliderType::sliderTypeLast; i++) + { + sliderValue[i] = 1; + slider[i]->setPercent(sliderValue[i]); + } + + sliderValue[sliderType::Thickness] = 10; + slider[sliderType::Thickness]->setPercent(sliderValue[sliderType::Thickness]); + + DrawNodeBaseTest::onEnter(); +} + +string DrawNodeMorphTest_SolidPolygon::title() const +{ + return "Morphing"; +} + +string DrawNodeMorphTest_SolidPolygon::subtitle() const +{ + return "Solid Polygons"; +} + +DrawNodeMorphTest_Polygon::DrawNodeMorphTest_Polygon() +{ + const float coef = 2.0f * (float)M_PI / segments; + float scaleX = 1.0f; + float scaleY = 1.0f; + + const float angle = 360 / segments; + + for (size_t n = 0; n < 10; n++) + { + drawNodeArray[n] = DrawNode::create(); + addChild(drawNodeArray[n]); + drawNodeArray[n]->setPosition( + Vec2(AXRANDOM_MINUS1_1() * size.width / 4, AXRANDOM_MINUS1_1() * size.height / 4) + Vec2(100, 100)); + color[n] = Color4F(AXRANDOM_0_1(), AXRANDOM_0_1(), AXRANDOM_0_1(), 1.0f); + rad[n] = 90 + AXRANDOM_0_1() * 10; + state[n] = (AXRANDOM_0_1() > 0.5f) ? false : true; + + verticesObj1[n] = new Vec2[segments]; // circle + verticesObj2[n] = new Vec2[segments]; // square + verticesObjMorph[n] = new Vec2[segments]; + + for (unsigned int i = 0; i < segments; i++) // + { + float rads = i * coef + angle; + int radius = 150 + AXRANDOM_MINUS1_1() * 50; + if (n > 2) + { + verticesObj1[n][i].x = radius * cosf(rads) * scaleX + center.x + AXRANDOM_0_1() * 30; + verticesObj1[n][i].y = radius * sinf(rads) * scaleY + center.y + AXRANDOM_0_1() * 30; + } + else + { + verticesObj1[n][i].x = radius * cosf(rads) * scaleX + center.x; + verticesObj1[n][i].y = radius * sinf(rads) * scaleY + center.y; + } + verticesObjMorph[n][i] = verticesObj1[n][i]; + } + + // A verticesObj2 is a bunch of vertices along straight lines + int i = 0; + float delta = segments / 4; + // Left side of verticesObj2 + for (float y = 50; y > -50; y -= delta) + { + verticesObj2[n][i++] = center + Vec2(-50, y); + } + // top + for (float x = -50; x < 50; x += delta) + { + verticesObj2[n][i++] = center + Vec2(x, -50); + } + // Right side + for (float y = -50; y < 50; y += delta) + { + verticesObj2[n][i++] = center + Vec2(50, y); + } + // Bottom + for (float x = 50; x > -50; x -= delta) + { + verticesObj2[n][i++] = center + Vec2(x, 50); + } + } + + initSliders(); + slider[sliderType::Thickness]->setEnabled(true); + + scheduleUpdate(); +} +void DrawNodeMorphTest_Polygon::update(float dt) +{ + for (int n = 0; n < 10; n++) + { + drawNodeArray[n]->clear(); + + Vec2 v1, v2; + float totalDistance = 0; + for (int i = 0; i < segments; i++) + { + if (state[n]) + { + v1 = verticesObj1[n][i]; + v2 = verticesObj2[n][i]; + } + else + { + v2 = verticesObj1[n][i]; + v1 = verticesObj2[n][i]; + } + v2 = verticesObjMorph[n][i]; + verticesObjMorph[n][i] = v2.lerp(v1, 0.05f); + totalDistance += v1.distance(v2); + } + // If all the vertices are close, switch shape + if (totalDistance < 300.0) + { + state[n] = !state[n]; + } + + drawNodeArray[n]->properties.setScale(Vec2(0.5f, 0.5f)); + drawNodeArray[n]->drawPolygon(verticesObjMorph[n], segments, sliderValue[sliderType::Thickness], color[n]); + } +} + +void DrawNodeMorphTest_Polygon::onEnter() +{ + for (int i = 0; i < sliderType::sliderTypeLast; i++) + { + sliderValue[i] = 1; + slider[i]->setPercent(sliderValue[i]); + } + + sliderValue[sliderType::Thickness] = 10; + slider[sliderType::Thickness]->setPercent(sliderValue[sliderType::Thickness]); + + DrawNodeBaseTest::onEnter(); +} + +string DrawNodeMorphTest_Polygon::title() const +{ + return "Morphing"; +} + +string DrawNodeMorphTest_Polygon::subtitle() const +{ + return "Polygons"; +} + +DrawNodePictureTest::DrawNodePictureTest() +{ + drawNode->runAction(RepeatForever::create(Sequence::create(FadeIn::create(1.2f), FadeOut::create(1.2f), NULL))); + + scheduleUpdate(); +} + +void DrawNodePictureTest::update(float dt) +{ + DrawNodeBaseTest::update(dt); + + static float rot = 0.1f; + static int count = 0; + static bool wait = false; + + drawNode->clear(); + + if (!wait) + { + rot += 0.05; + if (rot >= 6) + { + rot = count = 0; + wait = true; + } + } + else if (count++ > 30) + wait = false; + + float sph_xx[2326]; + float sph_yy[2326]; + int n = 0; + for (int i = 0; i < 2326;) // read data + { + sph_xx[n] = verticesHead[i++]; + sph_yy[n] = verticesHead[i++]; + n++; + } + + float sph_cmb = sph_yy[0]; + int sph_la = 0; + do + { + Color4F color = Color4F(sph_xx[sph_la + 1], sph_yy[sph_la + 1], sph_xx[sph_la + 2], sph_yy[sph_la + 2] * 255); + // color = Color4F(AXRANDOM_0_1(), AXRANDOM_0_1(), AXRANDOM_0_1(), 1); + Vec2* vertices = new Vec2[(int)(sph_cmb - 3)]; + for (int n = 3; n < sph_cmb; n++) + { + vertices[n - 3] = Vec2(sph_xx[sph_la + n], sph_yy[sph_la + n]); + } + drawNode->setPosition(Vec2(420, 280)); + drawNode->setScale(0.4); + drawNode->setAnchorPoint(Vec2::ANCHOR_MIDDLE); + drawNode->setRotation(180); + drawNode->properties.setCenter(vertices[0]); + drawNode->properties.setRotation(rot); + drawNode->drawPolygon(vertices, sph_cmb - 3, color, /*rot*/ 0.f, + Color4F(AXRANDOM_0_1(), AXRANDOM_0_1(), AXRANDOM_0_1(), 1), true); + + sph_la += sph_cmb; + sph_cmb = sph_yy[sph_la]; + } while (sph_yy[sph_la] != 0); +} + +string DrawNodePictureTest::title() const +{ + return "Example: Picture"; +} + +string DrawNodePictureTest::subtitle() const +{ + return "Actions Test"; +} + +DrawNodeThicknessTest::DrawNodeThicknessTest() +{ + initSliders(); + slider[sliderType::Thickness]->setEnabled(true); + + scheduleUpdate(); +} + +void DrawNodeThicknessTest::update(float dt) +{ + DrawNodeBaseTest::update(dt); + + drawNode->clear(); + + drawNode->drawCircle(VisibleRect::center(), 60, AX_DEGREES_TO_RADIANS(77), 30, false, Color4F::GREEN, + sliderValue[sliderType::Thickness]); + + drawNode->drawLine(Vec2(0.0f, size.height), Vec2(size.width, size.height - 20), Color4F::YELLOW, + sliderValue[sliderType::Thickness]); + drawNode->drawLine(Vec2(0.0f, 0.0f), Vec2(size.width, size.height - 20), Color4F::YELLOW, + sliderValue[sliderType::Thickness]); + + // drawNode a rectangles + drawNode->drawRect(Vec2(123, 123), Vec2(227, 227), Color4F(1, 1, 0, 1), sliderValue[sliderType::Thickness]); + drawNode->drawRect(Vec2(115, 130), Vec2(130, 115), Vec2(115, 100), Vec2(100, 115), Color4F::MAGENTA, + sliderValue[sliderType::Thickness]); + + drawNode->drawLine(Vec2(200.0f, size.height - 20), Vec2(size.width - 100, size.height - 20), Color4F::YELLOW, + sliderValue[sliderType::Thickness]); + drawNode->drawLine(Vec2(300.0f, 100.0f), Vec2(size.width - 200, size.height - 120), Color4F::GREEN, + sliderValue[sliderType::Thickness]); + + Vec2 vertices24[] = { + {45.750000f, 144.375000f}, {75.500000f, 136.875000f}, {75.500000f, 159.125000f}, {100.250000f, 161.375000f}, + {65.500000f, 181.375000f}, {102.250000f, 179.125000f}, {95.000000f, 215.125000f}, {129.331467f, 189.926208f}, + {131.371460f, 206.366196f}, {139.651474f, 192.446198f}, {161.851471f, 200.606201f}, {151.000000f, 220.375000f}, + {110.500000f, 244.375000f}, {153.750000f, 238.125000f}, {142.500000f, 253.875000f}, {220.750000f, 259.375000f}, + {250.500000f, 244.375000f}, {168.750000f, 241.875000f}, {182.250000f, 154.125000f}, {190.250000f, 227.375000f}, + {196.500000f, 197.375000f}, {208.750000f, 210.625000f}, {220.750000f, 194.375000f}, {208.750000f, 176.375000f}, + {253.250000f, 173.875000f}, {243.750000f, 154.125000f}, {213.750000f, 161.375000f}, {202.250000f, 139.875000f}, + {236.000000f, 131.875000f}, {218.500000f, 120.875000f}, {206.500000f, 125.625000f}, {184.500000f, 110.375000f}, + {157.000000f, 108.625000f}, {147.500000f, 96.625000f}, {153.750000f, 85.125000f}, {147.500000f, 75.375000f}, + {126.500000f, 74.125000f}, {110.500000f, 86.625000f}, {127.750000f, 85.125000f}, {135.250000f, 91.125000f}, + {135.250000f, 97.875000f}, {124.000000f, 93.875000f}, {115.500000f, 100.875000f}, {115.500000f, 111.875000f}, + {135.250000f, 108.625000f}, {151.000000f, 124.125000f}, {90.500000f, 131.875000f}, {113.250000f, 120.875000f}, + {88.000000f, 116.875000f}, {106.000000f, 103.875000f}, {88.000000f, 97.875000f}, + }; + drawNode->drawPolygon(vertices24, sizeof(vertices24) / sizeof(vertices24[0]), Color4B::TRANSPARENT, + sliderValue[sliderType::Thickness] / 2, Color4F::RED); + + // open random color poly + Vec2 vertices[] = {Vec2(0.0f, 0.0f), Vec2(50.0f, 50.0f), Vec2(100.0f, 50.0f), Vec2(100.0f, 100.0f), + Vec2(50.0f, 100.0f)}; + drawNode->drawPoly(vertices, 5, false, Color4F(AXRANDOM_0_1(), AXRANDOM_0_1(), AXRANDOM_0_1(), 1.0f), + sliderValue[sliderType::Thickness]); + + // closed random color poly + Vec2 vertices2[] = {Vec2(30.0f, 130.0f), Vec2(30.0f, 230.0f), Vec2(50.0f, 200.0f)}; + drawNode->drawPoly(vertices2, 3, true, Color4F(AXRANDOM_0_1(), AXRANDOM_0_1(), AXRANDOM_0_1(), 1.0f), + sliderValue[sliderType::Thickness]); + + // drawNode some beziers + drawNode->drawQuadBezier(Vec2(size.width - 150, size.height - 150), Vec2(size.width - 70, size.height - 10), + Vec2(size.width - 10, size.height - 10), 10, Color4F::BLUE, + sliderValue[sliderType::Thickness]); + + drawNode->drawQuadBezier(Vec2(0.0f + 100, size.height - 100), Vec2(size.width / 2, size.height / 2), + Vec2(size.width - 100, size.height - 100), 50, Color4F::RED, + sliderValue[sliderType::Thickness]); + + drawNode->drawCubicBezier(VisibleRect::center(), Vec2(VisibleRect::center().x + 30, VisibleRect::center().y + 50), + Vec2(VisibleRect::center().x + 60, VisibleRect::center().y - 50), VisibleRect::right(), + 100, Color4F::WHITE, sliderValue[sliderType::Thickness]); + + drawNode->drawCubicBezier(Vec2(size.width - 250, 40.0f), Vec2(size.width - 70, 100.0f), + Vec2(size.width - 30, 250.0f), Vec2(size.width - 10, size.height - 50), 10, Color4F::GRAY, + sliderValue[sliderType::Thickness]); + + auto array = ax::PointArray::create(20); + array->addControlPoint(Vec2(0.0f, 0.0f)); + array->addControlPoint(Vec2(80.0f, 80.0f)); + array->addControlPoint(Vec2(size.width - 80, 80.0f)); + array->addControlPoint(Vec2(size.width - 80, size.height - 80)); + array->addControlPoint(Vec2(80.0f, size.height - 80)); + array->addControlPoint(Vec2(80.0f, 80.0f)); + array->addControlPoint(Vec2(size.width / 2, size.height / 2)); + drawNode->drawCardinalSpline(array, 0.5f, 50, Color4F::MAGENTA, sliderValue[sliderType::Thickness]); + + auto array2 = ax::PointArray::create(20); + array2->addControlPoint(Vec2(size.width / 2, 30.0f)); + array2->addControlPoint(Vec2(size.width - 80, 30.0f)); + array2->addControlPoint(Vec2(size.width - 80, size.height - 80)); + array2->addControlPoint(Vec2(size.width / 2, size.height - 80)); + array2->addControlPoint(Vec2(size.width / 2, 30.0f)); + drawNode->drawCatmullRom(array2, 50, Color4F::ORANGE, sliderValue[sliderType::Thickness]); + + auto s = Director::getInstance()->getWinSize(); + + drawNode->drawPoint(Vec2(s.width / 2 - 120, s.height / 2 - 120), 10, + Color4F(AXRANDOM_0_1(), AXRANDOM_0_1(), AXRANDOM_0_1(), 1)); + + drawNode->drawPoint(Vec2(s.width / 2 + 120, s.height / 2 + 120), 10, + Color4F(AXRANDOM_0_1(), AXRANDOM_0_1(), AXRANDOM_0_1(), 1)); + + // drawNode 4 small points + Vec2 position[] = {Vec2(60, 60), Vec2(70, 70), Vec2(60, 70), Vec2(70, 60)}; + drawNode->drawPoints(position, 4, 5, Color4F(AXRANDOM_0_1(), AXRANDOM_0_1(), AXRANDOM_0_1(), 1)); + + // drawNode a line + drawNode->drawLine(Vec2(0, 0), Vec2(s.width, s.height), Color4F(1.0, 0.0, 0.0, 0.5)); + + // drawNode a rectangle + drawNode->drawRect(Vec2(23, 23), Vec2(7, 7), Color4F(1, 1, 0, 1)); + + drawNode->drawRect(Vec2(15, 30), Vec2(30, 15), Vec2(15, 0), Vec2(0, 15), + Color4F(AXRANDOM_0_1(), AXRANDOM_0_1(), AXRANDOM_0_1(), 1)); + + // drawNode a circle + drawNode->drawCircle(VisibleRect::center() + Vec2(140, 0), 100, AX_DEGREES_TO_RADIANS(90), 50, true, 1.0f, 2.0f, + Color4F(1.0f, 0.0f, 0.0f, 0.5f)); + + drawNode->drawCircle(VisibleRect::center() - Vec2(140, 0), 50, AX_DEGREES_TO_RADIANS(90), 30, false, + Color4F(AXRANDOM_0_1(), AXRANDOM_0_1(), AXRANDOM_0_1(), 1.0f)); + + // drawNode some beziers + drawNode->drawQuadBezier(Vec2(s.width - 150, s.height - 150), Vec2(s.width - 70, s.height - 10), + Vec2(s.width - 10, s.height - 10), 10, + Color4F(AXRANDOM_0_1(), AXRANDOM_0_1(), AXRANDOM_0_1(), 0.5f)); + + drawNode->drawQuadBezier(Vec2(0.0f, s.height), Vec2(s.width / 2, s.height / 2), Vec2(s.width, s.height), 50, + Color4F(AXRANDOM_0_1(), AXRANDOM_0_1(), AXRANDOM_0_1(), 0.5f)); + + drawNode->drawCubicBezier(VisibleRect::center(), Vec2(VisibleRect::center().x + 30, VisibleRect::center().y + 50), + Vec2(VisibleRect::center().x + 60, VisibleRect::center().y - 50), VisibleRect::right(), + 100, Color4F(AXRANDOM_0_1(), AXRANDOM_0_1(), AXRANDOM_0_1(), 0.5f)); + + drawNode->drawCubicBezier(Vec2(s.width - 250, 40.0f), Vec2(s.width - 70, 100.0f), Vec2(s.width - 30, 250.0f), + Vec2(s.width - 10, s.height - 50), 10, + Color4F(AXRANDOM_0_1(), AXRANDOM_0_1(), AXRANDOM_0_1(), 0.5f)); + + auto array3 = PointArray::create(20); + array3->addControlPoint(Vec2(0.0f, 0.0f)); + array3->addControlPoint(Vec2(80.0f, 80.0f)); + array3->addControlPoint(Vec2(s.width - 80, 80.0f)); + array3->addControlPoint(Vec2(s.width - 80, s.height - 80)); + array3->addControlPoint(Vec2(80.0f, s.height - 80)); + array3->addControlPoint(Vec2(80.0f, 80.0f)); + array3->addControlPoint(Vec2(s.width / 2, s.height / 2)); + drawNode->drawCardinalSpline(array3, 0.5f, 50, Color4F(AXRANDOM_0_1(), AXRANDOM_0_1(), AXRANDOM_0_1(), 0.5f)); + + auto array4 = PointArray::create(20); + array4->addControlPoint(Vec2(s.width / 2, 30.0f)); + array4->addControlPoint(Vec2(s.width - 80, 30.0f)); + array4->addControlPoint(Vec2(s.width - 80, s.height - 80)); + array4->addControlPoint(Vec2(s.width / 2, s.height - 80)); + array4->addControlPoint(Vec2(s.width / 2, 30.0f)); + drawNode->drawCatmullRom(array4, 50, Color4F(AXRANDOM_0_1(), AXRANDOM_0_1(), AXRANDOM_0_1(), 0.5f)); + + // open random color poly + Vec2 verticesA[] = {Vec2(0.0f, 0.0f), Vec2(50.0f, 50.0f), Vec2(100.0f, 50.0f), Vec2(100.0f, 100.0f), + Vec2(50.0f, 100.0f)}; + drawNode->drawPoly(verticesA, 5, false, Color4F(AXRANDOM_0_1(), AXRANDOM_0_1(), AXRANDOM_0_1(), 1.0f)); + + // closed random color poly + Vec2 verticesB[] = {Vec2(30.0f, 130.0f), Vec2(30.0f, 230.0f), Vec2(50.0f, 200.0f)}; + drawNode->drawPoly(verticesB, 3, true, Color4F(AXRANDOM_0_1(), AXRANDOM_0_1(), AXRANDOM_0_1(), 1.0f)); + + // drawNode 10 circles + for (int i = 0; i < 10; i++) + { + drawNode->drawDot(Vec2(s.width / 2, s.height / 2), 10.f * (10 - i), + Color4F(AXRANDOM_0_1(), AXRANDOM_0_1(), AXRANDOM_0_1(), 1.0f)); + } + + // drawNode polygons + Vec2 points[] = {Vec2(s.height / 4, 0.0f), Vec2(s.width, s.height / 5), Vec2(s.width / 3 * 2, s.height)}; + drawNode->drawPolygon(points, sizeof(points) / sizeof(points[0]), Color4F(1.0f, 0.0f, 0.0f, 0.5f), 4, + Color4F(0.0f, 0.0f, 1.0f, 0.5f)); + + // star poly (triggers buggs) + { + const float o = 80; + const float w = 20; + const float h = 50; + Vec2 star[] = { + Vec2(o + w, o - h), Vec2(o + w * 2, o), // lower spike + Vec2(o + w * 2 + h, o + w), Vec2(o + w * 2, o + w * 2), // right spike + // {o +w, o+w*2+h}, {o,o+w*2}, // top spike + // {o -h, o+w}, {o,o}, // left spike + }; + + drawNode->drawPolygon(star, sizeof(star) / sizeof(star[0]), Color4F(1.0f, 0.0f, 0.0f, 0.5f), 1, + Color4F(0.0f, 0.0f, 1.0f, 1.0f)); + } + + // star poly (doesn't trigger bug... order is important un tesselation is supported. + { + const float o = 180; + const float w = 20; + const float h = 50; + Vec2 star[] = { + Vec2(o, o), + Vec2(o + w, o - h), + Vec2(o + w * 2, o), // lower spike + Vec2(o + w * 2 + h, o + w), + Vec2(o + w * 2, o + w * 2), // right spike + Vec2(o + w, o + w * 2 + h), + Vec2(o, o + w * 2), // top spike + Vec2(o - h, o + w), // left spike + }; + + drawNode->drawPolygon(star, sizeof(star) / sizeof(star[0]), Color4F(1.0f, 0.0f, 0.0f, 0.5f), 1, + Color4F(0.0f, 0.0f, 1.0f, 1.0f)); + } + + // drawNode a solid polygon + Vec2 vertices3[] = {Vec2(60.0f, 160.0f), Vec2(70.0f, 190.0f), Vec2(100.0f, 190.0f), Vec2(90.0f, 160.0f)}; + drawNode->drawSolidPoly(vertices3, 4, Color4F(1.0f, 1.0f, 0.0f, 1.0f)); + + // drawNode a solid rectangle + drawNode->drawSolidRect(Vec2(10.0f, 10.0f), Vec2(20.0f, 20.0f), Color4F(1.0f, 1.0f, 0.0f, 1.0f)); + + // drawNode a solid circle + drawNode->drawSolidCircle(VisibleRect::center() + Vec2(140.0f, 0.0f), 40, AX_DEGREES_TO_RADIANS(90), 50, 2.0f, 2.0f, + Color4F(0.0f, 1.0f, 0.0f, 1.0f)); + + // drawNode segment + drawNode->drawSegment(Vec2(20.0f, s.height), Vec2(20.0f, s.height / 2), 10, Color4F(0.0f, 1.0f, 0.0f, 1.0f)); + + drawNode->drawSegment(Vec2(10.0f, s.height / 2), Vec2(s.width / 2, s.height / 2), 40, + Color4F(1.0f, 0.0f, 1.0f, 0.5f)); + + // drawNode triangle + drawNode->drawTriangle(Vec2(10.0f, 10.0f), Vec2(70.0f, 30.0f), Vec2(100.0f, 140.0f), + Color4F(AXRANDOM_0_1(), AXRANDOM_0_1(), AXRANDOM_0_1(), 0.5f)); + + for (int i = 0; i < 100; i++) + { + drawNode->drawPoint(Vec2(i * 7.0f, 5.0f), (float)i / 5 + 1, + Color4F(AXRANDOM_0_1(), AXRANDOM_0_1(), AXRANDOM_0_1(), 1.0f)); + } + + drawNode->setLineWidth(4); + drawNode->drawLine(Vec2(0.0f, s.height), Vec2(s.width, s.height - 20), Color4F::YELLOW); + drawNode->drawLine(Vec2(0.0f, 0.0f), Vec2(s.width, s.height - 20), Color4F::YELLOW); + + drawNode->runAction(RepeatForever::create(Sequence::create(FadeIn::create(1.2f), FadeOut::create(1.2f), NULL))); +} + +void DrawNodeThicknessTest::onEnter() +{ + for (int i = 0; i < sliderType::sliderTypeLast; i++) + { + sliderValue[i] = 1; + slider[i]->setPercent(sliderValue[i]); + } + // sliderValue[sliderType::Counter] = 100; + // slider[sliderType::Counter]->setPercent(sliderValue[sliderType::Counter]); + sliderValue[sliderType::Thickness] = 10; + slider[sliderType::Thickness]->setPercent(sliderValue[sliderType::Thickness]); + + DrawNodeBaseTest::onEnter(); +} + +string DrawNodeThicknessTest::title() const +{ + return "Thickness Test"; +} + +string DrawNodeThicknessTest::subtitle() const +{ + return ""; +} + +DrawNodeThicknessStressTest::DrawNodeThicknessStressTest() +{ + initSliders(); + slider[sliderType::Thickness]->setEnabled(true); + + scheduleUpdate(); +} + +void DrawNodeThicknessStressTest::update(float dt) +{ + static float negativThickness = -99999999.9999; + DrawNodeBaseTest::update(dt); + + drawNode->clear(); + + drawNode->drawCircle(VisibleRect::center(), 60, AX_DEGREES_TO_RADIANS(77), 30, false, Color4F::GREEN, + negativThickness); + + drawNode->drawLine(Vec2(0.0f, size.height), Vec2(size.width, size.height - 20), Color4F::YELLOW, negativThickness); + + // drawNode a rectangles + drawNode->drawRect(Vec2(123, 123), Vec2(227, 227), Color4F(1, 1, 0, 1), negativThickness); + + Vec2 vertices24[] = { + {45.750000f, 144.375000f}, {75.500000f, 136.875000f}, {75.500000f, 159.125000f}, {100.250000f, 161.375000f}, + {65.500000f, 181.375000f}, {102.250000f, 179.125000f}, {95.000000f, 215.125000f}, {129.331467f, 189.926208f}, + {131.371460f, 206.366196f}, {139.651474f, 192.446198f}, {161.851471f, 200.606201f}, {151.000000f, 220.375000f}, + {110.500000f, 244.375000f}, {153.750000f, 238.125000f}, {142.500000f, 253.875000f}, {220.750000f, 259.375000f}, + {250.500000f, 244.375000f}, {168.750000f, 241.875000f}, {182.250000f, 154.125000f}, {190.250000f, 227.375000f}, + {196.500000f, 197.375000f}, {208.750000f, 210.625000f}, {220.750000f, 194.375000f}, {208.750000f, 176.375000f}, + {253.250000f, 173.875000f}, {243.750000f, 154.125000f}, {213.750000f, 161.375000f}, {202.250000f, 139.875000f}, + {236.000000f, 131.875000f}, {218.500000f, 120.875000f}, {206.500000f, 125.625000f}, {184.500000f, 110.375000f}, + {157.000000f, 108.625000f}, {147.500000f, 96.625000f}, {153.750000f, 85.125000f}, {147.500000f, 75.375000f}, + {126.500000f, 74.125000f}, {110.500000f, 86.625000f}, {127.750000f, 85.125000f}, {135.250000f, 91.125000f}, + {135.250000f, 97.875000f}, {124.000000f, 93.875000f}, {115.500000f, 100.875000f}, {115.500000f, 111.875000f}, + {135.250000f, 108.625000f}, {151.000000f, 124.125000f}, {90.500000f, 131.875000f}, {113.250000f, 120.875000f}, + {88.000000f, 116.875000f}, {106.000000f, 103.875000f}, {88.000000f, 97.875000f}, + }; + drawNode->drawPolygon(vertices24, sizeof(vertices24) / sizeof(vertices24[0]), Color4B::TRANSPARENT, + negativThickness, Color4F::RED); + + // open random color poly + Vec2 vertices[] = {Vec2(0.0f, 0.0f), Vec2(50.0f, 50.0f), Vec2(100.0f, 50.0f), Vec2(100.0f, 100.0f), + Vec2(50.0f, 100.0f)}; + drawNode->drawPoly(vertices, 5, false, Color4F(AXRANDOM_0_1(), AXRANDOM_0_1(), AXRANDOM_0_1(), 1.0f), + negativThickness); + + // closed random color poly + Vec2 vertices2[] = {Vec2(30.0f, 130.0f), Vec2(30.0f, 230.0f), Vec2(50.0f, 200.0f)}; + drawNode->drawPoly(vertices2, 3, true, Color4F(AXRANDOM_0_1(), AXRANDOM_0_1(), AXRANDOM_0_1(), 1.0f), + negativThickness); + + // drawNode some beziers + drawNode->drawQuadBezier(Vec2(size.width - 150, size.height - 150), Vec2(size.width - 70, size.height - 10), + Vec2(size.width - 10, size.height - 10), 10, Color4F::BLUE, negativThickness); + + drawNode->drawCubicBezier(VisibleRect::center(), Vec2(VisibleRect::center().x + 30, VisibleRect::center().y + 50), + Vec2(VisibleRect::center().x + 60, VisibleRect::center().y - 50), VisibleRect::right(), + 100, Color4F::WHITE, negativThickness); + + auto array = ax::PointArray::create(20); + array->addControlPoint(Vec2(0.0f, 0.0f)); + array->addControlPoint(Vec2(80.0f, 80.0f)); + array->addControlPoint(Vec2(size.width - 80, 80.0f)); + array->addControlPoint(Vec2(size.width - 80, size.height - 80)); + array->addControlPoint(Vec2(80.0f, size.height - 80)); + array->addControlPoint(Vec2(80.0f, 80.0f)); + array->addControlPoint(Vec2(size.width / 2, size.height / 2)); + drawNode->drawCardinalSpline(array, 0.5f, 50, Color4F::MAGENTA, negativThickness); + + auto array2 = ax::PointArray::create(20); + array2->addControlPoint(Vec2(size.width / 2, 30.0f)); + array2->addControlPoint(Vec2(size.width - 80, 30.0f)); + array2->addControlPoint(Vec2(size.width - 80, size.height - 80)); + array2->addControlPoint(Vec2(size.width / 2, size.height - 80)); + array2->addControlPoint(Vec2(size.width / 2, 30.0f)); + drawNode->drawCatmullRom(array2, 50, Color4F::ORANGE, negativThickness); + + auto s = Director::getInstance()->getWinSize(); + + drawNode->drawPoint(Vec2(s.width / 2 - 120, s.height / 2 - 120), negativThickness, + Color4F(AXRANDOM_0_1(), AXRANDOM_0_1(), AXRANDOM_0_1(), 1)); + + // drawNode 4 small points + Vec2 position[] = {Vec2(60, 60), Vec2(70, 70), Vec2(60, 70), Vec2(70, 60)}; + drawNode->drawPoints(position, 4, 5, Color4F(AXRANDOM_0_1(), AXRANDOM_0_1(), AXRANDOM_0_1(), 1), DrawNode::Rect); + + Vec2 position1[] = {Vec2(100, 100), Vec2(170, 170), Vec2(260, 170), Vec2(170, 260)}; + drawNode->drawPoints(position1, 4, 25, Color4F(AXRANDOM_0_1(), AXRANDOM_0_1(), AXRANDOM_0_1(), 1), DrawNode::Rect); + + // drawNode a rectangle + drawNode->drawRect(Vec2(23, 23), Vec2(7, 7), Color4F(1, 1, 0, 1), negativThickness); + + // drawNode 10 circles + for (int i = 0; i < 10; i++) + { + drawNode->drawDot(Vec2(s.width / 2, s.height / 2), negativThickness, + Color4F(AXRANDOM_0_1(), AXRANDOM_0_1(), AXRANDOM_0_1(), 1.0f)); + } + + // star poly (doesn't trigger bug... order is important un tesselation is supported. + { + const float o = 180; + const float w = 20; + const float h = 50; + Vec2 star[] = { + Vec2(o, o), + Vec2(o + w, o - h), + Vec2(o + w * 2, o), // lower spike + Vec2(o + w * 2 + h, o + w), + Vec2(o + w * 2, o + w * 2), // right spike + Vec2(o + w, o + w * 2 + h), + Vec2(o, o + w * 2), // top spike + Vec2(o - h, o + w), // left spike + }; + + drawNode->drawPolygon(star, sizeof(star) / sizeof(star[0]), Color4F(1.0f, 0.0f, 0.0f, 0.5f), 1, + Color4F(0.0f, 0.0f, 1.0f, 1.0f)); + } + + // drawNode a solid polygon + Vec2 vertices3[] = {Vec2(60.0f, 160.0f), Vec2(70.0f, 190.0f), Vec2(100.0f, 190.0f), Vec2(90.0f, 160.0f)}; + drawNode->drawSolidPoly(vertices3, 4, Color4F(1.0f, 1.0f, 0.0f, 1.0f)); + + // drawNode a solid rectangle + drawNode->drawSolidRect(Vec2(10.0f, 10.0f), Vec2(20.0f, 20.0f), Color4F(1.0f, 1.0f, 0.0f, 1.0f)); + + // drawNode a solid circle + drawNode->drawSolidCircle(VisibleRect::center() + Vec2(140.0f, 0.0f), 40, AX_DEGREES_TO_RADIANS(90), 50, 2.0f, 2.0f, + Color4F(0.0f, 1.0f, 0.0f, 1.0f)); + + // drawNode segment + drawNode->drawSegment(Vec2(20.0f, s.height), Vec2(20.0f, s.height / 2), 10, Color4F(0.0f, 1.0f, 0.0f, 1.0f)); + + // drawNode triangle + drawNode->drawTriangle(Vec2(10.0f, 10.0f), Vec2(70.0f, 30.0f), Vec2(100.0f, 140.0f), + Color4F(AXRANDOM_0_1(), AXRANDOM_0_1(), AXRANDOM_0_1(), 0.5f)); +} + +void DrawNodeThicknessStressTest::onEnter() +{ + for (int i = 0; i < sliderType::sliderTypeLast; i++) + { + sliderValue[i] = 1; + slider[i]->setPercent(sliderValue[i]); + } + + sliderValue[sliderType::Thickness] = 5; + slider[sliderType::Thickness]->setPercent(sliderValue[sliderType::Thickness]); + + DrawNodeBaseTest::onEnter(); +} + +string DrawNodeThicknessStressTest::title() const +{ + return "Thickness Stress Test"; +} + +string DrawNodeThicknessStressTest::subtitle() const +{ + return ""; +} + +DrawNodePieTest::DrawNodePieTest() +{ + initSliders(); + slider[sliderType::AngleStart]->setEnabled(true); + slider[sliderType::AngleEnd]->setEnabled(true); + slider[sliderType::Rotation]->setEnabled(true); + slider[sliderType::Thickness]->setEnabled(true); + + scheduleUpdate(); +} + +void DrawNodePieTest::update(float dt) +{ + DrawNodeBaseTest::update(dt); + + drawNode->clear(); + + // Filled + drawNode->drawPie(VisibleRect::center() - Vec2(190.0f, -35.0f), 40, sliderValue[sliderType::Rotation], + sliderValue[sliderType::AngleStart], sliderValue[sliderType::AngleEnd], 1.0f, 1.0f, Color4F::RED, + Color4F::BLUE, drawNode->DrawMode::Fill, sliderValue[sliderType::Thickness]); + + // Outlined + drawNode->drawPie(VisibleRect::center() - Vec2(95.0f, -35.0f), 40, sliderValue[sliderType::Rotation], + sliderValue[sliderType::AngleStart], sliderValue[sliderType::AngleEnd], 1.0f, 1.0f, + Color4F::TRANSPARENT, Color4F::BLUE, drawNode->DrawMode::Outline, + sliderValue[sliderType::Thickness]); + + // Line + drawNode->drawPie(VisibleRect::center() + Vec2(0.0f, 35.0f), 40, sliderValue[sliderType::Rotation], + sliderValue[sliderType::AngleStart], sliderValue[sliderType::AngleEnd], 1.0f, 1.0f, + Color4F::TRANSPARENT, Color4F::BLUE, drawNode->DrawMode::Line, + sliderValue[sliderType::Thickness]); + + // Semi + drawNode->drawPie(VisibleRect::center() + Vec2(95.0f, 35.0f), 40, sliderValue[sliderType::Rotation], + sliderValue[sliderType::AngleStart], sliderValue[sliderType::AngleEnd], 1.0f, 1.0f, + Color4F::TRANSPARENT, Color4F::BLUE, drawNode->DrawMode::Semi, + sliderValue[sliderType::Thickness]); + + // Semi (Filled) + drawNode->drawPie(VisibleRect::center() + Vec2(190.0f, 35.0f), 40, sliderValue[sliderType::Rotation], + sliderValue[sliderType::AngleStart], sliderValue[sliderType::AngleEnd], 1.0f, 1.0f, Color4F::RED, + Color4F::BLUE, drawNode->DrawMode::Semi, sliderValue[sliderType::Thickness]); +} + +void DrawNodePieTest::onEnter() +{ + for (int i = 0; i < sliderType::sliderTypeLast; i++) + { + sliderValue[i] = 1; + slider[i]->setPercent(sliderValue[i]); + } + + sliderValue[sliderType::AngleStart] = 10; + slider[sliderType::AngleStart]->setPercent(sliderValue[sliderType::AngleStart]); + + sliderValue[sliderType::AngleEnd] = 100; + slider[sliderType::AngleEnd]->setPercent(sliderValue[sliderType::AngleEnd]); + + sliderValue[sliderType::Rotation] = 10; + slider[sliderType::Rotation]->setPercent(sliderValue[sliderType::Rotation]); + + sliderValue[sliderType::Thickness] = 10; + slider[sliderType::Thickness]->setPercent(sliderValue[sliderType::Thickness]); + + DrawNodeBaseTest::onEnter(); +} + +string DrawNodePieTest::title() const +{ + return "drawPie"; +} + +string DrawNodePieTest::subtitle() const +{ + return "Filled, Outlined, Line, Semi, Semi (Filled)"; +} + +DrawNodeMethodsTest::DrawNodeMethodsTest() +{ + static const float BUTTON_WIDTH = 30; + static float startPosX = 0; + + auto listview = createListView(); + listview->setPosition(Vec2(0.0f, 40.0f)); + addChild(listview); + + drawNode->setScale(0.5); + drawNode->setPosition(center); + + initSliders(); + slider[sliderType::Thickness]->setEnabled(true); + slider[sliderType::Rotation]->setEnabled(true); + + labelRound = Label::createWithTTF("DrawNode::Round", "fonts/arial.ttf", 12); + addChild(labelRound, 1); + labelRound->setVisible(false); + labelSquare = Label::createWithTTF("DrawNode::Square", "fonts/arial.ttf", 12); + addChild(labelSquare, 1); + labelSquare->setVisible(false); + labelButt = Label::createWithTTF("DrawNode::Butt", "fonts/arial.ttf", 12); + addChild(labelButt, 1); + labelButt->setVisible(false); + + scheduleUpdate(); +} + +ax::ui::ListView* DrawNodeMethodsTest::createListView() +{ + auto listview = ax::ui::ListView::create(); + Vec2 contentSize = {0, 0}; + for (size_t i = 0; i < (drawMethodes::LAST); i++) + { + auto ui = ax::ui::Text::create(); + ui->setString(drawMethods[i].c_str()); + contentSize.x = MAX(ui->getContentSize().x, contentSize.x); + contentSize.y = MAX(ui->getContentSize().y, contentSize.y); + ui->setTouchEnabled(true); + listview->pushBackCustomItem(ui); + } + + listview->setContentSize(contentSize * (drawMethodes::LAST)); + listview->setCurSelectedIndex(0); + listview->setTouchEnabled(true); + listview->addEventListener( + (ui::ListView::ccListViewCallback)AX_CALLBACK_2(DrawNodeBaseTest::listviewCallback, this)); + listview->setTag(100); + + listview->getItem(_currentSeletedItemIndex)->setColor(Color3B::RED); + + return listview; +} + +void DrawNodeMethodsTest::update(float dt) +{ + drawAll(); +} + +void DrawNodeMethodsTest::onEnter() +{ + for (int i = 0; i < sliderType::sliderTypeLast; i++) + { + sliderValue[i] = 1; + slider[i]->setPercent(sliderValue[i]); + } + sliderValue[sliderType::Thickness] = 10; + slider[sliderType::Thickness]->setPercent(sliderValue[sliderType::Thickness]); + sliderValue[sliderType::Rotation] = 0; + slider[sliderType::Rotation]->setPercent(sliderValue[sliderType::Rotation]); + + DrawNodeBaseTest::onEnter(); +} + +std::string DrawNodeMethodsTest::title() const +{ + return "DrawNode Methods Test"; +} + +string DrawNodeMethodsTest::subtitle() const +{ + return ""; +} + +void DrawNodeMethodsTest::drawAll() +{ + static float rotation = 0.1f; + rotation += 0.1; + if (rotation > 62.8f) + { + rotation = 0.0f; + } + + drawNode->clear(); + drawNode->properties.setDefaultValues(); + + labelRound->setVisible(false); + labelSquare->setVisible(false); + labelButt->setVisible(false); + + switch (_currentSeletedItemIndex) + { + case drawMethodes::Line: + { + for (int i = 0; i < 100; i++) + { + drawNode->drawLine(Vec2(-size.x / 2, -size.y / 2 + i * 4), Vec2(size.x - 50, -size.y / 2 + i * 4), + Color4F(AXRANDOM_0_1(), AXRANDOM_0_1(), AXRANDOM_0_1(), 1.0f), + sliderValue[sliderType::Thickness]); + drawNode->drawLine(Vec2(-size.x + 50, -size.y + AXRANDOM_0_1() * 2 * size.y), + Vec2(size.x - 50, -size.y + AXRANDOM_0_1() * 2 * size.y), + Color4F(AXRANDOM_0_1(), AXRANDOM_0_1(), AXRANDOM_0_1(), 1.0f), + sliderValue[sliderType::Thickness]); + } + + break; + } + case drawMethodes::Rect: + { + Vec2 rec; + for (int i = 0; i < 100; i++) + { + rec = Vec2(i * 3, i * 3); + drawNode->drawRect(center / 2 - rec, center / 2 + rec, + Color4F(AXRANDOM_0_1(), AXRANDOM_0_1(), AXRANDOM_0_1(), 1.0f), + sliderValue[sliderType::Thickness]); + drawNode->drawRect(Vec2(AXRANDOM_MINUS1_1() * 300, AXRANDOM_MINUS1_1() * 300), + Vec2(AXRANDOM_MINUS1_1() * 400, AXRANDOM_MINUS1_1() * 400), + Color4F(AXRANDOM_0_1(), AXRANDOM_0_1(), AXRANDOM_0_1(), 1.0f), + sliderValue[sliderType::Thickness]); + } + + break; + } + case drawMethodes::Circle: + { + for (int i = 0; i < 100; i++) + { + drawNode->drawCircle(VisibleRect::center(), 3 * i, AX_DEGREES_TO_RADIANS(90), i, false, 1.0f, 1.0f, + Color4F(AXRANDOM_0_1(), AXRANDOM_0_1(), AXRANDOM_0_1(), 1.0f), + sliderValue[sliderType::Thickness]); + + Vec2 pos = Vec2(-100, -100) + Vec2(AXRANDOM_MINUS1_1() * VisibleRect::rightTop().x, + AXRANDOM_MINUS1_1() * VisibleRect::rightTop().y); + drawNode->drawCircle(VisibleRect::center() + pos, AXRANDOM_0_1() * 200, + AX_DEGREES_TO_RADIANS(AXRANDOM_MINUS1_1() * 90), 30, true, + Color4F(AXRANDOM_0_1(), AXRANDOM_0_1(), AXRANDOM_0_1(), 1.0f), + sliderValue[sliderType::Thickness]); + } + + break; + } + case drawMethodes::QuadBezier: + { + drawNode->drawQuadBezier(Vec2(size.width - 150, size.height - 150), Vec2(size.width - 70, size.height - 10), + Vec2(size.width - 10, size.height - 10), 10, Color4F::BLUE, + sliderValue[sliderType::Thickness]); + drawNode->drawQuadBezier(Vec2(0.0f + 100, size.height - 100), Vec2(size.width / 2, size.height / 2), + Vec2(size.width - 100, size.height - 100), 50, Color4F::RED, + sliderValue[sliderType::Thickness]); + + for (int i = 0; i < 360;) + { + Vec2 p1 = pts->getControlPointAtIndex(i); + Vec2 p2 = pts->getControlPointAtIndex(i++); + Vec2 p3 = pts->getControlPointAtIndex(i); + + drawNode->properties.setPosition(Vec2(-100, -100)); + drawNode->drawQuadBezier(p1, p2, p3, 30, Color4F(AXRANDOM_0_1(), AXRANDOM_0_1(), AXRANDOM_0_1(), 1.0f), + sliderValue[sliderType::Thickness]); + } + + for (int i = 0; i < 360;) + { + Vec2 p1 = pts2->getControlPointAtIndex(i); + Vec2 p2 = pts2->getControlPointAtIndex(i++); + Vec2 p3 = pts2->getControlPointAtIndex(i); + + drawNode->properties.setPosition(Vec2(-100, -100)); + drawNode->drawQuadBezier(p1, p2, p3, 30, Color4F(AXRANDOM_0_1(), AXRANDOM_0_1(), AXRANDOM_0_1(), 1.0f), + sliderValue[sliderType::Thickness]); + } + + break; + } + case drawMethodes::CubicBezier: + { + drawNode->drawCubicBezier(VisibleRect::center(), + Vec2(VisibleRect::center().x + 30, VisibleRect::center().y + 50), + Vec2(VisibleRect::center().x + 60, VisibleRect::center().y - 50), + VisibleRect::right(), 20, Color4F::WHITE, sliderValue[sliderType::Thickness]); + drawNode->drawCubicBezier(Vec2(size.width - 250, 40.0f), Vec2(size.width - 70, 100.0f), + Vec2(size.width - 30, 250.0f), Vec2(size.width - 10, size.height - 50), 20, + Color4F::GRAY, sliderValue[sliderType::Thickness]); + + for (int i = 0; i < 360;) + { + Vec2 p1 = pts->getControlPointAtIndex(i); + Vec2 p2 = pts->getControlPointAtIndex(i++); + Vec2 p3 = pts->getControlPointAtIndex(i++); + Vec2 p4 = pts->getControlPointAtIndex(i); + drawNode->properties.setPosition(Vec2(-100, -100)); + drawNode->drawCubicBezier(p1, p2, p3, p4, 120, Color4F::ORANGE, sliderValue[sliderType::Thickness]); + } + + for (int i = 0; i < 360;) + { + Vec2 p1 = pts2->getControlPointAtIndex(i); + Vec2 p2 = pts2->getControlPointAtIndex(i++); + Vec2 p3 = pts2->getControlPointAtIndex(i++); + Vec2 p4 = pts2->getControlPointAtIndex(i); + drawNode->properties.setPosition(Vec2(-100, -100)); + drawNode->drawCubicBezier(p1, p2, p3, p4, 120, Color4F::ORANGE, sliderValue[sliderType::Thickness]); + } + + break; + } + case drawMethodes::CardinalSpline: + { + auto array = ax::PointArray::create(7); + array->addControlPoint(Vec2(0.0f, 0.0f)); + array->addControlPoint(Vec2(80.0f, 80.0f)); + array->addControlPoint(Vec2(size.width - 80, 80.0f)); + array->addControlPoint(Vec2(size.width - 80, size.height - 80)); + array->addControlPoint(Vec2(80.0f, size.height - 80)); + array->addControlPoint(Vec2(80.0f, 80.0f)); + array->addControlPoint(Vec2(size.width / 2, size.height / 2)); + drawNode->drawCardinalSpline(array, 0.5f, 120, Color4F::MAGENTA, sliderValue[sliderType::Thickness]); + + auto array2 = ax::PointArray::create(5); + array2->addControlPoint(Vec2(size.width / 2, 80.0f)); + array2->addControlPoint(Vec2(size.width - 80, 80.0f)); + array2->addControlPoint(Vec2(size.width - 80, size.height - 80)); + array2->addControlPoint(Vec2(size.width / 2, size.height - 80)); + array2->addControlPoint(Vec2(size.width / 2, 80.0f)); + drawNode->drawCardinalSpline(array2, 5.0f, 120, Color4F::ORANGE, sliderValue[sliderType::Thickness]); + + drawNode->drawCardinalSpline(pts, 0.1f, 360, Color4F::RED, 5.0f); + drawNode->drawCardinalSpline(pts2, 0.1f, 360, Color4F::GREEN, 2.0f); + + break; + } + case drawMethodes::CatmullRom: + { + auto array2 = ax::PointArray::create(5); + array2->addControlPoint(Vec2(size.width / 2, 80.0f)); + array2->addControlPoint(Vec2(size.width - 80, 80.0f)); + array2->addControlPoint(Vec2(size.width - 80, size.height - 80)); + array2->addControlPoint(Vec2(size.width / 2, size.height - 80)); + array2->addControlPoint(Vec2(size.width / 2, 80.0f)); + drawNode->drawCatmullRom(array2, 20, Color4F::ORANGE, sliderValue[sliderType::Thickness]); + + auto array = ax::PointArray::create(7); + array->addControlPoint(Vec2(0.0f, 0.0f)); + array->addControlPoint(Vec2(80.0f, 80.0f)); + array->addControlPoint(Vec2(size.width - 80, 80.0f)); + array->addControlPoint(Vec2(size.width - 80, size.height - 80)); + array->addControlPoint(Vec2(80.0f, size.height - 80)); + array->addControlPoint(Vec2(80.0f, 80.0f)); + array->addControlPoint(Vec2(size.width / 2, size.height / 2)); + drawNode->drawCatmullRom(array, 20, Color4F::MAGENTA, sliderValue[sliderType::Thickness]); + + drawNode->drawCatmullRom(pts, 360, Color4F::RED, 5.0f); + drawNode->drawCatmullRom(pts2, 360, Color4F::GREEN, 2.0f); + + break; + } + case drawMethodes::Poly: + { + Vec2 vertices[5] = {{0.0f, 0.0f}, {50.0f, 50.0f}, {100.0f, 50.0f}, {100.0f, 100.0f}, {50.0f, 100.0f}}; + drawNode->properties.setPosition(Vec2(-200, -300)); + drawNode->drawPoly(vertices, 5, false, Color4B::BLUE, sliderValue[sliderType::Thickness]); + + Vec2 vertices2[3] = {{30.0f, 130.0f}, {30.0f, 230.0f}, {50.0f, 200.0f}}; + drawNode->drawPoly(vertices2, 3, true, Color4B::GREEN, sliderValue[sliderType::Thickness]); + + drawNode->properties.setDefaultValues(); + drawNode->drawPoly(vertices1, sizeof(vertices1) / sizeof(vertices1[0]), true, Color4B::RED, + sliderValue[sliderType::Thickness]); + + drawNode->properties.setPosition(Vec2(0, -300)); + drawNode->properties.setRotation(sliderValue[sliderType::Rotation]); + drawNode->drawPoly(vertices1, sizeof(vertices1) / sizeof(vertices1[0]), true, Color4F::GREEN, + sliderValue[sliderType::Thickness]); + drawNode->properties.setPosition(Vec2(-100, -300)); + drawNode->properties.setRotation(sliderValue[sliderType::Rotation]); + drawNode->properties.setCenter(vertices1[0]); + drawNode->drawPoly(vertices1, sizeof(vertices1) / sizeof(vertices1[0]), true, Color4F::MAGENTA, + sliderValue[sliderType::Thickness]); + drawNode->properties.setPosition(Vec2(200, 0)); + drawNode->drawPoly(vertices1, sizeof(vertices1) / sizeof(vertices1[0]), true, Color4F::RED, + sliderValue[sliderType::Thickness]); + drawNode->properties.setPosition(Vec2(0.0f, -300.0f)); + drawNode->properties.setRotation(rotation / 10.0f); + drawNode->properties.setScale(Vec2(2.0f, 2.0f)); + drawNode->properties.setCenter(vertices1[4]); + drawNode->drawPoly(vertices1, sizeof(vertices1) / sizeof(vertices1[0]), true, Color4F::BLUE, + sliderValue[sliderType::Thickness]); + drawNode->properties.setRotation(rotation); + drawNode->drawPoly(vertices1, sizeof(vertices1) / sizeof(vertices1[0]), true, Color4F::YELLOW, + sliderValue[sliderType::Thickness]); + drawNode->properties.setRotation(-rotation / 5); + drawNode->drawPoly(vertices1, sizeof(vertices1) / sizeof(vertices1[0]), true, Color4F::WHITE, + sliderValue[sliderType::Thickness]); + + drawNode->properties.setDefaultValues(); + drawNode->drawPoly(vertices1, sizeof(vertices1) / sizeof(vertices1[0]), true, Color4F::GREEN, + sliderValue[sliderType::Thickness]); + break; + } + case drawMethodes::Polygon: + { + drawNode->properties.setPosition(Vec2(0, -300)); + drawNode->properties.setRotation(sliderValue[sliderType::Rotation]); + drawNode->drawPolygon(vertices1, sizeof(vertices1) / sizeof(vertices1[0]), Color4F::GREEN, + sliderValue[sliderType::Thickness], Color4F::YELLOW); + drawNode->properties.setPosition(Vec2(-100, -300)); + drawNode->properties.setRotation(sliderValue[sliderType::Rotation]); + drawNode->properties.setCenter(vertices1[0]); + drawNode->drawPolygon(vertices1, sizeof(vertices1) / sizeof(vertices1[0]), Color4F::MAGENTA, + sliderValue[sliderType::Thickness], Color4F::GRAY); + drawNode->properties.setPosition(Vec2(200, 0)); + drawNode->drawPolygon(vertices1, sizeof(vertices1) / sizeof(vertices1[0]), Color4F::RED, + sliderValue[sliderType::Thickness], Color4F::YELLOW); + + drawNode->properties.setPosition(Vec2(0.0f, -300.0f)); + drawNode->properties.setRotation(rotation / 10.0f); + drawNode->properties.setScale(Vec2(2.0f, 2.0f)); + drawNode->properties.setCenter(vertices1[4]); + drawNode->drawPolygon(vertices1, sizeof(vertices1) / sizeof(vertices1[0]), Color4F::BLUE, + sliderValue[sliderType::Thickness], Color4F::WHITE); + drawNode->properties.setRotation(rotation); + drawNode->drawPolygon(vertices1, sizeof(vertices1) / sizeof(vertices1[0]), Color4F::YELLOW, + sliderValue[sliderType::Thickness], Color4F::GREEN); + ; + drawNode->properties.setRotation(-rotation / 5); + drawNode->drawPolygon(vertices1, sizeof(vertices1) / sizeof(vertices1[0]), Color4F::WHITE, + sliderValue[sliderType::Thickness], Color4F::YELLOW); + + drawNode->properties.setDefaultValues(); + drawNode->drawPolygon(vertices1, sizeof(vertices1) / sizeof(vertices1[0]), Color4F::GREEN, + sliderValue[sliderType::Thickness], Color4F::BLUE); + + break; + } + case drawMethodes::Dot: + { + for (int i = 0; i < 100; i++) + { + drawNode->drawDot(Vec2(AXRANDOM_MINUS1_1() * 400 + 200, AXRANDOM_MINUS1_1() * 400), + 20 + sliderValue[sliderType::Thickness], + Color4F(AXRANDOM_0_1(), AXRANDOM_0_1(), AXRANDOM_0_1(), 1.0f)); + } + + break; + } + case drawMethodes::Point: + { + for (int i = 0; i < 100; i++) + { + drawNode->drawPoint(Vec2(AXRANDOM_MINUS1_1() * 400 + 200, AXRANDOM_MINUS1_1() * 400), + 30 + sliderValue[sliderType::Thickness], + Color4F(AXRANDOM_0_1(), AXRANDOM_0_1(), AXRANDOM_0_1(), 1.0f)); + } + break; + } + case drawMethodes::Points: + { + for (int i = 0; i < 100; i++) + { + Vec2 pos = Vec2(-100, -100) + Vec2(AXRANDOM_MINUS1_1() * VisibleRect::rightTop().x, + AXRANDOM_MINUS1_1() * VisibleRect::rightTop().y); + Vec2 position[] = {{60 + AXRANDOM_MINUS1_1() * VisibleRect::rightTop().x, + 60 + AXRANDOM_MINUS1_1() * VisibleRect::rightTop().y / 2}, + {70 + AXRANDOM_MINUS1_1() * VisibleRect::rightTop().x, + 70 + AXRANDOM_MINUS1_1() * VisibleRect::rightTop().y / 2}, + {60 + AXRANDOM_MINUS1_1() * VisibleRect::rightTop().x, + 60 + AXRANDOM_MINUS1_1() * VisibleRect::rightTop().y / 2}, + {70 + AXRANDOM_MINUS1_1() * VisibleRect::rightTop().x, + 70 + AXRANDOM_MINUS1_1() * VisibleRect::rightTop().y / 2}}; + drawNode->drawPoints(position, 4, 10 + 2 * sliderValue[sliderType::Thickness], + Color4F(AXRANDOM_0_1(), AXRANDOM_0_1(), AXRANDOM_0_1(), 1)); + } + break; + } + case drawMethodes::Triangle: + { + drawNode->properties.setScale(Vec2(3, 3)); + for (int i = 0; i < 10; i++) + { + drawNode->drawTriangle(Vec2(AXRANDOM_0_1() * 50 + 100, AXRANDOM_0_1() * 50 + 100), + Vec2(AXRANDOM_MINUS1_1() * 50, AXRANDOM_MINUS1_1() * 50), + Vec2(AXRANDOM_0_1() * 50 + 100, AXRANDOM_0_1() * 50 + 100), + Color4F(AXRANDOM_0_1(), AXRANDOM_0_1(), AXRANDOM_0_1(), 1.0f)); + } + break; + } + case drawMethodes::Segment: + { + labelRound->setVisible(true); + labelSquare->setVisible(true); + labelButt->setVisible(true); + + int yy1 = 150; + int yy = 0; + drawNode->drawSegment(Vec2(-150.0f, yy - yy1), Vec2(200, yy - yy1), 20 + 5 * sliderValue[sliderType::Thickness], + Color4F::GREEN, DrawNode::Round, DrawNode::Round); + labelRound->setPosition(Vec2(250.0f, 85)); + + yy += 170; + drawNode->drawSegment(Vec2(-150.0f, yy - yy1), Vec2(200, yy - yy1), 20 + 5 * sliderValue[sliderType::Thickness], + Color4F::BLUE, DrawNode::Square, DrawNode::Square); + labelSquare->setPosition(Vec2(250.0f, 170)); + + yy += 170; + drawNode->drawSegment(Vec2(-150.0f, yy - yy1), Vec2(200, yy - yy1), 20 + 5 * sliderValue[sliderType::Thickness], + Color4F::RED, DrawNode::Butt, DrawNode::Butt); + labelButt->setPosition(Vec2(250.0f, 255)); + + break; + } + case drawMethodes::SolidCircle: + { + for (int i = 100; i > 1; i--) + { + drawNode->drawSolidCircle( + VisibleRect::center(), 3 * i, AX_DEGREES_TO_RADIANS(90), AXRANDOM_0_1() * 20.f + 20.f, 1.0f, 1.0f, + Color4F(AXRANDOM_0_1(), AXRANDOM_0_1(), AXRANDOM_0_1(), 1.0f), sliderValue[sliderType::Thickness], + Color4F(AXRANDOM_0_1(), AXRANDOM_0_1(), AXRANDOM_0_1(), 0.5f)); + + Vec2 pos = Vec2(-100, -100) + Vec2(AXRANDOM_MINUS1_1() * VisibleRect::rightTop().x, + AXRANDOM_MINUS1_1() * VisibleRect::rightTop().y); + drawNode->drawSolidCircle( + VisibleRect::center() + pos, AXRANDOM_0_1() * 200, AX_DEGREES_TO_RADIANS(AXRANDOM_MINUS1_1() * 90), 10, + 1.0f, 1.0f, Color4F(AXRANDOM_0_1(), AXRANDOM_0_1(), AXRANDOM_0_1(), 1.0f), + sliderValue[sliderType::Thickness], Color4F(AXRANDOM_0_1(), AXRANDOM_0_1(), AXRANDOM_0_1(), 1.0f)); + } + + break; + } + case drawMethodes::SolidPoly: + { + Vec2 ppp = Vec2(AXRANDOM_MINUS1_1() * size.x / 2, AXRANDOM_MINUS1_1() * size.y / 2); + drawNode->properties.setPosition(Vec2(ppp)); + + drawNode->properties.setPosition(Vec2(0.0f, -300.0f)); + drawNode->properties.setRotation(rotation / 10.0f); + drawNode->properties.setScale(Vec2(2.0f, 2.0f)); + drawNode->properties.setCenter(vertices1[4]); + drawNode->drawSolidPoly(vertices1, sizeof(vertices1) / sizeof(vertices1[0]), Color4F::BLUE); + drawNode->properties.setRotation(rotation); + drawNode->drawSolidPoly(vertices1, sizeof(vertices1) / sizeof(vertices1[0]), Color4F::YELLOW); + drawNode->properties.setRotation(-rotation / 5); + drawNode->drawSolidPoly(vertices1, sizeof(vertices1) / sizeof(vertices1[0]), Color4F::WHITE); + + drawNode->properties.setDefaultValues(); + drawNode->drawSolidPoly(vertices1, sizeof(vertices1) / sizeof(vertices1[0]), Color4F::GREEN); + + break; + } + case drawMethodes::SolidRect: + { + for (int i = 0; i < 100; i++) + { + Vec2 pos = Vec2(-100, -100) + Vec2(AXRANDOM_MINUS1_1() * VisibleRect::rightTop().x, + AXRANDOM_MINUS1_1() * VisibleRect::rightTop().y); + drawNode->drawSolidRect( + pos, pos + Vec2(20.0f * sliderValue[sliderType::Thickness], 20.0f * sliderValue[sliderType::Thickness]), + Color4F(AXRANDOM_0_1(), AXRANDOM_0_1(), AXRANDOM_0_1(), 0.5f), sliderValue[sliderType::Thickness]); + } + + break; + } + case drawMethodes::Star: + { + + Vec2 gear1 = {270.f, 320.f}; + Vec2 gear2 = {160.f, 320.f}; + Vec2 gear3 = {200.f, 200.f}; + Vec2 gear4 = {size.width - 200, size.height - 200}; + + drawNode->properties.setRotation(rotation + 45); + drawNode->properties.setCenter(gear1); + drawNode->drawStar(Vec2(gear1), 30, 60, 8, Color4F::BLUE, 4.0); + drawNode->properties.setRotation(-rotation); + drawNode->properties.setCenter(gear2); + drawNode->drawStar(gear2, 30, 60, 8, Color4F::GREEN, 4.0); + + drawNode->properties.setDefaultValues(); + drawNode->drawLine(gear2, gear1, Color4F::RED, sliderValue[sliderType::Thickness]); // line + drawNode->properties.setCenter(gear4); + drawNode->properties.setRotation(rotation + 45); + drawNode->drawStar(gear3, 30, 60, 18, Color4F::RED, 1.0); + drawNode->drawLine(gear3, gear4, Color4F::YELLOW, sliderValue[sliderType::Thickness]); // line + // drawNode->properties.setDefaultValues(); + drawNode->properties.setRotation(rotation - 45); + drawNode->properties.setCenter(gear4); + drawNode->drawStar(gear4, 40, 60, 60, Color4F::GREEN, 1.0); + + drawNode->properties.setRotation(rotation); + drawNode->properties.setCenter(Vec2(-110, 250)); + drawNode->drawStar(Vec2(-110, 250), 30, 70, 5, Color4F::GREEN, 1.0); + drawNode->properties.setCenter(Vec2(-150, 100)); + drawNode->drawStar(Vec2(-150, 100), 80, 100, 40, Color4F::GREEN, 1.0); + drawNode->properties.setCenter(Vec2(-150, -100)); + drawNode->drawStar(Vec2(-150, -100), 5, 70, 3, Color4F::GREEN, 1.0); + + drawNode->properties.setRotation(0); + for (int i = 0; i < 10; i++) + { + Vec2 ppp = Vec2(AXRANDOM_MINUS1_1() * size.x / 2, AXRANDOM_MINUS1_1() * size.y / 2); + drawNode->properties.setPosition(Vec2(ppp)); + drawNode->drawStar( + Vec2::ZERO, 40, 60, AXRANDOM_0_1() * 60 + 3, + Color4F(AXRANDOM_0_1(), AXRANDOM_0_1(), AXRANDOM_0_1(), sliderValue[sliderType::Thickness])); + } + break; + } + case drawMethodes::SolidStar: + { + Vec2 gear1 = {270.f, 320.f}; + Vec2 gear2 = {160.f, 320.f}; + Vec2 gear3 = {200.f, 200.f}; + Vec2 gear4 = {size.width - 200, size.height - 200}; + + drawNode->properties.setRotation(rotation + 45); + drawNode->properties.setCenter(gear1); + drawNode->drawSolidStar(Vec2(gear1), 30, 60, 8, Color4F::BLUE, Color4F::YELLOW, 4.0); + drawNode->properties.setRotation(-rotation); + drawNode->properties.setCenter(gear2); + drawNode->drawSolidStar(gear2, 30, 60, 8, Color4F::GREEN, Color4F::YELLOW, 4.0); + + drawNode->properties.setDefaultValues(); + drawNode->drawLine(gear2, gear1, Color4F::RED, sliderValue[sliderType::Thickness]); // line + drawNode->properties.setCenter(gear4); + drawNode->properties.setRotation(rotation + 45); + drawNode->drawSolidStar(gear3, 30, 60, 18, Color4F::RED, Color4F::YELLOW, 1.0); + drawNode->drawLine(gear3, gear4, Color4F::YELLOW, sliderValue[sliderType::Thickness]); // line + drawNode->properties.setDefaultValues(); + drawNode->properties.setRotation(rotation - 45); + drawNode->properties.setCenter(gear4); + drawNode->drawSolidStar(gear4, 40, 60, 60, Color4F::GREEN, Color4F::YELLOW, 1.0); + + drawNode->properties.setRotation(rotation); + drawNode->properties.setCenter(Vec2(-110, 250)); + drawNode->drawSolidStar(Vec2(-110, 250), 30, 70, 5, Color4F::GREEN, Color4F::YELLOW, 1.0); + drawNode->properties.setCenter(Vec2(-150, 100)); + drawNode->drawSolidStar(Vec2(-150, 100), 80, 100, 40, Color4F::GREEN, Color4F::YELLOW, 1.0); + drawNode->properties.setCenter(Vec2(-150, -100)); + drawNode->drawSolidStar(Vec2(-150, -100), 5, 70, 3, Color4F::GREEN, Color4F::YELLOW, 1.0); + + drawNode->properties.setRotation(0); + for (int i = 0; i < 10; i++) + { + Vec2 ppp = Vec2(AXRANDOM_MINUS1_1() * size.x / 2, AXRANDOM_MINUS1_1() * size.y / 2); + drawNode->properties.setPosition(Vec2(ppp)); + drawNode->drawSolidStar(Vec2::ZERO, 40, 60, AXRANDOM_0_1() * 60 + 3, + Color4F(AXRANDOM_0_1(), AXRANDOM_0_1(), AXRANDOM_0_1(), 1.0f), + Color4F(AXRANDOM_0_1(), AXRANDOM_0_1(), AXRANDOM_0_1(), 1.0f)); + } + + break; + } + + default: + break; + } +} + + +DrawNodeDrawInWrongOrder_Issue1888::DrawNodeDrawInWrongOrder_Issue1888() +{ + drawNode->properties.setDrawOrder(true); + scheduleUpdate(); +} + +std::string DrawNodeDrawInWrongOrder_Issue1888::title() const +{ + return "Issue #1888: Drawing order"; +} + +std::string DrawNodeDrawInWrongOrder_Issue1888::subtitle() const +{ + return "Red behind all. Green behind the blue/grey.\nRandom Points behind the squares. Blue is top."; +} + +void DrawNodeDrawInWrongOrder_Issue1888::update(float dt) +{ + DrawNodeBaseTest::update(dt); + + drawNode->clear(); + + drawNode->drawLine(Vec2(20, 140), Vec2(450, 110), Color4B::RED, 20.0f); + + for (int i = 0; i < 200; i++) + { + Vec2 position1[] = { + {60 + AXRANDOM_0_1() * VisibleRect::rightTop().x, 60 + AXRANDOM_0_1() * VisibleRect::rightTop().y}, + {70 + AXRANDOM_0_1() * VisibleRect::rightTop().x, 70 + AXRANDOM_0_1() * VisibleRect::rightTop().y}, + {60 + AXRANDOM_0_1() * VisibleRect::rightTop().x, 60 + AXRANDOM_0_1() * VisibleRect::rightTop().y}, + {70 + AXRANDOM_0_1() * VisibleRect::rightTop().x, 70 + AXRANDOM_0_1() * VisibleRect::rightTop().y}}; + drawNode->drawPoints(position1, 4, 10, Color4F(AXRANDOM_0_1(), AXRANDOM_0_1(), AXRANDOM_0_1(), 1)); + } + + drawNode->drawSolidRect(Vec2(150, 80), Vec2(400, 220), Color4B::YELLOW); + + for (int i = 0; i < 50; i++) + { + drawNode->drawPoint(Vec2(i * 7.0f, 120.0f), (float)i / 5 + 1, + Color4F(AXRANDOM_0_1(), AXRANDOM_0_1(), AXRANDOM_0_1(), 1.0f)); + } + + drawNode->drawLine(Vec2(20, 100), Vec2(450, 220), Color4B::GREEN, 8.0f); + + drawNode->drawLine(Vec2(200, 100), Vec2(450, 250), Color4B::BLUE, 6.0f); +} + +DrawNodeAxmolTest2::DrawNodeAxmolTest2() +{ + selectedRadioButton = 0; + + _radioButtonGroup = ui::RadioButtonGroup::create(); + addChild(_radioButtonGroup, 50); + + static const float BUTTON_WIDTH = 30; + static float startPosX = 0; + + // Create the radio buttons + static const int NUMBER_OF_BUTTONS = 2; + startPosX = size.width / 2.0f - ((NUMBER_OF_BUTTONS - 1) / 2.0f) * BUTTON_WIDTH; + for (int i = 0; i < NUMBER_OF_BUTTONS; ++i) + { + ui::RadioButton* radioButton = + ui::RadioButton::create("cocosui/radio_button_off.png", "cocosui/radio_button_on.png"); + float posX = startPosX + BUTTON_WIDTH * i; + radioButton->setPosition(Vec2(posX, size.height - 80)); + radioButton->setScale(1.2f); + radioButton->setTag(i); + _radioButtonGroup->addRadioButton(radioButton); + addChild(radioButton, 50); + radioButton->addEventListener(AX_CALLBACK_2(DrawNodeAxmolTest2::onChangedRadioButtonSelect, this)); + } + + drawNode = DrawNode::create(); + addChild(drawNode, 10); + + scheduleUpdate(); +} + +void DrawNodeAxmolTest2::onChangedRadioButtonSelect(ui::RadioButton* radioButton, ui::RadioButton::EventType type) +{ + if (radioButton == nullptr) + { + return; + } + switch (type) + { + case ui::RadioButton::EventType::SELECTED: + { + selectedRadioButton = radioButton->getTag(); + break; + } + + case ui::RadioButton::EventType::UNSELECTED: + { + break; + } + default: + break; + } +} + +void DrawNodeAxmolTest2::update(float dt) +{ + DrawNodeBaseTest::update(dt); + + if (!drawNode || !drawNode) + { + return; + } + + drawNode->clear(); + + switch (selectedRadioButton) + { + case 0: + setSubtitleLabel("Axmol v2 drawOrder ON (T)"); + drawAllv2(drawNode, true); + break; + case 1: + setSubtitleLabel("Axmol v2 drawOrder OFF (T,P,L)"); + drawAllv2(drawNode, false); + break; + default: + break; + } +} + +void DrawNodeAxmolTest2::drawAllv2(DrawNode* drawNode, bool drawOrder) +{ + drawNode->properties.setDrawOrder(drawOrder); + + drawNode->drawPoint(Vec2(size.width / 2 - 120, size.height / 2 - 120), 10, + Color4F(AXRANDOM_0_1(), AXRANDOM_0_1(), AXRANDOM_0_1(), 1)); + + drawNode->drawPoint(Vec2(size.width / 2 + 120, size.height / 2 + 120), 10, + Color4F(AXRANDOM_0_1(), AXRANDOM_0_1(), AXRANDOM_0_1(), 1)); + + // drawNode 4 small points + Vec2 position[] = {Vec2(60, 60), Vec2(70, 70), Vec2(60, 70), Vec2(70, 60)}; + drawNode->drawPoints(position, 4, 5, Color4F(AXRANDOM_0_1(), AXRANDOM_0_1(), AXRANDOM_0_1(), 1)); + + // drawNode a line + drawNode->drawLine(Vec2(0, 0), Vec2(size.width, size.height), Color4F(1.0, 0.0, 0.0, 0.5)); + + // drawNode a rectangle + drawNode->drawRect(Vec2(23, 23), Vec2(7, 7), Color4F::RED); + + drawNode->drawRect(Vec2(15, 30), Vec2(30, 15), Vec2(15, 0), Vec2(0, 15), + Color4F(AXRANDOM_0_1(), AXRANDOM_0_1(), AXRANDOM_0_1(), 1)); + + // drawNode a circle + drawNode->drawCircle(VisibleRect::center() + Vec2(140, 0), 100, AX_DEGREES_TO_RADIANS(90), 30, true, 1.0f, 2.0f, + Color4F(1.0f, 0.0f, 0.0f, 0.5f)); + + drawNode->drawCircle(VisibleRect::center() - Vec2(140, 0), 50, AX_DEGREES_TO_RADIANS(90), 30, false, + Color4F(AXRANDOM_0_1(), AXRANDOM_0_1(), AXRANDOM_0_1(), 1.0f)); + + // drawNode some beziers + drawNode->drawQuadBezier(Vec2(size.width - 150, size.height - 150), Vec2(size.width - 70, size.height - 10), + Vec2(size.width - 10, size.height - 10), 10, + Color4F(AXRANDOM_0_1(), AXRANDOM_0_1(), AXRANDOM_0_1(), 0.5f)); + + drawNode->drawQuadBezier(Vec2(0.0f, size.height), Vec2(size.width / 2, size.height / 2), + Vec2(size.width, size.height), 50, + Color4F(AXRANDOM_0_1(), AXRANDOM_0_1(), AXRANDOM_0_1(), 0.5f)); + + drawNode->drawCubicBezier(VisibleRect::center(), Vec2(VisibleRect::center().x + 30, VisibleRect::center().y + 50), + Vec2(VisibleRect::center().x + 60, VisibleRect::center().y - 50), VisibleRect::right(), + 100, Color4F(AXRANDOM_0_1(), AXRANDOM_0_1(), AXRANDOM_0_1(), 0.5f)); + + drawNode->drawCubicBezier(Vec2(size.width - 250, 40.0f), Vec2(size.width - 70, 100.0f), + Vec2(size.width - 30, 250.0f), Vec2(size.width - 10, size.height - 50), 10, + Color4F(AXRANDOM_0_1(), AXRANDOM_0_1(), AXRANDOM_0_1(), 0.5f)); + + auto array = PointArray::create(20); + array->addControlPoint(Vec2(0.0f, 0.0f)); + array->addControlPoint(Vec2(80.0f, 80.0f)); + array->addControlPoint(Vec2(size.width - 80, 80.0f)); + array->addControlPoint(Vec2(size.width - 80, size.height - 80)); + array->addControlPoint(Vec2(80.0f, size.height - 80)); + array->addControlPoint(Vec2(80.0f, 80.0f)); + array->addControlPoint(Vec2(size.width / 2, size.height / 2)); + drawNode->drawCardinalSpline(array, 0.5f, 50, Color4F(AXRANDOM_0_1(), AXRANDOM_0_1(), AXRANDOM_0_1(), 0.5f)); + + auto array2 = PointArray::create(20); + array2->addControlPoint(Vec2(size.width / 2, 30.0f)); + array2->addControlPoint(Vec2(size.width - 80, 30.0f)); + array2->addControlPoint(Vec2(size.width - 80, size.height - 80)); + array2->addControlPoint(Vec2(size.width / 2, size.height - 80)); + array2->addControlPoint(Vec2(size.width / 2, 30.0f)); + drawNode->drawCatmullRom(array2, 50, Color4F(AXRANDOM_0_1(), AXRANDOM_0_1(), AXRANDOM_0_1(), 0.5f)); + + // open random color poly + Vec2 vertices[] = {Vec2(0.0f, 0.0f), Vec2(50.0f, 50.0f), Vec2(100.0f, 50.0f), Vec2(100.0f, 100.0f), + Vec2(50.0f, 100.0f)}; + drawNode->drawPoly(vertices, 5, false, Color4F(AXRANDOM_0_1(), AXRANDOM_0_1(), AXRANDOM_0_1(), 1.0f)); + + // closed random color poly + Vec2 vertices2[] = {Vec2(30.0f, 130.0f), Vec2(30.0f, 230.0f), Vec2(50.0f, 200.0f)}; + drawNode->drawPoly(vertices2, 3, true, Color4F(AXRANDOM_0_1(), AXRANDOM_0_1(), AXRANDOM_0_1(), 1.0f)); + + // drawNode 10 circles + for (int i = 0; i < 10; i++) + { + drawNode->drawDot(Vec2(size.width / 2, size.height / 2), 10.f * (10 - i), + Color4F(AXRANDOM_0_1(), AXRANDOM_0_1(), AXRANDOM_0_1(), 1.0f)); + } + + // drawNode polygons + Vec2 points[] = {Vec2(size.height / 4, 0.0f), Vec2(size.width, size.height / 5), + Vec2(size.width / 3 * 2, size.height)}; + drawNode->drawPolygon(points, sizeof(points) / sizeof(points[0]), Color4F(1.0f, 0.0f, 0.0f, 0.5f), 4, + Color4F(0.0f, 0.0f, 1.0f, 0.5f)); + + // star poly (triggers buggs) + { + const float o = 80; + const float w = 20; + const float h = 50; + Vec2 star[] = { + Vec2(o + w, o - h), Vec2(o + w * 2, o), // lower spike + Vec2(o + w * 2 + h, o + w), Vec2(o + w * 2, o + w * 2), // right spike + //{o +w, o+w*2+h}, {o,o+w*2}, // top spike + //{o -h, o+w}, {o,o}, // left spike + }; + + drawNode->drawPolygon(star, sizeof(star) / sizeof(star[0]), Color4F(1.0f, 0.0f, 0.0f, 0.5f), 1, + Color4F(0.0f, 0.0f, 1.0f, 1.0f)); + } + + // star poly (doesn't trigger bug... order is important un tesselation is supported. + { + const float o = 180; + const float w = 20; + const float h = 50; + Vec2 star[] = { + Vec2(o, o), + Vec2(o + w, o - h), + Vec2(o + w * 2, o), // lower spike + Vec2(o + w * 2 + h, o + w), + Vec2(o + w * 2, o + w * 2), // right spike + Vec2(o + w, o + w * 2 + h), + Vec2(o, o + w * 2), // top spike + Vec2(o - h, o + w), // left spike + Vec2(o, o), // left spike + }; + + drawNode->drawPolygon(star, sizeof(star) / sizeof(star[0]), Color4F(1.0f, 0.0f, 0.0f, 0.5f), 1, + Color4F(0.0f, 0.0f, 1.0f, 1.0f)); + } + + // drawNode a solid polygon + Vec2 vertices3[] = {Vec2(60.0f, 160.0f), Vec2(70.0f, 190.0f), Vec2(100.0f, 190.0f), Vec2(90.0f, 160.0f)}; + drawNode->drawSolidPoly(vertices3, 4, Color4F(1.0f, 1.0f, 0.0f, 1.0f)); + + // drawNode a solid rectangle + drawNode->drawSolidRect(Vec2(10.0f, 10.0f), Vec2(20.0f, 20.0f), Color4F(1.0f, 1.0f, 0.0f, 1.0f)); + + // drawNode a solid circle + drawNode->drawSolidCircle(VisibleRect::center() + Vec2(140.0f, 0.0f), 40, AX_DEGREES_TO_RADIANS(90), 50, 2.0f, 2.0f, + Color4F(0.0f, 1.0f, 0.0f, 1.0f)); + + // drawNode segment + drawNode->drawSegment(Vec2(20.0f, size.height), Vec2(20.0f, size.height / 2), 10, Color4F(0.0f, 1.0f, 0.0f, 1.0f)); + + drawNode->drawSegment(Vec2(10.0f, size.height / 2), Vec2(size.width / 2, size.height / 2), 40, + Color4F(1.0f, 0.0f, 1.0f, 0.5f)); + + // drawNode triangle + drawNode->drawTriangle(Vec2(10.0f, 10.0f), Vec2(70.0f, 30.0f), Vec2(100.0f, 140.0f), + Color4F(AXRANDOM_0_1(), AXRANDOM_0_1(), AXRANDOM_0_1(), 0.5f)); + + for (int i = 0; i < 100; i++) + { + drawNode->drawPoint(Vec2(i * 7.0f, 5.0f), (float)i / 5 + 1, + Color4F(AXRANDOM_0_1(), AXRANDOM_0_1(), AXRANDOM_0_1(), 1.0f)); + } + + drawNode->setLineWidth(4); + drawNode->drawLine(Vec2(0.0f, size.height), Vec2(size.width, size.height - 20), Color4F::YELLOW); + drawNode->drawLine(Vec2(0.0f, 0.0f), Vec2(size.width, size.height - 20), Color4F::YELLOW); +} + +string DrawNodeAxmolTest2::title() const +{ + return "DrawNode Order test"; +} + +string DrawNodeAxmolTest2::subtitle() const +{ + return ""; +} + +DrawNodeIssueTester::DrawNodeIssueTester() +{ + static Vec2 vertices[] = {Vec2(0.0f, 0.0f), Vec2(50.0f, 50.0f), Vec2(100.0f, 50.0f), Vec2(100.0f, 100.0f), + Vec2(50.0f, 100.0f)}; + int verticesCount = 5; + + drawNode->properties.setPosition(Vec2(5, 150)); + drawNode->setLineWidth(1); + drawNode->drawPoly(vertices, verticesCount, false, Color4F::GREEN); + + auto draw = DrawNode::create(); + addChild(draw, 10); + draw->setPosition(70, 150); + draw->drawPoly(vertices, verticesCount, false, Color4F::BLUE); + + drawNode->properties.setPosition(Vec2(140, 150)); + drawNode->setLineWidth(1); + drawNode->drawPoly(vertices, verticesCount, false, Color4F::RED); + + drawNode->properties.setPosition(Vec2(200, 150)); + drawNode->setLineWidth(1); + drawNode->drawPoly(vertices, verticesCount, false, Color4F::RED, 3); + drawNode->drawPoly(vertices, verticesCount, false, Color4F::WHITE); + + drawNode->properties.setPosition(Vec2(270, 150)); + drawNode->setLineWidth(1); + drawNode->drawPoly(vertices, verticesCount, false, Color4F(0.0f, 0.5f, 0.5f, 0.5f), 10); + drawNode->drawPoly(vertices, verticesCount, false, Color4F::BLACK); + + float thick = 0.0f; + float y = -90.0f; + drawNode->properties.setPosition(Vec2(270, 100)); + for (int i = 0; i < 32; i++) + { + thick += 0.5f; + y += thick + 1; + drawNode->drawLine(Vec2(140, y), Vec2(180, y), Color4F(AXRANDOM_0_1(), AXRANDOM_0_1(), AXRANDOM_0_1(), 1.0f), + thick); + } + drawNode->drawPie(Vec2(-220, 150), 20, 0, 100, 300, 1, 1, Color4B::TRANSPARENT, Color4B::BLUE, + DrawNode::DrawMode::Line, 10); + + drawNode->properties.setPosition(Vec2(50, -100)); + for (int i = 2; i < 30; i++) + { + drawNode->drawCircle(center, 5 * i, AX_DEGREES_TO_RADIANS(90), i, false, 1.0f, 1.0f, + Color4F(AXRANDOM_0_1(), AXRANDOM_0_1(), AXRANDOM_0_1(), 1.0f), 0.5f); + } + + Vec2* fbHorse = new Vec2[856 / 2]; + int n = 0; + Vec2 pos = {100, 210}; + float scale = 3.0f; + drawNode->properties.setPosition(Vec2(-90, -160)); + for (size_t i = 0; i < sizeof(verticesFB) / sizeof(verticesFB[0]); i += 4) + { + drawNode->drawLine(Vec2(verticesFB[i] * scale, verticesFB[i + 1] * scale) + pos, + Vec2(verticesFB[i + 2] * scale, verticesFB[i + 3] * scale) + pos, Color4F::RED, 0.5f); + } + scheduleUpdate(); +} + +void DrawNodeIssueTester::onEnter() +{ + DrawNodeBaseTest::onEnter(); +} + +void DrawNodeIssueTester::update(float dt) +{ + // DrawNodeBaseTest::update(dt); +} + +string DrawNodeIssueTester::title() const +{ + return "For issue tests (future)"; +} + +string DrawNodeIssueTester::subtitle() const +{ + return "setLineWidth()"; +} + +DrawNodeSpLinesTest::DrawNodeSpLinesTest() +{ + auto listener = EventListenerTouchAllAtOnce::create(); + listener->onTouchesEnded = AX_CALLBACK_2(DrawNodeSpLinesTest::onTouchesEnded, this); + _eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this); + + drawNodeCP = DrawNode::create(); + addChild(drawNodeCP, 50); + + drawNode = DrawNode::create(); + addChild(drawNode, 30); + + screen = Director::getInstance()->getVisibleSize(); + origin = Director::getInstance()->getVisibleOrigin(); + center = Vec2(screen.width / 2, screen.height / 2); + sixth = Vec2(screen.width / 6, screen.height / 6); + sixth.y; + + defY = (int)(center.y + sixth.y); + defY2 = (int)(center.y - sixth.y); + dev = sixth.y; + + pts = PointArray::create(n); + pts2 = PointArray::create(n); + pts->retain(); + pts2->retain(); + for (int i = 0; i < n; ++i) + { + pts->insertControlPoint(Vec2(0, 0), i); + pts2->insertControlPoint(Vec2(0, 0), i); + } + + DrawNodeBaseTest::generateDataPoints(); + + addNewControlPoint(VisibleRect::center()); + + scheduleUpdate(); +} + +void DrawNodeSpLinesTest::addNewControlPoint(Vec2 p) +{ + points.emplace_back(Vec2(p.x, p.y)); +} + +void DrawNodeSpLinesTest::onTouchesEnded(const std::vector& touches, Event* event) +{ + for (auto& touch : touches) + { + auto location = touch->getLocation(); + addNewControlPoint(location); + } +} + +std::string DrawNodeSpLinesTest::title() const +{ + return "Testing SpLines"; +} + +std::string DrawNodeSpLinesTest::subtitle() const +{ + return "Tap screen to add more (control) points"; +} + +void DrawNodeSpLinesTest::update(float dt) +{ + if (points.size() == 0) + return; + + array = PointArray::create(points.size()); + + drawNodeCP->clear(); + + drawNode->clear(); + drawNode->clear(); + + int boxSize = 3; + for (auto&& p : points) + { + drawNodeCP->drawRect(Vec2(p.x - boxSize, p.y - boxSize), Vec2(p.x + boxSize, p.y + boxSize), Color4F::BLUE); + array->addControlPoint(Vec2(p.x, p.y)); + } + + drawNode->drawCardinalSpline(array, 0.2f, points.size() * 8, Color4F::GREEN, 20.0f); + drawNode->drawCardinalSpline(array, 0.2f, points.size() * 8, Color4F::BLUE); + + drawNode->drawCardinalSpline(array, 0.2f, points.size() * 16, Color4F(1.0f, 1.0f, 0.5f, 1.0f), 10.0f); + + // drawNode->drawCatmullRom(array, points.size() * 8, Color4F::YELLOW,5); + // if (points.size()>3) + //{ + // int step = points.size()/4; + // drawNode->drawCubicBezier(points.at(0), points.at(step),points.at(step*2),points.at(points.size()-1), + // points.size(), Color4F::BLUE); + //} + + drawNode->drawCardinalSpline(pts, 0.5f, 360, Color4F::RED, 5.0f); + drawNode->drawCardinalSpline(pts2, 0.5f, 360, Color4F::GREEN, 2.0f); + + int i1 = RandomHelper::random_int(0, n - 1); + int i2 = RandomHelper::random_int(0, n - 1); + drawNode->drawDot(pts->getControlPointAtIndex(i1), 7, Color4F(0, 1, 0, 0.3)); + drawNode->drawDot(pts->getControlPointAtIndex(i1), 4, Color4F::GREEN); + + drawNode->drawDot(pts2->getControlPointAtIndex(i2), 7, Color4F(0, 1, 0, 0.3)); + drawNode->drawDot(pts2->getControlPointAtIndex(i2), 4, Color4F::GREEN); +} + +#if defined(AX_PLATFORM_PC) +CandyMixEeffect::CandyMixEeffect() +{ + static const float BUTTON_WIDTH = 30; + static float startPosX = 0; + + scheduleUpdate(); +} + +std::string CandyMixEeffect::title() const +{ + return "Performance: Candy Mix"; +} + +std::string CandyMixEeffect::subtitle() const +{ + return ""; +} + +void CandyMixEeffect::renderLine(float x1, float x2, float y, ax::Color4F color, float angle) +{ + static float WID = 400; + + float xMid = (x1 + x2) * 0.5f; + float r = color.r; + float g = color.g; + float b = color.b; + float rng = 1.0f / (x2 - xMid); + x1 = MIN(MAX(0.0f, x1), WID - 1); + x2 = MIN(MAX(0.0f, x2), WID - 1); + + float mm = 0.8f; + + for (size_t x = x1; x < x2; x++) + { + float pos = (x - xMid) * rng; + float ang = (angle + asin(pos) + (cos((angle + pos * (float)M_PI) * 1.78f) * 0.3f)) + (float)M_PI * 0.5f; + float sf = 0.2f + 0.8f * MAX(mm - 0.8, MIN(mm, cos(ang))); + float sp = pow(MAX(0, cos(2 * ang)), 20); + float rr = MIN(mm, r * sf + sp); + float gg = MIN(mm, g * sf + sp); + float bb = MIN(mm, b * sf + sp); + drawNode->drawPoint(Vec2(y, x - 50), 2.0f, Color4F(rr, gg, bb, 1.0f)); + } +} + +void CandyMixEeffect::update(float dt) +{ + DrawNodeBaseTest::update(dt); + drawNode->clear(); + + static float WID = 400; + static float HIG = 600; + static b2Timer timer; + + float t = timer.GetMilliseconds() / 1000.0f; + float ta = sin(t * cos(t) * 0.02f) + t; + float tb = (1.0f + sin(t) * 1.0f) * 0.02f + 0.01f; + float xa = WID * 0.5f; + for (int y = 0; y < HIG; y++) + { + float ya = y * 0.01f; + float rad = 60 + sin(ta + ya) * 30; + float rot = t + sin(ya * 2) * 0.5f + cos(ta * 0.3f) * 0.3f; + float x1 = xa + sin(rot) * rad; + float x2 = xa + sin(rot + (float)M_PI * 0.5f) * rad; + float x3 = xa + sin(rot + (float)M_PI) * rad; + float x4 = xa + sin(rot + (float)M_PI * 1.5f) * rad; + if (x1 < x2) + renderLine(x1, x2, y, Color4F::RED, rot); + if (x2 < x3) + renderLine(x2, x3, y, Color4F::GREEN, rot + (float)M_PI * 0.5f); + if (x3 < x4) + renderLine(x3, x4, y, Color4F::BLUE, rot + (float)M_PI); + if (x4 < x1) + renderLine(x4, x1, y, Color4F::YELLOW, rot + (float)M_PI * 1.5f); + t += sin(ta + ya) * tb; + xa += sin(t + ta) * 0.1f; + } +} +#endif + +#if defined(_WIN32) +# pragma pop_macro("TRANSPARENT") +#endif diff --git a/tests/cpp-tests/Source/DrawNodeTest/DrawNodeTest.h b/tests/cpp-tests/Source/DrawNodeTest/DrawNodeTest.h new file mode 100644 index 000000000000..06e612e558c5 --- /dev/null +++ b/tests/cpp-tests/Source/DrawNodeTest/DrawNodeTest.h @@ -0,0 +1,438 @@ +/**************************************************************************** +Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. +Copyright (c) 2019-present Axmol Engine contributors (see AUTHORS.md). + +https://axmol.dev/ + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ +#pragma once + +#include "axmol.h" +#include "ui/CocosGUI.h" +#include "../BaseTest.h" +#include "2d/DrawNode.h" + +DEFINE_TEST_SUITE(DrawNodeTests); + +class DrawNodeBaseTest : public TestCase +{ + +protected: + + enum sliderType + { + AngleStart = 0, + AngleEnd, + Rotation, + Thickness, + sliderTypeLast + }; + enum drawMethodes + { + Line = 0, + Rect, + Circle, + QuadBezier, + CubicBezier, + CardinalSpline, + CatmullRom, + Poly, + Polygon, + Dot, + Point, + Points, + Triangle, + Segment, + SolidCircle, + SolidPoly, + SolidRect, + Star, + SolidStar, + LAST + }; + + std::string drawMethods[drawMethodes::LAST] = { "drawLine", + "drawRect", + "drawCircle", + "drawQuadBezier", + "drawCubicBezier", + "drawCardinalSpline", + "drawCatmullRom", + "drawPoly", + "drawPolygon", + "drawDot", + "drawPoint", + "drawPoints", + "drawTriangle", + "drawSegment", + "drawSolidCircle", + "drawSolidPoly", + "drawSolidRect", + "drawStar", + "drawSolidStar", }; + +public: + + DrawNodeBaseTest(); + + void onChangedRadioButtonSelect(ax::ui::RadioButton* radioButton, ax::ui::RadioButton::EventType type); + void listviewCallback(ax::Object* sender, ax::ui::ListView::EventType type); + void setDrawOrder(Object* sender); + void setTransform(Object* sender); + + void update(float dt); + + virtual std::string title() const override; + void drawDirection(const ax::Vec2* vec, const int size, ax::Vec2 offset); + + void initSliders(); + + void changeStartAngle(ax::Object* pSender, ax::ui::Slider::EventType type); + void changeEndAngle(ax::Object* pSender, ax::ui::Slider::EventType type); + void changeRotation(ax::Object* pSender, ax::ui::Slider::EventType type); + void changeThickness(ax::Object* pSender, ax::ui::Slider::EventType type); + + // using from https://github.com/intmainreturn00/AwesomeNode/ + void generateDataPoints(); + + ax::PointArray *pts = nullptr; + ax::PointArray *pts2 = nullptr; + float defY, defY2, dev; + const int n = 50; + const int grid = 10; + const int margin = 20; + ax::Size screen; + ax::Vec2 sixth; + +protected: + + int _currentSeletedItemIndex = 0; + + //UI stuff + ax::ui::Slider* slider[sliderType::sliderTypeLast]; + ax::Label* sliderLabel[sliderType::sliderTypeLast]; + float sliderValue[sliderType::sliderTypeLast]; + + + ax::ui::RadioButtonGroup* _radioButtonGroup; + ax::Layer* _uiLayer; + ax::ui::Layout* _widget; + int selectedRadioButton; + + ax::MenuItemFont* menuItemDrawOrder; + ax::MenuItemFont* menuItemTransform; + + // DrawNode stuff + ax::DrawNode* drawNode = nullptr; + ax::DrawNode* drawNodeArray[10]; + + + // Window stuff + ax::Vec2 origin; + ax::Vec2 size; + ax::Vec2 center; +}; + +class DrawNodePictureTest : public DrawNodeBaseTest +{ +public: + CREATE_FUNC(DrawNodePictureTest); + + DrawNodePictureTest(); + + virtual std::string title() const override; + virtual std::string subtitle() const override; + void update(float dt) override; + +private: + ax::any_buffer _abuf; +}; + +class DrawNodeMorphTest_SolidPolygon : public DrawNodeBaseTest +{ +public: + CREATE_FUNC(DrawNodeMorphTest_SolidPolygon); + + DrawNodeMorphTest_SolidPolygon(); + + virtual std::string title() const override; + virtual std::string subtitle() const override; + void update(float dt); + void onEnter(); + +private: + ax::Vec2* verticesObj1[10]; + ax::Vec2* verticesObj2[10]; + ax::Vec2* verticesObjMorph[10]; + ax::Color4F color[10]; + float rad[10]; + bool state[10]; + + int segments = 40; +}; + +class DrawNodeMorphTest_Polygon : public DrawNodeBaseTest +{ +public: + CREATE_FUNC(DrawNodeMorphTest_Polygon); + + DrawNodeMorphTest_Polygon(); + + virtual std::string title() const override; + virtual std::string subtitle() const override; + void update(float dt); + void onEnter(); + +private: + ax::Vec2* verticesObj1[10]; + ax::Vec2* verticesObj2[10]; + ax::Vec2* verticesObjMorph[10]; + ax::Color4F color[10]; + float rad[10]; + bool state[10]; + + int segments = 40; +}; + +class DrawNodeThicknessTest : public DrawNodeBaseTest +{ +public: + CREATE_FUNC(DrawNodeThicknessTest); + + DrawNodeThicknessTest(); + + virtual std::string title() const override; + virtual std::string subtitle() const override; + + void update(float dt); + void onEnter(); + +private: + // ax::Label* _lineWidthLabel; + // float lineWidth = 0; + ax::Label* _thicknessLabel; + float thickness = 1.0f; +}; + +class DrawNodeVersionsTest : public DrawNodeBaseTest +{ +public: + CREATE_FUNC(DrawNodeVersionsTest); + + DrawNodeVersionsTest(); + void drawDirection(const ax::Vec2* vec, const int size, ax::Vec2 offset); + + virtual std::string title() const override; + virtual std::string subtitle() const override; + void update(float dt) override; + +private: + ax::Vec2 center; +}; + +class DrawNodeFilledPolygonTest : public DrawNodeBaseTest +{ +public: + CREATE_FUNC(DrawNodeFilledPolygonTest); + + DrawNodeFilledPolygonTest(); + + virtual std::string title() const override; + virtual std::string subtitle() const override; +}; + +class DrawNodePieTest : public DrawNodeBaseTest +{ +public: + CREATE_FUNC(DrawNodePieTest); + + DrawNodePieTest(); + + virtual std::string title() const override; + virtual std::string subtitle() const override; + + void update(float dt); + void onEnter(); + +}; + +class DrawNodeMethodsTest : public DrawNodeBaseTest +{ +public: + CREATE_FUNC(DrawNodeMethodsTest); + + DrawNodeMethodsTest(); + + virtual std::string title() const override; + virtual std::string subtitle() const override; + + void update(float dt); + void onEnter(); + + void drawAll(); + +private: + ax::ui::ListView* createListView(); + + ax::Vec2* verticess; + + int count = 1; + + ax::Label* labelRound; + ax::Label* labelSquare; + ax::Label* labelButt; + + ax::ui::RadioButtonGroup* _radioButtonGroup; + int selectedRadioButton; +}; + + +class DrawNodeDrawInWrongOrder_Issue1888 : public DrawNodeBaseTest +{ +public: + CREATE_FUNC(DrawNodeDrawInWrongOrder_Issue1888); + + DrawNodeDrawInWrongOrder_Issue1888(); + + virtual std::string title() const override; + virtual std::string subtitle() const override; + void update(float dt) override; + +private: + ax::Vec2* heart; + const int totalFrames = 240; + ax::any_buffer _abuf; +}; + +class DrawNodeAxmolTest2 : public DrawNodeBaseTest +{ +public: + CREATE_FUNC(DrawNodeAxmolTest2); + + DrawNodeAxmolTest2(); + void onChangedRadioButtonSelect(ax::ui::RadioButton* radioButton, ax::ui::RadioButton::EventType type); + + virtual std::string title() const override; + virtual std::string subtitle() const override; + void update(float dt); + void drawAllv2(ax::DrawNode* drawNode, bool drawOrder); + void drawAllv1(ax::DrawNode* drawNode); + +private: + ax::Vec2 s; + + ax::ui::RadioButtonGroup* _radioButtonGroup; + int selectedRadioButton; +}; + +class DrawNodeIssueTester : public DrawNodeBaseTest +{ +public: + CREATE_FUNC(DrawNodeIssueTester); + + DrawNodeIssueTester(); + + virtual std::string title() const override; + virtual std::string subtitle() const override; + + void update(float dt); + void onEnter(); + + void changeThreshold(Object* pSender, ax::ui::Slider::EventType type); + void changeLineWidth(Object* pSender, ax::ui::Slider::EventType type); + +private: + ax::Label* _lineWidthLabel; + float lineWidth = 0; + ax::Label* _thresholdLabel; + float threshold = 0; +}; + + +class DrawNodeThicknessStressTest : public DrawNodeBaseTest +{ +public: + CREATE_FUNC(DrawNodeThicknessStressTest); + + DrawNodeThicknessStressTest(); + + virtual std::string title() const override; + virtual std::string subtitle() const override; + + void update(float dt); + void onEnter(); + + void changeThreshold(Object* pSender, ax::ui::Slider::EventType type); + void changeLineWidth(Object* pSender, ax::ui::Slider::EventType type); + +private: + ax::Label* _lineWidthLabel; + float lineWidth = 0; + ax::Label* _thresholdLabel; + float threshold = 0; +}; + + + + + + +class DrawNodeSpLinesTest : public DrawNodeBaseTest +{ +public: + CREATE_FUNC(DrawNodeSpLinesTest); + + DrawNodeSpLinesTest(); + + virtual std::string title() const override; + virtual std::string subtitle() const override; + + void onTouchesEnded(const std::vector& touches, ax::Event* event); + void addNewControlPoint(ax::Vec2 p); + void update(float dt); + +private: + ax::DrawNode* drawNodeCP = nullptr; + std::vector points; + ax::PointArray* array; +}; + +#if defined(AX_PLATFORM_PC) +class CandyMixEeffect : public DrawNodeBaseTest +{ +public: + CREATE_FUNC(CandyMixEeffect); + + CandyMixEeffect(); + + virtual std::string title() const override; + virtual std::string subtitle() const override; + + void update(float dt); + void renderLine(float x1, float x2, float y, ax::Color4F color, float angle); + +private: + std::vector points; + ax::PointArray* array; + + ax::ui::RadioButtonGroup* _radioButtonGroup; + int selectedRadioButton; +}; +#endif diff --git a/tests/cpp-tests/Source/DrawPrimitivesTest/DrawPrimitivesTest.cpp b/tests/cpp-tests/Source/DrawPrimitivesTest/DrawPrimitivesTest.cpp index a90465a703dd..488ca187f754 100644 --- a/tests/cpp-tests/Source/DrawPrimitivesTest/DrawPrimitivesTest.cpp +++ b/tests/cpp-tests/Source/DrawPrimitivesTest/DrawPrimitivesTest.cpp @@ -234,6 +234,7 @@ DrawNodeBackwardsAPITest::DrawNodeBackwardsAPITest() Vec2 vertices[4]; drawNode1->setScale(0.5); Color4F color; + bool setIsConvex = false; for (int iy = 0; iy < 5; iy++) { x = 0; @@ -247,14 +248,16 @@ DrawNodeBackwardsAPITest::DrawNodeBackwardsAPITest() if (AXRANDOM_0_1() > 0.5f) { drawNode1->setIsConvex(true); + setIsConvex = true; color = Color4F::YELLOW; } else { drawNode1->setIsConvex(false); // default value! + setIsConvex = false; color = Color4F::ORANGE; } - drawNode1->drawPolygon(vertices, 4, Color4F(0.7f, 0.7f, 0.7f, 0.5f), 1, color); + drawNode1->drawPolygon(vertices, 4, Color4F(0.7f, 0.7f, 0.7f, 0.5f), 1, color, setIsConvex); x += 70; } y += 80; diff --git a/tests/cpp-tests/Source/controller.cpp b/tests/cpp-tests/Source/controller.cpp index d1939d6f12a8..75aa911c9404 100644 --- a/tests/cpp-tests/Source/controller.cpp +++ b/tests/cpp-tests/Source/controller.cpp @@ -46,10 +46,6 @@ class RootTests : public TestList # pragma message("The optional extension Effekseer is enabled.") addTest("Effekseer", []() { return new EffekseerTests(); }); #endif -#if defined(AX_ENABLE_EXT_DRAWNODE) -# pragma message("The optional extension DrawNodeEx is enabled.") - addTest("DrawNodeEx", []() { return new DrawNodeExTests(); }); -#endif // addTest("Node: Scene3D", [](){return new Scene3DTests(); }); #if defined(AX_PLATFORM_PC) || (AX_TARGET_PLATFORM == AX_PLATFORM_ANDROID) || defined(__EMSCRIPTEN__) addTest("ImGui", []() { return new ImGuiTests(); }); @@ -92,7 +88,8 @@ class RootTests : public TestList addTest("Node: BillBoard Test", []() { return new BillBoardTests(); }); addTest("Node: Camera3D Test", []() { return new Camera3DTests(); }); addTest("Node: Clipping", []() { return new ClippingNodeTests(); }); - addTest("Node: Draw", []() { return new DrawPrimitivesTests(); }); + addTest("Node: Draw", []() { return new DrawNodeTests(); }); + addTest("Node: Draw (cocos2dx)", []() { return new DrawPrimitivesTests(); }); addTest("Node: Label - New API", []() { return new NewLabelTests(); }); addTest("Node: Layer", []() { return new LayerTests(); }); addTest("Node: Light", []() { return new LightTests(); }); diff --git a/tests/cpp-tests/Source/tests.h b/tests/cpp-tests/Source/tests.h index 45ea43f9b10a..4fb85bc278fe 100644 --- a/tests/cpp-tests/Source/tests.h +++ b/tests/cpp-tests/Source/tests.h @@ -72,12 +72,8 @@ #include "CurrentLanguageTest/CurrentLanguageTest.h" #include "DataVisitorTest/DataVisitorTest.h" #include "NetworkTest/NetworkTest.h" +#include "DrawNodeTest/DrawNodeTest.h" #include "DrawPrimitivesTest/DrawPrimitivesTest.h" - -#if defined(AX_ENABLE_EXT_DRAWNODE) -#include "DrawNodeExTest/DrawNodeExTest.h" -#endif - #include "EffectsAdvancedTest/EffectsAdvancedTest.h" #include "EffectsTest/EffectsTest.h" #include "ExtensionsTest/ExtensionsTest.h" diff --git a/tests/unit-tests/CMakeLists.txt b/tests/unit-tests/CMakeLists.txt index 4eb621765e4e..693883ad7006 100644 --- a/tests/unit-tests/CMakeLists.txt +++ b/tests/unit-tests/CMakeLists.txt @@ -170,10 +170,6 @@ if (AX_ENABLE_EXT_EFFEKSEER) target_compile_definitions(${APP_NAME} PRIVATE AX_ENABLE_EXT_EFFEKSEER=1) endif() -if (AX_ENABLE_EXT_DRAWNODEEX) - target_compile_definitions(${APP_NAME} PRIVATE AX_ENABLE_EXT_DRAWNODE=1) -endif() - # mark app resources ax_setup_app_config(${APP_NAME} CONSOLE)