summaryrefslogtreecommitdiffstats
path: root/wgpu/src
diff options
context:
space:
mode:
Diffstat (limited to 'wgpu/src')
-rw-r--r--wgpu/src/widget/canvas/frame.rs4
-rw-r--r--wgpu/src/widget/canvas/path.rs32
2 files changed, 29 insertions, 7 deletions
diff --git a/wgpu/src/widget/canvas/frame.rs b/wgpu/src/widget/canvas/frame.rs
index 65c22c0c..e5daeedb 100644
--- a/wgpu/src/widget/canvas/frame.rs
+++ b/wgpu/src/widget/canvas/frame.rs
@@ -33,7 +33,7 @@ impl Frame {
Point::new(self.width as f32 / 2.0, self.height as f32 / 2.0)
}
- pub fn fill(&mut self, path: Path, fill: Fill) {}
+ pub fn fill(&mut self, path: &Path, fill: Fill) {}
- pub fn stroke(&mut self, path: Path, stroke: Stroke) {}
+ pub fn stroke(&mut self, path: &Path, stroke: Stroke) {}
}
diff --git a/wgpu/src/widget/canvas/path.rs b/wgpu/src/widget/canvas/path.rs
index 2732b1bd..86326e8e 100644
--- a/wgpu/src/widget/canvas/path.rs
+++ b/wgpu/src/widget/canvas/path.rs
@@ -1,13 +1,28 @@
use iced_native::{Point, Vector};
-#[allow(missing_debug_implementations)]
+#[derive(Debug, Clone)]
pub struct Path {
- raw: lyon::path::Builder,
+ raw: lyon::path::Path,
}
impl Path {
- pub fn new() -> Path {
- Path {
+ pub fn new(f: impl FnOnce(&mut Builder)) -> Self {
+ let mut builder = Builder::new();
+
+ f(&mut builder);
+
+ builder.build()
+ }
+}
+
+#[allow(missing_debug_implementations)]
+pub struct Builder {
+ raw: lyon::path::Builder,
+}
+
+impl Builder {
+ pub fn new() -> Builder {
+ Builder {
raw: lyon::path::Path::builder(),
}
}
@@ -24,7 +39,7 @@ impl Path {
#[inline]
pub fn arc(&mut self, arc: Arc) {
- self.ellipse(arc.into())
+ self.ellipse(arc.into());
}
#[inline]
@@ -46,6 +61,13 @@ impl Path {
pub fn close(&mut self) {
self.raw.close()
}
+
+ #[inline]
+ pub fn build(self) -> Path {
+ Path {
+ raw: self.raw.build(),
+ }
+ }
}
#[derive(Debug, Clone, Copy)]