init
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
//! Automated visual check for the Leaves brush.
|
||||
//!
|
||||
//! Purpose: Renders several Leaf 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 leaves_check and inspect target/leaves_check.png"]
|
||||
fn leaves_brush_visual_check() {
|
||||
let mut engine = Engine::new_with_options("LeavesCheck", 512, 512, false);
|
||||
let layer_id = engine.active_layer_id();
|
||||
|
||||
let mut tip = BrushTip::default();
|
||||
tip.style = BrushStyle::Leaf;
|
||||
tip.size = 70.0;
|
||||
tip.opacity = 0.95;
|
||||
tip.hardness = 0.85;
|
||||
tip.spacing = 0.35;
|
||||
tip.color_variant = true;
|
||||
tip.variant_amount = 0.5;
|
||||
engine.set_brush_tip(tip);
|
||||
engine.set_color([40, 140, 40, 255]);
|
||||
|
||||
engine.begin_stroke(layer_id, 100.0, 400.0);
|
||||
for i in 0..=30 {
|
||||
let t = i as f32 / 30.0;
|
||||
let x = 80.0 + t * 120.0;
|
||||
let y = 400.0 - (t * 40.0).sin() * 20.0 - t * 30.0;
|
||||
engine.stroke_to(layer_id, x, y, 0.6 + 0.4 * (1.0 - t));
|
||||
}
|
||||
engine.end_stroke(layer_id);
|
||||
|
||||
engine.begin_stroke(layer_id, 300.0, 420.0);
|
||||
for i in 0..=25 {
|
||||
let t = i as f32 / 25.0;
|
||||
let x = 300.0 + t * 10.0;
|
||||
let y = 420.0 - t * 80.0;
|
||||
engine.stroke_to(layer_id, x, y, 1.0);
|
||||
}
|
||||
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("leaves_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, "Leaves check produced no colored pixels");
|
||||
}
|
||||
Reference in New Issue
Block a user