Skip to main content

WidgetRotation

Enum WidgetRotation 

Source
pub enum WidgetRotation {
    None,
    Quarter,
    Half,
    ThreeQuarter,
}
Expand description

A widget annotation’s /MK /R, normalized to one of the four quadrants.

ISO 32000-1 Table 189 defines /R as “the number of degrees by which the widget annotation shall be rotated counterclockwise relative to the page”, and says it “shall be a multiple of 90”. Neither clause is a guarantee about real files, so WidgetRotation::from_degrees rules on both: a negative or out-of-range angle is the same quadrant it names modulo a full turn, and an angle that is not a multiple of 90 names no quadrant at all and is upright.

This is the one normalization both readers of the key share — the appearance builder, which needs the box, and pdfrum-form’s routing, which needs the map. They used to fold it separately and disagreed.

Variants§

§

None

Upright.

§

Quarter

A quarter turn counterclockwise.

§

Half

A half turn.

§

ThreeQuarter

Three quarters counterclockwise.

Implementations§

Source§

impl WidgetRotation

Source

pub fn from_degrees(degrees: i64) -> WidgetRotation

The quadrant /MK /R n names, or WidgetRotation::None when it names none.

The fold is rem_euclid(360), so -90 is 270 — a quarter turn clockwise is three quarters counterclockwise, which is what a counterclockwise angle of -90 means. A value that is not a multiple of 90 is upright.

[oracle-bug] A negative multiple of 90 keeps its sign through the fold, so /R -90 draws and hit-tests as a three-quarter turn — the specification’s “counterclockwise” reading, and pdf.js’s.

use pdfrum_doc::geom::WidgetRotation;

assert_eq!(WidgetRotation::from_degrees(90), WidgetRotation::Quarter);
// `-90` counterclockwise is three quarters, and folds there.
assert_eq!(WidgetRotation::from_degrees(-90), WidgetRotation::ThreeQuarter);
// Not a multiple of 90: no quadrant at all.
assert_eq!(WidgetRotation::from_degrees(45), WidgetRotation::None);
Source

pub fn swaps_axes(self) -> bool

Whether this rotation exchanges the widget’s width and height.

use pdfrum_doc::geom::WidgetRotation;

assert!(WidgetRotation::Quarter.swaps_axes());
assert!(!WidgetRotation::Half.swaps_axes());

Trait Implementations§

Source§

impl Clone for WidgetRotation

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for WidgetRotation

Source§

impl Debug for WidgetRotation

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for WidgetRotation

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Eq for WidgetRotation

Source§

impl Hash for WidgetRotation

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for WidgetRotation

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for WidgetRotation

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.