pub struct Fp(/* private fields */);
Expand description
A fixed-point number with 16.16 format.
Implementations§
Source§impl Fp
impl Fp
pub const SCALE: i32 = 65_536i32
pub const SCALE_I64: i64 = 65_536i64
pub const FSCALE: f32 = 65536f32
pub const FRAC_PI_2: Fp
pub const PI: Fp
pub const TAU: Fp
pub const MIN: Fp
pub const MAX: Fp
Sourcepub const fn from_raw(raw: i32) -> Fp
pub const fn from_raw(raw: i32) -> Fp
Creates a new Fp
instance from a raw integer value.
Warning: This constructor should be used with caution. It directly creates
an Fp
instance from a raw integer without any validation or
scaling logic. It is almost always preferable to use higher-level
constructors or conversion traits like From<T>
to ensure that the
fixed-point values are correctly initialized.
§Example
use fixed32::Fp;
let fp = Fp::from_raw(100);
Sourcepub const fn neg_one() -> Fp
pub const fn neg_one() -> Fp
Returns the constant Fp
value for negative one.
§Examples
use fixed32::Fp;
assert_eq!(<Fp as Into<i16>>::into(Fp::neg_one()), -1);
Sourcepub const fn zero() -> Fp
pub const fn zero() -> Fp
Returns the constant Fp
value for zero.
§Examples
use fixed32::Fp;
assert_eq!(<Fp as Into<i16>>::into(Fp::zero()), 0);
pub const fn normalize(self) -> Fp
pub const fn floor(self) -> Fp
pub const fn ceil(self) -> Fp
pub const fn round(self) -> Fp
pub fn clamp(self, min: Fp, max: Fp) -> Fp
pub fn sin(self) -> Fp
pub fn asin(self) -> Fp
pub fn cos(self) -> Fp
pub fn acos(self) -> Fp
pub const fn abs(self) -> Fp
pub const fn signum(self) -> Fp
pub fn sqrt(self) -> Fp
Sourcepub const fn inner(self) -> i32
pub const fn inner(self) -> i32
Returns the raw integer value from the Fp
.
This method retrieves the underlying raw scaled value stored in the
Fp
instance. The returned value is the raw integer that represents
the scaled fixed-point number.
Warning: Directly using the raw value returned by this method should be avoided
unless absolutely necessary. It is generally preferable to use higher-level
methods or conversion traits like From<T>
and into()
for conversions,
which handle scaling and ensure correctness. Using inner()
may expose
the raw value in a way that bypasses intended abstractions and checks,
potentially leading to incorrect usage.
§Example
use fixed32::Fp;
let fp = Fp::from_raw(100);
let raw_value = fp.inner();
// Preferred conversion using From<T> trait
let value_from_fp: i32 = fp.into();
Trait Implementations§
Source§impl AddAssign for Fp
impl AddAssign for Fp
Source§fn add_assign(&mut self, other: Fp)
fn add_assign(&mut self, other: Fp)
+=
operation. Read moreSource§impl Ord for Fp
impl Ord for Fp
Source§impl PartialOrd<i16> for Fp
impl PartialOrd<i16> for Fp
Source§impl PartialOrd for Fp
impl PartialOrd for Fp
Source§impl SubAssign for Fp
impl SubAssign for Fp
Source§fn sub_assign(&mut self, other: Fp)
fn sub_assign(&mut self, other: Fp)
-=
operation. Read moreimpl Copy for Fp
impl Eq for Fp
impl StructuralPartialEq for Fp
Auto Trait Implementations§
impl Freeze for Fp
impl RefUnwindSafe for Fp
impl Send for Fp
impl Sync for Fp
impl Unpin for Fp
impl UnwindSafe for Fp
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<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
Source§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self
with the foreground set to
value
.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red()
and
green()
, which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg()
:
use yansi::{Paint, Color};
painted.fg(Color::White);
Set foreground color to white using white()
.
use yansi::Paint;
painted.white();
Source§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
Source§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
Source§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
Source§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
Source§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
Source§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
Source§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
Source§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
Source§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self
with the background set to
value
.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red()
and
on_green()
, which have the same functionality but
are pithier.
§Example
Set background color to red using fg()
:
use yansi::{Paint, Color};
painted.bg(Color::Red);
Set background color to red using on_red()
.
use yansi::Paint;
painted.on_red();
Source§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
Source§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
Source§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
Source§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
Source§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
Source§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
Source§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
Source§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
Source§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
Source§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
Source§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling Attribute
value
.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold()
and
underline()
, which have the same functionality
but are pithier.
§Example
Make text bold using attr()
:
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);
Make text bold using using bold()
.
use yansi::Paint;
painted.bold();
Source§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
Source§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi
Quirk
value
.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask()
and
wrap()
, which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk()
:
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);
Enable wrapping using wrap()
.
use yansi::Paint;
painted.wrap();
Source§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting()
due to conflicts with Vec::clear()
.
The clear()
method will be removed in a future release.
fn clear(&self) -> Painted<&T>
resetting()
due to conflicts with Vec::clear()
.
The clear()
method will be removed in a future release.Source§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the Condition
value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted
only when both stdout
and stderr
are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);