Skip to content

Commit

Permalink
A proper fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Narre committed Jul 19, 2023
1 parent 4c0bc5f commit b8b19a1
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions src/video/sdl/sdl_painter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,26 +278,20 @@ SDLPainter::draw_gradient(const GradientRequest& request)
for (int i = 0; i < n; ++i)
{
SDL_Rect rect;
if (region.get_left() || region.get_top())
{
rect.x = static_cast<int>(region.get_left());
rect.y = static_cast<int>(region.get_top());
rect.w = static_cast<int>(region.get_right() - region.get_left() + 1);
rect.h = static_cast<int>(region.get_bottom() - region.get_top());
}
else if (direction == VERTICAL || direction == VERTICAL_SECTOR)

if (direction == VERTICAL || direction == VERTICAL_SECTOR)
{
rect.x = static_cast<int>(region.get_left());
rect.y = static_cast<int>(region.get_bottom() * static_cast<float>(i) / static_cast<float>(n));
rect.w = static_cast<int>(region.get_right());
rect.h = static_cast<int>((region.get_bottom() * static_cast<float>(i+1) / static_cast<float>(n)) - static_cast<float>(rect.y));
rect.y = static_cast<int>(region.get_top() + (region.get_bottom() - region.get_top()) * static_cast<float>(i) / static_cast<float>(n));
rect.w = static_cast<int>(region.get_right() - region.get_left());
rect.h = static_cast<int>(ceilf((region.get_bottom() - region.get_top()) / static_cast<float>(n)));
}
else
{
rect.x = static_cast<int>(region.get_right() * static_cast<float>(i) / static_cast<float>(n));
rect.x = static_cast<int>(region.get_left() + (region.get_right() - region.get_left()) * static_cast<float>(i) / static_cast<float>(n));
rect.y = static_cast<int>(region.get_top());
rect.w = static_cast<int>((region.get_right() * static_cast<float>(i+1) / static_cast<float>(n)) - static_cast<float>(rect.x));
rect.h = static_cast<int>(region.get_bottom());
rect.w = static_cast<int>(ceilf((region.get_right() - region.get_left()) / static_cast<float>(n)));
rect.h = static_cast<int>(region.get_bottom() - region.get_top());
}

float p = static_cast<float>(i+1) / static_cast<float>(n);
Expand Down

0 comments on commit b8b19a1

Please sign in to comment.