| 3247 | ImVec4 SampleColormap(float t, ImPlot3DColormap cmap) { return ImGui::ColorConvertU32ToFloat4(SampleColormapU32(t, cmap)); } |
| 3248 | |
| 3249 | void RenderColorBar(const ImU32* colors, int size, ImDrawList& DrawList, const ImRect& bounds, bool vert, bool reversed, bool continuous) { |
| 3250 | const int n = continuous ? size - 1 : size; |
| 3251 | ImU32 col1, col2; |
| 3252 | if (vert) { |
| 3253 | const float step = bounds.GetHeight() / n; |
| 3254 | ImRect rect(bounds.Min.x, bounds.Min.y, bounds.Max.x, bounds.Min.y + step); |
| 3255 | for (int i = 0; i < n; ++i) { |
| 3256 | if (reversed) { |
| 3257 | col1 = colors[size - i - 1]; |
| 3258 | col2 = continuous ? colors[size - i - 2] : col1; |
| 3259 | } else { |
| 3260 | col1 = colors[i]; |
| 3261 | col2 = continuous ? colors[i + 1] : col1; |
| 3262 | } |
| 3263 | DrawList.AddRectFilledMultiColor(rect.Min, rect.Max, col1, col1, col2, col2); |
| 3264 | rect.TranslateY(step); |
| 3265 | } |
| 3266 | } else { |
| 3267 | const float step = bounds.GetWidth() / n; |
| 3268 | ImRect rect(bounds.Min.x, bounds.Min.y, bounds.Min.x + step, bounds.Max.y); |
| 3269 | for (int i = 0; i < n; ++i) { |
| 3270 | if (reversed) { |
| 3271 | col1 = colors[size - i - 1]; |
| 3272 | col2 = continuous ? colors[size - i - 2] : col1; |
| 3273 | } else { |
| 3274 | col1 = colors[i]; |
| 3275 | col2 = continuous ? colors[i + 1] : col1; |
| 3276 | } |
| 3277 | DrawList.AddRectFilledMultiColor(rect.Min, rect.Max, col1, col2, col2, col1); |
| 3278 | rect.TranslateX(step); |
| 3279 | } |
| 3280 | } |
| 3281 | } |
| 3282 | |
| 3283 | bool ColormapSlider(const char* label, float* t, ImVec4* out, const char* format, ImPlot3DColormap cmap) { |
| 3284 | *t = ImClamp(*t, 0.0f, 1.0f); |
no outgoing calls
no test coverage detected