summaryrefslogtreecommitdiffstats
path: root/wgpu/src/widget/canvas/path.rs
diff options
context:
space:
mode:
Diffstat (limited to 'wgpu/src/widget/canvas/path.rs')
-rw-r--r--wgpu/src/widget/canvas/path.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/wgpu/src/widget/canvas/path.rs b/wgpu/src/widget/canvas/path.rs
index e7ff47f3..d714ad05 100644
--- a/wgpu/src/widget/canvas/path.rs
+++ b/wgpu/src/widget/canvas/path.rs
@@ -7,6 +7,8 @@ mod builder;
pub use arc::Arc;
pub use builder::Builder;
+use iced_native::{Point, Size};
+
/// An immutable set of points that may or may not be connected.
///
/// A single [`Path`] can represent different kinds of 2D shapes!
@@ -33,6 +35,14 @@ impl Path {
builder.build()
}
+ /// Creates a new [`Path`] representing a rectangle given its top-left
+ /// corner coordinate and its `Size`.
+ ///
+ /// [`Path`]: struct.Path.html
+ pub fn rectangle(top_left: Point, size: Size) -> Self {
+ Self::new(|p| p.rectangle(top_left, size))
+ }
+
#[inline]
pub(crate) fn raw(&self) -> &lyon::path::Path {
&self.raw