mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-14 17:07:01 +00:00
This commit is contained in:
parent
f05aede098
commit
4d5dcdb57a
@ -12854,7 +12854,7 @@ bool ImGui::ColorPicker4(const char* label, float col[4], ImGuiColorEditFlags fl
|
||||
// Paint colors over existing vertices
|
||||
ImVec2 gradient_p0(wheel_center.x + ImCos(a0) * wheel_r_inner, wheel_center.y + ImSin(a0) * wheel_r_inner);
|
||||
ImVec2 gradient_p1(wheel_center.x + ImCos(a1) * wheel_r_inner, wheel_center.y + ImSin(a1) * wheel_r_inner);
|
||||
ShadeVertsLinearColorGradientKeepAlpha(draw_list->VtxBuffer.Data + vert_start_idx, draw_list->VtxBuffer.Data + vert_end_idx, gradient_p0, gradient_p1, hue_colors[n], hue_colors[n+1]);
|
||||
ShadeVertsLinearColorGradientKeepAlpha(draw_list, vert_start_idx, vert_end_idx, gradient_p0, gradient_p1, hue_colors[n], hue_colors[n+1]);
|
||||
}
|
||||
|
||||
// Render Cursor + preview on Hue Wheel
|
||||
|
@ -1210,7 +1210,7 @@ void ImDrawList::AddImageRounded(ImTextureID user_texture_id, const ImVec2& a, c
|
||||
PathRect(a, b, rounding, rounding_corners);
|
||||
PathFillConvex(col);
|
||||
int vert_end_idx = VtxBuffer.Size;
|
||||
ImGui::ShadeVertsLinearUV(VtxBuffer.Data + vert_start_idx, VtxBuffer.Data + vert_end_idx, a, b, uv_a, uv_b, true);
|
||||
ImGui::ShadeVertsLinearUV(this, vert_start_idx, vert_end_idx, a, b, uv_a, uv_b, true);
|
||||
|
||||
if (push_texture_id)
|
||||
PopTextureID();
|
||||
@ -1258,10 +1258,12 @@ void ImDrawData::ScaleClipRects(const ImVec2& scale)
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Generic linear color gradient, write to RGB fields, leave A untouched.
|
||||
void ImGui::ShadeVertsLinearColorGradientKeepAlpha(ImDrawVert* vert_start, ImDrawVert* vert_end, ImVec2 gradient_p0, ImVec2 gradient_p1, ImU32 col0, ImU32 col1)
|
||||
void ImGui::ShadeVertsLinearColorGradientKeepAlpha(ImDrawList* draw_list, int vert_start_idx, int vert_end_idx, ImVec2 gradient_p0, ImVec2 gradient_p1, ImU32 col0, ImU32 col1)
|
||||
{
|
||||
ImVec2 gradient_extent = gradient_p1 - gradient_p0;
|
||||
float gradient_inv_length2 = 1.0f / ImLengthSqr(gradient_extent);
|
||||
ImDrawVert* vert_start = draw_list->VtxBuffer.Data + vert_start_idx;
|
||||
ImDrawVert* vert_end = draw_list->VtxBuffer.Data + vert_end_idx;
|
||||
for (ImDrawVert* vert = vert_start; vert < vert_end; vert++)
|
||||
{
|
||||
float d = ImDot(vert->pos - gradient_p0, gradient_extent);
|
||||
@ -1274,7 +1276,7 @@ void ImGui::ShadeVertsLinearColorGradientKeepAlpha(ImDrawVert* vert_start, ImDra
|
||||
}
|
||||
|
||||
// Distribute UV over (a, b) rectangle
|
||||
void ImGui::ShadeVertsLinearUV(ImDrawVert* vert_start, ImDrawVert* vert_end, const ImVec2& a, const ImVec2& b, const ImVec2& uv_a, const ImVec2& uv_b, bool clamp)
|
||||
void ImGui::ShadeVertsLinearUV(ImDrawList* draw_list, int vert_start_idx, int vert_end_idx, const ImVec2& a, const ImVec2& b, const ImVec2& uv_a, const ImVec2& uv_b, bool clamp)
|
||||
{
|
||||
const ImVec2 size = b - a;
|
||||
const ImVec2 uv_size = uv_b - uv_a;
|
||||
@ -1282,11 +1284,12 @@ void ImGui::ShadeVertsLinearUV(ImDrawVert* vert_start, ImDrawVert* vert_end, con
|
||||
size.x != 0.0f ? (uv_size.x / size.x) : 0.0f,
|
||||
size.y != 0.0f ? (uv_size.y / size.y) : 0.0f);
|
||||
|
||||
ImDrawVert* vert_start = draw_list->VtxBuffer.Data + vert_start_idx;
|
||||
ImDrawVert* vert_end = draw_list->VtxBuffer.Data + vert_end_idx;
|
||||
if (clamp)
|
||||
{
|
||||
const ImVec2 min = ImMin(uv_a, uv_b);
|
||||
const ImVec2 max = ImMax(uv_a, uv_b);
|
||||
|
||||
for (ImDrawVert* vertex = vert_start; vertex < vert_end; ++vertex)
|
||||
vertex->uv = ImClamp(uv_a + ImMul(ImVec2(vertex->pos.x, vertex->pos.y) - a, scale), min, max);
|
||||
}
|
||||
|
@ -1202,8 +1202,8 @@ namespace ImGui
|
||||
IMGUI_API void PlotEx(ImGuiPlotType plot_type, const char* label, float (*values_getter)(void* data, int idx), void* data, int values_count, int values_offset, const char* overlay_text, float scale_min, float scale_max, ImVec2 graph_size);
|
||||
|
||||
// Shade functions (write over already created vertices)
|
||||
IMGUI_API void ShadeVertsLinearColorGradientKeepAlpha(ImDrawVert* vert_start, ImDrawVert* vert_end, ImVec2 gradient_p0, ImVec2 gradient_p1, ImU32 col0, ImU32 col1);
|
||||
IMGUI_API void ShadeVertsLinearUV(ImDrawVert* vert_start, ImDrawVert* vert_end, const ImVec2& a, const ImVec2& b, const ImVec2& uv_a, const ImVec2& uv_b, bool clamp);
|
||||
IMGUI_API void ShadeVertsLinearColorGradientKeepAlpha(ImDrawList* draw_list, int vert_start_idx, int vert_end_idx, ImVec2 gradient_p0, ImVec2 gradient_p1, ImU32 col0, ImU32 col1);
|
||||
IMGUI_API void ShadeVertsLinearUV(ImDrawList* draw_list, int vert_start_idx, int vert_end_idx, const ImVec2& a, const ImVec2& b, const ImVec2& uv_a, const ImVec2& uv_b, bool clamp);
|
||||
|
||||
} // namespace ImGui
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user