summaryrefslogtreecommitdiffstats
path: root/wgpu/src/widget/canvas/path.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2020-02-12 06:41:24 +0100
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2020-02-12 06:41:24 +0100
commit74dd79e97f83d3e9e13d87444740edeb353f9be8 (patch)
tree22c5d14e7aec9eb3d268424d6deaa3fad32513d9 /wgpu/src/widget/canvas/path.rs
parent64097983f195ac1e923b6a1bd8cb0fc2c109fabc (diff)
downloadiced-74dd79e97f83d3e9e13d87444740edeb353f9be8.tar.gz
iced-74dd79e97f83d3e9e13d87444740edeb353f9be8.tar.bz2
iced-74dd79e97f83d3e9e13d87444740edeb353f9be8.zip
Rename current `Path` to `path::Builder`
Diffstat (limited to 'wgpu/src/widget/canvas/path.rs')
-rw-r--r--wgpu/src/widget/canvas/path.rs32
1 files changed, 27 insertions, 5 deletions
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)]