Skip to content

Commit

Permalink
Add (missing) parameter 'drawLineToCenter' to 'drawSolidCircle(...)' (#…
Browse files Browse the repository at this point in the history
…2160)

* Add parameter drawLineToCenter to drawSolidCircle

* fix  drawSolidTringle/drawTriangle

* Update axlua_base_auto.cpp
  • Loading branch information
aismann authored Sep 17, 2024
1 parent 96be23e commit c488380
Show file tree
Hide file tree
Showing 5 changed files with 208 additions and 157 deletions.
37 changes: 14 additions & 23 deletions core/2d/DrawNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -704,14 +704,16 @@ void DrawNode::drawSolidCircle(const Vec2& center,
float scaleY,
const Color4B& fillColor,
float thickness,
const Color4B& borderColor)
const Color4B& borderColor,
bool drawLineToCenter)
{
if (thickness < 0.0f)
{
AXLOGW("{}: thickness < 0, changed to 0", __FUNCTION__);
thickness = 0.0f;
}
_drawCircle(center, radius, angle, segments, false, scaleX, scaleY, borderColor, fillColor, true, thickness);
_drawCircle(center, radius, angle, segments, drawLineToCenter, scaleX, scaleY, borderColor, fillColor, true,
thickness);
}

void DrawNode::drawSolidCircle(const Vec2& center,
Expand Down Expand Up @@ -744,20 +746,16 @@ void DrawNode::drawSolidCircle(const Vec2& center,
_drawCircle(center, radius, angle, segments, false, 1.0f, 1.0f, Color4B(), color, true);
}

void DrawNode::drawTriangle(const Vec2* _vertices3, const Color4B& color, float thickness)
void DrawNode::drawTriangle(const Vec2* _vertices3, const Color4B& color)
{
_drawTriangle(_vertices3, Color4B::TRANSPARENT, color, false, thickness);
_drawTriangle(_vertices3, Color4B::TRANSPARENT, color, false, 0.0f);
}

void DrawNode::drawTriangle(const Vec2& p1, const Vec2& p2, const Vec2& p3, const Color4B& color, float thickness)
void DrawNode::drawTriangle(const Vec2& p1, const Vec2& p2, const Vec2& p3, const Color4B& color)
{
if (thickness <= 0.0f)
{
AXLOGW("{}: thickness <= 0", __FUNCTION__);
return;
}

Vec2 _vertices3[3] = {p1, p2, p3};
_drawTriangle(_vertices3, Color4B::TRANSPARENT, color, false, thickness);
_drawTriangle(_vertices3, Color4B::TRANSPARENT, color, false, 0.0f);
}

void DrawNode::drawSolidTriangle(const Vec2* _vertices3,
Expand Down Expand Up @@ -1256,7 +1254,7 @@ void DrawNode::_drawCircle(const Vec2& center,
{
const float coef = 2.0f * (float)M_PI / segments;

int count = (drawLineToCenter) ? 3 : 2;
int count = (drawLineToCenter) ? 3 : 2;
Vec2* _vertices = new Vec2[segments + count];

float rsX = radius * scaleX;
Expand All @@ -1272,18 +1270,11 @@ void DrawNode::_drawCircle(const Vec2& center,
if (drawLineToCenter)
_vertices[++segments] = center;


if (solid)
{
_drawPolygon(_vertices, segments + 1, fillColor, borderColor, false, thickness, true);
}
else
{
if (drawLineToCenter)
_drawPoly(_vertices, segments + 1, false, borderColor, thickness, true);
else
_drawPoly(_vertices, segments + 1, false, borderColor, thickness, true);
}
_drawPoly(_vertices, segments + 1, false, borderColor, thickness, true);

AX_SAFE_DELETE_ARRAY(_vertices);
}

Expand All @@ -1295,9 +1286,9 @@ void DrawNode::_drawTriangle(const Vec2* _vertices3,
{
unsigned int vertex_count = 3;

if (thickness != 1.0f)
if (thickness != 0.0f)
{
_drawPolygon(_vertices3, vertex_count, Color4B::BLUE, Color4B::BLUE, true, thickness, true);
_drawPolygon(_vertices3, vertex_count, fillColor, borderColor, true, thickness, true);
}
else
{
Expand Down
8 changes: 5 additions & 3 deletions core/2d/DrawNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@ class AX_DLL DrawNode : public Node
* @param fillColor The color will fill in polygon.
* @param thickness The border of line width.
* @param borderColor The border of line color.
* @param drawLineToCenter Whether or not draw the line from the origin to center.
* @js NA
*/
void drawSolidCircle(const Vec2& center,
Expand All @@ -365,7 +366,8 @@ class AX_DLL DrawNode : public Node
float scaleY,
const Color4B& fillColor,
float thickness,
const Color4B& borderColor);
const Color4B& borderColor,
bool drawLineToCenter = false);

/** Draws a solid circle given the center, radius and number of segments.
* @param center The circle center point.
Expand Down Expand Up @@ -501,9 +503,9 @@ class AX_DLL DrawNode : public Node
* @js NA
*/

void drawTriangle(const Vec2* vertices3, const Color4B& color, float thickness = 1.0f);
void drawTriangle(const Vec2* vertices3, const Color4B& color);

void drawTriangle(const Vec2& p1, const Vec2& p2, const Vec2& p3, const Color4B& color, float thickness = 1.0f);
void drawTriangle(const Vec2& p1, const Vec2& p2, const Vec2& p3, const Color4B& color);

void drawSolidTriangle(const Vec2* vertices3,
const Color4B& fillColor,
Expand Down
96 changes: 48 additions & 48 deletions extensions/scripting/lua-bindings/auto/axlua_base_auto.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52627,6 +52627,54 @@ int lua_ax_base_DrawNode_drawSolidCircle(lua_State* tolua_S)
}
}while(0);
ok = true;
do{
if (argc == 10) {
ax::Vec2 arg0;
ok &= luaval_to_vec2(tolua_S, 2, &arg0, "ax.DrawNode:drawSolidCircle");

if (!ok) { break; }
double arg1;
ok &= luaval_to_number(tolua_S, 3,&arg1, "ax.DrawNode:drawSolidCircle");

if (!ok) { break; }
double arg2;
ok &= luaval_to_number(tolua_S, 4,&arg2, "ax.DrawNode:drawSolidCircle");

if (!ok) { break; }
unsigned int arg3;
ok &= luaval_to_uint32(tolua_S, 5,&arg3, "ax.DrawNode:drawSolidCircle");

if (!ok) { break; }
double arg4;
ok &= luaval_to_number(tolua_S, 6,&arg4, "ax.DrawNode:drawSolidCircle");

if (!ok) { break; }
double arg5;
ok &= luaval_to_number(tolua_S, 7,&arg5, "ax.DrawNode:drawSolidCircle");

if (!ok) { break; }
ax::Color4B arg6;
ok &=luaval_to_color4b(tolua_S, 8, &arg6, "ax.DrawNode:drawSolidCircle");

if (!ok) { break; }
double arg7;
ok &= luaval_to_number(tolua_S, 9,&arg7, "ax.DrawNode:drawSolidCircle");

if (!ok) { break; }
ax::Color4B arg8;
ok &=luaval_to_color4b(tolua_S, 10, &arg8, "ax.DrawNode:drawSolidCircle");

if (!ok) { break; }
bool arg9;
ok &= luaval_to_boolean(tolua_S, 11,&arg9, "ax.DrawNode:drawSolidCircle");

if (!ok) { break; }
cobj->drawSolidCircle(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9);
lua_settop(tolua_S, 1);
return 1;
}
}while(0);
ok = true;
do{
if (argc == 5) {
ax::Vec2 arg0;
Expand Down Expand Up @@ -53133,34 +53181,6 @@ int lua_ax_base_DrawNode_drawTriangle(lua_State* tolua_S)
}
}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;
Expand All @@ -53177,26 +53197,6 @@ int lua_ax_base_DrawNode_drawTriangle(lua_State* tolua_S)
}
}while(0);
ok = true;
do{
if (argc == 3) {
const ax::Vec2* arg0;
ok &= luaval_to_object<const ax::Vec2>(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;

Expand Down
Loading

0 comments on commit c488380

Please sign in to comment.