57 lines
2.2 KiB
Rust
57 lines
2.2 KiB
Rust
//! Automated visual check for the Stamp Floor (formerly Dirt) brush.
|
|
//!
|
|
//! Purpose: Renders several Dirt/StampFloor strokes onto a transparent canvas
|
|
//! using the public engine API and saves the result as a PNG. Used for manual
|
|
//! inspection and regression detection.
|
|
|
|
use hcie_engine_api::{Engine, BrushTip, BrushStyle};
|
|
|
|
#[test]
|
|
#[ignore = "manual visual check: run with --ignored --test stamp_floor_check and inspect target/stamp_floor_check.png"]
|
|
fn stamp_floor_brush_visual_check() {
|
|
let mut engine = Engine::new_with_options("StampFloorCheck", 512, 512, false);
|
|
let layer_id = engine.active_layer_id();
|
|
|
|
let mut tip = BrushTip::default();
|
|
tip.style = BrushStyle::Dirt;
|
|
tip.size = 90.0;
|
|
tip.opacity = 0.9;
|
|
tip.hardness = 0.7;
|
|
tip.spacing = 0.18;
|
|
tip.color_variant = true;
|
|
tip.variant_amount = 0.35;
|
|
engine.set_brush_tip(tip);
|
|
engine.set_color([120, 110, 100, 255]);
|
|
|
|
// Wide horizontal stroke to show banded floor texture.
|
|
engine.begin_stroke(layer_id, 60.0, 250.0);
|
|
for i in 0..=80 {
|
|
let t = i as f32 / 80.0;
|
|
let x = 60.0 + t * 400.0;
|
|
let y = 250.0 + (t * 40.0).sin() * 8.0;
|
|
engine.stroke_to(layer_id, x, y, 1.0);
|
|
}
|
|
engine.end_stroke(layer_id);
|
|
|
|
// Second overlapping stroke.
|
|
engine.begin_stroke(layer_id, 60.0, 320.0);
|
|
for i in 0..=80 {
|
|
let t = i as f32 / 80.0;
|
|
let x = 60.0 + t * 400.0;
|
|
let y = 320.0 + (t * 50.0).cos() * 10.0;
|
|
engine.stroke_to(layer_id, x, y, 0.8);
|
|
}
|
|
engine.end_stroke(layer_id);
|
|
|
|
let pixels = engine.get_composite_pixels();
|
|
let mut output_layer = hcie_protocol::Layer::new_transparent("", 512, 512);
|
|
output_layer.pixels = pixels.clone();
|
|
let out_dir = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR")).parent().unwrap().join("target");
|
|
std::fs::create_dir_all(&out_dir).unwrap();
|
|
let path = out_dir.join("stamp_floor_check.png");
|
|
hcie_engine_api::dynamic_loader::save_image(&output_layer, &path, "png").expect("save png");
|
|
|
|
let has_color = pixels.chunks_exact(4).any(|p| p[3] > 0 && (p[0] != 255 || p[1] != 255 || p[2] != 255));
|
|
assert!(has_color, "Stamp Floor check produced no colored pixels");
|
|
}
|