flags for flipping (unimplemented)

This commit is contained in:
Crispy 2024-05-03 13:12:54 +02:00
parent e066025836
commit 970eb402a2
2 changed files with 25 additions and 14 deletions

View file

@ -22,7 +22,8 @@ pub struct Rule {
pub to: RulePattern,
pub enabled: bool,
// probability: u8
// flip:
pub flip_h: bool,
pub flip_v: bool,
// rotate:
}
@ -42,6 +43,8 @@ impl Rule {
enabled: false,
from: RulePattern::new(),
to: RulePattern::new(),
flip_h: false,
flip_v: false,
}
}
@ -100,6 +103,8 @@ impl Dish {
height: 2,
contents: vec![Some(Cell(0)), Some(Cell(1))],
},
flip_h: false,
flip_v: false,
},
Rule {
enabled: true,
@ -113,19 +118,8 @@ impl Dish {
height: 2,
contents: vec![Some(Cell(0)), None, Some(Cell(1)), Some(Cell(1))],
},
},
Rule {
enabled: true,
from: RulePattern {
width: 2,
height: 2,
contents: vec![None, Some(Cell(1)), Some(Cell(0)), Some(Cell(1))],
},
to: RulePattern {
width: 2,
height: 2,
contents: vec![None, Some(Cell(0)), Some(Cell(1)), Some(Cell(1))],
},
flip_h: true,
flip_v: false,
},
],
}
@ -270,3 +264,18 @@ impl Cell {
self.0 as usize
}
}
#[derive(Debug)]
enum Dir {
Pos,
Neg,
}
impl Dir {
fn sign(&self) -> isize {
match self {
Dir::Pos => 1,
Dir::Neg => -1,
}
}
}

View file

@ -125,6 +125,8 @@ const CSIZE: f32 = 24.;
const OUTLINE: (f32, Color32) = (3., Color32::GRAY);
fn rule_editor(ui: &mut Ui, rule: &mut Rule, cells: &[CellData]) {
ui.checkbox(&mut rule.enabled, "enable rule");
ui.checkbox(&mut rule.flip_h, "flip H");
ui.checkbox(&mut rule.flip_v, "flip V");
let cells_y = rule.from.height();
let cells_x = rule.from.width();