mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
LibGfx/Painter: Add draw_rect_with_thickness
method
Previously there was no way to draw rectangles with any specific thickness, like we can do with ellises, for instance. This method is just a simple wrapper around `draw_line()` several times. At least for now, we don't need to do anything sophisticated since this will only be used by PixelPaint.`
This commit is contained in:
parent
6910cbc075
commit
9ed32582e2
Notes:
sideshowbarker
2024-07-18 04:48:47 +09:00
Author: https://github.com/mustafaquraish Commit: https://github.com/SerenityOS/serenity/commit/9ed32582e26 Pull-request: https://github.com/SerenityOS/serenity/pull/9777
2 changed files with 17 additions and 0 deletions
|
@ -1,6 +1,7 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2021, Idan Horowitz <idan.horowitz@serenityos.org>
|
||||
* Copyright (c) 2021, Mustafa Quraish <mustafa@cs.toronto.edu>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -585,6 +586,21 @@ void Painter::draw_rect(const IntRect& a_rect, Color color, bool rough)
|
|||
}
|
||||
}
|
||||
|
||||
void Painter::draw_rect_with_thickness(const IntRect& rect, Color color, int thickness)
|
||||
{
|
||||
VERIFY(scale() == 1); // FIXME: Add scaling support.
|
||||
|
||||
IntPoint p1 = rect.location();
|
||||
IntPoint p2 = { rect.location().x() + rect.width(), rect.location().y() };
|
||||
IntPoint p3 = { rect.location().x() + rect.width(), rect.location().y() + rect.height() };
|
||||
IntPoint p4 = { rect.location().x(), rect.location().y() + rect.height() };
|
||||
|
||||
draw_line(p1, p2, color, thickness);
|
||||
draw_line(p2, p3, color, thickness);
|
||||
draw_line(p3, p4, color, thickness);
|
||||
draw_line(p4, p1, color, thickness);
|
||||
}
|
||||
|
||||
void Painter::draw_bitmap(const IntPoint& p, const CharacterBitmap& bitmap, Color color)
|
||||
{
|
||||
VERIFY(scale() == 1); // FIXME: Add scaling support.
|
||||
|
|
|
@ -42,6 +42,7 @@ public:
|
|||
void fill_rect_with_rounded_corners(const IntRect&, Color, int top_left_radius, int top_right_radius, int bottom_right_radius, int bottom_left_radius);
|
||||
void fill_ellipse(const IntRect&, Color);
|
||||
void draw_rect(const IntRect&, Color, bool rough = false);
|
||||
void draw_rect_with_thickness(const IntRect&, Color, int thickness);
|
||||
void draw_focus_rect(const IntRect&, Color);
|
||||
void draw_bitmap(const IntPoint&, const CharacterBitmap&, Color = Color());
|
||||
void draw_bitmap(const IntPoint&, const GlyphBitmap&, Color = Color());
|
||||
|
|
Loading…
Reference in a new issue