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/frame.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/frame.rs')
-rw-r--r-- | graphics/src/widget/canvas/frame.rs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/graphics/src/widget/canvas/frame.rs b/graphics/src/widget/canvas/frame.rs index 4873e7fb..b98c3002 100644 --- a/graphics/src/widget/canvas/frame.rs +++ b/graphics/src/widget/canvas/frame.rs @@ -1,6 +1,9 @@ +use std::borrow::Cow; + use iced_native::{Point, Rectangle, Size, Vector}; use crate::{ + canvas::path, canvas::{Fill, Geometry, Path, Stroke, Text}, triangle, Primitive, }; @@ -164,6 +167,12 @@ impl Frame { options.end_cap = stroke.line_cap.into(); options.line_join = stroke.line_join.into(); + let path = if stroke.line_dash.segments.is_empty() { + Cow::Borrowed(path) + } else { + Cow::Owned(path::dashed(path, stroke.line_dash)) + }; + let result = if self.transforms.current.is_identity { self.stroke_tessellator.tessellate_path( path.raw(), |