Skip to content

Feat: PlotPolygon#673

Open
brenocq wants to merge 2 commits intomasterfrom
feat/polygon
Open

Feat: PlotPolygon#673
brenocq wants to merge 2 commits intomasterfrom
feat/polygon

Conversation

@brenocq
Copy link
Collaborator

@brenocq brenocq commented Feb 14, 2026

This PR introduces PlotPolygon as requested by #631.

// Flags for PlotPolygon. Used by setting ImPlotSpec::Flags.
enum ImPlotPolygonFlags_ {
  ImPlotPolygonFlags_None     = 0,       // default (closed, convex polygon)
  ImPlotPolygonFlags_Concave  = 1 << 10, // use concave polygon filling (slower but supports concave shapes)
};

// Plots a polygon. Points are specified as separate x and y arrays. Supports both convex and concave polygons.
IMPLOT_TMP void PlotPolygon(const char* label_id, const T* xs, const T* ys, int count, const ImPlotSpec& spec=ImPlotSpec());

Usage

...
if (ImPlot::BeginPlot("Polygon Plot", ImVec2(-1,0), ImPlotFlags_Equal)) {
    ImPlot::PlotPolygon("Triangle", tri_xs, tri_ys, 3, {
        ImPlotProp_FillAlpha, 0.5f,
    });
    ImPlot::PlotPolygon("Pentagon", pent_xs, pent_ys, 5, {
        ImPlotProp_FillAlpha, 0.5f,
        ImPlotProp_FillColor, ImVec4(0,1,0,1),
    });
    ImPlot::PlotPolygon("Star (Concave)", star_xs, star_ys, 10, {
        ImPlotProp_FillAlpha, 0.5f,
        ImPlotProp_FillColor, ImVec4(1,1,0,1),
        ImPlotProp_Flags, ImPlotPolygonFlags_Concave,
    });

    ImPlot::EndPlot();
}
image

@brenocq brenocq self-assigned this Feb 14, 2026
@brenocq brenocq added type:feat New feature or request prio:medium Medium priority status:review The task is under review labels Feb 14, 2026
@brenocq brenocq linked an issue Feb 14, 2026 that may be closed by this pull request
@brenocq brenocq added this to the v0.18 - ImPlotSpec milestone Feb 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

prio:medium Medium priority status:review The task is under review type:feat New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Plot polygon

1 participant

Comments