LibWeb: Fix drawing axis-aligned lines
Previously, these were clipped by the RecordingPainter, which used the path's bounding box (which in this case is zero width or height). The fix is to expand the bounding box by the stroke width. Fixes #22661 Note: This is unrelated to any recent LibGfx changes :^)
This commit is contained in:
parent
fc41c282ec
commit
00b24a55b1
Notes:
sideshowbarker
2024-07-16 21:51:02 +09:00
Author: https://github.com/MacDue Commit: https://github.com/SerenityOS/serenity/commit/00b24a55b1 Pull-request: https://github.com/SerenityOS/serenity/pull/22663 Issue: https://github.com/SerenityOS/serenity/issues/22661
4 changed files with 24 additions and 0 deletions
BIN
Tests/LibWeb/Ref/reference/images/svg-axis-aligned-lines-ref.png
Normal file
BIN
Tests/LibWeb/Ref/reference/images/svg-axis-aligned-lines-ref.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 196 B |
|
@ -0,0 +1,9 @@
|
|||
<style>
|
||||
* {
|
||||
margin: 0;
|
||||
}
|
||||
body {
|
||||
background-color: white;
|
||||
}
|
||||
</style>
|
||||
<img src="./images/svg-axis-aligned-lines-ref.png">
|
11
Tests/LibWeb/Ref/svg-axis-aligned-lines.html
Normal file
11
Tests/LibWeb/Ref/svg-axis-aligned-lines.html
Normal file
|
@ -0,0 +1,11 @@
|
|||
<!doctype html>
|
||||
<style>
|
||||
body {
|
||||
background-color: white;
|
||||
}
|
||||
</style>
|
||||
<link rel="match" href="reference/svg-axis-aligned-lines-ref.html" />
|
||||
<svg width="100" height="100" viewBox="0 0 24 24" stroke="black" stroke-width="5">
|
||||
<line x1="12" y1="0" x2="12" y2="24"></line>
|
||||
<line x1="0" y1="12" x2="24" y2="12"></line>
|
||||
</svg>
|
|
@ -97,6 +97,8 @@ void RecordingPainter::stroke_path(StrokePathUsingColorParams params)
|
|||
{
|
||||
auto aa_translation = state().translation.map(params.translation.value_or(Gfx::FloatPoint {}));
|
||||
auto path_bounding_rect = params.path.bounding_box().translated(aa_translation).to_type<int>();
|
||||
// Increase path bounding box by `thickness` to account for stroke.
|
||||
path_bounding_rect.inflate(params.thickness, params.thickness);
|
||||
push_command(StrokePathUsingColor {
|
||||
.path_bounding_rect = path_bounding_rect,
|
||||
.path = params.path,
|
||||
|
@ -110,6 +112,8 @@ void RecordingPainter::stroke_path(StrokePathUsingPaintStyleParams params)
|
|||
{
|
||||
auto aa_translation = state().translation.map(params.translation.value_or(Gfx::FloatPoint {}));
|
||||
auto path_bounding_rect = params.path.bounding_box().translated(aa_translation).to_type<int>();
|
||||
// Increase path bounding box by `thickness` to account for stroke.
|
||||
path_bounding_rect.inflate(params.thickness, params.thickness);
|
||||
push_command(StrokePathUsingPaintStyle {
|
||||
.path_bounding_rect = path_bounding_rect,
|
||||
.path = params.path,
|
||||
|
|
Loading…
Add table
Reference in a new issue