diff options
| author | Laurenz <laurmaedje@gmail.com> | 2020-10-10 22:19:36 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2020-10-10 22:19:36 +0200 |
| commit | 92c01da36016e94ff20163806ddcbcf7e33d4031 (patch) | |
| tree | 1a900b3c11edcc93e9153fada3ce92310db5768b /src/paper.rs | |
| parent | 42500d5ed85539c5ab04dd3544beaf802da29be9 (diff) | |
Switch back to custom geometry types, unified with layout primitives 🏞
Diffstat (limited to 'src/paper.rs')
| -rw-r--r-- | src/paper.rs | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/src/paper.rs b/src/paper.rs index 21762b17..21f54756 100644 --- a/src/paper.rs +++ b/src/paper.rs @@ -1,18 +1,16 @@ //! Predefined papers. -use crate::geom::{Linear, Size}; -use crate::layout::Sides; -use crate::length::Length; +use crate::geom::{Length, Linear, Relative, Sides, Size}; /// Specification of a paper. #[derive(Debug, Copy, Clone, PartialEq)] pub struct Paper { /// The kind of paper, which defines the default margins. pub class: PaperClass, - /// The width of the paper. - pub width: Length, - /// The height of the paper. - pub height: Length, + /// The width of the paper in millimeters. + pub width: f64, + /// The height of the paper in millimeters. + pub height: f64, } impl Paper { @@ -23,7 +21,7 @@ impl Paper { /// The size of the paper. pub fn size(self) -> Size { - Size::new(self.width.as_raw(), self.height.as_raw()) + Size::new(Length::mm(self.width), Length::mm(self.height)) } } @@ -40,7 +38,7 @@ pub enum PaperClass { impl PaperClass { /// The default margins for this page class. pub fn default_margins(self) -> Sides<Linear> { - let f = Linear::rel; + let f = |r| Relative::new(r).into(); let s = |l, r, t, b| Sides::new(f(l), f(r), f(t), f(b)); match self { Self::Custom => s(0.1190, 0.0842, 0.1190, 0.0842), @@ -69,9 +67,9 @@ macro_rules! papers { #[doc = $names] #[doc = "`."] pub const $var: Paper = Paper { - width: Length::mm($width), - height: Length::mm($height), class: PaperClass::$class, + width: $width, + height: $height, }; }; } |
