mod opts; use crate::opts::Options; use clap::Parser; use thyme::{ data::{Config, Mapping}, draw::Pattern, file::ThymeFile, image::Image, }; fn main() -> Result<(), Box> { // read the command-line options let opts = Options::parse(); // load the PNG image for the pattern let image = Image::load(opts.image)?; // load the color map file let mapping = Mapping::load(opts.mapping, &image)?; let thyme = ThymeFile::from_image_and_config(&image, &mapping); 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(image.width), config.scale(image.height), Some(opts.output.unwrap_or_else(|| "output.svg".to_string())), )?; Pattern { thyme, config, } .draw(cairo::Context::new(&surf)?)?; surf.finish(); Ok(()) }