1
0
Fork 0
mirror of https://github.com/gwm17/implot.git synced 2024-11-29 21:48:53 -05: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
//-----------------------------------------------------------------------------
// 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<ImPlotTick> ticks;
static ImGuiTextBuffer txt_buff;

View File

@ -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