diff options
author | Tim Ledbetter <timledbetter@gmail.com> | 2023-01-06 00:53:54 +0000 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2023-01-06 15:41:48 +0100 |
commit | 0cf29f6c457fe4d6f4b39c924806459b14fc7339 (patch) | |
tree | b95e775410a6bcf0ab145ce85051a6672b447cdd | |
parent | 2f6c71c8297df2dbdac374be463efffc7170738e (diff) | |
download | serenity-0cf29f6c457fe4d6f4b39c924806459b14fc7339.zip |
PixelPaint: Draw polygonal select tool lines with two colors
This stops lines from disappearing when entering a dark area of the
image.
-rw-r--r-- | Userland/Applications/PixelPaint/Tools/PolygonalSelectTool.cpp | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/Userland/Applications/PixelPaint/Tools/PolygonalSelectTool.cpp b/Userland/Applications/PixelPaint/Tools/PolygonalSelectTool.cpp index 49352b48d0..e3664f26b3 100644 --- a/Userland/Applications/PixelPaint/Tools/PolygonalSelectTool.cpp +++ b/Userland/Applications/PixelPaint/Tools/PolygonalSelectTool.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, the SerenityOS developers. + * Copyright (c) 2022-2023, the SerenityOS developers. * * SPDX-License-Identifier: BSD-2-Clause */ @@ -139,15 +139,20 @@ void PolygonalSelectTool::on_second_paint(Layer const* layer, GUI::PaintEvent& e painter.translate(editor_layer_location(*layer)); - for (size_t i = 0; i < m_polygon_points.size() - 1; i++) { - auto preview_start = editor_stroke_position(m_polygon_points.at(i), 1); - auto preview_end = editor_stroke_position(m_polygon_points.at(i + 1), 1); - painter.draw_line(preview_start, preview_end, Color::Black, 1); - } + auto draw_preview_lines = [&](auto color, auto thickness) { + for (size_t i = 0; i < m_polygon_points.size() - 1; i++) { + auto preview_start = editor_stroke_position(m_polygon_points.at(i), 1); + auto preview_end = editor_stroke_position(m_polygon_points.at(i + 1), 1); + painter.draw_line(preview_start, preview_end, color, thickness); + } + + auto last_line_start = editor_stroke_position(m_polygon_points.at(m_polygon_points.size() - 1), 1); + auto last_line_stop = editor_stroke_position(m_last_selecting_cursor_position, 1); + painter.draw_line(last_line_start, last_line_stop, color, thickness); + }; - auto last_line_start = editor_stroke_position(m_polygon_points.at(m_polygon_points.size() - 1), 1); - auto last_line_stop = editor_stroke_position(m_last_selecting_cursor_position, 1); - painter.draw_line(last_line_start, last_line_stop, Color::Black, 1); + draw_preview_lines(Gfx::Color::Black, 3); + draw_preview_lines(Gfx::Color::White, 1); } bool PolygonalSelectTool::on_keydown(GUI::KeyEvent& key_event) |