|
|
@ -1,19 +1,26 @@
|
|
|
|
use std::fmt::{self, Display};
|
|
|
|
use strum_macros::{Display, EnumString, IntoStaticStr};
|
|
|
|
|
|
|
|
|
|
|
|
/// https://oreillymedia.github.io/Using_SVG/guide/units.html
|
|
|
|
/// https://oreillymedia.github.io/Using_SVG/guide/units.html
|
|
|
|
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
|
|
|
|
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
|
|
|
|
|
|
|
|
#[derive(Display, EnumString, IntoStaticStr)]
|
|
|
|
pub enum SVGUnit {
|
|
|
|
pub enum SVGUnit {
|
|
|
|
/// Pixel units, directly equivalent to SVG user units.
|
|
|
|
/// Pixel units, directly equivalent to SVG user units.
|
|
|
|
|
|
|
|
#[strum(serialize = "px")]
|
|
|
|
Pixel,
|
|
|
|
Pixel,
|
|
|
|
/// Inches.
|
|
|
|
/// Inches.
|
|
|
|
|
|
|
|
#[strum(serialize = "in")]
|
|
|
|
Inch,
|
|
|
|
Inch,
|
|
|
|
/// Centimeters.
|
|
|
|
/// Centimeters.
|
|
|
|
|
|
|
|
#[strum(serialize = "cm")]
|
|
|
|
Centimeter,
|
|
|
|
Centimeter,
|
|
|
|
/// Millimeters.
|
|
|
|
/// Millimeters.
|
|
|
|
|
|
|
|
#[strum(serialize = "mm")]
|
|
|
|
Millimeter,
|
|
|
|
Millimeter,
|
|
|
|
/// Points.
|
|
|
|
/// Points.
|
|
|
|
|
|
|
|
#[strum(serialize = "pt")]
|
|
|
|
Point,
|
|
|
|
Point,
|
|
|
|
// Picas.
|
|
|
|
// Picas.
|
|
|
|
|
|
|
|
#[strum(serialize = "pc")]
|
|
|
|
Pica,
|
|
|
|
Pica,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -30,21 +37,3 @@ impl SVGUnit {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
impl Display for SVGUnit {
|
|
|
|
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
|
|
|
|
|
|
|
use SVGUnit::*;
|
|
|
|
|
|
|
|
write!(
|
|
|
|
|
|
|
|
f,
|
|
|
|
|
|
|
|
"{}",
|
|
|
|
|
|
|
|
match &self {
|
|
|
|
|
|
|
|
Pixel => "px",
|
|
|
|
|
|
|
|
Inch => "in",
|
|
|
|
|
|
|
|
Centimeter => "cm",
|
|
|
|
|
|
|
|
Millimeter => "mm",
|
|
|
|
|
|
|
|
Point => "pt",
|
|
|
|
|
|
|
|
Pica => "pc",
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|