diff --git a/implot.cpp b/implot.cpp index e3cd5a5..778605a 100644 --- a/implot.cpp +++ b/implot.cpp @@ -277,12 +277,6 @@ inline ImU32 CalcTextColor(const ImVec4& bg) { } // private namespace -//----------------------------------------------------------------------------- -// Forwards -//----------------------------------------------------------------------------- - -ImVec4 NextColor(); - //----------------------------------------------------------------------------- // Structs //----------------------------------------------------------------------------- @@ -358,7 +352,7 @@ struct ImPlotItem { Show = true; SeenThisFrame = false; Highlight = false; - Color = NextColor(); + Color = ImPlot::NextColormapColor(); NameOffset = -1; ID = 0; } @@ -533,13 +527,6 @@ ImPlotInputMap& GetInputMap() { return gp.InputMap; } -// Returns the next unused default plot color -ImVec4 NextColor() { - ImVec4 col = gp.Colormap[gp.CurrentPlot->ColorIdx % gp.ColormapSize]; - gp.CurrentPlot->ColorIdx++; - return col; -} - inline void FitPoint(const ImPlotPoint& p) { ImPlotRange* extents_x = &gp.ExtentsX; ImPlotRange* extents_y = &gp.ExtentsY[gp.CurrentPlot->CurrentYAxis]; @@ -3486,6 +3473,12 @@ ImVec4 LerpColormap(float t) { return ImLerp(gp.Colormap[i1], gp.Colormap[i2], tr); } +ImVec4 NextColormapColor() { + ImVec4 col = gp.Colormap[gp.CurrentPlot->ColorIdx % gp.ColormapSize]; + gp.CurrentPlot->ColorIdx++; + return col; +} + void ShowColormapScale(double scale_min, double scale_max, float height) { static ImVector ticks; static ImGuiTextBuffer txt_buff; diff --git a/implot.h b/implot.h index 2ce98ce..62127bc 100644 --- a/implot.h +++ b/implot.h @@ -196,7 +196,7 @@ struct ImPlotInputMap { namespace ImPlot { // Starts a 2D plotting context. If this function returns true, EndPlot() must -// be called, e.g. "if (BeginPlot(...)) { ... EndPlot(); }"". #title_id must +// be called, e.g. "if (BeginPlot(...)) { ... EndPlot(); }". #title_id must // be unique. If you need to avoid ID collisions or don't want to display a // title in the plot, use double hashes (e.g. "MyPlot##Hidden"). If #x_label // and/or #y_label are provided, axes labels will be displayed. @@ -346,6 +346,8 @@ int GetColormapSize(); ImVec4 GetColormapColor(int index); // Linearly interpolates a color from the current colormap given t between 0 and 1. ImVec4 LerpColormap(float t); +// Returns the next unused colormap color and advances the colormap. Can be used to skip colors if desired. +ImVec4 NextColormapColor(); //----------------------------------------------------------------------------- // Plot Utils