(&self, line: Vec<Pos2>, mut stroke: PathStroke, highlight: bool, shapes: &mut Vec<Shape>)
| 33 | } |
| 34 | |
| 35 | pub(crate) fn style_line(&self, line: Vec<Pos2>, mut stroke: PathStroke, highlight: bool, shapes: &mut Vec<Shape>) { |
| 36 | let path_stroke_color = match &stroke.color { |
| 37 | ColorMode::Solid(c) => *c, |
| 38 | ColorMode::UV(callback) => callback(Rect::from_min_max(pos2(0., 0.), pos2(0., 0.)), pos2(0., 0.)), |
| 39 | }; |
| 40 | match line.len() { |
| 41 | 0 => {} |
| 42 | 1 => { |
| 43 | let mut radius = stroke.width / 2.0; |
| 44 | if highlight { |
| 45 | radius *= 2f32.sqrt(); |
| 46 | } |
| 47 | shapes.push(Shape::circle_filled(line[0], radius, path_stroke_color)); |
| 48 | } |
| 49 | _ => { |
| 50 | match self { |
| 51 | Self::Solid => { |
| 52 | if highlight { |
| 53 | stroke.width *= 2.0; |
| 54 | } |
| 55 | shapes.push(Shape::line(line, stroke)); |
| 56 | } |
| 57 | Self::Dotted { spacing } => { |
| 58 | // Take the stroke width for the radius even though it's not "correct", |
| 59 | // otherwise the dots would become too small. |
| 60 | let mut radius = stroke.width; |
| 61 | if highlight { |
| 62 | radius *= 2f32.sqrt(); |
| 63 | } |
| 64 | shapes.extend(Shape::dotted_line(&line, path_stroke_color, *spacing, radius)); |
| 65 | } |
| 66 | Self::Dashed { length } => { |
| 67 | if highlight { |
| 68 | stroke.width *= 2.0; |
| 69 | } |
| 70 | let golden_ratio = (5.0_f32.sqrt() - 1.0) / 2.0; // 0.61803398875 |
| 71 | shapes.extend(Shape::dashed_line( |
| 72 | &line, |
| 73 | Stroke::new(stroke.width, path_stroke_color), |
| 74 | *length, |
| 75 | length * golden_ratio, |
| 76 | )); |
| 77 | } |
| 78 | } |
| 79 | } |
| 80 | } |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | impl std::fmt::Display for LineStyle { |
no outgoing calls
no test coverage detected