diff options
| author | Laurenz <laurmaedje@gmail.com> | 2020-10-03 13:23:59 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2020-10-03 13:23:59 +0200 |
| commit | 0fc25d732d7cbc37cf801645849d1060f2cec4a3 (patch) | |
| tree | 706aa8d1bf4135d1dd3ac17a5023bc5e24ded69d /src/paper.rs | |
| parent | 8dbc5b60cc4a88f68ee82607af3a3c454cd8f68b (diff) | |
Port to kurbo 🎋
Diffstat (limited to 'src/paper.rs')
| -rw-r--r-- | src/paper.rs | 27 |
1 files changed, 10 insertions, 17 deletions
diff --git a/src/paper.rs b/src/paper.rs index 266f22d1..8f855d5a 100644 --- a/src/paper.rs +++ b/src/paper.rs @@ -1,6 +1,6 @@ //! Predefined papers. -use crate::geom::{Size, Value4}; +use crate::geom::{Sides, Size}; use crate::length::{Length, ScaleLength}; /// Specification of a paper. @@ -37,23 +37,16 @@ pub enum PaperClass { } impl PaperClass { - /// The default margins for this page class. - pub fn default_margins(self) -> Value4<ScaleLength> { - let values = |l, t, r, b| { - Value4::new( - ScaleLength::Scaled(l), - ScaleLength::Scaled(t), - ScaleLength::Scaled(r), - ScaleLength::Scaled(b), - ) - }; - + /// The default margin ratios for this page class. + pub fn default_margins(self) -> Sides<ScaleLength> { + let s = ScaleLength::Scaled; + let f = |l, r, t, b| Sides::new(s(l), s(r), s(t), s(b)); match self { - Self::Custom => values(0.1190, 0.0842, 0.1190, 0.0842), - Self::Base => values(0.1190, 0.0842, 0.1190, 0.0842), - Self::US => values(0.1760, 0.1092, 0.1760, 0.0910), - Self::Newspaper => values(0.0455, 0.0587, 0.0455, 0.0294), - Self::Book => values(0.1200, 0.0852, 0.1500, 0.0965), + Self::Custom => f(0.1190, 0.0842, 0.1190, 0.0842), + Self::Base => f(0.1190, 0.0842, 0.1190, 0.0842), + Self::US => f(0.1760, 0.1092, 0.1760, 0.0910), + Self::Newspaper => f(0.0455, 0.0587, 0.0455, 0.0294), + Self::Book => f(0.1200, 0.0852, 0.1500, 0.0965), } } } |
