@ -4869,21 +4869,22 @@ static void ShowExampleAppCustomRendering(bool* p_open)
// Draw gradients
// (note that those are currently exacerbating our sRGB/Linear issues)
// Calling ImGui::GetColorU32() multiplies the given colors by the current Style Alpha, but you may pass the IM_COL32() directly as well..
ImGui : : Text ( " Gradients " ) ;
ImVec2 gradient_size = ImVec2 ( ImGui : : CalcItemWidth ( ) , ImGui : : GetFrameHeight ( ) ) ;
{
ImVec2 p0 = ImGui : : GetCursorScreenPos ( ) ;
ImVec2 p1 = ImVec2 ( p0 . x + gradient_size . x , p0 . y + gradient_size . y ) ;
ImU32 col_a = ImGui : : GetColorU32 ( ImVec4 ( 0.0f , 0.0f , 0.0f , 1.0f ) ) ;
ImU32 col_b = ImGui : : GetColorU32 ( ImVec4 ( 1.0f , 1.0f , 1.0f , 1.0f ) ) ;
ImU32 col_a = ImGui : : GetColorU32 ( IM_COL32 ( 0 , 0 , 0 , 255 ) ) ;
ImU32 col_b = ImGui : : GetColorU32 ( IM_COL32 ( 255 , 255 , 255 , 255 ) ) ;
draw_list - > AddRectFilledMultiColor ( p0 , p1 , col_a , col_b , col_b , col_a ) ;
ImGui : : InvisibleButton ( " ##gradient1 " , gradient_size ) ;
}
{
ImVec2 p0 = ImGui : : GetCursorScreenPos ( ) ;
ImVec2 p1 = ImVec2 ( p0 . x + gradient_size . x , p0 . y + gradient_size . y ) ;
ImU32 col_a = ImGui : : GetColorU32 ( ImVec4 ( 0.0f , 1.0f , 0.0f , 1.0f ) ) ;
ImU32 col_b = ImGui : : GetColorU32 ( ImVec4 ( 1.0f , 0.0f , 0.0f , 1.0f ) ) ;
ImU32 col_a = ImGui : : GetColorU32 ( IM_COL32 ( 0 , 255 , 0 , 255 ) ) ;
ImU32 col_b = ImGui : : GetColorU32 ( IM_COL32 ( 255 , 0 , 0 , 255 ) ) ;
draw_list - > AddRectFilledMultiColor ( p0 , p1 , col_a , col_b , col_b , col_a ) ;
ImGui : : InvisibleButton ( " ##gradient2 " , gradient_size ) ;
}
@ -4904,6 +4905,7 @@ static void ShowExampleAppCustomRendering(bool* p_open)
if ( ImGui : : SliderInt ( " Circle segments " , & circle_segments_override_v , 3 , 40 ) )
circle_segments_override = true ;
ImGui : : ColorEdit4 ( " Color " , & colf . x ) ;
const ImVec2 p = ImGui : : GetCursorScreenPos ( ) ;
const ImU32 col = ImColor ( colf ) ;
const float spacing = 10.0f ;
@ -4911,38 +4913,39 @@ static void ShowExampleAppCustomRendering(bool* p_open)
const ImDrawCornerFlags corners_all = ImDrawCornerFlags_All ;
const ImDrawCornerFlags corners_tl_br = ImDrawCornerFlags_TopLeft | ImDrawCornerFlags_BotRight ;
const int circle_segments = circle_segments_override ? circle_segments_override_v : 0 ;
float x = p . x + 4.0f , y = p . y + 4.0f ;
float x = p . x + 4.0f ;
float y = p . y + 4.0f ;
for ( int n = 0 ; n < 2 ; n + + )
{
// First line uses a thickness of 1.0f, second line uses the configurable thickness
float th = ( n = = 0 ) ? 1.0f : thickness ;
draw_list - > AddNgon ( ImVec2 ( x + sz * 0.5f , y + sz * 0.5f ) , sz * 0.5f , col , ngon_sides , th ) ; x + = sz + spacing ; // N-gon
draw_list - > AddCircle ( ImVec2 ( x + sz * 0.5f , y + sz * 0.5f ) , sz * 0.5f , col , circle_segments , th ) ; x + = sz + spacing ; // Circle
draw_list - > AddRect ( ImVec2 ( x , y ) , ImVec2 ( x + sz , y + sz ) , col , 0.0f , corners_none , th ) ; x + = sz + spacing ; // Square
draw_list - > AddRect ( ImVec2 ( x , y ) , ImVec2 ( x + sz , y + sz ) , col , 10.0f , corners_all , th ) ; x + = sz + spacing ; // Square with all rounded corners
draw_list - > AddRect ( ImVec2 ( x , y ) , ImVec2 ( x + sz , y + sz ) , col , 10.0f , corners_tl_br , th ) ; x + = sz + spacing ; // Square with two rounded corners
draw_list - > AddTriangle ( ImVec2 ( x + sz * 0.5f , y ) , ImVec2 ( x + sz , y + sz - 0.5f ) , ImVec2 ( x , y + sz - 0.5f ) , col , th ) ; x + = sz + spacing ; // Triangle
draw_list - > AddTriangle ( ImVec2 ( x + sz * 0.2f , y ) , ImVec2 ( x , y + sz - 0.5f ) , ImVec2 ( x + sz * 0.4f , y + sz - 0.5f ) , col , th ) ; x + = sz * 0.4f + spacing ; // Thin triangle
draw_list - > AddLine ( ImVec2 ( x , y ) , ImVec2 ( x + sz , y ) , col , th ) ; x + = sz + spacing ; // Horizontal line (note: drawing a filled rectangle will be faster!)
draw_list - > AddLine ( ImVec2 ( x , y ) , ImVec2 ( x , y + sz ) , col , th ) ; x + = spacing ; // Vertical line (note: drawing a filled rectangle will be faster!)
draw_list - > AddLine ( ImVec2 ( x , y ) , ImVec2 ( x + sz , y + sz ) , col , th ) ; x + = sz + spacing ; // Diagonal line
draw_list - > AddNgon ( ImVec2 ( x + sz * 0.5f , y + sz * 0.5f ) , sz * 0.5f , col , ngon_sides , th ) ; x + = sz + spacing ; // N-gon
draw_list - > AddCircle ( ImVec2 ( x + sz * 0.5f , y + sz * 0.5f ) , sz * 0.5f , col , circle_segments , th ) ; x + = sz + spacing ; // Circle
draw_list - > AddRect ( ImVec2 ( x , y ) , ImVec2 ( x + sz , y + sz ) , col , 0.0f , corners_none , th ) ; x + = sz + spacing ; // Square
draw_list - > AddRect ( ImVec2 ( x , y ) , ImVec2 ( x + sz , y + sz ) , col , 10.0f , corners_all , th ) ; x + = sz + spacing ; // Square with all rounded corners
draw_list - > AddRect ( ImVec2 ( x , y ) , ImVec2 ( x + sz , y + sz ) , col , 10.0f , corners_tl_br , th ) ; x + = sz + spacing ; // Square with two rounded corners
draw_list - > AddTriangle ( ImVec2 ( x + sz * 0.5f , y ) , ImVec2 ( x + sz , y + sz - 0.5f ) , ImVec2 ( x , y + sz - 0.5f ) , col , th ) ; x + = sz + spacing ; // Triangle
//draw_list->AddTriangle(ImVec2(x+sz*0.2f,y), ImVec2(x, y+sz-0.5f), ImVec2(x+sz*0.4f, y+sz-0.5f), col, th);x+= sz*0.4f + spacing; // Thin triangle
draw_list - > AddLine ( ImVec2 ( x , y ) , ImVec2 ( x + sz , y ) , col , th ) ; x + = sz + spacing ; // Horizontal line (note: drawing a filled rectangle will be faster!)
draw_list - > AddLine ( ImVec2 ( x , y ) , ImVec2 ( x , y + sz ) , col , th ) ; x + = spacing ; // Vertical line (note: drawing a filled rectangle will be faster!)
draw_list - > AddLine ( ImVec2 ( x , y ) , ImVec2 ( x + sz , y + sz ) , col , th ) ; x + = sz + spacing ; // Diagonal line
draw_list - > AddBezierCurve ( ImVec2 ( x , y ) , ImVec2 ( x + sz * 1.3f , y + sz * 0.3f ) , ImVec2 ( x + sz - sz * 1.3f , y + sz - sz * 0.3f ) , ImVec2 ( x + sz , y + sz ) , col , th ) ;
x = p . x + 4 ;
y + = sz + spacing ;
}
draw_list - > AddNgonFilled ( ImVec2 ( x + sz * 0.5f , y + sz * 0.5f ) , sz * 0.5f , col , ngon_sides ) ; x + = sz + spacing ; // N-gon
draw_list - > AddCircleFilled ( ImVec2 ( x + sz * 0.5f , y + sz * 0.5f ) , sz * 0.5f , col , circle_segments ) ; x + = sz + spacing ; // Circle
draw_list - > AddRectFilled ( ImVec2 ( x , y ) , ImVec2 ( x + sz , y + sz ) , col ) ; x + = sz + spacing ; // Square
draw_list - > AddRectFilled ( ImVec2 ( x , y ) , ImVec2 ( x + sz , y + sz ) , col , 10.0f ) ; x + = sz + spacing ; // Square with all rounded corners
draw_list - > AddRectFilled ( ImVec2 ( x , y ) , ImVec2 ( x + sz , y + sz ) , col , 10.0f , corners_tl_br ) ; x + = sz + spacing ; // Square with two rounded corners
draw_list - > AddTriangleFilled ( ImVec2 ( x + sz * 0.5f , y ) , ImVec2 ( x + sz , y + sz - 0.5f ) , ImVec2 ( x , y + sz - 0.5f ) , col ) ; x + = sz + spacing ; // Triangle
draw_list - > AddTriangleFilled ( ImVec2 ( x + sz * 0.2f , y ) , ImVec2 ( x , y + sz - 0.5f ) , ImVec2 ( x + sz * 0.4f , y + sz - 0.5f ) , col ) ; x + = sz * 0.4f + spacing ; // Thin triangle
draw_list - > AddRectFilled ( ImVec2 ( x , y ) , ImVec2 ( x + sz , y + thickness ) , col ) ; x + = sz + spacing ; // Horizontal line (faster than AddLine, but only handle integer thickness)
draw_list - > AddRectFilled ( ImVec2 ( x , y ) , ImVec2 ( x + thickness , y + sz ) , col ) ; x + = spacing * 2.0f ; // Vertical line (faster than AddLine, but only handle integer thickness)
draw_list - > AddRectFilled ( ImVec2 ( x , y ) , ImVec2 ( x + 1 , y + 1 ) , col ) ; x + = sz ; // Pixel (faster than AddLine)
draw_list - > AddNgonFilled ( ImVec2 ( x + sz * 0.5f , y + sz * 0.5f ) , sz * 0.5f , col , ngon_sides ) ; x + = sz + spacing ; // N-gon
draw_list - > AddCircleFilled ( ImVec2 ( x + sz * 0.5f , y + sz * 0.5f ) , sz * 0.5f , col , circle_segments ) ; x + = sz + spacing ; // Circle
draw_list - > AddRectFilled ( ImVec2 ( x , y ) , ImVec2 ( x + sz , y + sz ) , col ) ; x + = sz + spacing ; // Square
draw_list - > AddRectFilled ( ImVec2 ( x , y ) , ImVec2 ( x + sz , y + sz ) , col , 10.0f ) ; x + = sz + spacing ; // Square with all rounded corners
draw_list - > AddRectFilled ( ImVec2 ( x , y ) , ImVec2 ( x + sz , y + sz ) , col , 10.0f , corners_tl_br ) ; x + = sz + spacing ; // Square with two rounded corners
draw_list - > AddTriangleFilled ( ImVec2 ( x + sz * 0.5f , y ) , ImVec2 ( x + sz , y + sz - 0.5f ) , ImVec2 ( x , y + sz - 0.5f ) , col ) ; x + = sz + spacing ; // Triangle
//draw_list->AddTriangleFilled(ImVec2(x+sz*0.2f,y), ImVec2(x, y+sz-0.5f), ImVec2(x+sz*0.4f, y+sz-0.5f), col); x += sz*0.4f + spacing; // Thin triangle
draw_list - > AddRectFilled ( ImVec2 ( x , y ) , ImVec2 ( x + sz , y + thickness ) , col ) ; x + = sz + spacing ; // Horizontal line (faster than AddLine, but only handle integer thickness)
draw_list - > AddRectFilled ( ImVec2 ( x , y ) , ImVec2 ( x + thickness , y + sz ) , col ) ; x + = spacing * 2.0f ; // Vertical line (faster than AddLine, but only handle integer thickness)
draw_list - > AddRectFilled ( ImVec2 ( x , y ) , ImVec2 ( x + 1 , y + 1 ) , col ) ; x + = sz ; // Pixel (faster than AddLine)
draw_list - > AddRectFilledMultiColor ( ImVec2 ( x , y ) , ImVec2 ( x + sz , y + sz ) , IM_COL32 ( 0 , 0 , 0 , 255 ) , IM_COL32 ( 255 , 0 , 0 , 255 ) , IM_COL32 ( 255 , 255 , 0 , 255 ) , IM_COL32 ( 0 , 255 , 0 , 255 ) ) ;
ImGui : : Dummy ( ImVec2 ( ( sz + spacing ) * 9.8f , ( sz + spacing ) * 3 ) ) ;
ImGui : : Dummy ( ImVec2 ( ( sz + spacing ) * 8.8f , ( sz + spacing ) * 3.0f ) ) ;
ImGui : : PopItemWidth ( ) ;
ImGui : : EndTabItem ( ) ;
}