| 4434 | } |
| 4435 | |
| 4436 | void RenderColorBar(const ImU32* colors, int size, ImDrawList& DrawList, const ImRect& bounds, bool vert, bool reversed, bool continuous) { |
| 4437 | const int n = continuous ? size - 1 : size; |
| 4438 | ImU32 col1, col2; |
| 4439 | if (vert) { |
| 4440 | const float step = bounds.GetHeight() / n; |
| 4441 | ImRect rect(bounds.Min.x, bounds.Min.y, bounds.Max.x, bounds.Min.y + step); |
| 4442 | for (int i = 0; i < n; ++i) { |
| 4443 | if (reversed) { |
| 4444 | col1 = colors[size-i-1]; |
| 4445 | col2 = continuous ? colors[size-i-2] : col1; |
| 4446 | } |
| 4447 | else { |
| 4448 | col1 = colors[i]; |
| 4449 | col2 = continuous ? colors[i+1] : col1; |
| 4450 | } |
| 4451 | DrawList.AddRectFilledMultiColor(rect.Min, rect.Max, col1, col1, col2, col2); |
| 4452 | rect.TranslateY(step); |
| 4453 | } |
| 4454 | } |
| 4455 | else { |
| 4456 | const float step = bounds.GetWidth() / n; |
| 4457 | ImRect rect(bounds.Min.x, bounds.Min.y, bounds.Min.x + step, bounds.Max.y); |
| 4458 | for (int i = 0; i < n; ++i) { |
| 4459 | if (reversed) { |
| 4460 | col1 = colors[size-i-1]; |
| 4461 | col2 = continuous ? colors[size-i-2] : col1; |
| 4462 | } |
| 4463 | else { |
| 4464 | col1 = colors[i]; |
| 4465 | col2 = continuous ? colors[i+1] : col1; |
| 4466 | } |
| 4467 | DrawList.AddRectFilledMultiColor(rect.Min, rect.Max, col1, col2, col2, col1); |
| 4468 | rect.TranslateX(step); |
| 4469 | } |
| 4470 | } |
| 4471 | } |
| 4472 | |
| 4473 | void ColormapScale(const char* label, double scale_min, double scale_max, const ImVec2& size, const char* format, ImPlotColormapScaleFlags flags, ImPlotColormap cmap) { |
| 4474 | ImGuiContext &G = *GImGui; |
no test coverage detected