Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 25 additions & 6 deletions src/WeatherEditor/EditorWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,40 @@ inline void HelpMarker(const char* a_desc)
AddTooltip(a_desc, ImGuiHoveredFlags_DelayShort);
}

void DrawIconStar(ImVec2 center, float radius, ImU32 color, bool /*filled*/)
void DrawIconStar(ImVec2 center, float radius, ImU32 color, bool filled)
{
auto* drawList = ImGui::GetWindowDrawList();
const int numPoints = 5;
const float angleStep = 3.14159f / numPoints;
constexpr int numPoints = 5;
const float angleStep = IM_PI / numPoints;
ImVec2 points[10];

for (int i = 0; i < numPoints * 2; i++) {
float angle = -1.57079f + i * angleStep;
float angle = -IM_PI * 0.5f + i * angleStep;
float r = (i % 2 == 0) ? radius : radius * 0.38f;
points[i] = ImVec2(center.x + cosf(angle) * r, center.y + sinf(angle) * r);
}

for (int i = 0; i < 10; i++) {
drawList->AddLine(points[i], points[(i + 1) % 10], color, 1.5f);
if (filled) {
// Disable AA fill temporarily — ImGui adds a 1px fringe around each filled shape
// that creates visible seams at the pentagon/triangle boundaries.
ImDrawListFlags oldFlags = drawList->Flags;
drawList->Flags &= ~ImDrawListFlags_AntiAliasedFill;

ImVec2 innerPentagon[5];
for (int i = 0; i < 5; i++) {
innerPentagon[i] = points[i * 2 + 1]; // inner points
}
drawList->AddConvexPolyFilled(innerPentagon, 5, color);
for (int i = 0; i < 5; i++) {
drawList->AddTriangleFilled(points[i * 2], points[i * 2 + 1], points[(i * 2 + 9) % 10], color);
}

drawList->Flags = oldFlags;

// Draw an AA polyline over the outer perimeter to restore smooth edges
drawList->AddPolyline(points, 10, color, ImDrawFlags_Closed, 1.5f);
} else {
drawList->AddPolyline(points, 10, color, ImDrawFlags_Closed, 1.5f);
}
}

Expand Down