diff --git a/crates/engine/src/cmd/brushlib.rs b/crates/engine/src/cmd/brushlib.rs index 3a56958efc..24e5a21d04 100644 --- a/crates/engine/src/cmd/brushlib.rs +++ b/crates/engine/src/cmd/brushlib.rs @@ -481,9 +481,11 @@ fn scatter(name: &str, art: Node, s: Scatter) -> Brush { } /// Four original raster stamps. Scatter brushes preserve their image art while placing a copy -/// along the path; art brushes bend their art and cannot bend an image. +/// along the path; art brushes bend their art and cannot bend an image. Each 24 px stamp is placed +/// 6 pt wide, the size of the Scatter Shapes art, so a 1 pt stroke on a 10 pt line shows a stamp. fn image_brush() -> BrushLibrary { const SIDE: u32 = 24; + const PT_PER_PX: f64 = 0.25; let mut doc = Document::new(100.0, 100.0); let mut brushes = Vec::new(); for (index, name) in ["Soft Bloom", "Halftone Field", "Solar Grain", "Color Flecks"].into_iter().enumerate() { @@ -530,7 +532,7 @@ fn image_brush() -> BrushLibrary { key, width: SIDE, height: SIDE, - xf: Affine::translate((-12.0, -12.0)), + xf: Affine::scale(PT_PER_PX) * Affine::translate((-12.0, -12.0)), link: None, placement: Default::default(), pixels: None, diff --git a/crates/engine/src/tests/brushlib.rs b/crates/engine/src/tests/brushlib.rs index 6a94bc7272..166c598da0 100644 --- a/crates/engine/src/tests/brushlib.rs +++ b/crates/engine/src/tests/brushlib.rs @@ -206,6 +206,9 @@ fn image_brush_stamps_draw_and_carry_their_pixels_when_added_and_saved() { assert!(lib.doc.images.get(&image.key).is_some_and(|blob| blob.bytes.starts_with(b"\x89PNG\r\n\x1a\n"))); let pieces = vectorcraft_brush::stroke_pieces(&lib.doc, b, &line_to(180.0), &black_stroke()); assert!(pieces.len() >= 3 && pieces.iter().all(|p| matches!(p.kind, NodeKind::Image(_))), "{}", b.name); + // A short accent shows at least one stamp at a 1 pt stroke. + let short = vectorcraft_brush::stroke_pieces(&lib.doc, b, &line_to(10.0), &black_stroke()); + assert!(!short.is_empty() && short.iter().all(|p| matches!(p.kind, NodeKind::Image(_))), "{} on a 10 pt line", b.name); let before = undo_len(&s); let added = run(&mut s, "brush.addFromLibrary", json!({"library": "image-brush", "name": b.name, "apply": true, "ids": [path]})); assert_eq!(strs(&added["added"]), [b.name.as_str()]);