diff --git a/crates/tools/src/symbolism.rs b/crates/tools/src/symbolism.rs index 9d6fe2e887..828aff4e01 100644 --- a/crates/tools/src/symbolism.rs +++ b/crates/tools/src/symbolism.rs @@ -440,7 +440,8 @@ impl Tool for BrushPaintTool { } /// The brush it paints with varies with the wheel: a Calligraphic brush with a value on Stylus /// Wheel and a variation other than 0, a Scatter brush with a value on it whose two values - /// differ, or an Art brush whose width is on it with two different widths. + /// differ, an Art brush whose width is on it with two different widths, or a Pattern brush + /// whose scale is on it with two different scales. fn reads_wheel(&self, cx: &ToolContext) -> bool { use vectorcraft_brush::{BrushKind, Variation}; let wheel = |mode: Variation| mode == Variation::StylusWheel; @@ -449,7 +450,8 @@ impl Tool for BrushPaintTool { BrushKind::Calligraphic(c) => c.modes().into_iter().zip(c.variation).any(|(m, v)| wheel(m) && v != 0.0), BrushKind::Scatter(s) => s.modes().into_iter().zip(s.values()).any(|(m, (a, b))| wheel(m) && a != b), BrushKind::Art(a) => a.width_mode.is_some_and(wheel) && a.width_range().0 != a.width_range().1, - BrushKind::Pattern(_) | BrushKind::Bristle(_) => false, + BrushKind::Pattern(p) => p.scale_mode.is_some_and(wheel) && p.scale_range().0 != p.scale_range().1, + BrushKind::Bristle(_) => false, } } fn busy(&self) -> bool { @@ -775,7 +777,7 @@ mod tests { #[test] fn the_paintbrush_reads_the_wheel_only_with_a_stylus_wheel_brush() { - use vectorcraft_brush::{ArtBrush, Brush, BrushKind, Calligraphic, Scatter, Variation}; + use vectorcraft_brush::{ArtBrush, Brush, BrushKind, Calligraphic, PatternBrush, Scatter, Variation}; let wheel = Variation::StylusWheel; let calligraphic = |modes, size| BrushKind::Calligraphic(Calligraphic { variation: [0.0, 0.0, size], modes: Some(modes), ..Calligraphic::default() }); @@ -783,6 +785,7 @@ mod tests { BrushKind::Scatter(Scatter { size, modes: Some([wheel, Variation::Fixed, Variation::Fixed, Variation::Fixed]), ..Scatter::default() }) }; let art = |width_mode, width_max| BrushKind::Art(ArtBrush { width_mode, width_max: Some(width_max), ..ArtBrush::default() }); + let pattern = |scale_mode, scale_max| BrushKind::Pattern(PatternBrush { scale_mode, scale_max: Some(scale_max), ..PatternBrush::default() }); let library = [ Brush { name: "Plain".into(), kind: calligraphic([Variation::Fixed, Variation::Fixed, Variation::Pressure], 2.0) }, Brush { name: "Nib".into(), kind: calligraphic([Variation::Fixed, Variation::Fixed, wheel], 2.0) }, @@ -792,6 +795,9 @@ mod tests { Brush { name: "Taper".into(), kind: art(Some(wheel), 200.0) }, Brush { name: "Even taper".into(), kind: art(Some(wheel), 100.0) }, Brush { name: "Flat".into(), kind: art(None, 200.0) }, + Brush { name: "Tiles".into(), kind: pattern(Some(wheel), 200.0) }, + Brush { name: "Even tiles".into(), kind: pattern(Some(wheel), 100.0) }, + Brush { name: "Fixed tiles".into(), kind: pattern(None, 200.0) }, ]; let (mut d, _) = doc_with_rect(); d.unknown.insert(vectorcraft_brush::DOC_KEY.into(), serde_json::to_value(library).unwrap()); @@ -808,6 +814,9 @@ mod tests { ("Taper", true), ("Even taper", false), ("Flat", false), + ("Tiles", true), + ("Even tiles", false), + ("Fixed tiles", false), ("Deleted", false), ]; for (name, varies) in brushes {