mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 03:27:45 +00:00
PixelPaint: Put the main gradient color at the cursor
It doesn't seem right to me that we are 'holding' a transparent color, with the main color being on the opposite side.
This commit is contained in:
parent
d27d19f012
commit
1ce2d7e674
1 changed files with 4 additions and 6 deletions
|
@ -283,17 +283,15 @@ void GradientTool::draw_gradient(GUI::Painter& painter, bool with_guidelines, co
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto gradient_half_width_percentage_offset = (m_gradient_half_length * scale) / overall_gradient_length_in_rect;
|
auto gradient_half_width_percentage_offset = (m_gradient_half_length * scale) / overall_gradient_length_in_rect;
|
||||||
auto color_to_use = m_editor->color_for(GUI::MouseButton::Primary);
|
auto start_color = m_editor->color_for(GUI::MouseButton::Primary);
|
||||||
int base_opacity = color_to_use.alpha() * m_opacity / 100;
|
start_color.set_alpha(start_color.alpha() * m_opacity / 100);
|
||||||
color_to_use.set_alpha(base_opacity);
|
auto end_color = start_color.with_alpha(0);
|
||||||
auto gradient_start_color = color_to_use;
|
|
||||||
gradient_start_color.set_alpha(0);
|
|
||||||
|
|
||||||
{
|
{
|
||||||
Gfx::PainterStateSaver saver(painter);
|
Gfx::PainterStateSaver saver(painter);
|
||||||
if (gradient_clip.has_value())
|
if (gradient_clip.has_value())
|
||||||
painter.add_clip_rect(*gradient_clip);
|
painter.add_clip_rect(*gradient_clip);
|
||||||
painter.fill_rect_with_linear_gradient(gradient_rect, Array { Gfx::ColorStop { gradient_start_color, 0.5f - gradient_half_width_percentage_offset }, Gfx::ColorStop { color_to_use, 0.5f + gradient_half_width_percentage_offset } }, rotation_degrees);
|
painter.fill_rect_with_linear_gradient(gradient_rect, Array { Gfx::ColorStop { start_color, 0.5f - gradient_half_width_percentage_offset }, Gfx::ColorStop { end_color, 0.5f + gradient_half_width_percentage_offset } }, rotation_degrees);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (with_guidelines) {
|
if (with_guidelines) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue