mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-25 20:01:07 +01:00
Brushes: Image Brush stamps show on short strokes
Each 24 px stamp is now placed 6 pt wide, the size of the Scatter Shapes art, so a 1 pt stroke on a 10 pt line shows at least one stamp with every preset. The test checks a 10 pt line as well as the 180 pt line.
This commit is contained in:
1 parent
d5068b90e7
commit
3afba4bb35
2 files changed
+7
-2
No files matched your search
@@ -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,
|
||||
|
||||
@@ -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()]);
|
||||
|
||||
Reference in new issue
Block a user