1
0
Fork 0
mirror of https://github.com/gwm17/implot.git synced 2024-10-09 23:57:26 -04:00

expose NextColormapColor

This commit is contained in:
epezent 2020-08-16 00:49:34 -05:00
parent 510366e12e
commit 96dc5b5a28
2 changed files with 10 additions and 15 deletions

View File

@ -277,12 +277,6 @@ inline ImU32 CalcTextColor(const ImVec4& bg) {
} // private namespace } // private namespace
//-----------------------------------------------------------------------------
// Forwards
//-----------------------------------------------------------------------------
ImVec4 NextColor();
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Structs // Structs
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -358,7 +352,7 @@ struct ImPlotItem {
Show = true; Show = true;
SeenThisFrame = false; SeenThisFrame = false;
Highlight = false; Highlight = false;
Color = NextColor(); Color = ImPlot::NextColormapColor();
NameOffset = -1; NameOffset = -1;
ID = 0; ID = 0;
} }
@ -533,13 +527,6 @@ ImPlotInputMap& GetInputMap() {
return gp.InputMap; 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) { inline void FitPoint(const ImPlotPoint& p) {
ImPlotRange* extents_x = &gp.ExtentsX; ImPlotRange* extents_x = &gp.ExtentsX;
ImPlotRange* extents_y = &gp.ExtentsY[gp.CurrentPlot->CurrentYAxis]; 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); 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) { void ShowColormapScale(double scale_min, double scale_max, float height) {
static ImVector<ImPlotTick> ticks; static ImVector<ImPlotTick> ticks;
static ImGuiTextBuffer txt_buff; static ImGuiTextBuffer txt_buff;

View File

@ -196,7 +196,7 @@ struct ImPlotInputMap {
namespace ImPlot { namespace ImPlot {
// Starts a 2D plotting context. If this function returns true, EndPlot() must // 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 // 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 // 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. // and/or #y_label are provided, axes labels will be displayed.
@ -346,6 +346,8 @@ int GetColormapSize();
ImVec4 GetColormapColor(int index); ImVec4 GetColormapColor(int index);
// Linearly interpolates a color from the current colormap given t between 0 and 1. // Linearly interpolates a color from the current colormap given t between 0 and 1.
ImVec4 LerpColormap(float t); 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 // Plot Utils