mirror of
https://github.com/Drezil/imgui.git
synced 2024-12-18 14:16:36 +00:00
Merge pull request #1313 from thevaber/master
Improved ColorPicker hue wheel color interpolation
This commit is contained in:
commit
8971d70149
@ -9510,11 +9510,11 @@ static void RenderArrowsForVerticalBar(ImDrawList* draw_list, ImVec2 pos, ImVec2
|
||||
static void PaintVertsLinearGradientKeepAlpha(ImDrawVert* vert_start, ImDrawVert* vert_end, ImVec2 gradient_p0, ImVec2 gradient_p1, ImU32 col0, ImU32 col1)
|
||||
{
|
||||
ImVec2 gradient_extent = gradient_p1 - gradient_p0;
|
||||
float gradient_inv_length = ImInvLength(gradient_extent, 0.0f);
|
||||
float gradient_inv_length2 = 1.0f / ImLengthSqr(gradient_extent);
|
||||
for (ImDrawVert* vert = vert_start; vert < vert_end; vert++)
|
||||
{
|
||||
float d = ImDot(vert->pos - gradient_p0, gradient_extent);
|
||||
float t = ImMin(sqrtf(ImMax(d, 0.0f)) * gradient_inv_length, 1.0f);
|
||||
float t = ImClamp(d * gradient_inv_length2, 0.0f, 1.0f);
|
||||
int r = ImLerp((int)(col0 >> IM_COL32_R_SHIFT) & 0xFF, (int)(col1 >> IM_COL32_R_SHIFT) & 0xFF, t);
|
||||
int g = ImLerp((int)(col0 >> IM_COL32_G_SHIFT) & 0xFF, (int)(col1 >> IM_COL32_G_SHIFT) & 0xFF, t);
|
||||
int b = ImLerp((int)(col0 >> IM_COL32_B_SHIFT) & 0xFF, (int)(col1 >> IM_COL32_B_SHIFT) & 0xFF, t);
|
||||
|
Loading…
Reference in New Issue
Block a user