diff options
author | 2020-02-12 08:49:42 +0100 | |
---|---|---|
committer | 2020-02-12 08:49:42 +0100 | |
commit | 578ea4abb8a2dd0d53d7087322796bf9ad541b56 (patch) | |
tree | be684d9262fbf1ae0c5fc2db469d74ab0a5a98c4 /wgpu/src/widget/canvas/frame.rs | |
parent | f34407bfdaf06c4bf204dc31b152be9451c243b8 (diff) | |
download | iced-578ea4abb8a2dd0d53d7087322796bf9ad541b56.tar.gz iced-578ea4abb8a2dd0d53d7087322796bf9ad541b56.tar.bz2 iced-578ea4abb8a2dd0d53d7087322796bf9ad541b56.zip |
Finish `clock` example
Diffstat (limited to 'wgpu/src/widget/canvas/frame.rs')
-rw-r--r-- | wgpu/src/widget/canvas/frame.rs | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/wgpu/src/widget/canvas/frame.rs b/wgpu/src/widget/canvas/frame.rs index 82ff526b..3c667426 100644 --- a/wgpu/src/widget/canvas/frame.rs +++ b/wgpu/src/widget/canvas/frame.rs @@ -7,13 +7,13 @@ use crate::{ #[derive(Debug)] pub struct Frame { - width: u32, - height: u32, + width: f32, + height: f32, buffers: lyon::tessellation::VertexBuffers<triangle::Vertex2D, u16>, } impl Frame { - pub(crate) fn new(width: u32, height: u32) -> Frame { + pub fn new(width: f32, height: f32) -> Frame { Frame { width, height, @@ -21,16 +21,16 @@ impl Frame { } } - pub fn width(&self) -> u32 { + pub fn width(&self) -> f32 { self.width } - pub fn height(&self) -> u32 { + pub fn height(&self) -> f32 { self.height } pub fn center(&self) -> Point { - Point::new(self.width as f32 / 2.0, self.height as f32 / 2.0) + Point::new(self.width / 2.0, self.height / 2.0) } pub fn fill(&mut self, path: &Path, fill: Fill) { @@ -74,6 +74,13 @@ impl Frame { .tessellate_path(path.raw(), &options, &mut buffers) .expect("Stroke path"); } + + pub fn into_mesh(self) -> triangle::Mesh2D { + triangle::Mesh2D { + vertices: self.buffers.vertices, + indices: self.buffers.indices, + } + } } struct FillVertex([f32; 4]); |