mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-22 12:35:14 +00:00
LibWeb: Implement CanvasRenderingContext2D::stroke_rect() with lines
Stroking rects by drawing individual lines gives us line width support without having to extend the Painter::draw_rect() code. :^)
This commit is contained in:
parent
ecd900b4b4
commit
d5fb916bf0
Notes:
sideshowbarker
2024-07-19 07:32:21 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/d5fb916bf07
1 changed files with 11 additions and 1 deletions
|
@ -79,7 +79,17 @@ void CanvasRenderingContext2D::stroke_rect(float x, float y, float width, float
|
|||
return;
|
||||
|
||||
auto rect = m_transform.map(Gfx::FloatRect(x, y, width, height));
|
||||
painter->draw_rect(enclosing_int_rect(rect), m_stroke_style);
|
||||
|
||||
auto top_left = m_transform.map(Gfx::FloatPoint(x, y)).to_int_point();
|
||||
auto top_right = m_transform.map(Gfx::FloatPoint(x + width - 1, y)).to_int_point();
|
||||
auto bottom_left = m_transform.map(Gfx::FloatPoint(x, y + height - 1)).to_int_point();
|
||||
auto bottom_right = m_transform.map(Gfx::FloatPoint(x + width - 1, y + height - 1)).to_int_point();
|
||||
|
||||
painter->draw_line(top_left, top_right, m_stroke_style, m_line_width);
|
||||
painter->draw_line(top_right, bottom_right, m_stroke_style, m_line_width);
|
||||
painter->draw_line(bottom_right, bottom_left, m_stroke_style, m_line_width);
|
||||
painter->draw_line(bottom_left, top_left, m_stroke_style, m_line_width);
|
||||
|
||||
did_draw(rect);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue