Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion implot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@ bool ShowLegendEntries(ImPlotItemGroup& items, const ImRect& legend_bb, bool hov
label_bb.Min = top_left;
label_bb.Max = top_left + ImVec2(label_width + icon_size, icon_size);
ImU32 col_txt_hl;
ImU32 col_item = ImAlphaU32(item->Color,1);
ImU32 col_item = ImAlphaU32(item->Color, ImGui::GetStyle().Alpha);

ImRect button_bb(icon_bb.Min, label_bb.Max);

Expand Down
14 changes: 10 additions & 4 deletions implot_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,10 @@ static inline ImU32 ImLerpU32(const ImU32* colors, int size, float t) {
return ImMixU32(colors[i1], colors[i2], (ImU32)(tr*256));
}

// Set alpha channel of 32-bit color from float in range [0.0 1.0]
static inline ImU32 ImAlphaU32(ImU32 col, float alpha) {
return col & ~((ImU32)((1.0f-alpha)*255)<<IM_COL32_A_SHIFT);
// Multiply alpha channel of 32-bit color by float
static inline ImU32 ImAlphaU32(ImU32 col, float alpha_mul) {
ImU32 alpha = (ImU32)ImClamp((int)((col >> IM_COL32_A_SHIFT) * alpha_mul), 0, 255);
return (col & ~IM_COL32_A_MASK) | (alpha << IM_COL32_A_SHIFT);
}

// Returns true of two ranges overlap
Expand Down Expand Up @@ -1468,7 +1469,12 @@ static inline bool IsColorAuto(ImPlotCol idx) { return IsColorAuto(GImPlot->Styl
IMPLOT_API ImVec4 GetAutoColor(ImPlotCol idx);

// Returns the style color whether it is automatic or custom set
static inline ImVec4 GetStyleColorVec4(ImPlotCol idx) { return IsColorAuto(idx) ? GetAutoColor(idx) : GImPlot->Style.Colors[idx]; }
static inline ImVec4 GetStyleColorVec4(ImPlotCol idx, float alpha_mul = 1.0f) {
ImVec4 color = IsColorAuto(idx) ? GetAutoColor(idx) : GImPlot->Style.Colors[idx];
color.w *= ImGui::GetStyle().Alpha * alpha_mul;
return color;
}

static inline ImU32 GetStyleColorU32(ImPlotCol idx) { return ImGui::ColorConvertFloat4ToU32(GetStyleColorVec4(idx)); }

// Draws vertical text. The position is the bottom left of the text rect.
Expand Down