Skip to content

Commit 8f2f328

Browse files
M-Adoonical
authored andcommitted
fix: 🐛 the typo in building the rounded rectangle path
1 parent 54169fb commit 8f2f328

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

crates/path/src/builder.rs

+20-2
Original file line numberDiff line numberDiff line change
@@ -1629,7 +1629,7 @@ fn add_rounded_rectangle<Builder: PathBuilder>(
16291629
builder.cubic_bezier_to(points[1], points[2], points[3], attributes);
16301630
}
16311631
builder.line_to(points[4], attributes);
1632-
if tl > 0.0 {
1632+
if tr > 0.0 {
16331633
builder.cubic_bezier_to(points[5], points[6], points[7], attributes);
16341634
}
16351635
builder.line_to(points[8], attributes);
@@ -1650,7 +1650,7 @@ fn add_rounded_rectangle<Builder: PathBuilder>(
16501650
builder.cubic_bezier_to(points[10], points[9], points[8], attributes);
16511651
}
16521652
builder.line_to(points[7], attributes);
1653-
if tl > 0.0 {
1653+
if tr > 0.0 {
16541654
builder.cubic_bezier_to(points[6], points[5], points[4], attributes);
16551655
}
16561656
builder.line_to(points[3], attributes);
@@ -1803,3 +1803,21 @@ fn straight_line_arc() {
18031803
point(100.0, 0.0),
18041804
);
18051805
}
1806+
1807+
#[test]
1808+
fn top_right_rounded_rect() {
1809+
use crate::{math::*, Path};
1810+
let mut builder = Path::builder();
1811+
builder.add_rounded_rectangle(
1812+
&Box2D::new(point(0., 0.), point(100., 100.)),
1813+
&BorderRadii {
1814+
top_right: 2.,
1815+
..Default::default()
1816+
},
1817+
Winding::Positive,
1818+
);
1819+
let path = builder.build();
1820+
let tr = path.iter().skip(2).next().unwrap();
1821+
assert_eq!(tr.from(), point(98., 0.));
1822+
assert_eq!(tr.to(), point(100., 2.));
1823+
}

0 commit comments

Comments
 (0)