mod opts; use crate::opts::Options; use clap::Parser; use thyme::{ file::ThymeFile, data::Config, draw::Pattern, }; use std::fs::File; fn main() -> Result<(), Box> { // read the command-line options let opts = Options::parse(); // load the thyme file let thyme = { let mut f = File::open(opts.file)?; ThymeFile::from_stream(&mut f)? }; let config = Config { grid_every: opts.grid, line_weight: opts.line_weight, major_line_weight: opts.major_line_weight, grid_size: opts.size, font: opts.font.clone(), }; let surf = cairo::SvgSurface::new( config.scale(thyme.width), config.scale(thyme.height), Some(opts.output.unwrap_or_else(|| "output.svg".to_string())), )?; Pattern { thyme, config, } .draw(cairo::Context::new(&surf)?)?; surf.finish(); Ok(()) }