1
0
Fork 0
mirror of https://github.com/gwm17/implot.git synced 2024-11-22 18:28:53 -05:00

PlotImage

This commit is contained in:
epezent 2020-09-17 11:58:58 -05:00
parent 04cc84ece0
commit ec8e87561f
2 changed files with 26 additions and 0 deletions

View File

@ -393,9 +393,14 @@ template <typename T> IMPLOT_API void PlotHeatmap(const char* label_id, const T*
template <typename T> IMPLOT_API void PlotDigital(const char* label_id, const T* xs, const T* ys, int count, int offset=0, int stride=sizeof(T));
IMPLOT_API void PlotDigitalG(const char* label_id, ImPlotPoint (*getter)(void* data, int idx), void* data, int count, int offset=0);
// Plots an image.
IMPLOT_API void PlotImage(const char* label_id, ImTextureID user_texture_id, const ImPlotPoint& bounds_min, const ImPlotPoint& bounds_max, const ImVec2& uv0 = ImVec2(0, 0), const ImVec2& uv1 = ImVec2(1,1), const ImVec4& tint_col = ImVec4(1,1,1,1));
// Plots a centered text label at point x,y with optional pixel offset. Text color can be changed with ImPlot::PushStyleColor(ImPlotCol_InlayText, ...).
IMPLOT_API void PlotText(const char* text, double x, double y, bool vertical=false, const ImVec2& pixel_offset=ImVec2(0,0));
//-----------------------------------------------------------------------------
// Plot Utils
//-----------------------------------------------------------------------------

View File

@ -1705,6 +1705,27 @@ void PlotRects(const char* label_id, ImPlotPoint (*getter_func)(void* data, int
return PlotRectsEx(label_id, getter);
}
//-----------------------------------------------------------------------------
// PLOT IMAGE
//-----------------------------------------------------------------------------
void PlotImage(const char* label_id, ImTextureID user_texture_id, const ImPlotPoint& bmin, const ImPlotPoint& bmax, const ImVec2& uv0, const ImVec2& uv1, const ImVec4& tint_col) {
if (BeginItem(label_id)) {
if (FitThisFrame()) {
FitPoint(bmin);
FitPoint(bmax);
}
GetCurrentItem()->Color = tint_col;
ImDrawList& DrawList = *GetPlotDrawList();
ImVec2 p1 = PlotToPixels(bmin.x, bmax.y);
ImVec2 p2 = PlotToPixels(bmax.x, bmin.y);
PushPlotClipRect();
DrawList.AddImage(user_texture_id, p1, p2, uv0, uv1, ImGui::ColorConvertFloat4ToU32(tint_col));
PopPlotClipRect();;
EndItem();
}
}
//-----------------------------------------------------------------------------
// PLOT TEXT
//-----------------------------------------------------------------------------