main
Elnu 1 year ago
parent 0ad5b4df3b
commit 7c27f869c9

@ -1,9 +1,9 @@
pub mod svg;
use svg::*;
use std::{fs::OpenOptions, io::Write};
use askama::Template;
use derive_more::From;
use std::{fs::OpenOptions, io::Write};
#[derive(Template)]
#[template(path = "document.xml")]
@ -26,7 +26,7 @@ fn main() -> Result<(), Error> {
.open("output.svg")?;
let document = DocumentTemplate {
width: SVGMeasure::new(8.5, SVGUnit::Inch),
height: SVGMeasure::new(11.0,SVGUnit::Inch),
height: SVGMeasure::new(11.0, SVGUnit::Inch),
};
write!(file, "{}", document.render()?)?;
Ok(())

@ -1,6 +1,9 @@
use super::SVGUnit;
use std::fmt;
use std::{ops::{Add, Sub, Mul, Div}, fmt::Display};
use std::{
fmt::Display,
ops::{Add, Div, Mul, Sub},
};
pub struct SVGMeasure {
pub measure: f64,

@ -35,7 +35,10 @@ pub enum SVGUnit {
impl Display for SVGUnit {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
use SVGUnit::*;
write!(f, "{}", match &self {
write!(
f,
"{}",
match &self {
Pixel => "px",
Inch => "in",
Centimeter => "cm",
@ -50,6 +53,7 @@ impl Display for SVGUnit {
ViewportHeight => "vh",
ViewportMinimum => "vmin",
ViewportMaximum => "vmax",
})
}
)
}
}
Loading…
Cancel
Save