mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +00:00
PixelPaint: Draw polygonal select tool lines with two colors
This stops lines from disappearing when entering a dark area of the image.
This commit is contained in:
parent
2f6c71c829
commit
0cf29f6c45
Notes:
sideshowbarker
2024-07-17 10:05:47 +09:00
Author: https://github.com/tcl3 Commit: https://github.com/SerenityOS/serenity/commit/0cf29f6c45 Pull-request: https://github.com/SerenityOS/serenity/pull/16846 Reviewed-by: https://github.com/MacDue ✅
1 changed files with 14 additions and 9 deletions
|
@ -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::Black, 1);
|
||||
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);
|
||||
};
|
||||
|
||||
draw_preview_lines(Gfx::Color::Black, 3);
|
||||
draw_preview_lines(Gfx::Color::White, 1);
|
||||
}
|
||||
|
||||
bool PolygonalSelectTool::on_keydown(GUI::KeyEvent& key_event)
|
||||
|
|
Loading…
Reference in a new issue