Implement canvas::Path::line helper method

This commit is contained in:
Héctor Ramón Jiménez 2020-04-14 07:08:12 +02:00
parent 46cd0891d2
commit 3df49bebd4

View File

@ -35,6 +35,17 @@ impl Path {
builder.build()
}
/// Creates a new [`Path`] representing a line segment given its starting
/// and end points.
///
/// [`Path`]: struct.Path.html
pub fn line(from: Point, to: Point) -> Self {
Self::new(|p| {
p.move_to(from);
p.line_to(to);
})
}
/// Creates a new [`Path`] representing a rectangle given its top-left
/// corner coordinate and its `Size`.
///