site-cart.rs
1.1 kB · rust · 38 lines
1use mrlycore::errors::Result;2use mrlyfig::{grid, ink, save, Board, Frame, Grid};34const CELL: f64 = 55.0;56const CART: [&str; 11] = [7 "11000000000000",8 "00100000000000",9 "00010000000000",10 "00001111111111",11 "00001000000001",12 "00001000000001",13 "00000100000010",14 "00000011111100",15 "00000010000100",16 "00000111001110",17 "00000010000100",18];1920fn main() -> Result<()> {21 let mut board = Board::square();22 let cols = CART[0].len();23 let rows = CART.len();24 let (w, h) = (CELL * cols as f64, CELL * rows as f64);25 let x = ((board.width as f64 - w) / 2.0).round();26 let y = ((board.height as f64 - h) / 2.0).round();27 let cells = Grid::new(Frame::new(x, y, w, h), cols, rows, 0.0);28 cells.carpet(&mut board, &grid::mask(&CART, 1), ink::fg());29 for col in [5, 6, 7, 10, 11, 12] {30 cells.fill(&mut board, col, 9, ink::orange());31 }32 for row in [8, 10] {33 cells.fill(&mut board, 6, row, ink::orange());34 cells.fill(&mut board, 11, row, ink::orange());35 }36 save("site-cart", &board)?;37 Ok(())38}