diff options
author | 2022-01-27 09:40:52 -0800 | |
---|---|---|
committer | 2022-01-27 09:40:52 -0800 | |
commit | e835cea03c5d6eeba2d76b52206516dcc2a6b628 (patch) | |
tree | b54e2c27925284e16230f5d1eaf76ea9afe86860 /graphics/src/widget/canvas/stroke.rs | |
parent | 4aa943cbc63230dfcb995c469ceec9f74e6132e1 (diff) | |
download | iced-e835cea03c5d6eeba2d76b52206516dcc2a6b628.tar.gz iced-e835cea03c5d6eeba2d76b52206516dcc2a6b628.tar.bz2 iced-e835cea03c5d6eeba2d76b52206516dcc2a6b628.zip |
Add line dash API
Diffstat (limited to 'graphics/src/widget/canvas/stroke.rs')
-rw-r--r-- | graphics/src/widget/canvas/stroke.rs | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/graphics/src/widget/canvas/stroke.rs b/graphics/src/widget/canvas/stroke.rs index 9f0449d0..5c20405e 100644 --- a/graphics/src/widget/canvas/stroke.rs +++ b/graphics/src/widget/canvas/stroke.rs @@ -1,7 +1,7 @@ use iced_native::Color; /// The style of a stroke. -#[derive(Debug, Clone, Copy)] +#[derive(Debug, Clone)] pub struct Stroke { /// The color of the stroke. pub color: Color, @@ -12,6 +12,8 @@ pub struct Stroke { /// The shape to be used at the corners of paths or basic shapes when they /// are stroked. pub line_join: LineJoin, + /// The dash pattern used when stroking the line. + pub line_dash: LineDash, } impl Stroke { @@ -43,6 +45,7 @@ impl Default for Stroke { width: 1.0, line_cap: LineCap::default(), line_join: LineJoin::default(), + line_dash: LineDash::default(), } } } @@ -103,3 +106,12 @@ impl From<LineJoin> for lyon::tessellation::LineJoin { } } } + +/// The dash pattern used when stroking the line. +#[derive(Debug, Clone, Default)] +pub struct LineDash { + /// The alternating lengths of lines and gaps which describe the pattern. + pub segments: Vec<f32>, + /// The offset of [`LineDash::segments`] to start the pattern. + pub offset: usize, +} |