demo-volume.rs
851 B · rust · 26 lines
1use mrlycore::colors::{shades, INDIGO};2use mrlycore::errors::Result;3use mrlyfig::{iso, save, Board};4use mrlylab::moire::volume::volume;5use mrlylab::moire::{Combine, Spec};6use mrlymath::three::Cell3d;78const CODE: u128 = 23;9const SIZE: usize = 64;10const SCALES: [usize; 6] = [1, 3, 5, 7, 9, 11];1112fn main() -> Result<()> {13 let field = volume(Spec::new(CODE, 2, 3), &SCALES, Combine::Sum, 1, SIZE)?;14 let mark = SCALES.len() as f32;15 assert_eq!(field.data.len(), SIZE * SIZE * SIZE);16 assert_eq!(field.max(), mark);17 assert_eq!(field.count(mark), 34416);18 let shell = Cell3d::new(field.solid(mark));19 assert_eq!(shell.types().sum(), 34416);2021 let mut board = Board::square();22 let frame = board.frame(0.08);23 iso::draw(&mut board, frame, &shell, shades(INDIGO), None);24 save("demo-volume", &board)?;25 Ok(())26}