Skip to content

Commit

Permalink
Improve DrawNode::drawPie() (#2222)
Browse files Browse the repository at this point in the history
  • Loading branch information
aismann authored Oct 28, 2024
1 parent c993da1 commit 53ec946
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions core/2d/DrawNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -992,7 +992,7 @@ void DrawNode::_drawPolygon(const Vec2* verts,
extrude[i] = {offset, n2};
}

for (unsigned int i = 0; i < count-1; i++)
for (unsigned int i = 0; i < count; i++)
{
int j = (i + 1) % count;
Vec2 v0 = _vertices[i];
Expand Down Expand Up @@ -1461,18 +1461,21 @@ void DrawNode::_drawPie(const Vec2& center,
case DrawMode::Fill:
_vertices[n++] = center;
_vertices[n++] = _vertices[0];
_drawPolygon(_vertices.data(), n, fillColor, borderColor, true, thickness, false);
_drawPolygon(_vertices.data(), n, fillColor, Color4B::TRANSPARENT, true, 0, false);
_drawPoly(_vertices.data(), n, false, borderColor, thickness, true);
break;
case DrawMode::Outline:
_vertices[n++] = center;
_vertices[n++] = _vertices[0];
_drawPolygon(_vertices.data(), n, Color4B::TRANSPARENT, borderColor, false, thickness, false);
_drawPoly(_vertices.data(), n, false, borderColor, thickness, true);
break;
case DrawMode::Line:
_drawPolygon(_vertices.data(), n - 1, Color4B::TRANSPARENT, borderColor, false, thickness, false);
_drawPoly(_vertices.data(), n, false, borderColor, thickness, true);
break;
case DrawMode::Semi:
_drawPolygon(_vertices.data(), n - 1, fillColor, borderColor, true, thickness, false);
if (fillColor != Color4B::TRANSPARENT)
_drawPolygon(_vertices.data(), n, fillColor, borderColor, true, 0, false);
_drawPoly(_vertices.data(), n, true, borderColor, thickness, true);
break;
default:
break;
Expand Down

0 comments on commit 53ec946

Please sign in to comment.