Last active
July 5, 2026 21:13
-
-
Save therathatter/317e9bca057f550050108897df69cceb to your computer and use it in GitHub Desktop.
Gradients with ImGUI
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void gradient_rect( ImDrawList* list, const ImVec2& p_min, const ImVec2& p_max, | |
| ImU32 col_top, ImU32 col_bottom, float rounding, | |
| ImDrawFlags flags ) | |
| { | |
| /* | |
| * "It’s also that AddRectFilledMultiColor() doesn’t even support rounding. | |
| * In the event your shape could fill the window without requiring clipping | |
| * (which is always rectangular) you could use AddRectFilled() with rounding | |
| * and white color + the ShadeVertsLinearColorGradientKeepAlpha() function." | |
| * - ocornut | |
| * (https://github.com/ocornut/imgui/issues/6652#issuecomment-1653173953) | |
| */ | |
| const ImRect bb( p_min, p_max ); | |
| int vert_start_idx = list->VtxBuffer.Size; | |
| list->AddRectFilled( bb.Min, bb.Max, col_top, rounding, flags ); | |
| int vert_end_idx = list->VtxBuffer.Size; | |
| ShadeVertsLinearColorGradientKeepAlpha( list, vert_start_idx, vert_end_idx, | |
| bb.Min, bb.GetBL( ), col_top, | |
| col_bottom ); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment