MCPcopy Create free account
hub / github.com/IppClub/Dora-SSR / RenderColorBar

Function RenderColorBar

Source/3rdParty/implot/implot.cpp:4667–4702  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4665}
4666
4667void RenderColorBar(const ImU32* colors, int size, ImDrawList& DrawList, const ImRect& bounds, bool vert, bool reversed, bool continuous) {
4668 const int n = continuous ? size - 1 : size;
4669 ImU32 col1, col2;
4670 if (vert) {
4671 const float step = bounds.GetHeight() / n;
4672 ImRect rect(bounds.Min.x, bounds.Min.y, bounds.Max.x, bounds.Min.y + step);
4673 for (int i = 0; i < n; ++i) {
4674 if (reversed) {
4675 col1 = colors[size-i-1];
4676 col2 = continuous ? colors[size-i-2] : col1;
4677 }
4678 else {
4679 col1 = colors[i];
4680 col2 = continuous ? colors[i+1] : col1;
4681 }
4682 DrawList.AddRectFilledMultiColor(rect.Min, rect.Max, col1, col1, col2, col2);
4683 rect.TranslateY(step);
4684 }
4685 }
4686 else {
4687 const float step = bounds.GetWidth() / n;
4688 ImRect rect(bounds.Min.x, bounds.Min.y, bounds.Min.x + step, bounds.Max.y);
4689 for (int i = 0; i < n; ++i) {
4690 if (reversed) {
4691 col1 = colors[size-i-1];
4692 col2 = continuous ? colors[size-i-2] : col1;
4693 }
4694 else {
4695 col1 = colors[i];
4696 col2 = continuous ? colors[i+1] : col1;
4697 }
4698 DrawList.AddRectFilledMultiColor(rect.Min, rect.Max, col1, col2, col2, col1);
4699 rect.TranslateX(step);
4700 }
4701 }
4702}
4703
4704void ColormapScale(const char* label, double scale_min, double scale_max, const ImVec2& size, const char* format, ImPlotColormapScaleFlags flags, ImPlotColormap cmap) {
4705 ImGuiContext &G = *GImGui;

Callers 4

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

Calls 3

GetHeightMethod · 0.45
GetWidthMethod · 0.45

Tested by

no test coverage detected