research-sequences.rs
1.7 kB · rust · 51 lines
1use mrlycore::errors::Result;2use mrlyfig::board::Frame;3use mrlyfig::{ink, save, Board, Grid};4use mrlymath::formulas::counting;5use mrlymath::two::designs;67const CODES: [u128; 6] = [1, 3, 7, 9, 11, 15];8const SIDES: [usize; 4] = [3, 5, 7, 9];910fn main() -> Result<()> {11 let mut board = Board::square();12 let area = board.frame(0.08);13 let pitch = area.h / CODES.len() as f64;14 let block = Frame::new(15 area.x + (area.w - pitch * SIDES.len() as f64) / 2.0,16 area.y,17 pitch * SIDES.len() as f64,18 area.h,19 );20 let rule = 1.5;21 for col in 0..=SIDES.len() {22 let x = block.x + col as f64 * pitch;23 board.rect(x - rule / 2.0, block.y, rule, block.h, ink::line());24 }25 for row in 0..=CODES.len() {26 let y = block.y + row as f64 * pitch;27 board.rect(block.x, y - rule / 2.0, block.w, rule, ink::line());28 }29 for (row, code) in CODES.iter().enumerate() {30 for (col, number) in SIDES.iter().enumerate() {31 let cells = designs::create(*code, *number, 1, 0, 2)?;32 assert_eq!(cells.width(), *number);33 assert_eq!(34 cells.types().sum() as u128,35 counting::fill(*code, *number, 2, 1, 2)?36 );37 let tile = Frame::new(38 block.x + col as f64 * pitch,39 block.y + row as f64 * pitch,40 pitch,41 pitch,42 )43 .inset(pitch * 0.10);44 Grid::new(tile, *number, *number, 0.10).paint(&mut board, &cells, |kind| {45 (kind != 0).then_some(ink::yellow())46 });47 }48 }49 save("research-sequences", &board)?;50 Ok(())51}