Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed a rounding error in the border radius color lerp #203

Merged
merged 3 commits into from
Jul 10, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions Source/Core/GeometryBackgroundBorder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,17 @@ void GeometryBackgroundBorder::DrawArc(Vector2f pos_center, Vector2f r, float a0
const float t = float(i) / float(num_points - 1);

const float a = Math::Lerp(t, a0, a1);
const Colourb color = Math::Lerp(t, color0, color1);
const Colourb color
{
static_cast<unsigned char>(Math::RoundToInteger(Math::Lerp(t,
static_cast<float>(color0[0]), static_cast<float>(color1[0])))),
static_cast<unsigned char>(Math::RoundToInteger(Math::Lerp(t,
static_cast<float>(color0[1]), static_cast<float>(color1[1])))),
static_cast<unsigned char>(Math::RoundToInteger(Math::Lerp(t,
static_cast<float>(color0[2]), static_cast<float>(color1[2])))),
static_cast<unsigned char>(Math::RoundToInteger(Math::Lerp(t,
static_cast<float>(color0[3]), static_cast<float>(color1[3]))))
};

const Vector2f unit_vector(Math::Cos(a), Math::Sin(a));

Expand Down Expand Up @@ -336,7 +346,17 @@ void GeometryBackgroundBorder::DrawArcArc(Vector2f pos_center, float R, Vector2f
const float t = float(i) / float(num_points - 1);

const float a = Math::Lerp(t, a0, a1);
const Colourb color = Math::Lerp(t, color0, color1);
const Colourb color
{
static_cast<unsigned char>(Math::RoundToInteger(Math::Lerp(t,
static_cast<float>(color0[0]), static_cast<float>(color1[0])))),
static_cast<unsigned char>(Math::RoundToInteger(Math::Lerp(t,
static_cast<float>(color0[1]), static_cast<float>(color1[1])))),
static_cast<unsigned char>(Math::RoundToInteger(Math::Lerp(t,
static_cast<float>(color0[2]), static_cast<float>(color1[2])))),
static_cast<unsigned char>(Math::RoundToInteger(Math::Lerp(t,
static_cast<float>(color0[3]), static_cast<float>(color1[3]))))
};

const Vector2f unit_vector(Math::Cos(a), Math::Sin(a));

Expand Down