mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-10-24 09:46:59 -06:00
Water Paper: rustfmt (#2955)
This commit is contained in:
@@ -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),
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user