Skip to content

Commit

Permalink
Fix sharp corners for rectangles with StrokeKind != Inside (#5675)
Browse files Browse the repository at this point in the history
Oops!
  • Loading branch information
emilk authored Feb 4, 2025
1 parent b8051cc commit c90b97f
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 16 deletions.
13 changes: 13 additions & 0 deletions crates/egui_demo_lib/src/demo/tests/tessellation_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,19 @@ impl TessellationTest {
)
.with_blur_width(5.0),
),
(
"Additive rectangle",
RectShape::new(
sized([24.0, 12.0]),
0.0,
egui::Color32::LIGHT_RED.additive().linear_multiply(0.025),
(
1.0,
egui::Color32::LIGHT_BLUE.additive().linear_multiply(0.1),
),
StrokeKind::Outside,
),
),
];

for (_name, shape) in &mut shapes {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 12 additions & 4 deletions crates/epaint/src/tessellator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1885,19 +1885,27 @@ impl Tessellator {

let extra_cr_tweak = 0.4; // Otherwise is doesn't _feels_ enough.

if 0.0 < original_cr.nw {
if original_cr.nw == 0.0 {
corner_radius.nw = 0.0;
} else {
corner_radius.nw += extra_cr_tweak;
corner_radius.nw = corner_radius.nw.at_least(min_outside_cr);
}
if 0.0 < original_cr.ne {
if original_cr.ne == 0.0 {
corner_radius.ne = 0.0;
} else {
corner_radius.ne += extra_cr_tweak;
corner_radius.ne = corner_radius.ne.at_least(min_outside_cr);
}
if 0.0 < original_cr.sw {
if original_cr.sw == 0.0 {
corner_radius.sw = 0.0;
} else {
corner_radius.sw += extra_cr_tweak;
corner_radius.sw = corner_radius.sw.at_least(min_outside_cr);
}
if 0.0 < original_cr.se {
if original_cr.se == 0.0 {
corner_radius.se = 0.0;
} else {
corner_radius.se += extra_cr_tweak;
corner_radius.se = corner_radius.se.at_least(min_outside_cr);
}
Expand Down

0 comments on commit c90b97f

Please sign in to comment.