Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
bokuweb committed Sep 22, 2024
1 parent e9ea0fe commit 505d51d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
6 changes: 5 additions & 1 deletion crates/reg_cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ struct Args {
#[arg(long)]
report: Option<PathBuf>,

#[arg(long)]
matching_threshold: Option<f32>,

#[arg(long)]
threshold_rate: Option<f32>,

Expand All @@ -35,11 +38,12 @@ pub fn main() {

let options = Options {
report: args.report.as_deref().map(Path::new),
matching_threshold: args.matching_threshold,
threshold_rate: args.threshold_rate,
threshold_pixel: args.threshold_pixel,
concurrency: args.concurrency,
enable_antialias: args.enable_antialias,
};

run(args.actual_dir, args.expected_dir, args.diff_dir, options)
let _ = run(args.actual_dir, args.expected_dir, args.diff_dir, options);
}
10 changes: 5 additions & 5 deletions crates/reg_core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ pub struct Options<'a> {
// update?: boolean,
// extendedErrors?: boolean,
// urlPrefix?: string,
// matchingThreshold?: number,
pub matching_threshold: Option<f32>,
pub threshold_rate: Option<f32>,
pub threshold_pixel: Option<u64>,
pub concurrency: Option<usize>,
Expand All @@ -69,6 +69,7 @@ impl<'a> Default for Options<'a> {
fn default() -> Self {
Self {
report: None,
matching_threshold: Some(0.0),
threshold_rate: None,
threshold_pixel: None,
concurrency: Some(4),
Expand Down Expand Up @@ -117,7 +118,7 @@ pub fn run(
img1,
img2,
&DiffOption {
threshold: Some(0.05),
threshold: options.matching_threshold,
include_anti_alias: Some(!options.enable_antialias.unwrap_or_default()),
},
)?;
Expand Down Expand Up @@ -149,9 +150,9 @@ pub fn run(
let mut diff_image = image_name.clone();
failed.insert(image_name.clone());
differences.insert(diff_image.clone());
// TODO:
// TODO: make webp, png selectable
diff_image.set_extension("webp");
std::fs::write(diff_dir.join(&diff_image), item.diff_image.clone())?;
std::fs::write(diff_dir.join(&diff_image), item.diff_image)?;
}
}

Expand All @@ -174,7 +175,6 @@ pub fn run(
std::fs::write("./report.html", html)?;
};
Ok(())

}

pub(crate) fn find_images(
Expand Down

0 comments on commit 505d51d

Please sign in to comment.