summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMustafa Quraish <mustafaq9@gmail.com>2021-09-06 20:45:52 -0400
committerAndreas Kling <kling@serenityos.org>2021-09-07 16:53:40 +0200
commit0a9c64a4f57a548589aeeb94a351d86bbe373394 (patch)
treeacf1c0724a8e48892e67aab51e176801afcf1a2b
parent9669bf29f61591990f26688ae5cdd331bd5c6fa1 (diff)
downloadserenity-0a9c64a4f57a548589aeeb94a351d86bbe373394.zip
PixelPaint: Use correct thickness in `EllipseTool::on_second_paint()`
Previously, we were ignoring the scale of the editor in the second paint step. If you were zoomed in, the size while you were drawing was not the same as the size of the final shape.
-rw-r--r--Userland/Applications/PixelPaint/EllipseTool.cpp8
-rw-r--r--Userland/Applications/PixelPaint/EllipseTool.h2
2 files changed, 5 insertions, 5 deletions
diff --git a/Userland/Applications/PixelPaint/EllipseTool.cpp b/Userland/Applications/PixelPaint/EllipseTool.cpp
index d389e61133..6fd331eca8 100644
--- a/Userland/Applications/PixelPaint/EllipseTool.cpp
+++ b/Userland/Applications/PixelPaint/EllipseTool.cpp
@@ -27,7 +27,7 @@ EllipseTool::~EllipseTool()
{
}
-void EllipseTool::draw_using(GUI::Painter& painter, Gfx::IntPoint const& start_position, Gfx::IntPoint const& end_position)
+void EllipseTool::draw_using(GUI::Painter& painter, Gfx::IntPoint const& start_position, Gfx::IntPoint const& end_position, int thickness)
{
Gfx::IntRect ellipse_intersecting_rect;
if (m_draw_mode == DrawMode::FromCenter) {
@@ -39,7 +39,7 @@ void EllipseTool::draw_using(GUI::Painter& painter, Gfx::IntPoint const& start_p
switch (m_fill_mode) {
case FillMode::Outline:
- painter.draw_ellipse_intersecting(ellipse_intersecting_rect, m_editor->color_for(m_drawing_button), m_thickness);
+ painter.draw_ellipse_intersecting(ellipse_intersecting_rect, m_editor->color_for(m_drawing_button), thickness);
break;
case FillMode::Fill:
painter.fill_ellipse(ellipse_intersecting_rect, m_editor->color_for(m_drawing_button));
@@ -74,7 +74,7 @@ void EllipseTool::on_mouseup(Layer* layer, MouseEvent& event)
if (event.layer_event().button() == m_drawing_button) {
GUI::Painter painter(layer->bitmap());
- draw_using(painter, m_ellipse_start_position, m_ellipse_end_position);
+ draw_using(painter, m_ellipse_start_position, m_ellipse_end_position, m_thickness);
m_drawing_button = GUI::MouseButton::None;
m_editor->update();
m_editor->did_complete_action();
@@ -101,7 +101,7 @@ void EllipseTool::on_second_paint(Layer const* layer, GUI::PaintEvent& event)
painter.add_clip_rect(event.rect());
auto preview_start = m_editor->layer_position_to_editor_position(*layer, m_ellipse_start_position).to_type<int>();
auto preview_end = m_editor->layer_position_to_editor_position(*layer, m_ellipse_end_position).to_type<int>();
- draw_using(painter, preview_start, preview_end);
+ draw_using(painter, preview_start, preview_end, m_thickness * m_editor->scale());
}
void EllipseTool::on_keydown(GUI::KeyEvent& event)
diff --git a/Userland/Applications/PixelPaint/EllipseTool.h b/Userland/Applications/PixelPaint/EllipseTool.h
index 059c4f055f..6a98957d29 100644
--- a/Userland/Applications/PixelPaint/EllipseTool.h
+++ b/Userland/Applications/PixelPaint/EllipseTool.h
@@ -37,7 +37,7 @@ private:
FromCorner,
};
- void draw_using(GUI::Painter&, Gfx::IntPoint const& start_position, Gfx::IntPoint const& end_position);
+ void draw_using(GUI::Painter&, Gfx::IntPoint const& start_position, Gfx::IntPoint const& end_position, int thickness);
RefPtr<GUI::Widget> m_properties_widget;
GUI::MouseButton m_drawing_button { GUI::MouseButton::None };