pub enum Rotation {
None,
Quarter,
Half,
ThreeQuarter,
}Expand description
A page’s /Rotate, normalized to one of four quarter turns
(ISO 32000-1 §7.7.3.3).
The value is always clockwise and always a multiple of 90 degrees: a
document writing /Rotate 450 means Rotation::Quarter, and one
writing -90 means Rotation::ThreeQuarter.
Variants§
None
Upright.
Quarter
Ninety degrees clockwise.
Half
Half a turn.
ThreeQuarter
Two hundred and seventy degrees clockwise.
Implementations§
Source§impl Rotation
impl Rotation
Sourcepub fn from_degrees(n: i64) -> Self
pub fn from_degrees(n: i64) -> Self
The rotation /Rotate n names.
The division comes first, so 45 truncates to zero quarter turns
rather than rounding to one.
Sourcepub fn display_matrix(self, box_rect: Rect) -> Affine
pub fn display_matrix(self, box_rect: Rect) -> Affine
The matrix mapping the crop box onto a width by height device
rectangle.
Width and height are swapped for the quarter and three-quarter turns, which is what makes a rotated page’s device box the right way round.
Trait Implementations§
impl Copy for Rotation
impl Eq for Rotation
Source§impl FromStr for Rotation
impl FromStr for Rotation
Source§fn from_str(s: &str) -> Result<Rotation, NotAQuarterTurn>
fn from_str(s: &str) -> Result<Rotation, NotAQuarterTurn>
The inverse of Display: "0", "90", "180"
and "270", and nothing else.
Not "450" and not "-90". Normalizing a document’s out-of-range
/Rotate is Rotation::from_degrees’s job; doing it here would
make a caller’s round trip lossy.
§Errors
NotAQuarterTurn when the string is not one of those four.
assert_eq!("270".parse(), Ok(pdfrum_page::Rotation::ThreeQuarter));
assert!("45".parse::<pdfrum_page::Rotation>().is_err());