1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- mod opts;
- use crate::opts::Options;
- use clap::Parser;
- use thyme::{
- data::{Config, Mapping},
- draw::Pattern,
- image::Image,
- };
- fn main() -> Result<(), Box<dyn std::error::Error>> {
- // 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 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 {
- image,
- config,
- mapping,
- }
- .draw(cairo::Context::new(&surf)?)?;
- surf.finish();
- Ok(())
- }
|