Skip to content

Commit 55f7714

Browse files
committed
Fix sharp corners for rectangles with StrokeKind != Inside
1 parent b8051cc commit 55f7714

File tree

9 files changed

+40
-16
lines changed

9 files changed

+40
-16
lines changed

crates/egui_demo_lib/src/demo/tests/tessellation_test.rs

+13
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,19 @@ impl TessellationTest {
9393
)
9494
.with_blur_width(5.0),
9595
),
96+
(
97+
"Additive rectangle",
98+
RectShape::new(
99+
sized([24.0, 12.0]),
100+
0.0,
101+
egui::Color32::LIGHT_RED.additive().linear_multiply(0.025),
102+
(
103+
1.0,
104+
egui::Color32::LIGHT_BLUE.additive().linear_multiply(0.1),
105+
),
106+
StrokeKind::Outside,
107+
),
108+
),
96109
];
97110

98111
for (_name, shape) in &mut shapes {
Loading
Loading
Loading
Loading
Loading
Loading
Loading

crates/epaint/src/tessellator.rs

+12-4
Original file line numberDiff line numberDiff line change
@@ -1885,19 +1885,27 @@ impl Tessellator {
18851885

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

1888-
if 0.0 < original_cr.nw {
1888+
if original_cr.nw == 0.0 {
1889+
corner_radius.nw = 0.0;
1890+
} else {
18891891
corner_radius.nw += extra_cr_tweak;
18901892
corner_radius.nw = corner_radius.nw.at_least(min_outside_cr);
18911893
}
1892-
if 0.0 < original_cr.ne {
1894+
if original_cr.ne == 0.0 {
1895+
corner_radius.ne = 0.0;
1896+
} else {
18931897
corner_radius.ne += extra_cr_tweak;
18941898
corner_radius.ne = corner_radius.ne.at_least(min_outside_cr);
18951899
}
1896-
if 0.0 < original_cr.sw {
1900+
if original_cr.sw == 0.0 {
1901+
corner_radius.sw = 0.0;
1902+
} else {
18971903
corner_radius.sw += extra_cr_tweak;
18981904
corner_radius.sw = corner_radius.sw.at_least(min_outside_cr);
18991905
}
1900-
if 0.0 < original_cr.se {
1906+
if original_cr.se == 0.0 {
1907+
corner_radius.se = 0.0;
1908+
} else {
19011909
corner_radius.se += extra_cr_tweak;
19021910
corner_radius.se = corner_radius.se.at_least(min_outside_cr);
19031911
}

0 commit comments

Comments
 (0)