diff options
Diffstat (limited to 'graphics/src/widget/canvas/stroke.rs')
| -rw-r--r-- | graphics/src/widget/canvas/stroke.rs | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/graphics/src/widget/canvas/stroke.rs b/graphics/src/widget/canvas/stroke.rs index a19937ea..aaac15bb 100644 --- a/graphics/src/widget/canvas/stroke.rs +++ b/graphics/src/widget/canvas/stroke.rs @@ -3,6 +3,7 @@ use iced_native::Color; use crate::gradient::Gradient; use crate::layer::mesh; +use crate::widget::canvas::frame::Transform; /// The style of a stroke. #[derive(Debug, Clone)] @@ -68,11 +69,16 @@ pub enum Style<'a> { Gradient(&'a Gradient), } -impl <'a> Into<mesh::Style> for Style<'a> { - fn into(self) -> mesh::Style { +impl<'a> Style<'a> { + /// Converts a fill's [Style] to a [mesh::Style] for use in the renderer's shader. + pub(crate) fn as_mesh_style(&self, transform: &Transform) -> mesh::Style { match self { - Style::Solid(color) => mesh::Style::Solid(color), - Style::Gradient(gradient) => gradient.clone().into() + Style::Solid(color) => { + mesh::Style::Solid(*color) + }, + Style::Gradient(gradient) => { + mesh::Style::Gradient((*gradient).clone().transform(transform)) + } } } } |
