paper-lemma-b-pincer.rs

1.1 kB · rust · 33 lines

1use mrlycore::errors::Result;2use mrlyfig::{ink, save, Board};34const LOWER: f64 = 0.447_597_813_453;5const UPPER: f64 = 0.640_212_193_8;6const WALLS: [f64; 3] = [0.447_931, 0.5, 0.605_303];78fn arm(board: &mut Board, x: f64, y: f64, w: f64, h: f64) {9    board.rect(x, y, w, h, ink::panel());10    let edge = [(x, y), (x + w, y), (x + w, y + h), (x, y + h), (x, y)];11    board.polyline(&edge, 2.0, ink::line());12}1314fn main() -> Result<()> {15    let mut board = Board::square();16    let frame = board.frame(0.08);17    let (_, cy) = frame.center();18    let thick = frame.h / 3.0;19    let top = cy - thick / 2.0;20    let at = |beta: f64| frame.x + frame.w * beta;2122    arm(&mut board, at(0.0), top, at(LOWER) - at(0.0), thick);23    arm(&mut board, at(UPPER), top, at(1.0) - at(UPPER), thick);24    board.rect(at(LOWER), top, at(UPPER) - at(LOWER), thick, ink::orange());2526    for wall in WALLS {27        let x = at(wall);28        board.rect(x - 1.0, frame.y, 2.0, frame.h, ink::fade(ink::dim(), 0.85));29        board.rect(x - 1.0, top, 2.0, thick, ink::line());30    }31    save("paper-lemma-b-pincer", &board)?;32    Ok(())33}