generated from ElnuDev/rust-project
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
930 B
39 lines
930 B
use strum_macros::{Display, EnumString, IntoStaticStr};
|
|
|
|
/// https://oreillymedia.github.io/Using_SVG/guide/units.html
|
|
#[derive(Clone, Copy, PartialEq, Eq, Debug, Display, EnumString, IntoStaticStr)]
|
|
pub enum SVGUnit {
|
|
/// Pixel units, directly equivalent to SVG user units.
|
|
#[strum(serialize = "px")]
|
|
Pixel,
|
|
/// Inches.
|
|
#[strum(serialize = "in")]
|
|
Inch,
|
|
/// Centimeters.
|
|
#[strum(serialize = "cm")]
|
|
Centimeter,
|
|
/// Millimeters.
|
|
#[strum(serialize = "mm")]
|
|
Millimeter,
|
|
/// Points.
|
|
#[strum(serialize = "pt")]
|
|
Point,
|
|
// Picas.
|
|
#[strum(serialize = "pc")]
|
|
Pica,
|
|
}
|
|
|
|
impl SVGUnit {
|
|
pub const fn to_user_units(&self) -> f64 {
|
|
use SVGUnit::*;
|
|
match self {
|
|
Pixel => 1.0,
|
|
Inch => 96.0,
|
|
Centimeter => 37.795,
|
|
Millimeter => 3.7795,
|
|
Point => 1.3333,
|
|
Pica => 16.0,
|
|
}
|
|
}
|
|
}
|