From 970eb402a2a4366be68a08ee5e316c5bbedfe2aa Mon Sep 17 00:00:00 2001 From: CrispyPin Date: Fri, 3 May 2024 13:12:54 +0200 Subject: [PATCH] flags for flipping (unimplemented) --- petri/src/lib.rs | 37 +++++++++++++++++++++++-------------- uscope/src/main.rs | 2 ++ 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/petri/src/lib.rs b/petri/src/lib.rs index 168d7b3..53fb819 100644 --- a/petri/src/lib.rs +++ b/petri/src/lib.rs @@ -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, + } + } +} diff --git a/uscope/src/main.rs b/uscope/src/main.rs index e2a10b2..7e0e2ed 100644 --- a/uscope/src/main.rs +++ b/uscope/src/main.rs @@ -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();