add rule fail rate property
This commit is contained in:
parent
ef14cef49b
commit
4d61184edd
2 changed files with 16 additions and 6 deletions
|
@ -36,7 +36,8 @@ pub struct Rule {
|
|||
pub flip_x: bool,
|
||||
pub flip_y: bool,
|
||||
pub rotate: bool,
|
||||
// probability: u8
|
||||
#[serde(default)]
|
||||
pub failrate: u8,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
|
@ -131,6 +132,7 @@ impl Rule {
|
|||
flip_x: false,
|
||||
flip_y: false,
|
||||
rotate: false,
|
||||
failrate: 0,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -383,6 +385,11 @@ impl Dish {
|
|||
return;
|
||||
}
|
||||
|
||||
let fail: u8 = random();
|
||||
if rule.failrate > fail {
|
||||
return;
|
||||
}
|
||||
|
||||
let width = variant.width;
|
||||
let height = variant.height;
|
||||
let mut old_state = Vec::new();
|
||||
|
|
|
@ -10,7 +10,7 @@ use eframe::{
|
|||
epaint::Hsva,
|
||||
NativeOptions,
|
||||
};
|
||||
use egui::{collapsing_header::CollapsingState, PointerButton};
|
||||
use egui::{collapsing_header::CollapsingState, DragValue, PointerButton};
|
||||
use native_dialog::FileDialog;
|
||||
use rand::prelude::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
@ -272,10 +272,13 @@ fn rule_editor(
|
|||
rule.generate_variants();
|
||||
}
|
||||
});
|
||||
if ui.checkbox(&mut rule.rotate, "rotate").changed() {
|
||||
rule.generate_variants();
|
||||
}
|
||||
|
||||
ui.horizontal(|ui| {
|
||||
if ui.checkbox(&mut rule.rotate, "rotate").changed() {
|
||||
rule.generate_variants();
|
||||
}
|
||||
ui.label("fail rate");
|
||||
ui.add(DragValue::new(&mut rule.failrate));
|
||||
});
|
||||
let cells_y = rule.height();
|
||||
let cells_x = rule.width();
|
||||
let patt_width = CSIZE * cells_x as f32;
|
||||
|
|
Loading…
Reference in a new issue