diff options
author | Zyper <zyperpl@gmail.com> | 2021-08-25 00:02:32 +0200 |
---|---|---|
committer | Brian Gianforcaro <b.gianfo@gmail.com> | 2021-09-15 00:10:14 +0000 |
commit | 344397557c7c26a275d4b83304d15a381d4f9d8e (patch) | |
tree | 927b82421782ccb511b633126f4626651149a27b | |
parent | 12e76bb3df17b3ba84248989cec36348347c6050 (diff) | |
download | serenity-344397557c7c26a275d4b83304d15a381d4f9d8e.zip |
PixelPaint: Add ability to draw squares and circles
Shift-key modifier for tools forces square aspect ratio.
It allows drawing squares with Rectangle Tool and circles
with Ellipse Tool.
-rw-r--r-- | Userland/Applications/PixelPaint/EllipseTool.cpp | 6 | ||||
-rw-r--r-- | Userland/Applications/PixelPaint/RectangleTool.cpp | 6 |
2 files changed, 10 insertions, 2 deletions
diff --git a/Userland/Applications/PixelPaint/EllipseTool.cpp b/Userland/Applications/PixelPaint/EllipseTool.cpp index 074835a208..6acb156b35 100644 --- a/Userland/Applications/PixelPaint/EllipseTool.cpp +++ b/Userland/Applications/PixelPaint/EllipseTool.cpp @@ -89,7 +89,11 @@ void EllipseTool::on_mousemove(Layer*, MouseEvent& event) m_draw_mode = event.layer_event().alt() ? DrawMode::FromCenter : DrawMode::FromCorner; - m_ellipse_end_position = event.layer_event().position(); + if (event.layer_event().shift()) + m_ellipse_end_position = m_ellipse_start_position.end_point_for_square_aspect_ratio(event.layer_event().position()); + else + m_ellipse_end_position = event.layer_event().position(); + m_editor->update(); } diff --git a/Userland/Applications/PixelPaint/RectangleTool.cpp b/Userland/Applications/PixelPaint/RectangleTool.cpp index 746c58c9db..a5fdde2923 100644 --- a/Userland/Applications/PixelPaint/RectangleTool.cpp +++ b/Userland/Applications/PixelPaint/RectangleTool.cpp @@ -95,7 +95,11 @@ void RectangleTool::on_mousemove(Layer* layer, MouseEvent& event) m_draw_mode = event.layer_event().alt() ? DrawMode::FromCenter : DrawMode::FromCorner; - m_rectangle_end_position = event.layer_event().position(); + if (event.layer_event().shift()) + m_rectangle_end_position = m_rectangle_start_position.end_point_for_square_aspect_ratio(event.layer_event().position()); + else + m_rectangle_end_position = event.layer_event().position(); + m_editor->update(); } |