pub enum Rotation {
None,
Quarter,
Half,
ThreeQuarter,
}Expand description
A widget’s rotation, normalized to one of the four quadrants.
The appearance builder reads the same key, so this is its type rather
than a second one that could fold /MK /R differently: routing and the
generator must agree about which box a click lands in.
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
impl WidgetRotation
Sourcepub fn from_degrees(degrees: i64) -> WidgetRotation
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);Sourcepub fn swaps_axes(self) -> bool
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
impl Clone for WidgetRotation
Source§fn clone(&self) -> WidgetRotation
fn clone(&self) -> WidgetRotation
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for WidgetRotation
Source§impl Debug for WidgetRotation
impl Debug for WidgetRotation
Source§impl Default for WidgetRotation
impl Default for WidgetRotation
Source§fn default() -> WidgetRotation
fn default() -> WidgetRotation
impl Eq for WidgetRotation
Source§impl Hash for WidgetRotation
impl Hash for WidgetRotation
Source§impl PartialEq for WidgetRotation
impl PartialEq for WidgetRotation
impl StructuralPartialEq for WidgetRotation
Auto Trait Implementations§
impl Freeze for WidgetRotation
impl RefUnwindSafe for WidgetRotation
impl Send for WidgetRotation
impl Sync for WidgetRotation
impl Unpin for WidgetRotation
impl UnsafeUnpin for WidgetRotation
impl UnwindSafe for WidgetRotation
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.