pub struct Fixed(/* private fields */);Expand description
The OpenType Fixed type, a 16.16-bit signed fixed-point type.
Implementations§
Source§impl Fixed
impl Fixed
Sourcepub const MIN: Self
pub const MIN: Self
The smallest value that can be represented by this type.
§Examples
assert_eq!(Fixed::MIN, -32768.0);Sourcepub const MAX: Self
pub const MAX: Self
The largest value that can be represented by this type.
§Examples
assert_eq!(Fixed::MAX, 32767.99998474121);Sourcepub const PRECISION: u32
pub const PRECISION: u32
The amount of decimal places the type can accurately represent.
§Examples
assert_eq!(Fixed::PRECISION, 4);Sourcepub const fn new(num: f64) -> Option<Self>
pub const fn new(num: f64) -> Option<Self>
§Examples
use ttf_view::types::Fixed;
assert_eq!(Fixed::new(-0.125).unwrap(), -0.125);
assert_eq!(Fixed::new(1.99609375).unwrap(), 1.99609375);
assert_eq!(Fixed::new(123456.78), None);
// numbers are rounded towards the closest value representable by Fixed
assert_eq!(Fixed::new(0.5156247).unwrap(), 0.515625);
assert_eq!(Fixed::new(0.5156250).unwrap(), 0.515625);
assert_eq!(Fixed::new(0.5156254).unwrap(), 0.515625);Sourcepub const unsafe fn new_unchecked(num: f64) -> Self
pub const unsafe fn new_unchecked(num: f64) -> Self
Sourcepub const fn from_be_bytes(bytes: [u8; 4]) -> Self
pub const fn from_be_bytes(bytes: [u8; 4]) -> Self
Creates a Fixed from big-endian bytes.
TODO: # Examples
Sourcepub const fn to_be_bytes(self) -> [u8; 4]
pub const fn to_be_bytes(self) -> [u8; 4]
Gets this Fixed’s big-endian bytes.
TODO: # Examples
Sourcepub const fn frac_num(&self) -> i32
pub const fn frac_num(&self) -> i32
Returns this Fixed fraction’s numerator
(Fixed represented as ).
TODO: # Examples
Sourcepub const fn round_to_precision(&self) -> f64
pub const fn round_to_precision(&self) -> f64
Trait Implementations§
impl Copy for Fixed
impl Eq for Fixed
Source§impl Ord for Fixed
impl Ord for Fixed
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
Source§impl PartialOrd for Fixed
impl PartialOrd for Fixed
Source§impl PartialOrd<f64> for Fixed
impl PartialOrd<f64> for Fixed
impl StructuralPartialEq for Fixed
Auto Trait Implementations§
impl Freeze for Fixed
impl RefUnwindSafe for Fixed
impl Send for Fixed
impl Sync for Fixed
impl Unpin for Fixed
impl UnsafeUnpin for Fixed
impl UnwindSafe for Fixed
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
Mutably borrows from an owned value. Read more