diff options
Diffstat (limited to 'wgpu/src/widget/canvas/frame.rs')
-rw-r--r-- | wgpu/src/widget/canvas/frame.rs | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/wgpu/src/widget/canvas/frame.rs b/wgpu/src/widget/canvas/frame.rs index 940be402..de4717f1 100644 --- a/wgpu/src/widget/canvas/frame.rs +++ b/wgpu/src/widget/canvas/frame.rs @@ -89,14 +89,14 @@ impl Frame { /// /// [`Path`]: path/struct.Path.html /// [`Frame`]: struct.Frame.html - pub fn fill(&mut self, path: &Path, fill: Fill) { + pub fn fill(&mut self, path: &Path, fill: impl Into<Fill>) { use lyon::tessellation::{ BuffersBuilder, FillOptions, FillTessellator, }; let mut buffers = BuffersBuilder::new( &mut self.buffers, - FillVertex(match fill { + FillVertex(match fill.into() { Fill::Color(color) => color.into_linear(), }), ); @@ -127,11 +127,13 @@ impl Frame { /// /// [`Path`]: path/struct.Path.html /// [`Frame`]: struct.Frame.html - pub fn stroke(&mut self, path: &Path, stroke: Stroke) { + pub fn stroke(&mut self, path: &Path, stroke: impl Into<Stroke>) { use lyon::tessellation::{ BuffersBuilder, StrokeOptions, StrokeTessellator, }; + let stroke = stroke.into(); + let mut buffers = BuffersBuilder::new( &mut self.buffers, StrokeVertex(stroke.color.into_linear()), @@ -173,9 +175,11 @@ impl Frame { /// [`Text`]: struct.Text.html /// [`Frame`]: struct.Frame.html /// [`Canvas`]: struct.Canvas.html - pub fn fill_text(&mut self, text: Text) { + pub fn fill_text(&mut self, text: impl Into<Text>) { use std::f32; + let text = text.into(); + let position = if self.transforms.current.is_identity { text.position } else { |