diff --git a/Userland/Libraries/LibGUI/OpacitySlider.cpp b/Userland/Libraries/LibGUI/OpacitySlider.cpp index a554017ffd..5e027fa226 100644 --- a/Userland/Libraries/LibGUI/OpacitySlider.cpp +++ b/Userland/Libraries/LibGUI/OpacitySlider.cpp @@ -41,16 +41,8 @@ void OpacitySlider::paint_event(PaintEvent& event) Gfx::StylePainter::paint_transparency_grid(painter, inner_rect, palette()); // Alpha gradient - for (int pos = inner_rect.first_edge_for_orientation(orientation()); pos <= inner_rect.last_edge_for_orientation(orientation()); ++pos) { - float relative_offset = (float)pos / (float)inner_rect.primary_size_for_orientation(orientation()); - float alpha = relative_offset * 255.0f; - Color color = m_base_color.with_alpha(static_cast(AK::min(alpha, UINT8_MAX))); - if (orientation() == Gfx::Orientation::Horizontal) { - painter.fill_rect({ pos, inner_rect.top(), 1, inner_rect.height() }, color); - } else { - painter.fill_rect({ inner_rect.left(), pos, inner_rect.right(), 1 }, color); - } - } + painter.fill_rect_with_linear_gradient(inner_rect, Array { Gfx::ColorStop { Color::Transparent, 0 }, Gfx::ColorStop { m_base_color, 1 } }, + orientation() == Orientation::Horizontal ? 90.0f : 180.0f); constexpr int notch_size = 3; if (orientation() == Gfx::Orientation::Horizontal) {