MCPcopy Create free account
hub / github.com/SatDump/SatDump / RenderColorBar

Function RenderColorBar

src-core/imgui/implot/implot.cpp:4587–4622  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4585}
4586
4587void RenderColorBar(const ImU32* colors, int size, ImDrawList& DrawList, const ImRect& bounds, bool vert, bool reversed, bool continuous) {
4588 const int n = continuous ? size - 1 : size;
4589 ImU32 col1, col2;
4590 if (vert) {
4591 const float step = bounds.GetHeight() / n;
4592 ImRect rect(bounds.Min.x, bounds.Min.y, bounds.Max.x, bounds.Min.y + step);
4593 for (int i = 0; i < n; ++i) {
4594 if (reversed) {
4595 col1 = colors[size-i-1];
4596 col2 = continuous ? colors[size-i-2] : col1;
4597 }
4598 else {
4599 col1 = colors[i];
4600 col2 = continuous ? colors[i+1] : col1;
4601 }
4602 DrawList.AddRectFilledMultiColor(rect.Min, rect.Max, col1, col1, col2, col2);
4603 rect.TranslateY(step);
4604 }
4605 }
4606 else {
4607 const float step = bounds.GetWidth() / n;
4608 ImRect rect(bounds.Min.x, bounds.Min.y, bounds.Min.x + step, bounds.Max.y);
4609 for (int i = 0; i < n; ++i) {
4610 if (reversed) {
4611 col1 = colors[size-i-1];
4612 col2 = continuous ? colors[size-i-2] : col1;
4613 }
4614 else {
4615 col1 = colors[i];
4616 col2 = continuous ? colors[i+1] : col1;
4617 }
4618 DrawList.AddRectFilledMultiColor(rect.Min, rect.Max, col1, col2, col2, col1);
4619 rect.TranslateX(step);
4620 }
4621 }
4622}
4623
4624void ColormapScale(const char* label, double scale_min, double scale_max, const ImVec2& size, const char* format, ImPlotColormapScaleFlags flags, ImPlotColormap cmap) {
4625 ImGuiContext &G = *GImGui;

Callers 4

ColormapScaleFunction · 0.85
ColormapSliderFunction · 0.85
ColormapButtonFunction · 0.85
ColormapIconFunction · 0.85

Calls 1

Tested by

no test coverage detected