| 4585 | } |
| 4586 | |
| 4587 | void 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 | |
| 4624 | void ColormapScale(const char* label, double scale_min, double scale_max, const ImVec2& size, const char* format, ImPlotColormapScaleFlags flags, ImPlotColormap cmap) { |
| 4625 | ImGuiContext &G = *GImGui; |
no test coverage detected