VectorCraft: An open-source, vector art tool written by scratch in pure Rust
Water Paper: rustfmt (#2955)
bflatastic55df023b655a
diff --git a/crates/effects/src/pixel/mod.rs b/crates/effects/src/pixel/mod.rsindex 4418fd37a..0ca1901e9 100644--- a/crates/effects/src/pixel/mod.rs+++ b/crates/effects/src/pixel/mod.rs@@ -601,7 +601,9 @@ impl PixelFx {| PixelFx::NotePaper { .. }| PixelFx::Reticulation { .. } => Some(0.0),PixelFx::Plaster { smoothness, .. } => Some(sketch::plaster_reach(smoothness)),- PixelFx::WaterPaper { fiber_length, .. } => Some(sketch::water_paper_shift(fiber_length) + 3.0 * (0.06 * fiber_length.clamp(3.0, 50.0)).max(0.35)),+ PixelFx::WaterPaper { fiber_length, .. } => {+ Some(sketch::water_paper_shift(fiber_length) + 3.0 * (0.06 * fiber_length.clamp(3.0, 50.0)).max(0.35))+ }// Cutout's palette comes from the whole object.PixelFx::Cutout { .. } => None,// The softened tones around the pixel.@@ -671,9 +673,7 @@ impl PixelFx {PixelFx::Stamp { balance, smoothness } => sketch_ink::stamp(px, w, h, space, balance, smoothness),PixelFx::Plaster { image_balance, smoothness, light } => sketch::plaster(px, w, h, space, image_balance, smoothness, light),PixelFx::Reticulation { density, foreground, background } => sketch::reticulation(px, w, h, space, density, foreground, background),- PixelFx::WaterPaper { fiber_length, brightness, contrast } => {- sketch::water_paper(px, w, h, space, fiber_length, brightness, contrast)- }+ PixelFx::WaterPaper { fiber_length, brightness, contrast } => sketch::water_paper(px, w, h, space, fiber_length, brightness, contrast),PixelFx::GlowingEdges { width, brightness, smoothness } => edges::glow(px, w, h, to_px(width), brightness, to_px(smoothness)),PixelFx::ColorHalftone { max_radius, angles } => pixelate::color_halftone(px, w, h, space, max_radius, angles),PixelFx::Crystallize { cell } => pixelate::crystallize(px, w, h, space, cell),diff --git a/crates/effects/src/pixel/sketch.rs b/crates/effects/src/pixel/sketch.rsindex dd17b2510..d05674cdd 100644--- a/crates/effects/src/pixel/sketch.rs+++ b/crates/effects/src/pixel/sketch.rs@@ -429,4 +429,3 @@ pub(super) fn water_paper(px: &mut [[u8; 4]], w: usize, h: usize, space: &PixelS*p = premultiply(rgb, f32::from(p[3]) / 255.0);});}-diff --git a/crates/effects/src/pixel/tests.rs b/crates/effects/src/pixel/tests.rsindex 4e34b785f..711a99840 100644--- a/crates/effects/src/pixel/tests.rs+++ b/crates/effects/src/pixel/tests.rs@@ -2153,10 +2153,7 @@ fn note_paper_embosses_a_gradient_and_grain_changes_pixels() {#[test]fn water_paper_params_take_defaults_and_stay_in_range() {- assert_eq!(- fx("sketch.waterPaper", json!({})),- PixelFx::WaterPaper { fiber_length: 15.0, brightness: 50.0, contrast: 50.0 }- );+ assert_eq!(fx("sketch.waterPaper", json!({})), PixelFx::WaterPaper { fiber_length: 15.0, brightness: 50.0, contrast: 50.0 });assert_eq!(fx("sketch.waterPaper", json!({"fiberLength": 1, "brightness": -5, "contrast": 200})),PixelFx::WaterPaper { fiber_length: 3.0, brightness: 0.0, contrast: 100.0 }@@ -2165,10 +2162,7 @@ fn water_paper_params_take_defaults_and_stay_in_range() {assert!(f.outset(Rect::new(0.0, 0.0, 100.0, 50.0)) > 0.0);assert!(f.reach().unwrap_or(0.0) > 0.0);let doc = crate::effect_info("sketch.waterPaper").unwrap().params;- assert!(- doc.contains("helpx.adobe.com/illustrator/using/summary-effects.html") && doc.contains("unverified"),- "{doc}"- );+ assert!(doc.contains("helpx.adobe.com/illustrator/using/summary-effects.html") && doc.contains("unverified"), "{doc}");}#[test]@@ -2176,10 +2170,10 @@ fn water_paper_softens_and_textures_a_flat_fill_without_losing_coverage() {let (w, h) = (64, 64);let src = image(w, h, |_, _| [200, 80, 40, 255]);let out = water_paper(json!({"fiberLength": 20, "brightness": 50, "contrast": 40}), &src, w, h, &space(w, h));- assert!(out.chunks_exact(4).filter(|p| p[3] > 200).count() > w * h / 2, "most of the fill stays visible");+ assert!(out.as_chunks::<4>().0.iter().filter(|p| p[3] > 200).count() > w * h / 2, "most of the fill stays visible");assert_ne!(out, src, "the wash changes pixels");let spread = |d: &[u8]| {- let reds: Vec<u8> = d.chunks_exact(4).map(|p| p[0]).collect();+ let reds: Vec<u8> = d.as_chunks::<4>().0.iter().map(|p| p[0]).collect();let (min, max) = (reds.iter().min().unwrap(), reds.iter().max().unwrap());max - min};