Skip to content

Commit

Permalink
fix: don't offset fill of quad
Browse files Browse the repository at this point in the history
  • Loading branch information
wash2 committed May 11, 2023
1 parent 46fc5a7 commit 1f83f1f
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions tiny_skia/src/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,21 +178,14 @@ impl Backend {
.min(bounds.width / 2.0)
.min(bounds.height / 2.0);

// Offset the fill by the border width
let path_bounds = Rectangle {
x: bounds.x + border_width,
y: bounds.y + border_width,
width: bounds.width - 2.0 * border_width,
height: bounds.height - 2.0 * border_width,
};
// fill border radius is the border radius minus the border width
let mut fill_border_radius = *border_radius;
for radius in &mut fill_border_radius {
*radius = (*radius - border_width / 2.0)
.min(path_bounds.width / 2.0)
.min(path_bounds.height / 2.0);
*radius = (*radius)
.min(bounds.width / 2.0)
.min(bounds.height / 2.0);
}
let path = rounded_rectangle(path_bounds, fill_border_radius);
let path = rounded_rectangle(*bounds, fill_border_radius);

pixels.fill_path(
&path,
Expand Down

0 comments on commit 1f83f1f

Please sign in to comment.