From 3df49bebd47e8ff7c54934d6474336b7439176f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Tue, 14 Apr 2020 07:08:12 +0200 Subject: [PATCH] Implement `canvas::Path::line` helper method --- wgpu/src/widget/canvas/path.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/wgpu/src/widget/canvas/path.rs b/wgpu/src/widget/canvas/path.rs index 19d8879a..c26bf187 100644 --- a/wgpu/src/widget/canvas/path.rs +++ b/wgpu/src/widget/canvas/path.rs @@ -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`. ///